From 54e3221555997d26d59b880e3e153f1fc979505d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 18 Jun 2010 13:01:18 +0200 Subject: Fix QWizard icon and metrics on Windows 7 and Vista This patch takes care of missing icon on Windows Vista+7. It also updates the metrics to look more native in both versions. Task-number: QTBUG-9873, QTBUG-11974, QTBUG-6120 Reviewed-by: prasanth --- src/gui/dialogs/qwizard_win.cpp | 42 +++++++++++++++++++++++++++-------------- src/gui/dialogs/qwizard_win_p.h | 21 +++++++++++++++------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index e406cba159..ad8801a094 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -180,7 +180,8 @@ QVistaBackButton::QVistaBackButton(QWidget *widget) QSize QVistaBackButton::sizeHint() const { ensurePolished(); - int width = 32, height = 32; + int size = int(QStyleHelper::dpiScaled(32)); + int width = size, height = size; /* HANDLE theme = pOpenThemeData(0, L"Navigation"); SIZE size; @@ -213,8 +214,8 @@ void QVistaBackButton::paintEvent(QPaintEvent *) HANDLE theme = pOpenThemeData(0, L"Navigation"); //RECT rect; RECT clipRect; - int xoffset = QWidget::mapToParent(r.topLeft()).x(); - int yoffset = QWidget::mapToParent(r.topLeft()).y(); + int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1; + int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1; clipRect.top = r.top() + yoffset; clipRect.bottom = r.bottom() + yoffset; @@ -245,6 +246,11 @@ QVistaHelper::QVistaHelper(QWizard *wizard) is_vista = resolveSymbols(); if (is_vista) backButton_ = new QVistaBackButton(wizard); + + // Handle diff between Windows 7 and Vista + iconSpacing = QStyleHelper::dpiScaled(7); + textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + iconSpacing : QStyleHelper::dpiScaled(20); } QVistaHelper::~QVistaHelper() @@ -308,18 +314,15 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) void QVistaHelper::drawTitleBar(QPainter *painter) { - if (vistaState() == VistaAero) - drawBlackRect( - QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), - painter->paintEngine()->getDC()); + HDC hdc = painter->paintEngine()->getDC(); + if (vistaState() == VistaAero) + drawBlackRect(QRect(0, 0, wizard->width(), + titleBarSize() + topOffset()), hdc); Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); - const int verticalCenter = (btnTop + btnHeight / 2); - - wizard->windowIcon().paint( - painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize())); + const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QWorkspaceTitleBar"); @@ -327,14 +330,25 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); + int glowOffset = 0; + if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); + glowOffset = glowSize(); } + drawTitleText( painter, text, - QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight), - painter->paintEngine()->getDC()); + QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight), + hdc); + + if (!wizard->windowIcon().isNull()) { + QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()); + HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON(); + DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); + DestroyIcon(hIcon); + } } void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) @@ -734,7 +748,7 @@ bool QVistaHelper::resolveSymbols() int QVistaHelper::titleOffset() { - int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + padding(); + int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing; return leftMargin() + iconOffset; } diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h index 5f3b6c2bcb..caf018d0e7 100644 --- a/src/gui/dialogs/qwizard_win_p.h +++ b/src/gui/dialogs/qwizard_win_p.h @@ -61,6 +61,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -100,9 +101,14 @@ public: enum VistaState { VistaAero, VistaBasic, Classic, Dirty }; static VistaState vistaState(); static int titleBarSize() { return frameSize() + captionSize(); } - static int topPadding() { return 8; } - static int topOffset() { return titleBarSize() + (vistaState() == VistaAero ? 13 : 3); } - + static int topPadding() { // padding under text + return int(QStyleHelper::dpiScaled( + QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6)); + } + static int topOffset() { + static int aeroOffset = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13); + return (titleBarSize() + (vistaState() == VistaAero ? aeroOffset : 3)); } private: static HFONT getCaptionFont(HANDLE hTheme); bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); @@ -111,11 +117,10 @@ private: static int frameSize() { return GetSystemMetrics(SM_CYSIZEFRAME); } static int captionSize() { return GetSystemMetrics(SM_CYCAPTION); } - static int backButtonSize() { return 31; } // ### should be queried from back button itself + static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); } static int iconSize() { return 16; } // Standard Aero - static int padding() { return 7; } // Standard Aero - static int leftMargin() { return backButtonSize() + padding(); } static int glowSize() { return 10; } + int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; } int titleOffset(); bool resolveSymbols(); @@ -139,6 +144,10 @@ private: QRect rtTitle; QWizard *wizard; QVistaBackButton *backButton_; + + int titleBarOffset; // Extra spacing above the text + int iconSpacing; // Space between button and icon + int textSpacing; // Space between icon and text }; -- cgit v1.2.1 From f14b644004498dc6fb1a9437b81e3164e89bfdb5 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 7 Jul 2010 09:51:34 +0200 Subject: qdoc: Fixed the case where the property and type names are the same. Also simplified some code. Task-number: QTBUG-6340 --- tools/qdoc3/codemarker.cpp | 8 ++++++++ tools/qdoc3/codemarker.h | 9 +++++---- tools/qdoc3/cppcodemarker.cpp | 15 +++++++++------ tools/qdoc3/cppcodemarker.h | 7 ++++--- tools/qdoc3/htmlgenerator.cpp | 8 +++++--- tools/qdoc3/htmlgenerator.h | 7 ++++--- tools/qdoc3/javacodemarker.cpp | 6 ++++-- tools/qdoc3/javacodemarker.h | 5 ++++- tools/qdoc3/plaincodemarker.cpp | 7 ------- tools/qdoc3/plaincodemarker.h | 1 - tools/qdoc3/qscodemarker.cpp | 7 ------- tools/qdoc3/qscodemarker.h | 1 - tools/qdoc3/tree.cpp | 10 ++++++---- tools/qdoc3/tree.h | 20 ++++++++++++-------- 14 files changed, 61 insertions(+), 50 deletions(-) diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp index 33ceaf5108..7130d61679 100644 --- a/tools/qdoc3/codemarker.cpp +++ b/tools/qdoc3/codemarker.cpp @@ -630,4 +630,12 @@ QList
CodeMarker::qmlSections(const QmlClassNode* , SynopsisStyle ) } #endif +const Node* CodeMarker::resolveTarget(const QString& , + const Tree* , + const Node* , + const Node* ) +{ + return 0; +} + QT_END_NAMESPACE diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h index aab8a9cee8..53ad4a8eed 100644 --- a/tools/qdoc3/codemarker.h +++ b/tools/qdoc3/codemarker.h @@ -155,10 +155,11 @@ class CodeMarker virtual QList
qmlSections(const QmlClassNode* qmlClassNode, SynopsisStyle style); #endif - virtual const Node *resolveTarget(const QString& target, - const Tree *tree, - const Node *relative) = 0; - virtual QStringList macRefsForNode(const Node *node); + virtual const Node* resolveTarget(const QString& target, + const Tree* tree, + const Node* relative, + const Node* self = 0); + virtual QStringList macRefsForNode(const Node* node); static void initialize(const Config& config); static void terminate(); diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index c4ee054af6..562e92bea0 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -825,9 +825,10 @@ QList
CppCodeMarker::sections(const InnerNode *inner, return sections; } -const Node *CppCodeMarker::resolveTarget(const QString &target, - const Tree *tree, - const Node *relative) +const Node *CppCodeMarker::resolveTarget(const QString& target, + const Tree* tree, + const Node* relative, + const Node* self) { if (target.endsWith("()")) { const FunctionNode *func; @@ -869,11 +870,13 @@ const Node *CppCodeMarker::resolveTarget(const QString &target, else { QStringList path = target.split("::"); const Node *node; + int flags = Tree::SearchBaseClasses | + Tree::SearchEnumValues | + Tree::NonFunction; if ((node = tree->findNode(path, relative, - Tree::SearchBaseClasses | - Tree::SearchEnumValues | - Tree::NonFunction))) + flags, + self))) return node; } return 0; diff --git a/tools/qdoc3/cppcodemarker.h b/tools/qdoc3/cppcodemarker.h index 2dcf400acd..eca3936b5c 100644 --- a/tools/qdoc3/cppcodemarker.h +++ b/tools/qdoc3/cppcodemarker.h @@ -81,9 +81,10 @@ class CppCodeMarker : public CodeMarker Status status); QList
qmlSections(const QmlClassNode* qmlClassNode, SynopsisStyle style); - const Node *resolveTarget(const QString& target, - const Tree *tree, - const Node *relative); + const Node* resolveTarget(const QString& target, + const Tree* tree, + const Node* relative, + const Node* self = 0); private: QString addMarkUp(const QString& protectedCode, diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 89b1e9853c..4461b48833 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2676,7 +2676,7 @@ void HtmlGenerator::generateQmlItem(const Node *node, } } } - out() << highlightedCode(marked, marker, relative); + out() << highlightedCode(marked, marker, relative, false, node); debugging_on = false; } #endif @@ -2988,7 +2988,8 @@ void HtmlGenerator::generateSynopsis(const Node *node, QString HtmlGenerator::highlightedCode(const QString& markedCode, CodeMarker* marker, const Node* relative, - bool alignNames) + bool alignNames, + const Node* self) { QString src = markedCode; QString html; @@ -3067,8 +3068,9 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, bool handled = false; if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) { par1 = QStringRef(); - const Node* n = marker->resolveTarget(arg.toString(), myTree, relative); + const Node* n = marker->resolveTarget(arg.toString(), myTree, relative, self); if (HtmlGenerator::debugging_on) { + qDebug() << "arg.toString()" << arg.toString(); if (n) { qDebug() << " " << n->name() << n->type() << n->subType(); qDebug() << " " << relative->name() << relative->type() << relative->subType(); diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 80341def61..a2fadf668e 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -210,9 +210,10 @@ class HtmlGenerator : public PageGenerator const Node *relative, CodeMarker *marker); QString highlightedCode(const QString& markedCode, - CodeMarker *marker, - const Node *relative, - bool alignNames = false); + CodeMarker* marker, + const Node* relative, + bool alignNames = false, + const Node* self = 0); void generateFullName(const Node *apparentNode, const Node *relative, diff --git a/tools/qdoc3/javacodemarker.cpp b/tools/qdoc3/javacodemarker.cpp index 1918cd8ead..c9a8f60929 100644 --- a/tools/qdoc3/javacodemarker.cpp +++ b/tools/qdoc3/javacodemarker.cpp @@ -155,8 +155,10 @@ QList
JavaCodeMarker::sections(const InnerNode * /* inner */, SynopsisS return QList
(); } -const Node *JavaCodeMarker::resolveTarget(const QString &target, const Tree *tree, - const Node *relative) +const Node *JavaCodeMarker::resolveTarget(const QString &target, + const Tree *tree, + const Node *relative, + const Node* /* self */) { if (target.endsWith("()")) { const FunctionNode *func; diff --git a/tools/qdoc3/javacodemarker.h b/tools/qdoc3/javacodemarker.h index a2d04dd1b7..c2aabc018a 100644 --- a/tools/qdoc3/javacodemarker.h +++ b/tools/qdoc3/javacodemarker.h @@ -72,7 +72,10 @@ public: QList
sections(const InnerNode *innerNode, SynopsisStyle style, Status status); QString functionBeginRegExp( const QString& funcName ); QString functionEndRegExp( const QString& funcName ); - const Node *resolveTarget( const QString& target, const Tree *tree, const Node *relative ); + const Node* resolveTarget( const QString& target, + const Tree* tree, + const Node* relative, + const Node* self = 0 ); }; QT_END_NAMESPACE diff --git a/tools/qdoc3/plaincodemarker.cpp b/tools/qdoc3/plaincodemarker.cpp index 4abfd2b9f7..d825c13f0f 100644 --- a/tools/qdoc3/plaincodemarker.cpp +++ b/tools/qdoc3/plaincodemarker.cpp @@ -129,11 +129,4 @@ QList
PlainCodeMarker::sections(const InnerNode * /* innerNode */, return QList
(); } -const Node *PlainCodeMarker::resolveTarget( const QString& /* target */, - const Tree * /* tree */, - const Node * /* relative */ ) -{ - return 0; -} - QT_END_NAMESPACE diff --git a/tools/qdoc3/plaincodemarker.h b/tools/qdoc3/plaincodemarker.h index e9cc40d0e5..7afb88e2ae 100644 --- a/tools/qdoc3/plaincodemarker.h +++ b/tools/qdoc3/plaincodemarker.h @@ -71,7 +71,6 @@ public: QString functionBeginRegExp( const QString& funcName ); QString functionEndRegExp( const QString& funcName ); QList
sections(const InnerNode *innerNode, SynopsisStyle style, Status status); - const Node *resolveTarget(const QString &target, const Tree *tree, const Node *relative); }; QT_END_NAMESPACE diff --git a/tools/qdoc3/qscodemarker.cpp b/tools/qdoc3/qscodemarker.cpp index d4b8e80f05..2ee5d99340 100644 --- a/tools/qdoc3/qscodemarker.cpp +++ b/tools/qdoc3/qscodemarker.cpp @@ -375,11 +375,4 @@ QList
QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty return sections; } -const Node *QsCodeMarker::resolveTarget( const QString& /* target */, - const Tree * /* tree */, - const Node * /* relative */ ) -{ - return 0; -} - QT_END_NAMESPACE diff --git a/tools/qdoc3/qscodemarker.h b/tools/qdoc3/qscodemarker.h index 1590009dad..c6a177f4e4 100644 --- a/tools/qdoc3/qscodemarker.h +++ b/tools/qdoc3/qscodemarker.h @@ -72,7 +72,6 @@ public: QList
sections(const InnerNode *innerNode, SynopsisStyle style, Status status); QString functionBeginRegExp( const QString& funcName ); QString functionEndRegExp( const QString& funcName ); - const Node *resolveTarget( const QString& target, const Tree *tree, const Node *relative ); }; QT_END_NAMESPACE diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index 70b998f041..022e1c2e10 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -125,18 +125,20 @@ Tree::~Tree() /*! */ -Node *Tree::findNode(const QStringList &path, Node *relative, int findFlags) +Node *Tree::findNode(const QStringList &path, Node *relative, int findFlags, const Node* self) { return const_cast(const_cast(this)->findNode(path, relative, - findFlags)); + findFlags, + self)); } /*! */ const Node* Tree::findNode(const QStringList &path, const Node* start, - int findFlags) const + int findFlags, + const Node* self) const { const Node* current = start; if (!current) @@ -172,7 +174,7 @@ const Node* Tree::findNode(const QStringList &path, if (node && i == path.size() && (!(findFlags & NonFunction) || node->type() != Node::Function || ((FunctionNode *)node)->metaness() == FunctionNode::MacroWithoutParams)) - if ((node != start) && (node->subType() != Node::QmlPropertyGroup)) + if ((node != self) && (node->subType() != Node::QmlPropertyGroup)) return node; current = current->parent(); } while (current); diff --git a/tools/qdoc3/tree.h b/tools/qdoc3/tree.h index 0865847b3e..b34c3a8d05 100644 --- a/tools/qdoc3/tree.h +++ b/tools/qdoc3/tree.h @@ -65,10 +65,13 @@ class Tree Tree(); ~Tree(); - Node *findNode(const QStringList &path, Node *relative=0, int findFlags=0); - Node *findNode(const QStringList &path, + Node* findNode(const QStringList &path, + Node* relative=0, + int findFlags=0, + const Node* self=0); + Node* findNode(const QStringList &path, Node::Type type, - Node *relative = 0, + Node* relative = 0, int findFlags = 0); FunctionNode *findFunctionNode(const QStringList &path, Node *relative = 0, @@ -98,12 +101,13 @@ class Tree NamespaceNode *root() { return &roo; } QString version() const { return vers; } - const Node *findNode(const QStringList &path, - const Node *relative = 0, - int findFlags = 0) const; - const Node *findNode(const QStringList &path, + const Node* findNode(const QStringList &path, + const Node* relative = 0, + int findFlags = 0, + const Node* self=0) const; + const Node* findNode(const QStringList &path, Node::Type type, const - Node *relative = 0, + Node* relative = 0, int findFlags = 0) const; const FunctionNode *findFunctionNode(const QStringList &path, const Node *relative = 0, -- cgit v1.2.1 From 401a6552f2601e5ca5b2e00a274baa6dcd83c96e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 7 Jul 2010 10:27:38 +0200 Subject: I18n: Complete German translation for 4.7.0 --- translations/qt_de.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/translations/qt_de.ts b/translations/qt_de.ts index 7d32ead8c0..74bd048539 100644 --- a/translations/qt_de.ts +++ b/translations/qt_de.ts @@ -2023,6 +2023,11 @@ nach Signal names cannot begin with an upper case letter Signalnamen dürfen nicht mit einem Großbuchstaben beginnen + + + Illegal signal name + Ungültiger Name für Signal + Duplicate method name @@ -2033,6 +2038,11 @@ nach Method names cannot begin with an upper case letter Methodennamen dürfen nicht mit einem Großbuchstaben beginnen + + + Illegal method name + Ungültiger Name für Methode + Property value set multiple times @@ -7713,20 +7723,52 @@ Bitte wählen Sie einen anderen Dateinamen. Kontext4 - + Call + Button to start a call (note: a separate button is used to end the call) Anruf - + Hangup + Button to end a call (note: a separate button is used to start the call) Auflegen + + + Toggle Call/Hangup + Button that will hang up if we're in call, or make a call if we're not. + Anrufen/Aufhängen + Flip Umdrehen + + + Voice Dial + Button to trigger voice dialling + Sprachwahl + + + + Last Number Redial + Button to redial the last number called + Wahlwiederholung + + + + Camera Shutter + Button to trigger the camera shutter (take a picture) + Auslöser + + + + Camera Focus + Button to focus the camera + Scharfstellen + Kanji -- cgit v1.2.1 From 1350f26569a4ab802ba93dc23e5dcb964a0cd3a5 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 7 Jul 2010 10:24:53 +0200 Subject: Add missing API shims There were still a couple of functions that didn't have them. This could cause said functions to crash if multiple script engines were being used. Reviewed-by: Jedrzej Nowacki --- src/script/api/qscriptvalue.cpp | 6 ++++++ tests/auto/qscriptengine/tst_qscriptengine.cpp | 29 ++++++++++++++++++++++++++ tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 451d1b0eac..f6390bb0be 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1268,6 +1268,7 @@ QDateTime QScriptValue::toDateTime() const Q_D(const QScriptValue); if (!d || !d->engine) return QDateTime(); + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toDateTime(d->engine->currentFrame, d->jscValue); } @@ -1284,6 +1285,7 @@ QRegExp QScriptValue::toRegExp() const Q_D(const QScriptValue); if (!d || !d->engine) return QRegExp(); + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toRegExp(d->engine->currentFrame, d->jscValue); } #endif // QT_NO_REGEXP @@ -1303,6 +1305,7 @@ QObject *QScriptValue::toQObject() const Q_D(const QScriptValue); if (!d || !d->engine) return 0; + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toQObject(d->engine->currentFrame, d->jscValue); } @@ -1317,6 +1320,7 @@ const QMetaObject *QScriptValue::toQMetaObject() const Q_D(const QScriptValue); if (!d || !d->engine) return 0; + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toQMetaObject(d->engine->currentFrame, d->jscValue); } @@ -1407,6 +1411,7 @@ QScriptValue QScriptValue::property(quint32 arrayIndex, Q_D(const QScriptValue); if (!d || !d->isObject()) return QScriptValue(); + QScript::APIShim shim(d->engine); return d->engine->scriptValueFromJSCValue(d->property(arrayIndex, mode)); } @@ -1434,6 +1439,7 @@ void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value, "cannot set value created in a different engine"); return; } + QScript::APIShim shim(d->engine); JSC::JSValue jsValue = d->engine->scriptValueToJSCValue(value); d->setProperty(arrayIndex, jsValue, flags); } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 6885adf3ad..7a732ccc58 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -4265,6 +4265,35 @@ void tst_QScriptEngine::reentrancy() QScriptEngine eng; QCOMPARE(eng.evaluate("Array()").toString(), QString()); } + + { + QScriptEngine eng1; + QScriptEngine eng2; + { + QScriptValue d1 = eng1.newDate(0); + QScriptValue d2 = eng2.newDate(0); + QCOMPARE(d1.toDateTime(), d2.toDateTime()); + QCOMPARE(d2.toDateTime(), d1.toDateTime()); + } + { + QScriptValue r1 = eng1.newRegExp("foo", "gim"); + QScriptValue r2 = eng2.newRegExp("foo", "gim"); + QCOMPARE(r1.toRegExp(), r2.toRegExp()); + QCOMPARE(r2.toRegExp(), r1.toRegExp()); + } + { + QScriptValue o1 = eng1.newQObject(this); + QScriptValue o2 = eng2.newQObject(this); + QCOMPARE(o1.toQObject(), o2.toQObject()); + QCOMPARE(o2.toQObject(), o1.toQObject()); + } + { + QScriptValue mo1 = eng1.newQMetaObject(&staticMetaObject); + QScriptValue mo2 = eng2.newQMetaObject(&staticMetaObject); + QCOMPARE(mo1.toQMetaObject(), mo2.toQMetaObject()); + QCOMPARE(mo2.toQMetaObject(), mo1.toQMetaObject()); + } + } } void tst_QScriptEngine:: incDecNonObjectProperty() diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 8aa4e711de..83a3388fd6 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2123,6 +2123,10 @@ void tst_QScriptValue::getSetProperty() QVERIFY(object.property(foo).strictlyEquals(num)); QVERIFY(object.property("foo").strictlyEquals(num)); QVERIFY(object.propertyFlags(foo) == 0); + + // Setting index property on non-Array + object.setProperty(13, num); + QVERIFY(object.property(13).equals(num)); } void tst_QScriptValue::arrayElementGetterSetter() -- cgit v1.2.1 From 0ad74254d0810459bc08fdf9c0898a0d73f596b0 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 7 Jul 2010 10:50:58 +0200 Subject: qdoc: Removed a lot of dead code to minimize confusion. --- tools/qdoc3/htmlgenerator.cpp | 229 +----------------------------------------- tools/qdoc3/htmlgenerator.h | 6 -- 2 files changed, 1 insertion(+), 234 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 4461b48833..b7ab4d6020 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -346,17 +346,6 @@ QString HtmlGenerator::format() */ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker) { -#if 0 - // Copy the stylesheets from the directory containing the qdocconf file. - // ### This should be changed to use a special directory in doc/src. - QStringList::ConstIterator styleIter = stylesheets.begin(); - QDir configPath = QDir::current(); - while (styleIter != stylesheets.end()) { - QString filePath = configPath.absoluteFilePath(*styleIter); - Config::copyFile(Location(), filePath, filePath, outputDir()); - ++styleIter; - } -#endif myTree = tree; nonCompatClasses.clear(); mainClasses.clear(); @@ -371,9 +360,6 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker) findAllFunctions(tree->root()); findAllLegaleseTexts(tree->root()); findAllNamespaces(tree->root()); -#ifdef ZZZ_QDOC_QML - findAllQmlClasses(tree->root()); -#endif findAllSince(tree->root()); PageGenerator::generateTree(tree, marker); @@ -1259,30 +1245,6 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "(" << Atom(Atom::AutoLink, fullTitle) << ")" << Atom(Atom::LineBreak); -#if 0 - // No longer used because the modeule name is a breadcrumb. - QString fixedModule = inner->moduleName(); - if (fixedModule == "Qt3SupportLight") - fixedModule = "Qt3Support"; - if (!fixedModule.isEmpty()) - subtitleText << "[" << Atom(Atom::AutoLink, fixedModule) << " module]"; - - if (fixedModule.isEmpty()) { - QMultiMap publicGroups = myTree->publicGroups(); - QList groupNames = publicGroups.values(inner->name()); - if (!groupNames.isEmpty()) { - qSort(groupNames.begin(), groupNames.end()); - subtitleText << "["; - for (int j=0; jsections(inner, CodeMarker::Summary, CodeMarker::Okay); generateTableOfContents(inner,marker,§ions); @@ -1853,7 +1815,7 @@ void HtmlGenerator::generateHeader(const QString& title, generateBreadCrumbs(title,node,marker); out() << QString(postPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); -#if 0 // Removed for new docf format. MWS +#if 0 // Removed for new doc format. MWS if (node && !node->links().empty()) out() << "

\n" << navigationLinks << "

\n"; #endif @@ -2665,19 +2627,7 @@ void HtmlGenerator::generateQmlItem(const Node *node, marked.replace("<@type>", ""); marked.replace("", ""); } - if (node->type() == Node::QmlProperty) { - const QmlPropertyNode* qpn = static_cast(node); - if (!summary && qpn->name() == "color" && qpn->dataType() == "color") { - if (relative && relative->name() == "GradientStop") { - qDebug() << "color : color"; - debugging_on = true; - qDebug() << " " << relative->name() << relative->type() << relative->subType(); - qDebug() << marked; - } - } - } out() << highlightedCode(marked, marker, relative, false, node); - debugging_on = false; } #endif @@ -3069,13 +3019,6 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) { par1 = QStringRef(); const Node* n = marker->resolveTarget(arg.toString(), myTree, relative, self); - if (HtmlGenerator::debugging_on) { - qDebug() << "arg.toString()" << arg.toString(); - if (n) { - qDebug() << " " << n->name() << n->type() << n->subType(); - qDebug() << " " << relative->name() << relative->type() << relative->subType(); - } - } addLink(linkForNode(n,relative), arg, &html); handled = true; } @@ -3681,13 +3624,6 @@ void HtmlGenerator::findAllSince(const InnerNode *node) } } -#if 0 - const QRegExp versionSeparator("[\\-\\.]"); - const int minorIndex = version.indexOf(versionSeparator); - const int patchIndex = version.indexOf(versionSeparator, minorIndex+1); - version = version.left(patchIndex); -#endif - void HtmlGenerator::findAllFunctions(const InnerNode *node) { NodeList::ConstIterator c = node->childNodes().begin(); @@ -3751,29 +3687,6 @@ void HtmlGenerator::findAllNamespaces(const InnerNode *node) } } -#ifdef ZZZ_QDOC_QML -/*! - This function finds all the qml element nodes and - stores them in a map for later use. - */ -void HtmlGenerator::findAllQmlClasses(const InnerNode *node) -{ - NodeList::const_iterator c = node->childNodes().constBegin(); - while (c != node->childNodes().constEnd()) { - if ((*c)->type() == Node::Fake) { - const FakeNode* fakeNode = static_cast(*c); - if (fakeNode->subType() == Node::QmlClass) { - const QmlClassNode* qmlNode = - static_cast(fakeNode); - const Node* n = qmlNode->classNode(); - } - qmlClasses.insert(fakeNode->name(),*c); - } - ++c; - } -} -#endif - int HtmlGenerator::hOffset(const Node *node) { switch (node->type()) { @@ -3782,12 +3695,6 @@ int HtmlGenerator::hOffset(const Node *node) return 2; case Node::Fake: return 1; -#if 0 - if (node->doc().briefText().isEmpty()) - return 1; - else - return 2; -#endif case Node::Enum: case Node::Typedef: case Node::Function: @@ -4461,138 +4368,4 @@ void HtmlGenerator::generatePageIndex(const QString& fileName, CodeMarker* marke #endif -#if 0 // fossil removed for new doc format MWS 19/04/2010 - out() << "\n"; - out() << QString("\n").arg(naturalLanguage); - - QString shortVersion; - if ((project != "Qtopia") && (project != "Qt Extended")) { - shortVersion = project + " " + shortVersion + ": "; - if (node && !node->doc().location().isEmpty()) - out() << "\n"; - - shortVersion = myTree->version(); - if (shortVersion.count(QChar('.')) == 2) - shortVersion.truncate(shortVersion.lastIndexOf(QChar('.'))); - if (!shortVersion.isEmpty()) { - if (project == "QSA") - shortVersion = "QSA " + shortVersion + ": "; - else - shortVersion = "Qt " + shortVersion + ": "; - } - } - - out() << "\n" - " " << shortVersion << protectEnc(title) << "\n"; - out() << QString("").arg(outputEncoding); - - if (!style.isEmpty()) - out() << " \n"; - - const QMap &metaMap = node->doc().metaTagMap(); - if (!metaMap.isEmpty()) { - QMapIterator i(metaMap); - while (i.hasNext()) { - i.next(); - out() << " \n"; - } - } - - navigationLinks.clear(); - - if (node && !node->links().empty()) { - QPair linkPair; - QPair anchorPair; - const Node *linkNode; - - if (node->links().contains(Node::PreviousLink)) { - linkPair = node->links()[Node::PreviousLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "[Previous: "; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::ContentsLink)) { - linkPair = node->links()[Node::ContentsLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "["; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::NextLink)) { - linkPair = node->links()[Node::NextLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - - out() << " \n"; - - navigationLinks += "[Next: "; - if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty()) - navigationLinks += protectEnc(anchorPair.second); - else - navigationLinks += protectEnc(linkPair.second); - navigationLinks += "]\n"; - } - if (node->links().contains(Node::IndexLink)) { - linkPair = node->links()[Node::IndexLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - out() << " \n"; - } - if (node->links().contains(Node::StartLink)) { - linkPair = node->links()[Node::StartLink]; - linkNode = findNodeForTarget(linkPair.first, node, marker); - if (!linkNode || linkNode == node) - anchorPair = linkPair; - else - anchorPair = anchorForNode(linkNode); - out() << " \n"; - } - } - - foreach (const QString &stylesheet, stylesheets) { - out() << " \n"; - } - - foreach (const QString &customHeadElement, customHeadElements) { - out() << " " << customHeadElement << "\n"; - } - - out() << "\n" - #endif - QT_END_NAMESPACE diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index a2fadf668e..9c5be15f62 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -237,9 +237,6 @@ class HtmlGenerator : public PageGenerator void findAllFunctions(const InnerNode *node); void findAllLegaleseTexts(const InnerNode *node); void findAllNamespaces(const InnerNode *node); -#ifdef ZZZ_QDOC_QML - void findAllQmlClasses(const InnerNode *node); -#endif void findAllSince(const InnerNode *node); static int hOffset(const Node *node); static bool isThreeColumnEnumValueTable(const Atom *atom); @@ -317,9 +314,6 @@ class HtmlGenerator : public PageGenerator NodeMap obsoleteClasses; NodeMap namespaceIndex; NodeMap serviceClasses; -#ifdef QDOC_QML - NodeMap qmlClasses; -#endif QMap funcIndex; QMap legaleseTexts; NewSinceMaps newSinceMaps; -- cgit v1.2.1 From b139e7e96e5c47b412c4f0bbc4ae11d5cca99e61 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 6 Jul 2010 19:39:52 +0200 Subject: run dep commands in build dir the file names are given relative to the build directory, so the command needs to be run in it as well. this is a more expected (and simpler) fix than the alternative, which would be giving file names relative to the source directory. reasons not to fix: - due to some other bug, the problem really affects only builds where the build dir is not at the same level as the source dir - otherwise, absolute paths would be passed anyway - it has some breakage potential for the cases where the commands actually expect being run in the source dir - it can be worked around by manually injecting the cd statement into the command reasons why i still fixed it: - it doesn't affect in-source builds, and it seems that most complex build systems (which would define custom compilers with depend_command) don't support shadow builds anyway - people who needed things to work probably already used $$OUT_PWD somehow (either a "cd" at the start, or prepending it to each path), so this change will be practically a no-op - "it's just dependencies, and these are known to be broken in qmake anyway" Reviewed-by: joerg Task-number: QTBUG-1918 --- qmake/generators/makefile.cpp | 8 ++++++-- tests/auto/qmake/testdata/simple_app/build/README | 1 + tests/auto/qmake/testdata/simple_app/simple_app.pro | 1 + tests/auto/qmake/testdata/simple_app/test.qrc | 5 +++++ tests/auto/qmake/tst_qmake.cpp | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qmake/testdata/simple_app/build/README create mode 100644 tests/auto/qmake/testdata/simple_app/test.qrc diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index d6b3e09d5b..45a96f51f8 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1756,6 +1756,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } QStringList tmp_dep = project->values((*it) + ".depends"); QString tmp_dep_cmd; + QString dep_cd_cmd; if(!project->isEmpty((*it) + ".depend_command")) { int argv0 = -1; QStringList cmdline = project->values((*it) + ".depend_command"); @@ -1774,6 +1775,9 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) cmdline[argv0] = escapeFilePath(cmdline.at(argv0)); } } + dep_cd_cmd = QLatin1String("cd ") + + escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false)) + + QLatin1String(" && "); } QStringList &vars = project->values((*it) + ".variables"); if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) @@ -1875,7 +1879,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) char buff[256]; QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, (*input), tmp_out); - dep_cmd = fixEnvVariables(dep_cmd); + dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) { QString indeps; while(!feof(proc)) { @@ -1973,7 +1977,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) if(!tmp_dep_cmd.isEmpty() && doDepends()) { char buff[256]; QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, (*input), out); - dep_cmd = fixEnvVariables(dep_cmd); + dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) { QString indeps; while(!feof(proc)) { diff --git a/tests/auto/qmake/testdata/simple_app/build/README b/tests/auto/qmake/testdata/simple_app/build/README new file mode 100644 index 0000000000..acfd9d9226 --- /dev/null +++ b/tests/auto/qmake/testdata/simple_app/build/README @@ -0,0 +1 @@ +Here to ensure build/ exists, used by the simple_app_shadowbuild2 test. diff --git a/tests/auto/qmake/testdata/simple_app/simple_app.pro b/tests/auto/qmake/testdata/simple_app/simple_app.pro index f496d5bb8e..a8c4ad613d 100644 --- a/tests/auto/qmake/testdata/simple_app/simple_app.pro +++ b/tests/auto/qmake/testdata/simple_app/simple_app.pro @@ -3,6 +3,7 @@ CONFIG += qt warn_on HEADERS = test_file.h SOURCES = test_file.cpp \ main.cpp +RESOURCES = test.qrc TARGET = simple_app DESTDIR = ./ diff --git a/tests/auto/qmake/testdata/simple_app/test.qrc b/tests/auto/qmake/testdata/simple_app/test.qrc new file mode 100644 index 0000000000..decde3dd24 --- /dev/null +++ b/tests/auto/qmake/testdata/simple_app/test.qrc @@ -0,0 +1,5 @@ + + + test.qrc + + diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 03054e709d..5efe7148db 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -65,6 +65,7 @@ public slots: private slots: void simple_app(); void simple_app_shadowbuild(); + void simple_app_shadowbuild2(); void simple_lib(); void simple_dll(); void subdirs(); @@ -163,6 +164,21 @@ void tst_qmake::simple_app_shadowbuild() QVERIFY( test_compiler.removeMakefile( buildDir ) ); } +void tst_qmake::simple_app_shadowbuild2() +{ + QString workDir = base_path + "/testdata/simple_app"; + QString buildDir = base_path + "/testdata/simple_app/build"; + + QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir )); + QVERIFY( test_compiler.make( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); + QVERIFY( test_compiler.makeClean( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean + QVERIFY( test_compiler.makeDistClean( buildDir )); + QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean + QVERIFY( test_compiler.removeMakefile( buildDir ) ); +} + void tst_qmake::simple_dll() { QString workDir = base_path + "/testdata/simple_dll"; -- cgit v1.2.1 From 42fe2bfb65c85fc630efe32aa1d62d66f2caab2a Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 7 Jul 2010 12:05:35 +0200 Subject: Fixed whitespace formatting Merge-request: 715 Reviewed-by: Oswald Buddenhagen --- src/plugins/sqldrivers/db2/db2.pro | 2 +- src/plugins/sqldrivers/ibase/ibase.pro | 2 +- src/plugins/sqldrivers/mysql/mysql.pro | 2 +- src/plugins/sqldrivers/oci/oci.pro | 2 +- src/plugins/sqldrivers/odbc/odbc.pro | 2 +- src/plugins/sqldrivers/psql/psql.pro | 2 +- src/plugins/sqldrivers/sqlite/sqlite.pro | 2 +- src/plugins/sqldrivers/sqlite2/sqlite2.pro | 2 +- src/plugins/sqldrivers/tds/tds.pro | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro index 5223beb96f..25ca49938c 100644 --- a/src/plugins/sqldrivers/db2/db2.pro +++ b/src/plugins/sqldrivers/db2/db2.pro @@ -1,4 +1,4 @@ -TARGET = qsqldb2 +TARGET = qsqldb2 HEADERS = ../../../sql/drivers/db2/qsql_db2.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro index ec2bc7b987..bb73adb846 100644 --- a/src/plugins/sqldrivers/ibase/ibase.pro +++ b/src/plugins/sqldrivers/ibase/ibase.pro @@ -1,4 +1,4 @@ -TARGET = qsqlibase +TARGET = qsqlibase HEADERS = ../../../sql/drivers/ibase/qsql_ibase.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro index 9f5c619e19..b808c8ed9e 100644 --- a/src/plugins/sqldrivers/mysql/mysql.pro +++ b/src/plugins/sqldrivers/mysql/mysql.pro @@ -1,4 +1,4 @@ -TARGET = qsqlmysql +TARGET = qsqlmysql HEADERS = ../../../sql/drivers/mysql/qsql_mysql.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro index 3bf70a13f9..d75827e064 100644 --- a/src/plugins/sqldrivers/oci/oci.pro +++ b/src/plugins/sqldrivers/oci/oci.pro @@ -1,4 +1,4 @@ -TARGET = qsqloci +TARGET = qsqloci HEADERS = ../../../sql/drivers/oci/qsql_oci.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 2bf85f1f7e..70070dbbf2 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -1,4 +1,4 @@ -TARGET = qsqlodbc +TARGET = qsqlodbc HEADERS = ../../../sql/drivers/odbc/qsql_odbc.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro index 80a5348f5e..95866959bb 100644 --- a/src/plugins/sqldrivers/psql/psql.pro +++ b/src/plugins/sqldrivers/psql/psql.pro @@ -1,4 +1,4 @@ -TARGET = qsqlpsql +TARGET = qsqlpsql HEADERS = ../../../sql/drivers/psql/qsql_psql.h SOURCES = main.cpp \ diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro index fb312334c1..75f04b9b54 100644 --- a/src/plugins/sqldrivers/sqlite/sqlite.pro +++ b/src/plugins/sqldrivers/sqlite/sqlite.pro @@ -1,4 +1,4 @@ -TARGET = qsqlite +TARGET = qsqlite HEADERS = ../../../sql/drivers/sqlite/qsql_sqlite.h SOURCES = smain.cpp \ diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro index 88db22a63a..0f6c19adbe 100644 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro +++ b/src/plugins/sqldrivers/sqlite2/sqlite2.pro @@ -1,4 +1,4 @@ -TARGET = qsqlite2 +TARGET = qsqlite2 HEADERS = ../../../sql/drivers/sqlite2/qsql_sqlite2.h SOURCES = smain.cpp \ diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro index 08a166baa9..ba40be5731 100644 --- a/src/plugins/sqldrivers/tds/tds.pro +++ b/src/plugins/sqldrivers/tds/tds.pro @@ -1,4 +1,4 @@ -TARGET = qsqltds +TARGET = qsqltds HEADERS = ../../../sql/drivers/tds/qsql_tds.h -- cgit v1.2.1 From d7557de99b38031906c17c54496cb76a13dec5f7 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 7 Jul 2010 12:05:36 +0200 Subject: Consolidate sql driver configuration redundancy Previously sql driver recipes each appeared in both the plugin pro file and src/sql/drivers/drivers.pri for building into QtSql. Split driver recipes into shared pri files. Also split bundled 3rd party sqlite code recipe into a shared pri. Merge-request: 715 Reviewed-by: Oswald Buddenhagen --- src/3rdparty/sqlite.pri | 4 + src/plugins/sqldrivers/db2/db2.pro | 8 +- src/plugins/sqldrivers/ibase/ibase.pro | 12 +-- src/plugins/sqldrivers/mysql/mysql.pro | 21 +---- src/plugins/sqldrivers/oci/oci.pro | 11 +-- src/plugins/sqldrivers/odbc/odbc.pro | 17 +--- src/plugins/sqldrivers/psql/psql.pro | 16 +--- src/plugins/sqldrivers/sqlite/sqlite.pro | 15 +--- src/plugins/sqldrivers/sqlite2/sqlite2.pro | 7 +- src/plugins/sqldrivers/tds/tds.pro | 13 +-- src/sql/drivers/db2/qsql_db2.pri | 8 ++ src/sql/drivers/drivers.pri | 130 +++-------------------------- src/sql/drivers/ibase/qsql_ibase.pri | 11 +++ src/sql/drivers/mysql/qsql_mysql.pri | 16 ++++ src/sql/drivers/oci/qsql_oci.pri | 9 ++ src/sql/drivers/odbc/qsql_odbc.pri | 13 +++ src/sql/drivers/psql/qsql_psql.pri | 13 +++ src/sql/drivers/sqlite/qsql_sqlite.pri | 9 ++ src/sql/drivers/sqlite2/qsql_sqlite2.pri | 4 + src/sql/drivers/tds/qsql_tds.pri | 10 +++ 20 files changed, 126 insertions(+), 221 deletions(-) create mode 100644 src/3rdparty/sqlite.pri create mode 100644 src/sql/drivers/db2/qsql_db2.pri create mode 100644 src/sql/drivers/ibase/qsql_ibase.pri create mode 100644 src/sql/drivers/mysql/qsql_mysql.pri create mode 100644 src/sql/drivers/oci/qsql_oci.pri create mode 100644 src/sql/drivers/odbc/qsql_odbc.pri create mode 100644 src/sql/drivers/psql/qsql_psql.pri create mode 100644 src/sql/drivers/sqlite/qsql_sqlite.pri create mode 100644 src/sql/drivers/sqlite2/qsql_sqlite2.pri create mode 100644 src/sql/drivers/tds/qsql_tds.pri diff --git a/src/3rdparty/sqlite.pri b/src/3rdparty/sqlite.pri new file mode 100644 index 0000000000..575412da09 --- /dev/null +++ b/src/3rdparty/sqlite.pri @@ -0,0 +1,4 @@ +CONFIG(release, debug|release):DEFINES *= NDEBUG +DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE +INCLUDEPATH += $$PWD/sqlite +SOURCES += $$PWD/sqlite/sqlite3.c diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro index 25ca49938c..e053f3756b 100644 --- a/src/plugins/sqldrivers/db2/db2.pro +++ b/src/plugins/sqldrivers/db2/db2.pro @@ -1,10 +1,6 @@ TARGET = qsqldb2 -HEADERS = ../../../sql/drivers/db2/qsql_db2.h -SOURCES = main.cpp \ - ../../../sql/drivers/db2/qsql_db2.cpp - -unix:!contains( LIBS, .*db2.* ):LIBS *= -ldb2 -win32:!contains( LIBS, .*db2.* ):LIBS *= -ldb2cli +SOURCES = main.cpp +include(../../../sql/drivers/db2/qsql_db2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro index bb73adb846..7870ec8465 100644 --- a/src/plugins/sqldrivers/ibase/ibase.pro +++ b/src/plugins/sqldrivers/ibase/ibase.pro @@ -1,14 +1,6 @@ TARGET = qsqlibase -HEADERS = ../../../sql/drivers/ibase/qsql_ibase.h -SOURCES = main.cpp \ - ../../../sql/drivers/ibase/qsql_ibase.cpp - -unix:!contains( LIBS, .*gds.* ):!contains( LIBS, .*libfb.* ):LIBS *= -lgds - -win32:!contains( LIBS, .*gds.* ):!contains( LIBS, .*fbclient.* ) { - !win32-borland:LIBS *= -lgds32_ms - win32-borland:LIBS += gds32.lib -} +SOURCES = main.cpp +include(../../../sql/drivers/ibase/qsql_ibase.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro index b808c8ed9e..b6d42fffc8 100644 --- a/src/plugins/sqldrivers/mysql/mysql.pro +++ b/src/plugins/sqldrivers/mysql/mysql.pro @@ -1,23 +1,6 @@ TARGET = qsqlmysql -HEADERS = ../../../sql/drivers/mysql/qsql_mysql.h -SOURCES = main.cpp \ - ../../../sql/drivers/mysql/qsql_mysql.cpp - -unix: { - isEmpty(QT_LFLAGS_MYSQL) { - !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { - use_libmysqlclient_r:LIBS *= -lmysqlclient_r - else:LIBS *= -lmysqlclient - } - } else { - LIBS *= $$QT_LFLAGS_MYSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL - } -} - -win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) { - LIBS *= -llibmysql -} +SOURCES = main.cpp +include(../../../sql/drivers/mysql/qsql_mysql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro index d75827e064..d7dcce9e35 100644 --- a/src/plugins/sqldrivers/oci/oci.pro +++ b/src/plugins/sqldrivers/oci/oci.pro @@ -1,13 +1,6 @@ TARGET = qsqloci -HEADERS = ../../../sql/drivers/oci/qsql_oci.h -SOURCES = main.cpp \ - ../../../sql/drivers/oci/qsql_oci.cpp - -win32:LIBS *= -loci - -unix:!contains( LIBS, .*clnts.* ):LIBS *= -lclntsh - -macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ +SOURCES = main.cpp +include(../../../sql/drivers/oci/qsql_oci.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 70070dbbf2..677eb6eedf 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -1,19 +1,6 @@ TARGET = qsqlodbc -HEADERS = ../../../sql/drivers/odbc/qsql_odbc.h -SOURCES = main.cpp \ - ../../../sql/drivers/odbc/qsql_odbc.cpp - -unix { - !contains( LIBS, .*odbc.* ) { - LIBS *= $$QT_LFLAGS_ODBC - } - DEFINES += UNICODE -} - -win32 { - !win32-borland:LIBS *= -lodbc32 - win32-borland:LIBS *= $(BCB)/lib/PSDK/odbc32.lib -} +SOURCES = main.cpp +include(../../../sql/drivers/odbc/qsql_odbc.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro index 95866959bb..8276c0ae90 100644 --- a/src/plugins/sqldrivers/psql/psql.pro +++ b/src/plugins/sqldrivers/psql/psql.pro @@ -1,18 +1,6 @@ TARGET = qsqlpsql -HEADERS = ../../../sql/drivers/psql/qsql_psql.h -SOURCES = main.cpp \ - ../../../sql/drivers/psql/qsql_psql.cpp - -unix|win32-g++*: { - !isEmpty(QT_LFLAGS_PSQL) { - !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz - !static:LIBS *= $$QT_LFLAGS_PSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL - } - !contains(LIBS, .*pq.*):LIBS *= -lpq -} - -win32:!win32-g++*:!contains(LIBS, .*pq.* ) LIBS *= -llibpq -lws2_32 -ladvapi32 +SOURCES = main.cpp +include(../../../sql/drivers/psql/qsql_psql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro index 75f04b9b54..f4c1671a4b 100644 --- a/src/plugins/sqldrivers/sqlite/sqlite.pro +++ b/src/plugins/sqldrivers/sqlite/sqlite.pro @@ -1,18 +1,7 @@ TARGET = qsqlite -HEADERS = ../../../sql/drivers/sqlite/qsql_sqlite.h -SOURCES = smain.cpp \ - ../../../sql/drivers/sqlite/qsql_sqlite.cpp - -!system-sqlite:!contains( LIBS, .*sqlite.* ) { - CONFIG(release, debug|release):DEFINES *= NDEBUG - DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE - INCLUDEPATH += ../../../3rdparty/sqlite - SOURCES += ../../../3rdparty/sqlite/sqlite3.c -} else { - LIBS *= $$QT_LFLAGS_SQLITE - QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE -} +SOURCES = smain.cpp +include(../../../sql/drivers/sqlite/qsql_sqlite.pri) wince*: DEFINES += HAVE_LOCALTIME_S=0 diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro index 0f6c19adbe..e6197b9906 100644 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro +++ b/src/plugins/sqldrivers/sqlite2/sqlite2.pro @@ -1,9 +1,6 @@ TARGET = qsqlite2 -HEADERS = ../../../sql/drivers/sqlite2/qsql_sqlite2.h -SOURCES = smain.cpp \ - ../../../sql/drivers/sqlite2/qsql_sqlite2.cpp - -!contains(LIBS, .*sqlite.*):LIBS *= -lsqlite +SOURCES = smain.cpp +include(../../../sql/drivers/sqlite2/qsql_sqlite2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro index ba40be5731..b8e8ded321 100644 --- a/src/plugins/sqldrivers/tds/tds.pro +++ b/src/plugins/sqldrivers/tds/tds.pro @@ -1,15 +1,6 @@ TARGET = qsqltds -HEADERS = ../../../sql/drivers/tds/qsql_tds.h - -SOURCES = main.cpp \ - ../../../sql/drivers/tds/qsql_tds.cpp - -unix:!contains( LIBS, .*sybdb.* ):LIBS *= -lsybdb - -win32 { - !win32-borland:LIBS *= -lNTWDBLIB - win32-borland:LIBS *= $(BCB)/lib/PSDK/NTWDBLIB.LIB -} +SOURCES = main.cpp +include(../../../sql/drivers/tds/qsql_tds.pri) include(../qsqldriverbase.pri) diff --git a/src/sql/drivers/db2/qsql_db2.pri b/src/sql/drivers/db2/qsql_db2.pri new file mode 100644 index 0000000000..e53a8a0f22 --- /dev/null +++ b/src/sql/drivers/db2/qsql_db2.pri @@ -0,0 +1,8 @@ +HEADERS += $$PWD/qsql_db2.h +SOURCES += $$PWD/qsql_db2.cpp + +unix { + !contains(LIBS, .*db2.*):LIBS *= -ldb2 +} else:!win32-borland { + !contains(LIBS, .*db2.*):LIBS *= -ldb2cli +} diff --git a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri index 05e7265120..3af5525175 100644 --- a/src/sql/drivers/drivers.pri +++ b/src/sql/drivers/drivers.pri @@ -1,119 +1,11 @@ -contains(sql-drivers, all ) { - sql-driver += psql mysql odbc oci tds db2 sqlite ibase -} - -contains(sql-drivers, psql) { - HEADERS += drivers/psql/qsql_psql.h - SOURCES += drivers/psql/qsql_psql.cpp - - unix|win32-g++* { - !static:!isEmpty(QT_LFLAGS_PSQL) { - !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz - !static:LIBS *= $$QT_LFLAGS_PSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL - } - !contains(LIBS, .*pq.*):LIBS *= -lpq - } else:win32:!contains(LIBS, .*pq.* ) LIBS *= -llibpq -lws2_32 -ladvapi32 -} - -contains(sql-drivers, mysql) { - HEADERS += drivers/mysql/qsql_mysql.h - SOURCES += drivers/mysql/qsql_mysql.cpp - - unix { - isEmpty(QT_LFLAGS_MYSQL) { - !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { - use_libmysqlclient_r:LIBS *= -lmysqlclient_r - else:LIBS *= -lmysqlclient - } - } else { - LIBS *= $$QT_LFLAGS_MYSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL - } - } - - win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) { - !win32-g++*:LIBS *= -llibmysql - else:LIBS *= -lmysql - } -} - -contains(sql-drivers, odbc) { - HEADERS += drivers/odbc/qsql_odbc.h - SOURCES += drivers/odbc/qsql_odbc.cpp - - mac:!contains( LIBS, .*odbc.* ):LIBS *= -liodbc - unix:!contains( LIBS, .*odbc.* ):LIBS *= -lodbc - unix:DEFINES += UNICODE - - win32 { - !win32-borland:LIBS *= -lodbc32 - else:LIBS *= $(BCB)/lib/PSDK/odbc32.lib - } -} - -contains(sql-drivers, oci) { - HEADERS += drivers/oci/qsql_oci.h - SOURCES += drivers/oci/qsql_oci.cpp - - unix:!contains( LIBS, .*clnts.* ):LIBS += -lclntsh - - win32:LIBS += -loci -} - -contains(sql-drivers, tds) { - HEADERS += drivers/tds/qsql_tds.h - SOURCES += drivers/tds/qsql_tds.cpp - - unix:LIBS += -L$SYBASE/lib -lsybdb - - win32 { - !win32-borland:LIBS += -lNTWDBLIB - else:LIBS += $(BCB)/lib/PSDK/NTWDBLIB.LIB - } -} - -contains(sql-drivers, db2) { - HEADERS += drivers/db2/qsql_db2.h - SOURCES += drivers/db2/qsql_db2.cpp - - unix:LIBS += -ldb2 - - win32 { - !win32-borland:LIBS += -ldb2cli -# else:LIBS += $(BCB)/lib/PSDK/db2cli.lib - } -} - -contains(sql-drivers, ibase) { - HEADERS += drivers/ibase/qsql_ibase.h - SOURCES += drivers/ibase/qsql_ibase.cpp - - unix:LIBS *= -lgds - - win32 { - !win32-borland:LIBS *= -lgds32_ms - else:LIBS += gds32.lib - } -} - -contains(sql-drivers, sqlite2) { - HEADERS += drivers/sqlite2/qsql_sqlite2.h - SOURCES += drivers/sqlite2/qsql_sqlite2.cpp - !contains(LIBS, .*sqlite.*):LIBS *= -lsqlite -} - -contains(sql-drivers, sqlite) { - !system-sqlite:!contains( LIBS, .*sqlite3.* ) { - CONFIG(release, debug|release):DEFINES *= NDEBUG - DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE - INCLUDEPATH += ../3rdparty/sqlite - SOURCES += ../3rdparty/sqlite/sqlite3.c - } else { - LIBS *= $$QT_LFLAGS_SQLITE - QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE - } - - HEADERS += drivers/sqlite/qsql_sqlite.h - SOURCES += drivers/sqlite/qsql_sqlite.cpp -} +contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase + +contains(sql-drivers, psql):include($$PWD/sqlite/qsql_psql.pri) +contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri) +contains(sql-drivers, odbc):include($$PWD/odbc/qsql_odbc.pri) +contains(sql-drivers, oci):include($$PWD/oci/qsql_oci.pri) +contains(sql-drivers, tds):include($$PWD/tds/qsql_tds.pri) +contains(sql-drivers, db2):include($$PWD/db2/qsql_db2.pri) +contains(sql-drivers, ibase):include($$PWD/db2/qsql_ibase.pri) +contains(sql-drivers, sqlite2):include($$PWD/sqlite2/qsql_sqlite2.pri) +contains(sql-drivers, sqlite):include($$PWD/sqlite/qsql_sqlite.pri) diff --git a/src/sql/drivers/ibase/qsql_ibase.pri b/src/sql/drivers/ibase/qsql_ibase.pri new file mode 100644 index 0000000000..ebcd18aa58 --- /dev/null +++ b/src/sql/drivers/ibase/qsql_ibase.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/qsql_ibase.h +SOURCES += $$PWD/qsql_ibase.cpp + +unix { + !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS *= -lgds +} else { + !contains(LIBS, .*gds.*):!contains(LIBS, .*fbclient.*) { + win32-borland:LIBS += gds32.lib + else:LIBS *= -lgds32_ms + } +} diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri new file mode 100644 index 0000000000..801b891856 --- /dev/null +++ b/src/sql/drivers/mysql/qsql_mysql.pri @@ -0,0 +1,16 @@ +HEADERS += $$PWD/qsql_mysql.h +SOURCES += $$PWD/qsql_mysql.cpp + +unix { + isEmpty(QT_LFLAGS_MYSQL) { + !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { + use_libmysqlclient_r:LIBS *= -lmysqlclient_r + else:LIBS *= -lmysqlclient + } + } else { + LIBS *= $$QT_LFLAGS_MYSQL + QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL + } +} else { + !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS *= -llibmysql +} diff --git a/src/sql/drivers/oci/qsql_oci.pri b/src/sql/drivers/oci/qsql_oci.pri new file mode 100644 index 0000000000..685915613f --- /dev/null +++ b/src/sql/drivers/oci/qsql_oci.pri @@ -0,0 +1,9 @@ +HEADERS += $$PWD/qsql_oci.h +SOURCES += $$PWD/qsql_oci.cpp + +unix { + !contains(LIBS, .*clnts.*):LIBS *= -lclntsh +} else { + LIBS *= -loci +} +macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ diff --git a/src/sql/drivers/odbc/qsql_odbc.pri b/src/sql/drivers/odbc/qsql_odbc.pri new file mode 100644 index 0000000000..c4c92be64c --- /dev/null +++ b/src/sql/drivers/odbc/qsql_odbc.pri @@ -0,0 +1,13 @@ +HEADERS += $$PWD/qsql_odbc.h +SOURCES += $$PWD/qsql_odbc.cpp + +mac { + !contains(LIBS, .*odbc.*):LIBS *= -liodbc +} else:unix { + DEFINES += UNICODE + !contains(LIBS, .*odbc.*):LIBS *= $$QT_LFLAGS_ODBC +} else:win32-borland { + LIBS *= $(BCB)/lib/PSDK/odbc32.lib +} else { + LIBS *= -lodbc32 +} diff --git a/src/sql/drivers/psql/qsql_psql.pri b/src/sql/drivers/psql/qsql_psql.pri new file mode 100644 index 0000000000..c282d578f9 --- /dev/null +++ b/src/sql/drivers/psql/qsql_psql.pri @@ -0,0 +1,13 @@ +HEADERS += $$PWD/qsql_psql.h +SOURCES += $$PWD/qsql_psql.cpp + +unix|win32-g++* { + !static:!isEmpty(QT_LFLAGS_PSQL) { + !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz + LIBS *= $$QT_LFLAGS_PSQL + QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL + } + !contains(LIBS, .*pq.*):LIBS *= -lpq +} else { + !contains(LIBS, .*pq.*):LIBS *= -llibpq -lws2_32 -ladvapi32 +} diff --git a/src/sql/drivers/sqlite/qsql_sqlite.pri b/src/sql/drivers/sqlite/qsql_sqlite.pri new file mode 100644 index 0000000000..7ad5936e25 --- /dev/null +++ b/src/sql/drivers/sqlite/qsql_sqlite.pri @@ -0,0 +1,9 @@ +HEADERS += $$PWD/qsql_sqlite.h +SOURCES += $$PWD/qsql_sqlite.cpp + +!system-sqlite:!contains(LIBS, .*sqlite3.*) { + include($$PWD/../../../3rdparty/sqlite.pri) +} else { + LIBS *= $$QT_LFLAGS_SQLITE + QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE +} diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.pri b/src/sql/drivers/sqlite2/qsql_sqlite2.pri new file mode 100644 index 0000000000..9f0e807b5a --- /dev/null +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.pri @@ -0,0 +1,4 @@ +HEADERS += $PWD/qsql_sqlite2.h +SOURCES += $PWD/qsql_sqlite2.cpp + +!contains(LIBS, .*sqlite.*):LIBS *= -lsqlite diff --git a/src/sql/drivers/tds/qsql_tds.pri b/src/sql/drivers/tds/qsql_tds.pri new file mode 100644 index 0000000000..e2662caa86 --- /dev/null +++ b/src/sql/drivers/tds/qsql_tds.pri @@ -0,0 +1,10 @@ +HEADERS += $$PWD/qsql_tds.h +SOURCES += $$PWD/qsql_tds.cpp + +unix { + !contains(LIBS, .*sybdb.*):LIBS *= -lsybdb +} else:win32-borland { + LIBS *= $(BCB)/lib/PSDK/NTWDBLIB.LIB +} else { + LIBS *= -lNTWDBLIB +} -- cgit v1.2.1 From 484c05ef374ef1c1043836b074693838d6b30adb Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 7 Jul 2010 12:05:37 +0200 Subject: Simplify *= to += after contains() test Merge-request: 715 Reviewed-by: Oswald Buddenhagen --- src/sql/drivers/db2/qsql_db2.pri | 4 ++-- src/sql/drivers/ibase/qsql_ibase.pri | 4 ++-- src/sql/drivers/mysql/qsql_mysql.pri | 6 +++--- src/sql/drivers/oci/qsql_oci.pri | 2 +- src/sql/drivers/odbc/qsql_odbc.pri | 4 ++-- src/sql/drivers/psql/qsql_psql.pri | 4 ++-- src/sql/drivers/sqlite2/qsql_sqlite2.pri | 2 +- src/sql/drivers/tds/qsql_tds.pri | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sql/drivers/db2/qsql_db2.pri b/src/sql/drivers/db2/qsql_db2.pri index e53a8a0f22..16557f0e00 100644 --- a/src/sql/drivers/db2/qsql_db2.pri +++ b/src/sql/drivers/db2/qsql_db2.pri @@ -2,7 +2,7 @@ HEADERS += $$PWD/qsql_db2.h SOURCES += $$PWD/qsql_db2.cpp unix { - !contains(LIBS, .*db2.*):LIBS *= -ldb2 + !contains(LIBS, .*db2.*):LIBS += -ldb2 } else:!win32-borland { - !contains(LIBS, .*db2.*):LIBS *= -ldb2cli + !contains(LIBS, .*db2.*):LIBS += -ldb2cli } diff --git a/src/sql/drivers/ibase/qsql_ibase.pri b/src/sql/drivers/ibase/qsql_ibase.pri index ebcd18aa58..33fbb0de30 100644 --- a/src/sql/drivers/ibase/qsql_ibase.pri +++ b/src/sql/drivers/ibase/qsql_ibase.pri @@ -2,10 +2,10 @@ HEADERS += $$PWD/qsql_ibase.h SOURCES += $$PWD/qsql_ibase.cpp unix { - !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS *= -lgds + !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS += -lgds } else { !contains(LIBS, .*gds.*):!contains(LIBS, .*fbclient.*) { win32-borland:LIBS += gds32.lib - else:LIBS *= -lgds32_ms + else:LIBS += -lgds32_ms } } diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri index 801b891856..1b9c3dd8ca 100644 --- a/src/sql/drivers/mysql/qsql_mysql.pri +++ b/src/sql/drivers/mysql/qsql_mysql.pri @@ -4,13 +4,13 @@ SOURCES += $$PWD/qsql_mysql.cpp unix { isEmpty(QT_LFLAGS_MYSQL) { !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { - use_libmysqlclient_r:LIBS *= -lmysqlclient_r - else:LIBS *= -lmysqlclient + use_libmysqlclient_r:LIBS += -lmysqlclient_r + else:LIBS += -lmysqlclient } } else { LIBS *= $$QT_LFLAGS_MYSQL QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL } } else { - !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS *= -llibmysql + !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS += -llibmysql } diff --git a/src/sql/drivers/oci/qsql_oci.pri b/src/sql/drivers/oci/qsql_oci.pri index 685915613f..60ccc4c227 100644 --- a/src/sql/drivers/oci/qsql_oci.pri +++ b/src/sql/drivers/oci/qsql_oci.pri @@ -2,7 +2,7 @@ HEADERS += $$PWD/qsql_oci.h SOURCES += $$PWD/qsql_oci.cpp unix { - !contains(LIBS, .*clnts.*):LIBS *= -lclntsh + !contains(LIBS, .*clnts.*):LIBS += -lclntsh } else { LIBS *= -loci } diff --git a/src/sql/drivers/odbc/qsql_odbc.pri b/src/sql/drivers/odbc/qsql_odbc.pri index c4c92be64c..839401203c 100644 --- a/src/sql/drivers/odbc/qsql_odbc.pri +++ b/src/sql/drivers/odbc/qsql_odbc.pri @@ -2,10 +2,10 @@ HEADERS += $$PWD/qsql_odbc.h SOURCES += $$PWD/qsql_odbc.cpp mac { - !contains(LIBS, .*odbc.*):LIBS *= -liodbc + !contains(LIBS, .*odbc.*):LIBS += -liodbc } else:unix { DEFINES += UNICODE - !contains(LIBS, .*odbc.*):LIBS *= $$QT_LFLAGS_ODBC + !contains(LIBS, .*odbc.*):LIBS += $$QT_LFLAGS_ODBC } else:win32-borland { LIBS *= $(BCB)/lib/PSDK/odbc32.lib } else { diff --git a/src/sql/drivers/psql/qsql_psql.pri b/src/sql/drivers/psql/qsql_psql.pri index c282d578f9..97db4beb59 100644 --- a/src/sql/drivers/psql/qsql_psql.pri +++ b/src/sql/drivers/psql/qsql_psql.pri @@ -7,7 +7,7 @@ unix|win32-g++* { LIBS *= $$QT_LFLAGS_PSQL QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL } - !contains(LIBS, .*pq.*):LIBS *= -lpq + !contains(LIBS, .*pq.*):LIBS += -lpq } else { - !contains(LIBS, .*pq.*):LIBS *= -llibpq -lws2_32 -ladvapi32 + !contains(LIBS, .*pq.*):LIBS += -llibpq -lws2_32 -ladvapi32 } diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.pri b/src/sql/drivers/sqlite2/qsql_sqlite2.pri index 9f0e807b5a..76fe255c99 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.pri +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.pri @@ -1,4 +1,4 @@ HEADERS += $PWD/qsql_sqlite2.h SOURCES += $PWD/qsql_sqlite2.cpp -!contains(LIBS, .*sqlite.*):LIBS *= -lsqlite +!contains(LIBS, .*sqlite.*):LIBS += -lsqlite diff --git a/src/sql/drivers/tds/qsql_tds.pri b/src/sql/drivers/tds/qsql_tds.pri index e2662caa86..c552ead1a7 100644 --- a/src/sql/drivers/tds/qsql_tds.pri +++ b/src/sql/drivers/tds/qsql_tds.pri @@ -2,7 +2,7 @@ HEADERS += $$PWD/qsql_tds.h SOURCES += $$PWD/qsql_tds.cpp unix { - !contains(LIBS, .*sybdb.*):LIBS *= -lsybdb + !contains(LIBS, .*sybdb.*):LIBS += -lsybdb } else:win32-borland { LIBS *= $(BCB)/lib/PSDK/NTWDBLIB.LIB } else { -- cgit v1.2.1 From 896de79554060aadf4963d8285ef3f5d8740428b Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 7 Jul 2010 14:21:55 +0200 Subject: qdoc: Fixed a few links to QtObject (QML:QtObject) --- doc/src/declarative/elements.qdoc | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 6 +++--- tools/qdoc3/cppcodeparser.cpp | 15 ++------------- tools/qdoc3/htmlgenerator.cpp | 5 ++++- tools/qdoc3/tree.cpp | 6 ++++-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 48eb09fd30..349a8eda9b 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -114,7 +114,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \row \o \l {Connections} \o Explicitly connects signals and signal handlers \row \o \l {Component} \o Encapsulate QML items as a component \row \o \l {Timer} \o Provides timed triggers -\row \o \l {QtObject} \o Basic element containing only the objectName property +\row \o \l {QML:QtObject} {QtObject} \o Basic element containing only the objectName property \row \o \l {WorkerScript} \o Enables the use of threads in QML \row \o \l {Loader} \o Controls the loading of items or components \row \o \l {Repeater} \o Uses a model to create multiples of components diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8b15ae96b9..036c8546a3 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -125,7 +125,7 @@ QT_BEGIN_NAMESPACE QObject. See the QObject documentation for further details. */ /*! - \qmlproperty string QtObject::objectName + \qmlproperty string QML:QtObject::objectName This property allows you to give a name to this specific object instance. See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects} @@ -236,8 +236,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) } /*! -\qmlmethod url Qt::resolvedUrl(url) -Returns \c url resolved relative to the URL of the caller. + \qmlmethod url Qt::resolvedUrl(url) + Returns \c url resolved relative to the URL of the caller. */ QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url) { diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index e4870e3f6d..d5108fd770 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -728,23 +728,12 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, if (n) classNode = static_cast(n); } - if (names[0].startsWith("Q")) + if (names[0].startsWith("Qt")) return new QmlClassNode(tre->root(), QLatin1String("QML:")+names[0], classNode); else return new QmlClassNode(tre->root(), names[0], classNode); } else if (command == COMMAND_QMLBASICTYPE) { -#if 0 - QStringList parts = arg.split(" "); - qDebug() << command << parts; - if (parts.size() > 1) { - FakeNode* pageNode = static_cast(tre->root()->findNode(parts[1], Node::Fake)); - if (pageNode) { - qDebug() << "FOUND"; - return new QmlBasicTypeNode(pageNode, parts[0]); - } - } -#endif return new QmlBasicTypeNode(tre->root(), arg); } else if ((command == COMMAND_QMLSIGNAL) || @@ -755,7 +744,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, QString type; QmlClassNode* qmlClass = 0; if (splitQmlMethodArg(doc,arg,type,element)) { - if (element.startsWith(QLatin1String("Q"))) + if (element.startsWith(QLatin1String("Qt"))) element = QLatin1String("QML:") + element; Node* n = tre->findNode(QStringList(element),Node::Fake); if (n && n->subType() == Node::QmlClass) { diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index b7ab4d6020..441cfc60df 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4197,7 +4197,10 @@ void HtmlGenerator::generateQmlInstantiates(const QmlClassNode* qcn, text << "["; text << Atom(Atom::LinkNode,CodeMarker::stringForNode(qcn)); text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); - text << Atom(Atom::String, qcn->name()); + QString name = qcn->name(); + if (name.startsWith(QLatin1String("QML:"))) + name = name.mid(4); // remove the "QML:" prefix + text << Atom(Atom::String, name); text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); text << " instantiates the C++ class "; text << Atom(Atom::LinkNode,CodeMarker::stringForNode(cn)); diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index 022e1c2e10..d22a09aae0 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -173,9 +173,11 @@ const Node* Tree::findNode(const QStringList &path, } if (node && i == path.size() && (!(findFlags & NonFunction) || node->type() != Node::Function - || ((FunctionNode *)node)->metaness() == FunctionNode::MacroWithoutParams)) - if ((node != self) && (node->subType() != Node::QmlPropertyGroup)) + || ((FunctionNode *)node)->metaness() == FunctionNode::MacroWithoutParams)) { + if ((node != self) && (node->subType() != Node::QmlPropertyGroup)) { return node; + } + } current = current->parent(); } while (current); -- cgit v1.2.1 From 6f6ec0ee680c7d4b5cf70116e756cca90668fd90 Mon Sep 17 00:00:00 2001 From: Adrian Constantin Date: Wed, 7 Jul 2010 16:13:07 +0300 Subject: Set QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH to default value Remove workaround introduced in Qt 4.6 as not needed any more Reviewed-by: Adrian Constantin --- mkspecs/linux-g++-maemo/qmake.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf index cced09029e..a977e7ac42 100644 --- a/mkspecs/linux-g++-maemo/qmake.conf +++ b/mkspecs/linux-g++-maemo/qmake.conf @@ -27,7 +27,4 @@ QMAKE_CXXFLAGS_RELEASE += -g -fno-omit-frame-pointer -fno-optimize-sibling-call # Work round PowerVR SGX 1.3 driver bug with glScissor & FBOs: DEFINES += QT_GL_NO_SCISSOR_TEST -# Work round SGX 1.4 driver bug (text corrupted), modify glyph cache width: -DEFINES += QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 - load(qt_config) -- cgit v1.2.1 From 495dfda1bea31017d08a435dcb61b43b4df81d24 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 7 Jul 2010 15:38:22 +0200 Subject: Phonon MediaSource fails to load when passed as a resource file Files fail to load when passing resoure path to mediasource. The original regression seems to be caused by a behavior change as reported here: http://bugreports.qt.nokia.com/browse/QTBUG-12015 Note a merge request is also pending on Gitorious http://gitorious.org/phonon/phonon/merge_requests/17 Task-number: QTBUG-9323 Reviewed-by: thierry --- src/3rdparty/phonon/phonon/mediasource.cpp | 2 +- tests/auto/mediaobject/tst_mediaobject.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/phonon/mediasource.cpp b/src/3rdparty/phonon/phonon/mediasource.cpp index be22dc3150..11d2428a9e 100644 --- a/src/3rdparty/phonon/phonon/mediasource.cpp +++ b/src/3rdparty/phonon/phonon/mediasource.cpp @@ -50,7 +50,7 @@ MediaSource::MediaSource(const QString &filename) const QFileInfo fileInfo(filename); if (fileInfo.exists()) { bool localFs = QAbstractFileEngine::LocalDiskFlag & QFSFileEngine(filename).fileFlags(QAbstractFileEngine::LocalDiskFlag); - if (localFs) { + if (localFs && !filename.startsWith(QLatin1String(":/")) && !filename.startsWith(QLatin1String("qrc://"))) { d->url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); } else { #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 994057b128..2f985213d3 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -204,9 +204,8 @@ void tst_MediaObject::testPlayFromResource() #ifdef Q_OS_SYMBIAN QSKIP("Not implemented yet.", SkipAll); #else - QFile file(MEDIA_FILEPATH); MediaObject media; - media.setCurrentSource(&file); + media.setCurrentSource(QString(MEDIA_FILEPATH)); QVERIFY(media.state() != Phonon::ErrorState); if (media.state() != Phonon::StoppedState) QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); -- cgit v1.2.1 From 4337d695410301b97b753231c3b8fc9560a9d4c7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 5 Jul 2010 11:52:11 +0200 Subject: immediately set function context when entering a namespace otherwise, tr() calls without absolute qualification will not be properly qualified inside the first function if it has no qualification, either. Task-number: QTBUG-11742 (not really) --- .../lupdate/testdata/good/parsecpp/main.cpp | 27 ++++++++++++++++++++++ .../testdata/good/parsecpp/project.ts.result | 13 +++++++++++ tools/linguist/lupdate/cpp.cpp | 7 +++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 0765bfcdfd..f58f932391 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -275,3 +275,30 @@ void bogosity() // no spaces here. test collateral damage from ignoring equal sign Class::member=QObject::tr("just QObject"); } + + + +namespace Internal { + +class Message : public QObject +{ + Q_OBJECT +public: + Message(QObject *parent = 0); +}; + +} // The temporary closing of the namespace triggers the problem + +namespace Internal { + +static inline QString message1() +{ + return Message::tr("message1"); // Had no namespace +} + +static inline QString message2() +{ + return Message::tr("message2"); // Already had namespace +} + +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 208191d8a8..7ac318e685 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -119,6 +119,19 @@ backslashed \ stuff.
+ + Internal::Message + + + message1 + + + + + message2 + + + Kåntekst diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 609bd3dff9..bc9bb261ce 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1686,9 +1686,14 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) HashString ns = HashString(text); yyTok = getToken(); if (yyTok == Tok_LeftBrace) { + yyTok = getToken(); namespaceDepths.push(namespaces.count()); enterNamespace(&namespaces, ns); - yyTok = getToken(); + + functionContext = namespaces; + functionContextUnresolved.clear(); + prospectiveContext.clear(); + pendingContext.clear(); } else if (yyTok == Tok_Equals) { // e.g. namespace Is = OuterSpace::InnerSpace; QList fullName; -- cgit v1.2.1 From f2187e31de13a6ab8631a9067487dab555f7c2e7 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 6 Jul 2010 11:06:40 +0200 Subject: SSL backend: load libraries for certificates only once Reviewed-by: Olivier Goffart --- src/network/ssl/qsslsocket.cpp | 6 ++--- src/network/ssl/qsslsocket_openssl.cpp | 42 ++++++++++++++++++---------------- src/network/ssl/qsslsocket_p.h | 11 ++++----- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index f85fa8449b..809e8aa2ca 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1849,7 +1849,7 @@ QList QSslSocketPrivate::defaultCiphers() */ QList QSslSocketPrivate::supportedCiphers() { - QSslSocketPrivate::ensureInitialized(); + QSslSocketPrivate::ensureCertsAndCiphersLoaded(); QMutexLocker locker(&globalData()->mutex); return globalData()->supportedCiphers; } @@ -1879,7 +1879,7 @@ void QSslSocketPrivate::setDefaultSupportedCiphers(const QList &ciph */ QList QSslSocketPrivate::defaultCaCertificates() { - QSslSocketPrivate::ensureInitialized(); + QSslSocketPrivate::ensureCertsAndCiphersLoaded(); QMutexLocker locker(&globalData()->mutex); return globalData()->config->caCertificates; } @@ -1962,7 +1962,7 @@ void QSslConfigurationPrivate::setDefaultConfiguration(const QSslConfiguration & */ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPrivate *ptr) { - QSslSocketPrivate::ensureInitialized(); + QSslSocketPrivate::ensureCertsAndCiphersLoaded(); QMutexLocker locker(&globalData()->mutex); const QSslConfigurationPrivate *global = globalData()->config.constData(); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index d7088eea91..b602b295f1 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -74,8 +74,9 @@ QT_BEGIN_NAMESPACE -bool QSslSocketPrivate::s_libraryLoaded = false; -bool QSslSocketPrivate::s_loadedCiphersAndCerts = false; +bool QSslSocketPrivate::s_initialized = false; +QBasicAtomicInt QSslSocketPrivate::s_CertsAndCiphersLoaded; +Q_GLOBAL_STATIC(QMutex, s_CertsAndCiphersLoadedMutex); // Useful defines #define SSL_ERRORSTR() QString::fromLocal8Bit(q_ERR_error_string(q_ERR_get_error(), NULL)) @@ -170,7 +171,7 @@ QSslSocketBackendPrivate::QSslSocketBackendPrivate() session(0) { // Calls SSL_library_init(). - ensureInitialized(); + ensureCertsAndCiphersLoaded(); } QSslSocketBackendPrivate::~QSslSocketBackendPrivate() @@ -421,18 +422,18 @@ void QSslSocketPrivate::deinitialize() bool QSslSocketPrivate::supportsSsl() { - return ensureLibraryLoaded(); + return ensureInitialized(); } -bool QSslSocketPrivate::ensureLibraryLoaded() +bool QSslSocketPrivate::ensureInitialized() { if (!q_resolveOpenSslSymbols()) return false; // Check if the library itself needs to be initialized. QMutexLocker locker(openssl_locks()->initLock()); - if (!s_libraryLoaded) { - s_libraryLoaded = true; + if (!s_initialized) { + s_initialized = true; // Initialize OpenSSL. q_CRYPTO_set_id_callback(id_function); @@ -473,16 +474,6 @@ bool QSslSocketPrivate::ensureLibraryLoaded() return true; } -void QSslSocketPrivate::ensureCiphersAndCertsLoaded() -{ - if (s_loadedCiphersAndCerts) - return; - s_loadedCiphersAndCerts = true; - - resetDefaultCiphers(); - setDefaultCaCertificates(systemCaCertificates()); -} - /*! \internal @@ -490,13 +481,18 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded() been initialized. */ -void QSslSocketPrivate::ensureInitialized() +void QSslSocketPrivate::ensureCertsAndCiphersLoaded() { - if (!supportsSsl()) + // use double-checked locking to speed up this function + if (s_CertsAndCiphersLoaded) return; - ensureCiphersAndCertsLoaded(); + QMutexLocker locker(s_CertsAndCiphersLoadedMutex()); + if (s_CertsAndCiphersLoaded) + return; + if (!supportsSsl()) + return; //load symbols needed to receive certificates from system store #if defined(Q_OS_MAC) QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security"); @@ -532,6 +528,12 @@ void QSslSocketPrivate::ensureInitialized() qWarning("could not load crypt32 library"); // should never happen } #endif + resetDefaultCiphers(); + setDefaultCaCertificates(systemCaCertificates()); + // we need to make sure that s_CertsAndCiphersLoaded is executed after the library loading above + // (the compiler/processor might reorder instructions otherwise) + if (!s_CertsAndCiphersLoaded.testAndSetRelease(0, 1)) + Q_ASSERT_X(false, "certificate store", "certificate store has already been initialized!"); } /*! diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 72b3ef73a0..b474175378 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -63,6 +63,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -113,7 +114,8 @@ public: QString verificationPeerName; static bool supportsSsl(); - static void ensureInitialized(); + static bool ensureInitialized(); + static void ensureCertsAndCiphersLoaded(); static void deinitialize(); static QList defaultCiphers(); static QList supportedCiphers(); @@ -161,11 +163,8 @@ public: virtual QSslCipher sessionCipher() const = 0; private: - static bool ensureLibraryLoaded(); - static void ensureCiphersAndCertsLoaded(); - - static bool s_libraryLoaded; - static bool s_loadedCiphersAndCerts; + static bool s_initialized; + static QBasicAtomicInt s_CertsAndCiphersLoaded; }; QT_END_NAMESPACE -- cgit v1.2.1 From 28f84d2ed4000391f855140f57c359bc858d4799 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 8 Jul 2010 09:18:50 +0200 Subject: qdoc: Fixed table of contents for namespace pages. Task-number: QTBUG-11992 --- tools/qdoc3/htmlgenerator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 441cfc60df..1e455dd712 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2034,7 +2034,8 @@ void HtmlGenerator::generateTableOfContents(const Node *node, } } } - else if (sections && (node->type() == Node::Class)) { + else if (sections && ((node->type() == Node::Class) || + (node->type() == Node::Namespace))) { QList
::ConstIterator s = sections->begin(); while (s != sections->end()) { if (!s->members.isEmpty() || !s->reimpMembers.isEmpty()) { -- cgit v1.2.1 From ab4e036137ba21bd6296837af1594db45064bce3 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:18:07 +0200 Subject: Doc: fixing typos --- doc/src/declarative/qdeclarativeintro.qdoc | 2 +- doc/src/getting-started/examples.qdoc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc index 9126a79af6..3f1b184d4b 100644 --- a/doc/src/declarative/qdeclarativeintro.qdoc +++ b/doc/src/declarative/qdeclarativeintro.qdoc @@ -314,7 +314,7 @@ Item { \section2 Signal Handlers -Signal handlers allow actions to be taken in reponse to an event. For instance, +Signal handlers allow actions to be taken in response to an event. For instance, the \l MouseArea element has signal handlers to handle mouse press, release and click: diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index b6766d5f41..a32d120e20 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -343,8 +343,8 @@ /*! \page examples-draganddrop.html \ingroup all-examples - \title Drag & Drop Examples - \brief How to access your platform's native darg & drop functionality + \title Drag & Drop Examples + \brief How to access your platform's native darg & drop functionality \image draganddrop-examples.png -- cgit v1.2.1 From 8feb9c7ee7deda8c5fa3459108d349497af82924 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:20:09 +0200 Subject: Doc: fixing typo --- tools/qdoc3/test/qt-html-templates.qdocconf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 31c9d5ae01..b7dead230d 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -113,7 +113,6 @@ HTML.postheader = "
\n" \ "
  • Tutorials
  • \n" \ "
  • Demos
  • \n" \ "
  • QML Examples
  • \n" \ - "
  • QML Demos
  • \n" \ " \n" \ "
    \n" \ " \n" \ @@ -160,8 +159,8 @@ HTML.footer = " \n" \ "
    \n" \ "
    X
    \n" \ "
    \n" \ - "

    Thank you for giving your feedback.

    Make sure it is related the page. For more general bugs and \n" \ - " requests, please use the Qt Bug Tracker

    \n" \ + "

    Thank you for giving your feedback.

    Make sure it is related to this specific page. For more general bugs and \n" \ + " requests, please use the Qt Bug Tracker.

    \n" \ "

    \n" \ "

    \n" \ "
    \n" \ -- cgit v1.2.1 From 272ccd24941465fd6a8fc79d9f7ab8546a6ce870 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:21:17 +0200 Subject: Doc: Fixing broken link --- doc/src/index.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 18a174683a..22ee63fb4c 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -44,7 +44,7 @@
  • Installation & first steps
  • How to learn Qt
  • Tutorials
  • -
  • Examples
  • +
  • Examples
  • Whats new in Qt 4.7
  • -- cgit v1.2.1 From 25e3227fc922f75cc772aadb9dd07cc8b965dcbd Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 8 Jul 2010 10:24:49 +0200 Subject: doc: Added doc for accessing views and models from delegates. Task-number: QTBUG-11648 --- doc/src/declarative/qdeclarativemodels.qdoc | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index b44e6f233f..a2f4d3ab56 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -429,4 +429,77 @@ Rectangle { } \endcode +\section1 Accessing Views and Models from Delegates + +You can access the view for which a delegate is used, and its +properties, by using ListView.view in a delegate on a ListView, or +GridView.view in a delegate on a GridView, etc. In particular, you can +access the model and its properties by using ListView.view.model. + +This is useful when you want to use the same delegate for a number of +views, for example, but you want decorations or other features to be +different for each view, and you would like these different settings to +be properties of each of the views. Similarly, it might be of interest +to access or show some properties of the model. + +In the following example, the delegate shows the property \e{language} +of the model, and the color of one of the fields depends on the +property \e{fruit_color} of the view. + +\code +Rectangle { + width: 200; height: 200 + + ListModel { + id: fruitModel + property string language: "en" + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + + Component { + id: fruitDelegate + Row { + Text { text: " Fruit: " + name; color: ListView.view.fruit_color } + Text { text: " Cost: $" + cost } + Text { text: " Language: " + ListView.view.model.language } + } + } + + ListView { + property color fruit_color: "green" + model: fruitModel + delegate: fruitDelegate + anchors.fill: parent + } +} +\endcode + +Another important case is when some action (e.g. mouse click) in the +delegate should update data in the model. In this case you can define +a function in the model, e.g.: + +\code + setData(int row, const QString & field_name, QVariant new_value), +\endcode + +...and call it from the delegate using: + +\code + ListView.view.model.setData(index, field, value) +\endcode + +...assuming that \e{field} holds the name of the field which should be +updated, and that \e{value} holds the new value. + */ -- cgit v1.2.1 From b24a4194b2b0c4420e1a8e4a95c73fd6673088d3 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:30:43 +0200 Subject: Doc: Fixing typo - background file name --- examples/declarative/tutorials/samegame/samegame1/samegame.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index 68f87122c1..80567efff9 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -55,7 +55,7 @@ Rectangle { Image { id: background anchors.fill: parent - source: "../shared/pics/background.jpg" + source: "../shared/pics/background.png" fillMode: Image.PreserveAspectCrop } } -- cgit v1.2.1 From 3062dac75befacffc1964d49392a58f5fb0b583f Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:36:50 +0200 Subject: Doc: adding HTML class names and style docs to the generator --- tools/qdoc3/htmlgenerator.cpp | 66 ++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 1e455dd712..5b6ea28db2 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -909,13 +909,13 @@ int HtmlGenerator::generateAtom(const Atom *atom, else out() << ""; - out() << "Constant" - << "Value" - << "Description\n"; + out() << "Constant" + << "Value" + << "Description\n"; } else { out() << "" - << "\n"; + << "\n"; } } else { @@ -1129,9 +1129,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, case Atom::TableItemLeft: { if (inTableHeader) - out() << "string().split(","); if (spans.size() == 2) { @@ -1764,35 +1764,37 @@ void HtmlGenerator::generateHeader(const QString& title, if (offlineDocs) { - out() << " "; + out() << " "; // Style common to all browsers + // out() << " "; // Only for Qt Creator out() << "\n"; - out() << "\n"; // narrow mainly for Creator + out() << "\n"; // narrow mainly for Creator + out() << " \n"; out() << " \n"; } else { out() << " "; - out() << " \n"; - out() << "\n"; - out() << "\n"; - out() << "\n"; + // out() << " \n"; + // out() << "\n"; + // out() << "\n"; + // out() << "\n"; // jquery functions out() << " \n"; out() << " \n"; // menus and small docs js and css - out() << " \n"; - out() << " \n"; - out() << " "; - out() << " "; + // out() << " \n"; + // out() << " \n"; + // out() << " "; + // out() << " "; // syntax highlighter js and css // out() << " \n"; @@ -1804,7 +1806,7 @@ void HtmlGenerator::generateHeader(const QString& title, // out() << " \n"; out() << "\n"; - out() << "\n"; + out() << "\n"; // CheckEmptyAndLoadList() activating online search } #ifdef GENERATE_MAC_REFS @@ -2296,20 +2298,20 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, out() << ""; else out() << ""; - out() << ""; if (!(node->type() == Node::Fake)) { Text brief = node->doc().trimmedBriefText(name); if (!brief.isEmpty()) { - out() << ""; } } else { - out() << ""; } @@ -4073,7 +4075,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, else out() << ""; - out() << ""; else out() << ""; - out() << ""; else out() << ""; - out() << ""; -- cgit v1.2.1 From baab1d25cbae435a6a84ba75c2702350adb027cc Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 10:49:14 +0200 Subject: Doc: fixing link to devnet --- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index b7dead230d..e032d6f10a 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -17,7 +17,7 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
      \n" \ "
    • Qt HOME
    • \n" \ - "
    • DEV
    • \n" \ + "
    • DEV
    • \n" \ "
    • LABS
    • \n" \ "
    • \n" \ " DOC
    • \n" \ -- cgit v1.2.1 From a538ccb93fd05b26dc7a7058bbb62e0dcb682f81 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 11:13:17 +0200 Subject: Doc: changing index page --- doc/src/index.qdoc | 33 +- doc/src/template/style/OfflineStyle.css | 832 ---------------------------- tools/qdoc3/htmlgenerator.cpp | 52 +- tools/qdoc3/test/qt-html-templates.qdocconf | 1 - 4 files changed, 62 insertions(+), 856 deletions(-) delete mode 100644 doc/src/template/style/OfflineStyle.css diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 22ee63fb4c..657f5d0724 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -44,7 +44,7 @@
    • Installation & first steps
    • How to learn Qt
    • Tutorials
    • -
    • Examples
    • +
    • Examples
    • Whats new in Qt 4.7
    @@ -56,30 +56,29 @@ diff --git a/doc/src/template/style/OfflineStyle.css b/doc/src/template/style/OfflineStyle.css deleted file mode 100644 index afa7de03a8..0000000000 --- a/doc/src/template/style/OfflineStyle.css +++ /dev/null @@ -1,832 +0,0 @@ -@media screen -{ - html - { - color: #000000; - background: #FFFFFF; - } - body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td - { - margin: 0; - padding: 0; - } - table - { - border-collapse: collapse; - border-spacing: 0; - } - fieldset, img - { - border: 0; - } - address, caption, cite, code, dfn, em, strong, th, var, optgroup - { - font-style: inherit; - font-weight: inherit; - } - del, ins - { - text-decoration: none; - } - li - { - list-style: none; - } - caption, th - { - text-align: left; - } - h1, h2, h3, h4, h5, h6 - { - font-size: 100%; - } - q:before, q:after - { - content: ''; - } - abbr, acronym - { - border: 0; - font-variant: normal; - } - sup - { - vertical-align: baseline; - } - sub - { - vertical-align: baseline; - } - tt, .qmlreadonly span, .qmldefault span - { - word-spacing:5px; - } - .heading - { - font: normal 600 16px/1.0 Arial; - } - .subtitle - { - font-size: 13px; - } - .small-subtitle - { - font-size: 13px; - } - legend - { - color: #000000; - } - input, button, textarea, select, optgroup, option - { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; - } - input, button, textarea, select - { - font-size: 100%; - } - body - { - font: normal 13px/1.2 Verdana; - color: #363534; - } - strong - { - font-weight: bold; - } - em - { - font-style: italic; - } - a - { - color: #00732f; - text-decoration: none; - } - .header, .footer, .wrapper - { - /*min-width: 600px;*/ - max-width: 1500px; - margin: 0 5px; - } - .wrapper - { - position:relative; - top:50px; - } - .wrapper .bd - { - position: relative; - } - - .header, .footer - { - display: block; - clear: both; - overflow: hidden; - } - .header - { - height: 115px; - position: relative; - } - - - .header .qtref - { - position: absolute; - top: 28px; - left: 88px; - width: 302px; - height: 22px; - } - .header .qtref span - { - display: block; - height: 22px; - } - .wrap .content h1 - { - font: 600 18px/1.2 Arial; - } - .wrap .content h2 - { - font: 600 16px/1.2 Arial; - } - .wrap .content h3 - { - font: 600 14px/1.2 Arial; - } - .wrap .content h4 - { - font: 600 12px/1.2 Arial; - } - - .wrap .content p - { - line-height: 20px; - padding: 5px; - } - .wrap .content table p - { - line-height: 20px; - padding: 0px; - } - .wrap .content ul - { - padding-left: 25px; - padding-top: 10px; - } - a:hover - { - color: #4c0033; - text-decoration: underline; - } - .content a:visited - { - color: #4c0033; - text-decoration: none; - } - .content a:visited:hover - { - color: #4c0033; - text-decoration: underline; - } - - pre - { - border: 1px solid #DDDDDD; - margin: 0 20px 10px 10px; - padding: 20px 15px 20px 20px; - overflow-x: auto; - } - table, pre - { - -moz-border-radius: 7px 7px 7px 7px; - background-color: #F6F6F6; - border: 1px solid #E6E6E6; - border-collapse: separate; - font-size: 11px; - /*min-width: 395px;*/ - margin-bottom: 25px; - display: inline-block; - } - thead - { - margin-top: 5px; - font:600 12px/1.2 Arial; - } - th - { - padding: 5px 15px 5px 15px; - background-color: #E1E1E1; - /* border-bottom: 1px solid #E6E6E6;*/ - border-left: 1px solid #E6E6E6; - /* border-right: 1px solid #E6E6E6;*/ - } - td - { - padding: 3px 15px 3px 20px; - /* border-left: 1px solid #E6E6E6; - border-right: 1px solid #E6E6E6;*/ - } - tr.odd td:hover, tr.even td:hover - { - /* border-right: 1px solid #C3C3C3; - border-left: 1px solid #C3C3C3;*/ - } - - td.rightAlign - { - padding: 3px 15px 3px 10px; - } - table tr.odd - { - border-left: 1px solid #E6E6E6; - background-color: #F6F6F6; - color: #66666E; - } - table tr.even - { - border-left: 1px solid #E6E6E6; - background-color: #ffffff; - color: #66666E; - } - table tr.odd td:hover, table tr.even td:hover - { - background-color: #E6E6E6; - } - - span.comment - { - color: #8B0000; - font-style: italic; - } - span.string, span.char - { - color: #254117; - } - - .qmltype - { - text-align: center; - font-size: 160%; - } - .qmlreadonly - { - float: right; - color: #254117; - } - - .qmldefault - { - float: right; - color: red; - } - - .footer - { - border-top:1px solid #E5E5E5; - min-height: 100px; - color: #797775; - font: normal 9px/1 Verdana; - text-align: center; - padding-top: 40px; - margin: 0; - } - - - .wrap - { - margin: 0 5px 0 5px; - } - .wrap .toolbar - { - display:block; - } - - .wrap .breadcrumb ul li - { - float: left; - background: url(../images/breadcrumb.png) no-repeat 0 5px; - padding-left: 15px; - margin-left: 15px; - font-weight: bold; - } - .wrap .breadcrumb ul li.last - { - font-weight: normal; - } - .wrap .breadcrumb ul li a - { - /* color: #363534;*/ - color: #00732F; - } - .wrap .breadcrumb ul li.first - { - background-image: none; - padding-left: 0; - margin-left: 0; - } - .wrap .content - { - word-wrap:break-word; - } - .wrap .content li - { - /*padding-left: 12px;*/ - background: url(../images/bullet_sq.png) no-repeat 0 5px; - font: normal 400 10pt/1 Verdana; - /* color: #44a51c;*/ - margin-bottom: 10px; - } - - .offline .wrap .content - { - padding-top: 15px; - } - - .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after - { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - - hr - { - background-color: #E6E6E6; - border: 1px solid #E6E6E6; - height: 1px; - width: 100%; - text-align: left; - margin: 5px 0px 5px 0px; - } - - .content .alignedsummary - { - margin: 5px; - width:100%; - } - - - .toc - { - float: right; - -moz-border-radius: 7px 7px 7px 7px; - background-color: #F6F6F6; - border: 1px solid #DDDDDD; - margin: 0 20px 10px 10px; - padding: 20px 15px 20px 20px; - height: auto; - width: 200px; - } - - .toc h3, .generic a - { - font: 600 12px/1.2 Arial; - } - - .wrap .content .toc ul - { - padding-left: 0px; - } - - - .wrap .content .toc .level2 - { - margin-left: 15px; - } - - .wrap .content .toc .level3 - { - margin-left: 30px; - } - - .content .toc li - { - font: normal 10px/1.2 Verdana; - background: url(../images/bullet_dn.png) no-repeat 0 5px; - } - - - .generic{ - max-width:75%; - } - .generic td{ - padding:0; - } - - .generic .odd .alphaChar{ - background-color: #F6F6F6; - } - - .generic .even .alphaChar{ - background-color: #FFFFFF; - } - - .highlightedCode - { - margin:10px; - } - - .flowList{ - vertical-align:top; - } - .alphaChar{ - width:100%; - background-color:#F6F6F6; - border:1px solid #E6E6E6; - font-size:12pt; - padding-left:10px; - margin-top:10px; - margin-bottom:10px; - } - - .flowList dl{ - } - .flowList dd{ - display:inline-block; - margin-left:10px; - width:250px; - } - .wrap .content .flowList p{ - padding:0px; - } - - .relpage - { - -moz-border-radius: 7px 7px 7px 7px; - border: 1px solid #DDDDDD; - padding: 25px 25px; - clear: both; - } - .relpage ul - { - float: none; - padding: 15px; - } - .content .relpage li - { - font: normal 11px/1.2 Verdana; - } - h3.fn, span.fn - { - background-color: #F6F6F6; - border-width: 1px; - border-style: solid; - border-color: #E6E6E6; - font-weight: bold; - word-spacing:3px; - } - - .functionIndex { - font-size:12pt; - word-spacing:10px; - margin-bottom:10px; - background-color: #F6F6F6; - border-width: 1px; - border-style: solid; - border-color: #E6E6E6; - width:100%; - } - - .centerAlign { text-align:center;} - .rightAlign {text-align:right;} - .leftAlign {text-align:left;} - .topAlign{vertical-align:top } - .functionIndex a{display:inline-block;} - - /* start index box */ - .indexbox - { - width: 100%; - display:inline-block; - } - - .indexboxcont { display: block; } - - .indexboxbar - { - border-bottom:1px solid #E5E5E5; - margin-bottom: 25px; - } - - .indexboxcont .section - { - display: inline-block; - padding:0 2% 0 1%; - vertical-align:top; - } - - .indexboxcont .section { - float: left; - } - - .indexboxcont .section p - { - padding-top: 20px; - padding-bottom: 20px; - } - .indexboxcont .sectionlist - { - display: inline-block; - vertical-align:top; - padding: 0; - } - .indexboxcont .sectionlist ul - { - margin-bottom: 20px; - } - - .indexboxcont .sectionlist ul li - { - line-height: 12px; - } - - .content .indexboxcont li - { - font: normal 600 13px/1 Verdana; - } - - .indexbox a:hover, .indexbox a:visited:hover - { - color: #4c0033; - text-decoration: underline; - } - - .indexbox a:visited - { - color: #00732f; - text-decoration: none; - } - - .indexbox .indexIcon { - width: 11%; - } - - - .indexboxcont:after - { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - - body.offline - { - background-image: none; - } - - .offline .footer { - margin: 0; - } - .offline .header - { - width: 100%; - margin: 0; - height: auto; - background-color: #ffffff; - padding: 10px 0 5px 0; - overflow: visible; - border-bottom: solid #E5E5E5 1px; - z-index:1; - position:fixed; - } - - .offline .header .content - { - } - .offline .header .qtref - { - color: #00732F; - position: static; - float: left; - margin-left: 5px; - font: bold 18px/1 Arial; - } - - .offline .header .qtref:visited - { - color: #00732F; - } - .offline .header .qtref:hover - { - color: #00732F; - text-decoration:none; - } - .offline .header .qtref span - { - background-image: none; - text-indent: 0; - text-decoration:none; - } - - .offline .wrap - { - margin: 0 5px 0 5px; - } - - .offline .wrap .toolbar - { - display:block; - padding-top:5px; - } - - .offline .wrap .breadcrumb ul li { - font-weight: normal; - } - - .offline .wrap .breadcrumb ul li a { - /*color: #44a51c;*/ - } - - .offline .wrap .breadcrumb ul li.last a { - /*color: #363534;*/ - } - - - - .narrow .indexboxcont .section { - width: 64%; - padding-left: 0; - } - - .narrow .indexboxcont .sectionlist { - width: 32.5%; - } - - .header .icon, - .sidebar, - .feedback, - .t_button, - .feedback, - #feedbackBox, - #feedback, - #blurpage, - .indexbox .indexIcon span, - .wrapper .hd, - .offline .indexbox .indexIcon, - .offline .header #nav-logo, - #offlinemenu, - #offlinesearch, - .offline .header #nav-topright, - .offline .header #shortCut , - .offline .wrapper .hd, - .offline .wrapper .ft, - .offline .sidebar, - .offline .wrap .feedback - { - display:none; - } - - /* end offline mode */ -#narrowmenu { - display: none; - float: right; - margin: 15px 40px 0 0; - font-size: 11px; - } - - .narrow #narrowmenu { - display: block; - } - - #narrowsearch{ - display:none; - } - - #narrowmenu ul - { - border-bottom:solid 1px #E5E5E5; - border-left:solid 1px #E5E5E5; - border-right:solid 1px #E5E5E5; - } - - #narrowmenu a { - line-height: 1.1; - background: url(../images/arrow_down.png) no-repeat 100% 50%; - white-space: nowrap; - padding: 0 16px 0 5px; - } - - #narrowmenu li { - margin-left: 20px; - } - - #narrowmenu li li { - margin: 0 0 5px 0; - } - - #narrowmenu li li a { - padding: 0; - background-image: none; - } - - #narrowmenu li, - #narrowmenu li ul { - background-color: #fff; - } - - #narrowmenu li ul { - width: auto; - padding: 5px; - margin-top:-15px; - } - - .sf-menu li:hover ul, .sf-menu li.sfHover ul { - top: 1.2em; - } -.sf-menu, .sf-menu * { - margin: 0; - padding: 0; - list-style: none; -} -.sf-menu { - line-height: 1.0; -} -.sf-menu ul { - position: absolute; - top: -999em; - width: 10em; /* left offset of submenus need to match (see below) */ -} -.sf-menu ul li { - width: 100%; -} -.sf-menu li:hover { - visibility: inherit; /* fixes IE7 'sticky bug' */ -} -.sf-menu li { - float: left; - position: relative; -} -.sf-menu a { - display: block; - position: relative; -} -.sf-menu li:hover ul, -.sf-menu li.sfHover ul { - left: 0; - top: 2.5em; /* match top ul list item height */ - z-index: 99; -} -ul.sf-menu li:hover li ul, -ul.sf-menu li.sfHover li ul { - top: -999em; -} -ul.sf-menu li li:hover ul, -ul.sf-menu li li.sfHover ul { - left: 10em; /* match ul width */ - top: 0; -} -ul.sf-menu li li:hover li ul, -ul.sf-menu li li.sfHover li ul { - top: -999em; -} -ul.sf-menu li li li:hover ul, -ul.sf-menu li li li.sfHover ul { - left: 10em; /* match ul width */ - top: 0; -} - .wrap .content ol li { - background:none; - font:400 10pt/1 Verdana; - margin-bottom:10px; - margin-left:12px; - } - .wrap .content ol li { - list-style-type:decimal; - - } - - - -} -/* end of screen media */ - -/* start of print media */ - -@media print -{ - input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft - { - display: none; - background: none; - } - .content - { - position: absolute; - top: 0px; - left: 0px; - background: none; - display: block; - } -} -/* end of print media */ diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 5b6ea28db2..5c2d17a473 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1757,22 +1757,41 @@ void HtmlGenerator::generateHeader(const QString& title, else shortVersion = "Qt " + shortVersion + ": "; } - + // Generating page title out() << " " << shortVersion << protectEnc(title) << "\n"; - - //out() << " Qt Reference Documentation"; - + // Adding style sheet + out() << " "; + // Adding jquery and functions - providing online tools and search features + out() << " \n"; + out() << " \n"; + // Adding style and js for small windows + out() << " \n"; + out() << " \n"; + out() << " "; + out() << " "; + + // Adding syntax highlighter // future release + + // Setting assistant configuration if (offlineDocs) { +<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp out() << " "; // Style common to all browsers // out() << " "; // Only for Qt Creator out() << "\n"; out() << "\n"; // narrow mainly for Creator out() << " \n"; out() << " \n"; +======= + out() << "\n"; + out() << "\n"; // narrow mainly for Creator +// out() << " \n"; +>>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp } + // Setting online doc configuration else { +<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp out() << " "; // out() << " \n"; +======= + // Custom browser styles + out() << " \n"; + out() << "\n"; + out() << "\n"; + out() << "\n"; +>>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp // jquery functions - out() << " \n"; - out() << " \n"; // menus and small docs js and css +<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp // out() << " \n"; // out() << " \n"; // out() << " "; @@ -1807,6 +1841,12 @@ void HtmlGenerator::generateHeader(const QString& title, out() << "\n"; out() << "\n"; // CheckEmptyAndLoadList() activating online search +======= + + out() << "\n"; + // CheckEmptyAndLoadList activating search + out() << "\n"; +>>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp } #ifdef GENERATE_MAC_REFS diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index e032d6f10a..550d80f647 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -22,7 +22,6 @@ HTML.postheader = "
    \n" \ "
  • \n" \ " DOC
  • \n" \ "
  • BLOG
  • \n" \ - "
  • SHOP
  • \n" \ " \n" \ "
    \n" \ "
    \n" \ -- cgit v1.2.1 From 5a6e3d952327753cb0cc00fa22804c5dab435c39 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 11:17:16 +0200 Subject: Doc: cleaning html generator --- tools/qdoc3/htmlgenerator.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 5c2d17a473..7075efc9c7 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1775,23 +1775,17 @@ void HtmlGenerator::generateHeader(const QString& title, // Setting assistant configuration if (offlineDocs) { -<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp out() << " "; // Style common to all browsers // out() << " "; // Only for Qt Creator out() << "\n"; out() << "\n"; // narrow mainly for Creator - out() << " \n"; - out() << " \n"; -======= out() << "\n"; out() << "\n"; // narrow mainly for Creator // out() << " \n"; ->>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp } // Setting online doc configuration else { -<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp out() << " "; // out() << " \n"; -======= // Custom browser styles out() << " \n"; ->>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp - // jquery functions - // menus and small docs js and css -<<<<<<< Updated upstream:tools/qdoc3/htmlgenerator.cpp - // out() << " \n"; - // out() << " \n"; - // out() << " "; - // out() << " "; - - // syntax highlighter js and css - // out() << " \n"; - // out() << " \n"; - // out() << " \n"; - // out() << " \n"; - // out() << " \n"; out() << "\n"; out() << "\n"; // CheckEmptyAndLoadList() activating online search -======= out() << "\n"; // CheckEmptyAndLoadList activating search out() << "\n"; ->>>>>>> Stashed changes:tools/qdoc3/htmlgenerator.cpp } #ifdef GENERATE_MAC_REFS -- cgit v1.2.1 From 16264dc0035260d3e68f1ed22ea647e7c157bd3c Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 11:19:37 +0200 Subject: Doc: fixing escape character --- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 550d80f647..b428a90071 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -17,7 +17,7 @@ HTML.postheader = "
    \n" \ "
    \n" \ "
      \n" \ "
    • Qt HOME
    • \n" \ - "
    • DEV
    • \n" \ + "
    • DEV
    • \n" \ "
    • LABS
    • \n" \ "
    • \n" \ " DOC
    • \n" \ -- cgit v1.2.1 From 25ace9513587abb5e52f78d900e6bec7b04bb663 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 11:35:27 +0200 Subject: Doc: more cleaning --- tools/qdoc3/htmlgenerator.cpp | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 7075efc9c7..567a29739b 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1766,8 +1766,8 @@ void HtmlGenerator::generateHeader(const QString& title, out() << " \n"; // Adding style and js for small windows out() << " \n"; - out() << " \n"; out() << " "; + out() << " \n"; out() << " "; // Adding syntax highlighter // future release @@ -1775,32 +1775,14 @@ void HtmlGenerator::generateHeader(const QString& title, // Setting assistant configuration if (offlineDocs) { - out() << " "; // Style common to all browsers - // out() << " "; // Only for Qt Creator + // out() << " "; // Only for Qt Creator out() << "\n"; out() << "\n"; // narrow mainly for Creator - out() << "\n"; - out() << "\n"; // narrow mainly for Creator -// out() << " \n"; } // Setting online doc configuration else { - out() << " "; - // out() << " \n"; - // out() << "\n"; - // out() << "\n"; - // out() << "\n"; - // Custom browser styles + // Browser spec styles out() << " \n"; - out() << "\n"; - out() << "\n"; // CheckEmptyAndLoadList() activating online search - out() << "\n"; // CheckEmptyAndLoadList activating search out() << "\n"; -- cgit v1.2.1 From e2db7c19dcf53458d480e148cc21f0577bcb0a44 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 7 Jul 2010 12:50:26 +0200 Subject: respect UI_DIR when creating image collections Reviewed-by: joerg Task-number: QTBUG-11752 --- mkspecs/features/uic.prf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index 5324e65997..0a18b478ce 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -86,20 +86,20 @@ defineReplace(imageCollectionCmd) { for(image, $$list($$split(1))) { EMBEDDED_IMAGES += $$image count(EMBEDDED_IMAGES, 5) { - isEmpty(RET): RET += echo $$EMBEDDED_IMAGES > images.tmp $$escape_expand(\\n\\t) - else: RET += echo $$EMBEDDED_IMAGES >> images.tmp $$escape_expand(\\n\\t) + isEmpty(RET): RET += echo $$EMBEDDED_IMAGES > $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) + else: RET += echo $$EMBEDDED_IMAGES >> $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) unset(EMBEDDED_IMAGES) } } - !isEmpty(EMBEDDED_IMAGES):RET += echo $$EMBEDDED_IMAGES >> images.tmp $$escape_expand(\\n\\t) + !isEmpty(EMBEDDED_IMAGES):RET += echo $$EMBEDDED_IMAGES >> $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) !isEmpty(RET) { - RET += $$QMAKE_UIC3 -embed $$TARGET -f images.tmp -o $$2 $$escape_expand(\\n\\t) + RET += $$QMAKE_UIC3 -embed $$TARGET -f $${UI_DIR}/images.tmp -o $$2 $$escape_expand(\\n\\t) return($$RET) } return($$QMAKE_UIC3 -embed $$TARGET $$1 -o $$2) } -image_collection.output = qmake_image_collection$${first(QMAKE_EXT_CPP)} +image_collection.output = $${UI_DIR}/qmake_image_collection$${first(QMAKE_EXT_CPP)} image_collection.variable_out = SOURCES image_collection.input = IMAGES image_collection.CONFIG += combine @@ -109,7 +109,7 @@ image_collection.name = UIC3 Image collection in ${QMAKE_FILE_OUT} silent:image_collection.commands = @echo uic3 -embed ${QMAKE_FILE_IN} && $$image_collection.commands } else { image_collection.commands = ${QMAKE_FUNC_imageCollectionCmd} - silent:image_collection.commands = @echo uic3 -embed $$TARGET -f images.tmp && $image_collection.commands + silent:image_collection.commands = @echo uic3 -embed $$TARGET -f $${UI_DIR}/images.tmp && $image_collection.commands } QMAKE_EXTRA_COMPILERS += image_collection -- cgit v1.2.1 From b57afadf3f91f87eba02458faa2809dd07b45da5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 8 Jul 2010 12:27:42 +0200 Subject: fix build with sqlite2 --- src/sql/drivers/sqlite2/qsql_sqlite2.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.pri b/src/sql/drivers/sqlite2/qsql_sqlite2.pri index 76fe255c99..9a9f6cdf9e 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.pri +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.pri @@ -1,4 +1,4 @@ -HEADERS += $PWD/qsql_sqlite2.h -SOURCES += $PWD/qsql_sqlite2.cpp +HEADERS += $$PWD/qsql_sqlite2.h +SOURCES += $$PWD/qsql_sqlite2.cpp !contains(LIBS, .*sqlite.*):LIBS += -lsqlite -- cgit v1.2.1 From bd576d42be264ff60503db0da509ad16139de09f Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 8 Jul 2010 12:47:11 +0200 Subject: Fix compilation when QT_NO_IM is defined Merge-request: 734 Reviewed-by: Oswald Buddenhagen --- src/gui/kernel/qapplication.cpp | 2 ++ src/gui/kernel/qapplication.h | 3 +++ src/gui/kernel/qwidget.cpp | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index ccfe88c953..d984721792 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5291,6 +5291,7 @@ bool QApplication::keypadNavigationEnabled() \sa QCoreApplication::instance() */ +#ifndef QT_NO_IM // ************************************************************************ // Input Method support // ************************************************************************ @@ -5356,6 +5357,7 @@ QInputContext *QApplication::inputContext() const #endif return d->inputContext; } +#endif // QT_NO_IM //Returns the current platform used by keyBindings uint QApplicationPrivate::currentPlatform(){ diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index d31d9e518a..799d4c2935 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -267,8 +267,11 @@ public: virtual void commitData(QSessionManager& sm); virtual void saveState(QSessionManager& sm); #endif + +#ifndef QT_NO_IM void setInputContext(QInputContext *); QInputContext *inputContext() const; +#endif static QLocale keyboardInputLocale(); static Qt::LayoutDirection keyboardInputDirection(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 233df15dce..fed8d0a309 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -338,8 +338,10 @@ QInputContext *QWidgetPrivate::inputContext() const #ifndef QT_NO_IM if (ic) return ic; -#endif return qApp->inputContext(); +#else + return 0; +#endif } /*! -- cgit v1.2.1 From a9c8decc741d8c2b340f38d7a854ef206672ab3e Mon Sep 17 00:00:00 2001 From: liang jian Date: Thu, 8 Jul 2010 12:56:03 +0200 Subject: Build Qt with option -Zc:wchar_t under MSVC This will make projects generated by visual studio being successfully linked to the Qt dlls if they use the QString::fromWCharArray() or QString::toWCharArray() methods. Merge-request: 727 Reviewed-by: Oswald Buddenhagen --- mkspecs/win32-msvc2005/qmake.conf | 2 +- mkspecs/win32-msvc2008/qmake.conf | 2 +- mkspecs/win32-msvc2010/qmake.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/win32-msvc2005/qmake.conf b/mkspecs/win32-msvc2005/qmake.conf index 0406fd03d6..a5999cc084 100644 --- a/mkspecs/win32-msvc2005/qmake.conf +++ b/mkspecs/win32-msvc2005/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD diff --git a/mkspecs/win32-msvc2008/qmake.conf b/mkspecs/win32-msvc2008/qmake.conf index 9805e906b4..1aab8e1a5f 100644 --- a/mkspecs/win32-msvc2008/qmake.conf +++ b/mkspecs/win32-msvc2008/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD diff --git a/mkspecs/win32-msvc2010/qmake.conf b/mkspecs/win32-msvc2010/qmake.conf index 28d4d3cc41..34a7782c63 100644 --- a/mkspecs/win32-msvc2010/qmake.conf +++ b/mkspecs/win32-msvc2010/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD -- cgit v1.2.1 From bc16436e33cfc61e0009474186cbb8210fb51df7 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 13:14:06 +0200 Subject: Doc: documenting docs --- tools/qdoc3/htmlgenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 567a29739b..8c7d5ad76c 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1777,7 +1777,7 @@ void HtmlGenerator::generateHeader(const QString& title, { // out() << " "; // Only for Qt Creator out() << "\n"; - out() << "\n"; // narrow mainly for Creator + out() << "\n"; // offline for Creator and Assistant } // Setting online doc configuration else -- cgit v1.2.1 From ea7aeec080c9c39449017ff683b27d3659236336 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 13:15:47 +0200 Subject: Doc: fixing style from 600 to bold weight --- doc/src/template/style/style.css | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 184a83234b..f7ff00ad7c 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -18,7 +18,6 @@ fieldset, img { border: 0; - height:100%; width:100% } address, caption, cite, code, dfn, em, strong, th, var, optgroup @@ -66,7 +65,7 @@ } .heading { - font: normal 600 16px/1.0 Arial; + font: normal bold 16px/1.0 Arial; padding-bottom: 15px; } .subtitle @@ -212,7 +211,7 @@ font-size: 11px; } - .offline .sidebar, .offline .feedback, .offline .t_button + .offline .sidebar, .offline .feedback, .offline .t_button, .offline #narrowsearch, .offline #narrowmenu { display: none; } @@ -258,7 +257,7 @@ .sidebar .box h2 { - font: 600 16px/1.2 Arial; + font: bold 16px/1.2 Arial; padding: 0; /* min-height: 32px;*/ } @@ -493,7 +492,7 @@ .wrap .content h1 { - font: 600 18px/1.2 Arial; + font: bold 18px/1.2 Arial; } .wrap .content h2 { @@ -506,7 +505,7 @@ } .wrap .content h3 { - font: 600 14px/1.2 Arial; + font: bold 14px/1.2 Arial; /*border-bottom:1px solid #DDDDDD;*/ font:600 16px/1.2 Arial; margin-top:15px; @@ -934,7 +933,7 @@ .toc h3, .generic a { - font: 600 12px/1.2 Arial; + font: bold 12px/1.2 Arial; } .generic{ @@ -1141,7 +1140,7 @@ .content .indexboxcont li { - font: normal 600 13px/1 Verdana; + font: normal bold 13px/1 Verdana; } .indexbox a:hover, .indexbox a:visited:hover -- cgit v1.2.1 From 062ceb0ec312e54670362c76aefdcac5353d64cd Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 6 Jul 2010 15:51:48 +0200 Subject: Avoid unneeded addition Reviewed-By: Denis --- src/gui/kernel/qgesturemanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index e43a560503..fe9dd8af6c 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE QGestureManager::QGestureManager(QObject *parent) - : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) + : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture) { qRegisterMetaType(); @@ -119,7 +119,7 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r if (type == Qt::CustomGesture) { // generate a new custom gesture id ++m_lastCustomGestureId; - type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId); + type = Qt::GestureType(m_lastCustomGestureId); } m_recognizers.insertMulti(type, recognizer); delete dummy; -- cgit v1.2.1 From 8b212b5f36ef7479bb902c6f8c8c1f4335f7f39f Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 7 Jul 2010 11:46:33 +0200 Subject: Change default TapAndHold timeout and make configurable The new default timeout is 700ms and is what Nokia Research found through usability studies. Nevertheless lets provide public API to set this through a platform plugin or similar. Reviewed-By: Denis --- src/gui/kernel/qgesture.cpp | 29 +++++++++++++++++++++++++++++ src/gui/kernel/qgesture.h | 3 +++ src/gui/kernel/qgesture_p.h | 1 + src/gui/kernel/qstandardgestures.cpp | 7 +++---- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index f5688f4f64..6359ecf8b2 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -41,6 +41,7 @@ #include "qgesture.h" #include "private/qgesture_p.h" +#include "private/qstandardgestures_p.h" #ifndef QT_NO_GESTURES @@ -726,6 +727,34 @@ void QTapAndHoldGesture::setPosition(const QPointF &value) d_func()->position = value; } +/*! + Set the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if \a msecs + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +void QTapAndHoldGesture::setTimeout(int msecs) +{ + QTapAndHoldGesturePrivate::Timeout = msecs; +} + +/*! + Gets the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if timeout() + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +int QTapAndHoldGesture::timeout() +{ + return QTapAndHoldGesturePrivate::Timeout; +} + +int QTapAndHoldGesturePrivate::Timeout = 700; // in ms + QT_END_NAMESPACE #endif // QT_NO_GESTURES diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 8c10895140..8f410b17e6 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -252,6 +252,9 @@ public: QPointF position() const; void setPosition(const QPointF &pos); + static void setTimeout(int msecs); + static int timeout(); + friend class QTapAndHoldGestureRecognizer; }; diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index f5474c1fe4..29b923e156 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -177,6 +177,7 @@ public: QPointF position; int timerId; + static int Timeout; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 62d8a5390d..e05f8ccec8 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -517,7 +517,6 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, const QMouseEvent *me = static_cast(event); const QGraphicsSceneMouseEvent *gsme = static_cast(event); - enum { TimerInterval = 2000 }; enum { TapRadius = 40 }; switch (event->type()) { @@ -526,21 +525,21 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::MouseButtonPress: d->position = me->globalPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::TouchBegin: d->position = ev->touchPoints().at(0).startScreenPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::GraphicsSceneMouseRelease: case QEvent::MouseButtonRelease: -- cgit v1.2.1 From dc1443ac784201bd9c016519d01481aeeb3d8f53 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 13:18:34 +0200 Subject: Doc: changing offline style This file will however be replaced in the near future --- doc/src/template/style/OfflineStyle.css | 251 ++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 doc/src/template/style/OfflineStyle.css diff --git a/doc/src/template/style/OfflineStyle.css b/doc/src/template/style/OfflineStyle.css new file mode 100644 index 0000000000..9f5d28b1b4 --- /dev/null +++ b/doc/src/template/style/OfflineStyle.css @@ -0,0 +1,251 @@ +@media screen +{ + + .wrapper + { + top:50px; + background: none; + + } + .wrapper .bd + { + background: none; + position: relative; + } + + + + + body.offline + { + background-image: none; + background-color: #FFFFFF; + + } + + .offline .footer { + margin: 0; + } + .offline .header + { + width: 100%; + margin: 0; + height: auto; + background-color: #ffffff; + padding: 10px 0 5px 0; + overflow: visible; + border-bottom: solid #E5E5E5 1px; + z-index:1; + position:fixed; + } + + .offline .header .content + { + } + .offline .header .qtref + { + color: #00732F; + position: static; + float: left; + margin-left: 5px; + font: bold 18px/1 Arial; + } + + .offline .header .qtref:visited + { + color: #00732F; + } + .offline .header .qtref:hover + { + color: #00732F; + text-decoration:none; + } + .offline .header .qtref span + { + background-image: none; + text-indent: 0; + text-decoration:none; + } + + .offline .wrap + { + margin: 0 5px 0 5px; + } + + .offline .wrap .toolbar + { + display:block; + padding-top:5px; + } + + .offline .wrap .breadcrumb ul li { + font-weight: normal; + } + + .offline .wrap .breadcrumb ul li a { + /*color: #44a51c;*/ + } + + .offline .wrap .breadcrumb ul li.last a { + /*color: #363534;*/ + } + + + + .narrow .indexboxcont .section { + width: 64%; + padding-left: 0; + } + + .narrow .indexboxcont .sectionlist { + width: 32.5%; + } + + .header .icon, + .sidebar, + .feedback, + .t_button, + .feedback, + #feedbackBox, + #feedback, + #blurpage, + .indexbox .indexIcon span, + .wrapper .hd, + .offline .indexbox .indexIcon, + .offline .header #nav-logo, + #offlinemenu, + #offlinesearch, + .offline .header #nav-topright, + .offline .header #shortCut , + .offline .wrapper .hd, + .offline .wrapper .ft, + .offline .sidebar, + .offline .wrap .feedback + { + display:none; + } + + /* end offline mode */ +#narrowmenu { + display: none; + float: right; + margin: 15px 40px 0 0; + font-size: 11px; + } + + .narrow #narrowmenu { + display: block; + } + + #narrowsearch{ + display:none; + } + + #narrowmenu ul + { + border-bottom:solid 1px #E5E5E5; + border-left:solid 1px #E5E5E5; + border-right:solid 1px #E5E5E5; + } + + #narrowmenu a { + line-height: 1.1; + background: url(../images/arrow_down.png) no-repeat 100% 50%; + white-space: nowrap; + padding: 0 16px 0 5px; + } + + #narrowmenu li { + margin-left: 20px; + } + + #narrowmenu li li { + margin: 0 0 5px 0; + } + + #narrowmenu li li a { + padding: 0; + background-image: none; + } + + #narrowmenu li, + #narrowmenu li ul { + background-color: #fff; + } + + #narrowmenu li ul { + width: auto; + padding: 5px; + margin-top:-15px; + } + + .sf-menu li:hover ul, .sf-menu li.sfHover ul { + top: 1.2em; + } +.sf-menu, .sf-menu * { + margin: 0; + padding: 0; + list-style: none; +} +.sf-menu { + line-height: 1.0; +} +.sf-menu ul { + position: absolute; + top: -999em; + width: 10em; /* left offset of submenus need to match (see below) */ +} +.sf-menu ul li { + width: 100%; +} +.sf-menu li:hover { + visibility: inherit; /* fixes IE7 'sticky bug' */ +} +.sf-menu li { + float: left; + position: relative; +} +.sf-menu a { + display: block; + position: relative; +} +.sf-menu li:hover ul, +.sf-menu li.sfHover ul { + left: 0; + top: 2.5em; /* match top ul list item height */ + z-index: 99; +} +ul.sf-menu li:hover li ul, +ul.sf-menu li.sfHover li ul { + top: -999em; +} +ul.sf-menu li li:hover ul, +ul.sf-menu li li.sfHover ul { + left: 10em; /* match ul width */ + top: 0; +} +ul.sf-menu li li:hover li ul, +ul.sf-menu li li.sfHover li ul { + top: -999em; +} +ul.sf-menu li li li:hover ul, +ul.sf-menu li li li.sfHover ul { + left: 10em; /* match ul width */ + top: 0; +} + .wrap .content ol li { + background:none; + font:400 10pt/1 Verdana; + margin-bottom:10px; + margin-left:12px; + } + .wrap .content ol li { + list-style-type:decimal; + + } + + + +} +/* end of screen media */ + -- cgit v1.2.1 From 0f5e63c6c8cdb81bfd1d202475a13b5730be9623 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 8 Jul 2010 13:22:19 +0200 Subject: Doc: change on index page --- doc/src/index.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 657f5d0724..42fd4fcd94 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -60,7 +60,7 @@
    • Function index
    • Modules
    • Namespaces
    • -
    • Global stuff
    • +
    • Global Declarations
    -- cgit v1.2.1 From 5903558f17a7a3173ad7a592892262bf297b52f2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 8 Jul 2010 13:43:57 +0200 Subject: qdoc: Fixed broken QML property links. Task-number: QTBUG-12038 --- tools/qdoc3/htmlgenerator.cpp | 2 +- tools/qdoc3/node.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 567a29739b..5a8fb86e30 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2949,7 +2949,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, static const QString headerTag("headerfile"); static const QString funcTag("func"); static const QString linkTag("link"); - + // replace all <@link> tags: "(<@link node=\"([^\"]+)\">).*()" bool done = false; for (int i = 0, srcSize = src.size(); i < srcSize;) { diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index b0770740ac..da62e29db7 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -299,7 +299,7 @@ InnerNode::~InnerNode() Node *InnerNode::findNode(const QString& name) { Node *node = childMap.value(name); - if (node) + if (node && node->subType() != QmlPropertyGroup) return node; if ((type() == Fake) && (subType() == QmlClass)) { for (int i=0; i Date: Thu, 8 Jul 2010 14:55:17 +0200 Subject: Doc: Correcting img bug Task-number: QTBUG-12028 --- doc/src/template/style/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index f7ff00ad7c..51440205fa 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -18,7 +18,6 @@ fieldset, img { border: 0; - width:100% } address, caption, cite, code, dfn, em, strong, th, var, optgroup { -- cgit v1.2.1 From c69dc51e5e03aaa87a9385f5557a4f6b8aaeded3 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Thu, 8 Jul 2010 15:28:24 +0200 Subject: Corrected paths Merge-request: 715 Reviewed-by: Oswald Buddenhagen --- src/sql/drivers/drivers.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri index 3af5525175..87cc0b1d9e 100644 --- a/src/sql/drivers/drivers.pri +++ b/src/sql/drivers/drivers.pri @@ -1,11 +1,11 @@ contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase -contains(sql-drivers, psql):include($$PWD/sqlite/qsql_psql.pri) +contains(sql-drivers, psql):include($$PWD/psql/qsql_psql.pri) contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri) contains(sql-drivers, odbc):include($$PWD/odbc/qsql_odbc.pri) contains(sql-drivers, oci):include($$PWD/oci/qsql_oci.pri) contains(sql-drivers, tds):include($$PWD/tds/qsql_tds.pri) contains(sql-drivers, db2):include($$PWD/db2/qsql_db2.pri) -contains(sql-drivers, ibase):include($$PWD/db2/qsql_ibase.pri) +contains(sql-drivers, ibase):include($$PWD/ibase/qsql_ibase.pri) contains(sql-drivers, sqlite2):include($$PWD/sqlite2/qsql_sqlite2.pri) contains(sql-drivers, sqlite):include($$PWD/sqlite/qsql_sqlite.pri) -- cgit v1.2.1 From 7787b548907add8b7c2ac642d161181070050ea4 Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 9 Jul 2010 11:16:28 +0200 Subject: qhelpgenerator: Fix namespace syntax checking. --- tools/assistant/lib/qhelpprojectdata.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/assistant/lib/qhelpprojectdata.cpp b/tools/assistant/lib/qhelpprojectdata.cpp index b0faf0caa4..52478478a4 100644 --- a/tools/assistant/lib/qhelpprojectdata.cpp +++ b/tools/assistant/lib/qhelpprojectdata.cpp @@ -327,10 +327,12 @@ bool QHelpProjectDataPrivate::hasValidSyntax(const QString &nameSpace, QUrl url; const QLatin1String scheme("qthelp"); url.setScheme(scheme); - url.setHost(nameSpace); + const QString canonicalNamespace = nameSpace.toLower(); + url.setHost(canonicalNamespace); url.setPath(vFolder); - const QString expectedUrl(scheme + QLatin1String("://") + nameSpace + slash + vFolder); + const QString expectedUrl(scheme + QLatin1String("://") + + canonicalNamespace + slash + vFolder); return url.isValid() && url.toString() == expectedUrl; } -- cgit v1.2.1 From e0a102ee171ddcebb1104d98d8a4ff4993e91c1d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 11:28:24 +0200 Subject: qdoc: Marked some missing declarative properties and functions as \internal. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 60 +++++++++++----------- src/declarative/qml/qdeclarativeengine.cpp | 4 +- tools/qdoc3/test/qt-cpp-ignore.qdocconf | 3 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 4abffc606a..70874f2839 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1387,26 +1387,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec necessary). */ -/*! - \property QDeclarativeItem::baseline - \internal -*/ - -/*! - \property QDeclarativeItem::focus - \internal -*/ - -/*! - \property QDeclarativeItem::wantsFocus - \internal -*/ - -/*! - \property QDeclarativeItem::transformOrigin - \internal -*/ - /*! \fn void QDeclarativeItem::childrenRectChanged(const QRectF &) \internal @@ -1970,6 +1950,9 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const return v; } +/*! + \internal + */ void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) { Q_D(QDeclarativeItem); @@ -1980,6 +1963,9 @@ void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) d->doneEventPreHandler = true; } +/*! + \internal + */ void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) { Q_D(QDeclarativeItem); @@ -1990,6 +1976,9 @@ void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) d->doneEventPreHandler = true; } +/*! + \internal + */ void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) { Q_D(QDeclarativeItem); @@ -2000,7 +1989,6 @@ void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) d->doneEventPreHandler = true; } - /*! \internal */ @@ -2539,11 +2527,6 @@ QDeclarativeListProperty QDeclarativeItemPrivate::transi \sa {qmlstates}{States} */ -/*! - \property QDeclarativeItem::state - \internal -*/ - /*! \internal */ QString QDeclarativeItemPrivate::state() const { @@ -2566,11 +2549,6 @@ void QDeclarativeItemPrivate::setState(const QString &state) For more information see \l Transform. */ -/*! - \property QDeclarativeItem::transform - \internal -*/ - /*! \internal */ QDeclarativeListProperty QDeclarativeItem::transform() { @@ -2858,6 +2836,26 @@ void QDeclarativeItem::setSmooth(bool smooth) update(); } +/*! + \property QDeclarativeItem::focus + \internal +*/ + +/*! + \property QDeclarativeItem::transform + \internal +*/ + +/*! + \property QDeclarativeItem::transformOrigin + \internal +*/ + +/*! + \property QDeclarativeItem::wantsFocus + \internal +*/ + /*! \internal Return the width of the item diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 036c8546a3..1ce668cc5d 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1077,7 +1077,7 @@ If you are certain the files will be local, you could simplify to: \snippet doc/src/snippets/declarative/componentCreation.js 2 To create a QML object from an arbitrary string of QML (instead of a file), -use \l{Qt::createQmlObject()}{Qt.createQmlObject()}. +use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}. */ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine) @@ -1124,7 +1124,7 @@ Each object in this array has the members \c lineNumber, \c columnNumber, \c fil Note that this function returns immediately, and therefore may not work if the \a qml string loads new components (that is, external QML files that have not yet been loaded). -If this is the case, consider using \l{Qt::createComponent()}{Qt.createComponent()} instead. +If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead. */ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) diff --git a/tools/qdoc3/test/qt-cpp-ignore.qdocconf b/tools/qdoc3/test/qt-cpp-ignore.qdocconf index dcf33dcd4a..8cc4fd9566 100644 --- a/tools/qdoc3/test/qt-cpp-ignore.qdocconf +++ b/tools/qdoc3/test/qt-cpp-ignore.qdocconf @@ -90,4 +90,5 @@ Cpp.ignoredirectives = Q_DECLARE_HANDLE \ __attribute__ \ K_DECLARE_PRIVATE \ PHONON_OBJECT \ - PHONON_HEIR + PHONON_HEIR \ + Q_PRIVATE_PROPERTY -- cgit v1.2.1 From 3b0a4bcf854e1d63b947e3f1690748850d416a6f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 12:07:20 +0200 Subject: doc: Fixed last of the declarative/QML qdoc warnings. --- doc/src/declarative/advtutorial.qdoc | 24 ++++++++++++++-------- .../graphicsitems/qdeclarativeloader.cpp | 7 +++---- .../graphicsitems/qdeclarativetextedit.cpp | 5 +++-- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index 9c72e95d59..740f6f948b 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -164,14 +164,22 @@ The \c createBlock() function creates a block from the \c Block.qml file and moves the new block to its position on the game canvas. This involves several steps: \list -\o \l {Qt::createComponent()}{Qt.createComponent()} is called to generate an element from \c Block.qml. - If the component is ready, we can call \c createObject() to create an instance of the \c Block item. -\o If \c createObject() returned null (i.e. if there was an error while - loading the object), print the error information. -\o Place the block in its position on the board and set its width and height. - Also, store it in the blocks array for future reference. -\o Finally, print error information to the console if the component could not be - loaded for some reason (for example, if the file is missing). + +\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to + generate an element from \c Block.qml. If the component is ready, + we can call \c createObject() to create an instance of the \c Block + item. + +\o If \c createObject() returned null (i.e. if there was an error + while loading the object), print the error information. + +\o Place the block in its position on the board and set its width and + height. Also, store it in the blocks array for future reference. + +\o Finally, print error information to the console if the component + could not be loaded for some reason (for example, if the file is + missing). + \endlist diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index c8c9e44aa1..cc7f8e5c29 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -118,9 +118,9 @@ void QDeclarativeLoaderPrivate::initResize() be instantiated may be specified directly by the \l sourceComponent property, or loaded from a URL via the \l source property. - Loader can be used to delay the creation of a component until it is required. - For example, this loads "Page1.qml" as a component into the \l Loader element - when the \l MouseArea is clicked: + Loader can be used to delay the creation of a component until it + is required. For example, this loads "Page1.qml" as a component + into the Loader element, when the \l MouseArea is clicked: \code import Qt 4.7 @@ -165,7 +165,6 @@ void QDeclarativeLoaderPrivate::initResize() /*! \internal \class QDeclarativeLoader - \qmlclass Loader */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index c6566fff56..3f179da849 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -202,8 +202,9 @@ QString QDeclarativeTextEdit::text() const Sets the font size in pixels. - Using this function makes the font device dependent. - Use \l pointSize to set the size of the font in a device independent manner. + Using this function makes the font device dependent. Use + \l{TextEdit::font.pointSize} to set the size of the font in a + device independent manner. */ /*! diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 0692aaad8a..8ed34ab675 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -589,7 +589,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Fri, 9 Jul 2010 12:18:18 +0200 Subject: Doc: Adding support for Qt Creator style Adding a variable to the qdocconf file will now generate the docs in Creator format Reviewed-by: Martin Smith --- tools/qdoc3/config.h | 1 + tools/qdoc3/htmlgenerator.cpp | 18 ++++++++++++++++-- tools/qdoc3/htmlgenerator.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/config.h b/tools/qdoc3/config.h index c29becca8a..af58a3f6c6 100644 --- a/tools/qdoc3/config.h +++ b/tools/qdoc3/config.h @@ -143,6 +143,7 @@ class Config #define CONFIG_NATURALLANGUAGE "naturallanguage" #define CONFIG_OBSOLETELINKS "obsoletelinks" #define CONFIG_ONLINE "online" +#define CONFIG_CREATOR "creator" #define CONFIG_OUTPUTDIR "outputdir" #define CONFIG_OUTPUTENCODING "outputencoding" #define CONFIG_OUTPUTLANGUAGE "outputlanguage" diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index c1e01d7f35..16b45d6c7d 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -214,6 +214,7 @@ HtmlGenerator::HtmlGenerator() numTableRows(0), threeColumnEnumValueTable(true), offlineDocs(true), + creatorDocs(false), funcLeftParen("\\S(\\()"), myTree(0), slow(false), @@ -276,6 +277,7 @@ void HtmlGenerator::initializeGenerator(const Config &config) project = config.getString(CONFIG_PROJECT); offlineDocs = !config.getBool(CONFIG_ONLINE); + creatorDocs = !config.getBool(CONFIG_CREATOR); projectDescription = config.getString(CONFIG_DESCRIPTION); if (projectDescription.isEmpty() && !project.isEmpty()) projectDescription = project + " Reference Documentation"; @@ -1775,9 +1777,17 @@ void HtmlGenerator::generateHeader(const QString& title, // Setting assistant configuration if (offlineDocs) { - // out() << " "; // Only for Qt Creator + out() << " "; // Only for Qt Creator out() << "\n"; - out() << "\n"; // offline for Creator and Assistant + //out() << "\n"; // offline for Assistant + out() << "\n"; // offline for Creator + } + if (creatorDocs) + { + out() << " "; // Only for Qt Creator + out() << "\n"; + //out() << "\n"; // offline for Assistant + out() << "\n"; // offline for Creator } // Setting online doc configuration else @@ -1845,6 +1855,10 @@ void HtmlGenerator::generateFooter(const Node *node) if (offlineDocs) { + out() << "\n"; + } + if (creatorDocs) + { out() << "\n"; } else diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 9c5be15f62..abfca6043f 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -288,6 +288,7 @@ class HtmlGenerator : public PageGenerator int numTableRows; bool threeColumnEnumValueTable; bool offlineDocs; + bool creatorDocs; QString link; QStringList sectionNumber; QRegExp funcLeftParen; -- cgit v1.2.1 From bf791d9beffe766bec954cb70495d13f773dc733 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 12:43:12 +0200 Subject: doc: Fixed several qdoc warnings. --- doc/src/examples/trafficinfo.qdoc | 2 +- .../frameworks-technologies/model-view-programming.qdoc | 16 ++++++++-------- src/corelib/kernel/qabstractitemmodel.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/src/examples/trafficinfo.qdoc b/doc/src/examples/trafficinfo.qdoc index fe69d52e50..bc061782b2 100644 --- a/doc/src/examples/trafficinfo.qdoc +++ b/doc/src/examples/trafficinfo.qdoc @@ -145,5 +145,5 @@ The rest of the code in this example is just for representing the time and station information to the user, and uses techniques described in the - \l{Widgets Examples}. + \l{Widget Examples}. */ diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index 94b9f0dd8b..6c38060943 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -900,7 +900,7 @@ after its application through the use of certain types of selection commands. These are discussed later in this section. - \section3 Current item & selected items + \section3 Current item and selected items In a view, there is always a current item and a selected item - two independent states. An item can be the current item and selected at the @@ -1257,7 +1257,7 @@ reimplement the \l{QAbstractItemModel::columnCount()}{columnCount()} function. - \section3 Model headers & data + \section3 Model headers and data For items in the view, we want to return the strings in the string list. The \l{QAbstractItemModel::data()}{data()} function is responsible for @@ -1350,7 +1350,7 @@ \snippet doc/src/snippets/stringlistmodel/model.cpp 1 - \section3 Inserting & removing rows + \section3 Inserting and removing rows It is possible to change the number of rows and columns in a model. In the string list model it only makes sense to change the number of rows, so we @@ -1634,7 +1634,7 @@ contain the text given in the search string. This pattern can also be used in the list and table widgets. - \section1 Using drag & drop with item views + \section1 Using drag & drop with item views Qt's drag and drop infrastructure is fully supported by the model/view framework. Items in lists, tables, and trees can be dragged within the views, and data can be @@ -1714,7 +1714,7 @@ of QAbstractItemModel::removeRows(), either directly or by inheriting the implementation from its base class. - \section3 Enabling drag & drop for items + \section3 Enabling drag & drop for items Models indicate to views which items can be dragged, and which will accept drops, by reimplementing the QAbstractItemModel::flags() function to provide suitable @@ -2124,12 +2124,12 @@ children may be displayed incorrectly in some views until the user attempts to view the non-existent child items. - \section2 Navigation & model index creation + \section2 Navigation and model index creation Hierarchical models need to provide functions that views can call to navigate the tree-like structures they expose, and obtain model indexes for items. - \section3 Parents & children + \section3 Parents and children Since the structure exposed to views is determined by the underlying data structure, it is up to each model subclass to create its own model indexes @@ -2153,7 +2153,7 @@ models to supply some unique identifier to this function to ensure that the model index can be re-associated with its corresponding item later on. - \section2 Drag & drop support and MIME type handling + \section2 Drag & drop support and MIME type handling The model/view classes support drag and drop operations, providing default behavior that is sufficient for many applications. However, it is also possible to customize diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 84152591da..464a91c433 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1197,7 +1197,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \l{QAbstractItemModel::}{endInsertRows()} must be called. \sa {Model Classes}, {Model Subclassing Reference}, QModelIndex, - QAbstractItemView, {Using Drag and Drop with Item Views}, + QAbstractItemView, {Using drag & drop with item views}, {Simple DOM Model Example}, {Simple Tree Model Example}, {Editable Tree Model Example}, {Fetch More Example} */ @@ -1761,7 +1761,7 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const where to place the data. This can occur in a tree when data is dropped on a parent. Models will usually append the data to the parent in this case. - \sa supportedDropActions(), {Using Drag and Drop with Item Views} + \sa supportedDropActions(), {Using drag & drop with item views} */ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) @@ -1798,8 +1798,8 @@ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti reimplement the dropMimeData() function to handle the additional operations. - \sa dropMimeData(), Qt::DropActions, {Using Drag and Drop with Item - Views} + \sa dropMimeData(), Qt::DropActions, {Using drag & drop with item + views} */ Qt::DropActions QAbstractItemModel::supportedDropActions() const { @@ -1815,7 +1815,7 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const supportedDragActions() is used by QAbstractItemView::startDrag() as the default values when a drag occurs. - \sa Qt::DropActions, {Using Drag and Drop with Item Views} + \sa Qt::DropActions, {Using drag & drop with item views} */ Qt::DropActions QAbstractItemModel::supportedDragActions() const { @@ -1831,7 +1831,7 @@ Qt::DropActions QAbstractItemModel::supportedDragActions() const Sets the supported drag \a actions for the items in the model. - \sa supportedDragActions(), {Using Drag and Drop with Item Views} + \sa supportedDragActions(), {Using drag & drop with item views} */ void QAbstractItemModel::setSupportedDragActions(Qt::DropActions actions) { -- cgit v1.2.1 From 630af9571cd65e4c74f682c401d791e2a1436d13 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 13:06:10 +0200 Subject: doc: Fixed several qdoc warnings. --- src/gui/graphicsview/qgraphicsitem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 51dc543377..74c51f4cd0 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -133,7 +133,8 @@ \img graphicsview-parentchild.png - \section1 Transformation + \target Transformations + \section1 Transformations QGraphicsItem supports projective transformations in addition to its base position, pos(). There are several ways to change an item's transformation. -- cgit v1.2.1 From a168d8dbeb3eed11cb0ae373d9076f34216155bb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 13:14:21 +0200 Subject: doc: Fixed several qdoc warnings. --- doc/src/examples/movie.qdoc | 4 ++-- doc/src/frameworks-technologies/phonon.qdoc | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/examples/movie.qdoc b/doc/src/examples/movie.qdoc index 733f52dcc0..4d7b3e0cbc 100644 --- a/doc/src/examples/movie.qdoc +++ b/doc/src/examples/movie.qdoc @@ -30,8 +30,8 @@ \title Movie Example The Movie example demonstrates how to use QMovie and QLabel to - display animations. Now that Qt comes with \l{Phonon - Overview}{Phonon} (the multimedia framework), QMovie is mostly + display animations. Now that Qt comes with the \l{Phonon multimedia + framework} {Phonon multimedia framework}, QMovie is mostly useful if one wants to play a simple animation without the added complexity of a multimedia framework to install and deploy. diff --git a/doc/src/frameworks-technologies/phonon.qdoc b/doc/src/frameworks-technologies/phonon.qdoc index 023b4ce2ab..5119638141 100644 --- a/doc/src/frameworks-technologies/phonon.qdoc +++ b/doc/src/frameworks-technologies/phonon.qdoc @@ -34,6 +34,7 @@ \tableofcontents + \target Phonon Overview \section1 Introduction Qt uses the Phonon multimedia framework to provide functionality -- cgit v1.2.1 From 3b2e680b5f56227af0716b3bc07b11cb7e044d78 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 13:16:48 +0200 Subject: doc: Fixed several qdoc warnings. --- doc/src/frameworks-technologies/model-view-programming.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index 6c38060943..131f06351c 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -2282,7 +2282,7 @@ \endlist For more information about drag and drop with item views, refer to - \l{Using Drag and Drop with Item Views}. + \l{Using drag & drop with item views}. \section3 Convenience views @@ -2293,7 +2293,7 @@ the existing contents with the data being transferred, the underlying model will set the data of the target items rather than insert new rows and columns into the model. For more information on drag and drop in convenience views, - you can see \l{Using Drag and Drop with Item Views}. + you can see \l{Using drag & drop with item views}. \section2 Performance optimization for large amounts of data -- cgit v1.2.1 From ad0e8a48eade0b2cdcf10a68f36d911784ff03ab Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 13:25:50 +0200 Subject: doc: Fixed several qdoc warnings. --- doc/src/frameworks-technologies/dnd.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/frameworks-technologies/dnd.qdoc b/doc/src/frameworks-technologies/dnd.qdoc index 4a1b631e12..c5dd27c572 100644 --- a/doc/src/frameworks-technologies/dnd.qdoc +++ b/doc/src/frameworks-technologies/dnd.qdoc @@ -45,7 +45,7 @@ outlines the approach used to enable it in custom widgets. Drag and drop operations are also supported by Qt's item views and by the graphics view framework. More information is available in - \l{Using Drag and Drop with Item Views} and \l{Graphics View + \l{Using drag & drop with item views} and \l{Graphics View Framework}. \section1 Drag and Drop Classes -- cgit v1.2.1 From 230ab8adb281aabc2d0ebf41ade5f2ec7f11e020 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 9 Jul 2010 10:11:13 +0200 Subject: Revert "SSL backend: load libraries for certificates only once" This reverts commit f2187e31de13a6ab8631a9067487dab555f7c2e7. Reviewed-by: Markus Goetz --- src/network/ssl/qsslsocket.cpp | 6 ++--- src/network/ssl/qsslsocket_openssl.cpp | 42 ++++++++++++++++------------------ src/network/ssl/qsslsocket_p.h | 11 +++++---- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 809e8aa2ca..f85fa8449b 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1849,7 +1849,7 @@ QList QSslSocketPrivate::defaultCiphers() */ QList QSslSocketPrivate::supportedCiphers() { - QSslSocketPrivate::ensureCertsAndCiphersLoaded(); + QSslSocketPrivate::ensureInitialized(); QMutexLocker locker(&globalData()->mutex); return globalData()->supportedCiphers; } @@ -1879,7 +1879,7 @@ void QSslSocketPrivate::setDefaultSupportedCiphers(const QList &ciph */ QList QSslSocketPrivate::defaultCaCertificates() { - QSslSocketPrivate::ensureCertsAndCiphersLoaded(); + QSslSocketPrivate::ensureInitialized(); QMutexLocker locker(&globalData()->mutex); return globalData()->config->caCertificates; } @@ -1962,7 +1962,7 @@ void QSslConfigurationPrivate::setDefaultConfiguration(const QSslConfiguration & */ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPrivate *ptr) { - QSslSocketPrivate::ensureCertsAndCiphersLoaded(); + QSslSocketPrivate::ensureInitialized(); QMutexLocker locker(&globalData()->mutex); const QSslConfigurationPrivate *global = globalData()->config.constData(); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index b602b295f1..d7088eea91 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -74,9 +74,8 @@ QT_BEGIN_NAMESPACE -bool QSslSocketPrivate::s_initialized = false; -QBasicAtomicInt QSslSocketPrivate::s_CertsAndCiphersLoaded; -Q_GLOBAL_STATIC(QMutex, s_CertsAndCiphersLoadedMutex); +bool QSslSocketPrivate::s_libraryLoaded = false; +bool QSslSocketPrivate::s_loadedCiphersAndCerts = false; // Useful defines #define SSL_ERRORSTR() QString::fromLocal8Bit(q_ERR_error_string(q_ERR_get_error(), NULL)) @@ -171,7 +170,7 @@ QSslSocketBackendPrivate::QSslSocketBackendPrivate() session(0) { // Calls SSL_library_init(). - ensureCertsAndCiphersLoaded(); + ensureInitialized(); } QSslSocketBackendPrivate::~QSslSocketBackendPrivate() @@ -422,18 +421,18 @@ void QSslSocketPrivate::deinitialize() bool QSslSocketPrivate::supportsSsl() { - return ensureInitialized(); + return ensureLibraryLoaded(); } -bool QSslSocketPrivate::ensureInitialized() +bool QSslSocketPrivate::ensureLibraryLoaded() { if (!q_resolveOpenSslSymbols()) return false; // Check if the library itself needs to be initialized. QMutexLocker locker(openssl_locks()->initLock()); - if (!s_initialized) { - s_initialized = true; + if (!s_libraryLoaded) { + s_libraryLoaded = true; // Initialize OpenSSL. q_CRYPTO_set_id_callback(id_function); @@ -474,6 +473,16 @@ bool QSslSocketPrivate::ensureInitialized() return true; } +void QSslSocketPrivate::ensureCiphersAndCertsLoaded() +{ + if (s_loadedCiphersAndCerts) + return; + s_loadedCiphersAndCerts = true; + + resetDefaultCiphers(); + setDefaultCaCertificates(systemCaCertificates()); +} + /*! \internal @@ -481,18 +490,13 @@ bool QSslSocketPrivate::ensureInitialized() been initialized. */ -void QSslSocketPrivate::ensureCertsAndCiphersLoaded() +void QSslSocketPrivate::ensureInitialized() { - // use double-checked locking to speed up this function - if (s_CertsAndCiphersLoaded) + if (!supportsSsl()) return; - QMutexLocker locker(s_CertsAndCiphersLoadedMutex()); - if (s_CertsAndCiphersLoaded) - return; + ensureCiphersAndCertsLoaded(); - if (!supportsSsl()) - return; //load symbols needed to receive certificates from system store #if defined(Q_OS_MAC) QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security"); @@ -528,12 +532,6 @@ void QSslSocketPrivate::ensureCertsAndCiphersLoaded() qWarning("could not load crypt32 library"); // should never happen } #endif - resetDefaultCiphers(); - setDefaultCaCertificates(systemCaCertificates()); - // we need to make sure that s_CertsAndCiphersLoaded is executed after the library loading above - // (the compiler/processor might reorder instructions otherwise) - if (!s_CertsAndCiphersLoaded.testAndSetRelease(0, 1)) - Q_ASSERT_X(false, "certificate store", "certificate store has already been initialized!"); } /*! diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index b474175378..72b3ef73a0 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -63,7 +63,6 @@ #include #include -#include QT_BEGIN_NAMESPACE @@ -114,8 +113,7 @@ public: QString verificationPeerName; static bool supportsSsl(); - static bool ensureInitialized(); - static void ensureCertsAndCiphersLoaded(); + static void ensureInitialized(); static void deinitialize(); static QList defaultCiphers(); static QList supportedCiphers(); @@ -163,8 +161,11 @@ public: virtual QSslCipher sessionCipher() const = 0; private: - static bool s_initialized; - static QBasicAtomicInt s_CertsAndCiphersLoaded; + static bool ensureLibraryLoaded(); + static void ensureCiphersAndCertsLoaded(); + + static bool s_libraryLoaded; + static bool s_loadedCiphersAndCerts; }; QT_END_NAMESPACE -- cgit v1.2.1 From b1a52a071e3741d46df5c45423c6654d517ac4c2 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 9 Jul 2010 10:44:59 +0200 Subject: SSL library loading: load system libs only once ... and make the loading thread-safe. The global methods for loading the OpenSSL libraries and the system libraries are accessed from within different QSslSocket and QSslConfiguration instances, so they need to be thread-safe. Reviewed-by: Markus Goetz --- src/network/ssl/qsslsocket_openssl.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index d7088eea91..b53758231e 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -475,27 +475,12 @@ bool QSslSocketPrivate::ensureLibraryLoaded() void QSslSocketPrivate::ensureCiphersAndCertsLoaded() { + QMutexLocker locker(openssl_locks()->initLock()); if (s_loadedCiphersAndCerts) return; s_loadedCiphersAndCerts = true; resetDefaultCiphers(); - setDefaultCaCertificates(systemCaCertificates()); -} - -/*! - \internal - - Declared static in QSslSocketPrivate, makes sure the SSL libraries have - been initialized. -*/ - -void QSslSocketPrivate::ensureInitialized() -{ - if (!supportsSsl()) - return; - - ensureCiphersAndCertsLoaded(); //load symbols needed to receive certificates from system store #if defined(Q_OS_MAC) @@ -532,6 +517,22 @@ void QSslSocketPrivate::ensureInitialized() qWarning("could not load crypt32 library"); // should never happen } #endif + setDefaultCaCertificates(systemCaCertificates()); +} + +/*! + \internal + + Declared static in QSslSocketPrivate, makes sure the SSL libraries have + been initialized. +*/ + +void QSslSocketPrivate::ensureInitialized() +{ + if (!supportsSsl()) + return; + + ensureCiphersAndCertsLoaded(); } /*! -- cgit v1.2.1 From 8e1edcd846a46cf55f2f198d3b959498b58fe352 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 13:58:17 +0200 Subject: doc: Fixed several qdoc warnings. --- src/gui/text/qtextoption.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 8f31e4603a..9eeec0bfae 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -392,7 +392,12 @@ QList QTextOption::tabs() const /*! \fn Tab::Tab(qreal pos, TabType tabType, QChar delim = QChar()) - Creates a tab with the given position, tab type, and (for DelimiterTab) delimiter + + Creates a tab with the given position, tab type, and delimiter + (\a pos, \a tabType, \a delim). + + \note \a delim is only used when \a tabType is DelimiterTab. + \since 4.7 */ -- cgit v1.2.1 From 5f2437ae9a11c360139599b4d4b01270cd276a52 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 9 Jul 2010 14:08:30 +0200 Subject: doc: Fixed several qdoc warnings. --- src/corelib/kernel/qabstractitemmodel.cpp | 4 ++-- src/gui/itemviews/qabstractitemview.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 464a91c433..e3fce1809e 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2547,7 +2547,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star For example, as shown in the diagram, we move three rows from row 2 to 4 in the source, so \a sourceFirst is 2 and \a sourceLast is 4. - We move those items to above row 2 in the destination, so \a destinationRow is 2. + We move those items to above row 2 in the destination, so \a destinationChild is 2. \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 6 @@ -2558,7 +2558,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star \o To append rows to another parent, move them to after the last row. For example, as shown in the diagram, we move three rows to a - collection of 6 existing rows (ending in row 5), so \a destinationStart is 6: + collection of 6 existing rows (ending in row 5), so \a destinationChild is 6: \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 7 diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 4fb93fc2c4..97499f3c82 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1363,7 +1363,7 @@ bool QAbstractItemView::dragEnabled() const Note that the model used needs to provide support for drag and drop operations. - \sa setDragDropMode() {Using Drag and Drop with Item Views} + \sa setDragDropMode() {Using drag & drop with item views} */ /*! -- cgit v1.2.1 From 653f180d4697e0c7ec1c58022622d5d140e7fda8 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 9 Jul 2010 14:33:16 +0200 Subject: Doc: fixing examples link --- doc/src/index.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 42fd4fcd94..92721c5351 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -44,7 +44,7 @@
  • Installation & first steps
  • How to learn Qt
  • Tutorials
  • -
  • Examples
  • +
  • Examples
  • Whats new in Qt 4.7
  • -- cgit v1.2.1 From 5f6018564668d368f75e431c4cdac88d7421cff0 Mon Sep 17 00:00:00 2001 From: "Richard J. Moore" Date: Sun, 6 Jun 2010 22:10:08 +0100 Subject: Fix handling of SSL certificates with wildcard domain names Merge-request: 731 Task-number: QTBUG-4455 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslsocket_openssl.cpp | 42 +++++++++++++++++++++++++++++--- src/network/ssl/qsslsocket_openssl_p.h | 1 + tests/auto/qsslsocket/tst_qsslsocket.cpp | 24 ++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index b53758231e..fa703810ea 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1101,17 +1101,16 @@ bool QSslSocketBackendPrivate::startHandshake() QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName); QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName); - QRegExp regexp(commonName, Qt::CaseInsensitive, QRegExp::Wildcard); - if (!regexp.exactMatch(peerName)) { + if (!isMatchingHostname(commonName.lower(), peerName.lower())) { bool matched = false; foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { - regexp.setPattern(altName); - if (regexp.exactMatch(peerName)) { + if (isMatchingHostname(altName.lower(), peerName.lower())) { matched = true; break; } } + if (!matched) { // No matches in common names or alternate names. QSslError error(QSslError::HostNameMismatch, configuration.peerCertificate); @@ -1241,4 +1240,39 @@ QList QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates return certificates; } +bool QSslSocketBackendPrivate::isMatchingHostname(const QString &cn, const QString &hostname) +{ + int wildcard = cn.indexOf(QLatin1Char('*')); + + // Check this is a wildcard cert, if not then just compare the strings + if (wildcard < 0) + return cn == hostname; + + int firstCnDot = cn.indexOf(QLatin1Char('.')); + int secondCnDot = cn.indexOf(QLatin1Char('.'), firstCnDot+1); + + // Check at least 3 components + if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length())) + return false; + + // Check * is last character of 1st component (ie. there's a following .) + if (wildcard+1 != firstCnDot) + return false; + + // Check only one star + if (cn.lastIndexOf(QLatin1Char('*')) != wildcard) + return false; + + // Check characters preceding * (if any) match + if (wildcard && (hostname.leftRef(wildcard) != cn.leftRef(wildcard))) + return false; + + // Check characters following first . match + if (hostname.midRef(hostname.indexOf(QLatin1Char('.'))) != cn.midRef(firstCnDot)) + return false; + + // Ok, I guess this was a wildcard CN and the hostname matches. + return true; +} + QT_END_NAMESPACE diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h index e41320da18..fd02838a9e 100644 --- a/src/network/ssl/qsslsocket_openssl_p.h +++ b/src/network/ssl/qsslsocket_openssl_p.h @@ -116,6 +116,7 @@ public: static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher); static QList STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509); + Q_AUTOTEST_EXPORT static bool isMatchingHostname(const QString &cn, const QString &hostname); }; #if defined(Q_OS_SYMBIAN) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 0cf638b56c..0c12974455 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -55,6 +55,7 @@ #include #include "private/qhostinfo_p.h" +#include "private/qsslsocket_openssl_p.h" #include "../network-settings.h" @@ -163,6 +164,7 @@ private slots: void setDefaultCiphers(); void supportedCiphers(); void systemCaCertificates(); + void wildcardCertificateNames(); void wildcard(); void setEmptyKey(); void spontaneousWrite(); @@ -1063,6 +1065,28 @@ void tst_QSslSocket::systemCaCertificates() QCOMPARE(certs, QSslSocket::defaultCaCertificates()); } +void tst_QSslSocket::wildcardCertificateNames() +{ + // Passing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("www.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx*.example.com"), QString("xxxwww.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("foo.example.com")), true ); + + // Failing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx.example.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.*.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("baa.foo.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("baa.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*fail.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example.")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString(""), QString("www")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www")), false ); +} + void tst_QSslSocket::wildcard() { QSKIP("TODO: solve wildcard problem", SkipAll); -- cgit v1.2.1 From c50d351df3b7fe2f0d10444c1080b6a8c9833e0f Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 9 Jul 2010 15:21:03 +0200 Subject: Doc: fixing offline style --- tools/qdoc3/htmlgenerator.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 16b45d6c7d..c8218dc155 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -214,7 +214,7 @@ HtmlGenerator::HtmlGenerator() numTableRows(0), threeColumnEnumValueTable(true), offlineDocs(true), - creatorDocs(false), + creatorDocs(true), funcLeftParen("\\S(\\()"), myTree(0), slow(false), @@ -1777,17 +1777,15 @@ void HtmlGenerator::generateHeader(const QString& title, // Setting assistant configuration if (offlineDocs) { - out() << " "; // Only for Qt Creator + out() << " "; // Only for Qt Creator out() << "\n"; - //out() << "\n"; // offline for Assistant - out() << "\n"; // offline for Creator + out() << "\n"; // offline for Assistant } if (creatorDocs) { - out() << " "; // Only for Qt Creator + out() << " "; // Only for Qt Creator out() << "\n"; - //out() << "\n"; // offline for Assistant - out() << "\n"; // offline for Creator + out() << "\n"; // offline for Creator } // Setting online doc configuration else -- cgit v1.2.1 From 63171ddd8ec99d9af17e0adcc2cad61586fed42b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 9 Jul 2010 16:49:39 +0200 Subject: QFileIconProvider: Load icons on demand. Drawing icons is quite costly and mostly, only 'file' and 'directory' are required. Speeds up application startup considerably. Reviewed-by: Olivier Goffart --- src/gui/itemviews/qfileiconprovider.cpp | 71 +++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index 5dbd1f08b8..4748f89eb7 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -100,69 +100,80 @@ public: QIcon getMacIcon(const QFileInfo &fi) const; #endif QFileIconProvider *q_ptr; - QString homePath; + const QString homePath; private: - QIcon file; - QIcon fileLink; - QIcon directory; - QIcon directoryLink; - QIcon harddisk; - QIcon floppy; - QIcon cdrom; - QIcon ram; - QIcon network; - QIcon computer; - QIcon desktop; - QIcon trashcan; - QIcon generic; - QIcon home; + mutable QIcon file; + mutable QIcon fileLink; + mutable QIcon directory; + mutable QIcon directoryLink; + mutable QIcon harddisk; + mutable QIcon floppy; + mutable QIcon cdrom; + mutable QIcon ram; + mutable QIcon network; + mutable QIcon computer; + mutable QIcon desktop; + mutable QIcon trashcan; + mutable QIcon generic; + mutable QIcon home; }; -QFileIconProviderPrivate::QFileIconProviderPrivate() +QFileIconProviderPrivate::QFileIconProviderPrivate() : + homePath(QDir::home().absolutePath()) { - QStyle *style = QApplication::style(); - file = style->standardIcon(QStyle::SP_FileIcon); - directory = style->standardIcon(QStyle::SP_DirIcon); - fileLink = style->standardIcon(QStyle::SP_FileLinkIcon); - directoryLink = style->standardIcon(QStyle::SP_DirLinkIcon); - harddisk = style->standardIcon(QStyle::SP_DriveHDIcon); - floppy = style->standardIcon(QStyle::SP_DriveFDIcon); - cdrom = style->standardIcon(QStyle::SP_DriveCDIcon); - network = style->standardIcon(QStyle::SP_DriveNetIcon); - computer = style->standardIcon(QStyle::SP_ComputerIcon); - desktop = style->standardIcon(QStyle::SP_DesktopIcon); - trashcan = style->standardIcon(QStyle::SP_TrashIcon); - home = style->standardIcon(QStyle::SP_DirHomeIcon); - homePath = QDir::home().absolutePath(); } QIcon QFileIconProviderPrivate::getIcon(QStyle::StandardPixmap name) const { switch (name) { case QStyle::SP_FileIcon: + if (file.isNull()) + file = QApplication::style()->standardIcon(name); return file; case QStyle::SP_FileLinkIcon: + if (fileLink.isNull()) + fileLink = QApplication::style()->standardIcon(name); return fileLink; case QStyle::SP_DirIcon: + if (directory.isNull()) + directory = QApplication::style()->standardIcon(name); return directory; case QStyle::SP_DirLinkIcon: + if (directoryLink.isNull()) + directoryLink = QApplication::style()->standardIcon(name); return directoryLink; case QStyle::SP_DriveHDIcon: + if (harddisk.isNull()) + harddisk = QApplication::style()->standardIcon(name); return harddisk; case QStyle::SP_DriveFDIcon: + if (floppy.isNull()) + floppy = QApplication::style()->standardIcon(name); return floppy; case QStyle::SP_DriveCDIcon: + if (cdrom.isNull()) + cdrom = QApplication::style()->standardIcon(name); return cdrom; case QStyle::SP_DriveNetIcon: + if (network.isNull()) + network = QApplication::style()->standardIcon(name); return network; case QStyle::SP_ComputerIcon: + if (computer.isNull()) + computer = QApplication::style()->standardIcon(name); return computer; case QStyle::SP_DesktopIcon: + if (desktop.isNull()) + desktop = QApplication::style()->standardIcon(name); return desktop; case QStyle::SP_TrashIcon: + if (trashcan.isNull()) + trashcan = QApplication::style()->standardIcon(name); return trashcan; case QStyle::SP_DirHomeIcon: + if (home.isNull()) + home = QApplication::style()->standardIcon(name); return home; default: return QIcon(); -- cgit v1.2.1 From bd287865d2b57395a340e85f1fac9b7ddff3ec14 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 9 Jul 2010 16:59:04 +0200 Subject: QIODPLB: Sync behavior of ungetBlock() and ungetChar() ungetChar() supports ungetting data that didn't originate from the QIODevicePrivateLinearBuffer, so ungetBlock() should too. --- src/corelib/io/qiodevice_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 4a25562605..1dd51ea8b2 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -155,10 +155,10 @@ public: if ((first - buf) < size) { // underflow, the existing valid data needs to move to the end of the (potentially bigger) buffer makeSpace(len + size, freeSpaceAtStart); - memcpy(first - size, block, size); } first -= size; len += size; + memcpy(first, block, size); } private: -- cgit v1.2.1 From 1b98fbd82c7145c2f81292f8a1feb6cac74e775d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 9 Jul 2010 11:39:01 +0200 Subject: Add NTLMv2 authentication support to QAuthenticator. This also fixes a long-standing bug in handling usernames of type "domainname\username", typical of Windows domains, that didn't work with the previous NTLMv1 code. Patch by subcontractor. Task-number: QTBUG-9408, QTBUG-2421, QT-3248 Reviewed-By: Markus Goetz --- src/network/kernel/qauthenticator.cpp | 286 +++++++++++++++++++++++++++++++++- 1 file changed, 279 insertions(+), 7 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index e4023c843d..e7442c0f35 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -50,6 +50,8 @@ #include #include #include +#include + QT_BEGIN_NAMESPACE @@ -162,7 +164,18 @@ QString QAuthenticator::user() const void QAuthenticator::setUser(const QString &user) { detach(); - d->user = user; + + int separatorPosn = 0; + separatorPosn = user.indexOf(QLatin1String("\\")); + + if (separatorPosn == -1) { + //No domain name present + d->user = user; + } else { + //domain name is present + d->realm = user.left(separatorPosn); + d->user = user.mid(separatorPosn+1); + } } /*! @@ -264,16 +277,17 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, switch(method) { case Basic: - realm = QString::fromLatin1(options.value("realm")); + if(realm.isEmpty()) + realm = QString::fromLatin1(options.value("realm")); if (user.isEmpty()) phase = Done; break; case Ntlm: // #### extract from header - realm.clear(); break; case DigestMd5: { - realm = QString::fromLatin1(options.value("realm")); + if(realm.isEmpty()) + realm = QString::fromLatin1(options.value("realm")); if (options.value("stale").toLower() == "true") phase = Start; if (user.isEmpty()) @@ -661,6 +675,20 @@ QByteArray QAuthenticatorPrivate::digestMd5Response(const QByteArray &challenge, */ #define NTLMSSP_NEGOTIATE_56 0x80000000 +/* + * AvId values + */ +#define AVTIMESTAMP 7 + +//#define NTLMV1_CLIENT + + +//************************Global variables*************************** + +const int blockSize = 64; //As per RFC2104 Block-size is 512 bits +const int nDigestLen = 16; //Trunctaion Length of the Hmac-Md5 digest +const quint8 respversion = 1; +const quint8 hirespversion = 1; /* usage: // fill up ctx with what we know. @@ -803,6 +831,7 @@ public: // extracted QString targetNameStr, targetInfoStr; + QByteArray targetInfoBuff; }; @@ -818,6 +847,7 @@ public: // extracted QByteArray lmResponseBuf, ntlmResponseBuf; QString domainStr, userStr, workstationStr, sessionKeyStr; + QByteArray v2Hash; }; @@ -899,7 +929,7 @@ static QString qStringFromUcs2Le(const QByteArray& src) return QString((const QChar *)src.data(), src.size()/2); } - +#ifdef NTLMV1_CLIENT static QByteArray qEncodeNtlmResponse(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch) { QCryptographicHash md4(QCryptographicHash::Md4); @@ -941,7 +971,232 @@ static QByteArray qEncodeLmResponse(const QAuthenticatorPrivate *ctx, const QNtl hash.fill(0); return rc; } +#endif + +/********************************************************************* +* Function Name: qEncodeHmacMd5 +* Params: +* key: Type - QByteArray +* - It is the Authentication key +* message: Type - QByteArray +* - This is the actual message which will be encoded +* using HMacMd5 hash algorithm +* +* Return Value: +* hmacDigest: Type - QByteArray +* +* Description: +* This function will be used to encode the input message using +* HMacMd5 hash algorithm. +* +* As per the RFC2104 the HMacMd5 algorithm can be specified +* --------------------------------------- +* MD5(K XOR opad, MD5(K XOR ipad, text)) +* --------------------------------------- +* +*********************************************************************/ +QByteArray qEncodeHmacMd5(QByteArray &key, const QByteArray &message) +{ + Q_ASSERT_X(!(message.isEmpty()),"qEncodeHmacMd5", "Empty message check"); + Q_ASSERT_X(!(key.isEmpty()),"qEncodeHmacMd5", "Empty key check"); + + QCryptographicHash hash(QCryptographicHash::Md5); + QByteArray hMsg; + + QByteArray iKeyPad(blockSize, 0x36); + QByteArray oKeyPad(blockSize, 0x5c); + + hash.reset(); + // Adjust the key length to blockSize + + if(blockSize < key.length()) { + hash.addData(key); + key = hash.result(); //MD5 will always return 16 bytes length output + } + + //Key will be <= 16 or 20 bytes as hash function (MD5 or SHA hash algorithms) + //key size can be max of Block size only + key = key.leftJustified(blockSize,0,true); + + //iKeyPad, oKeyPad and key are all of same size "blockSize" + + //xor of iKeyPad with Key and store the result into iKeyPad + for(int i = 0; iv2Hash.size() == 0) { + QCryptographicHash md4(QCryptographicHash::Md4); + QByteArray passUnicode = qStringAsUcs2Le(ctx->password); + md4.addData(passUnicode.data(), passUnicode.size()); + + QByteArray hashKey = md4.result(); + Q_ASSERT(hashKey.size() == 16); + // Assuming the user and domain is always unicode in challenge + QByteArray message = + qStringAsUcs2Le(ctx->user.toUpper()) + + qStringAsUcs2Le(ctx->realm); + + phase3->v2Hash = qEncodeHmacMd5(hashKey, message); + } + return phase3->v2Hash; +} + +static QByteArray clientChallenge(const QAuthenticatorPrivate *ctx) +{ + Q_ASSERT(ctx->cnonce.size() >= 8); + QByteArray clientCh = ctx->cnonce.right(8); + return clientCh; +} + +// caller has to ensure a valid targetInfoBuff +static bool qExtractServerTime(const QByteArray& targetInfoBuff, + quint64 *serverTime) +{ + Q_ASSERT(serverTime != 0); + bool retValue = false; + QDataStream ds(targetInfoBuff); + ds.setByteOrder(QDataStream::LittleEndian); + + quint16 avId; + quint16 avLen; + + ds >> avId; + ds >> avLen; + while(avId != 0) { + if(avId == AVTIMESTAMP) { + QByteArray timeArray(avLen, 0); + //avLen size of QByteArray is allocated + ds.readRawData(timeArray.data(), avLen); + bool ok; + *serverTime = timeArray.toHex().toLongLong(&ok, 16); + retValue = true; + break; + } + ds.skipRawData(avLen); + ds >> avId; + ds >> avLen; + } + return retValue; +} + +static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, + const QNtlmPhase2Block& ch, + QNtlmPhase3Block *phase3) +{ + Q_ASSERT(phase3 != 0); + // return value stored in phase3 + qCreatev2Hash(ctx, phase3); + + QByteArray temp; + QDataStream ds(&temp, QIODevice::WriteOnly); + ds.setByteOrder(QDataStream::LittleEndian); + + ds << respversion; + ds << hirespversion; + + //Reserved + QByteArray reserved1(6, 0); + ds.writeRawData(reserved1.constData(), reserved1.size()); + + quint64 time = 0; + + //if server sends time, use it instead of current time + if(!(ch.targetInfo.len && qExtractServerTime(ch.targetInfoBuff, &time))) { + QDateTime currentTime(QDate::currentDate(), + QTime::currentTime(), Qt::UTC); + + // number of seconds between 1601 and epoc(1970) + // 369 years, 89 leap years + // ((369 * 365) + 89) * 24 * 3600 = 11644473600 + + time = Q_UINT64_C(currentTime.toTime_t() + 11644473600); + + // represented as 100 nano seconds + time = Q_UINT64_C(time * 10000000); + } + ds << time; + + //8 byte client challenge + QByteArray clientCh = clientChallenge(ctx); + ds.writeRawData(clientCh.constData(), clientCh.size()); + + //Reserved + QByteArray reserved2(4, 0); + ds.writeRawData(reserved2.constData(), reserved2.size()); + + if (ch.targetInfo.len > 0) { + ds.writeRawData(ch.targetInfoBuff.constData(), + ch.targetInfoBuff.size()); + } + + //Reserved + QByteArray reserved3(4, 0); + ds.writeRawData(reserved3.constData(), reserved3.size()); + + QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); + message.append(temp); + + QByteArray ntChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); + ntChallengeResp.append(temp); + + return ntChallengeResp; +} + +static QByteArray qEncodeLmv2Response(const QAuthenticatorPrivate *ctx, + const QNtlmPhase2Block& ch, + QNtlmPhase3Block *phase3) +{ + Q_ASSERT(phase3 != 0); + // return value stored in phase3 + qCreatev2Hash(ctx, phase3); + + QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); + QByteArray clientCh = clientChallenge(ctx); + message.append(clientCh); + + QByteArray lmChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); + lmChallengeResp.append(clientCh); + + return lmChallengeResp; +} static bool qNtlmDecodePhase2(const QByteArray& data, QNtlmPhase2Block& ch) { @@ -976,7 +1231,10 @@ static bool qNtlmDecodePhase2(const QByteArray& data, QNtlmPhase2Block& ch) } if (ch.targetInfo.len > 0) { - // UNUSED right now + if (ch.targetInfo.len + ch.targetInfo.offset > (unsigned)data.size()) + return false; + + ch.targetInfoBuff = data.mid(ch.targetInfo.offset, ch.targetInfo.len); } return true; @@ -996,7 +1254,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas bool unicode = ch.flags & NTLMSSP_NEGOTIATE_UNICODE; - ctx->realm = ch.targetNameStr; + if(ctx->realm.isEmpty()) + ctx->realm = ch.targetNameStr; pb.flags = NTLMSSP_NEGOTIATE_NTLM; if (unicode) @@ -1010,6 +1269,7 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas offset = qEncodeNtlmString(pb.domain, offset, ctx->realm, unicode); pb.domainStr = ctx->realm; + offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode); pb.userStr = ctx->user; @@ -1017,11 +1277,23 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas pb.workstationStr = ctx->workstation; // Get LM response +#ifdef NTLMV1_CLIENT pb.lmResponseBuf = qEncodeLmResponse(ctx, ch); +#else + if (ch.targetInfo.len > 0) { + pb.lmResponseBuf = QByteArray(); + } else { + pb.lmResponseBuf = qEncodeLmv2Response(ctx, ch, &pb); + } +#endif offset = qEncodeNtlmBuffer(pb.lmResponse, offset, pb.lmResponseBuf); // Get NTLM response +#ifdef NTLMV1_CLIENT pb.ntlmResponseBuf = qEncodeNtlmResponse(ctx, ch); +#else + pb.ntlmResponseBuf = qEncodeNtlmv2Response(ctx, ch, &pb); +#endif offset = qEncodeNtlmBuffer(pb.ntlmResponse, offset, pb.ntlmResponseBuf); -- cgit v1.2.1 From 47ba8dba3fe48d317974acd55afeea8a434c95f8 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 9 Jul 2010 21:36:15 +0200 Subject: Doc: Cleaning style and adding support for Creator Note: Support for creator has been disabled. HTML-generator needs an update. --- doc/src/template/style/style.css | 1323 +++++++++++++++++++------------ tools/qdoc3/htmlgenerator.cpp | 4 +- tools/qdoc3/test/assistant.qdocconf | 24 +- tools/qdoc3/test/qt-build-docs.qdocconf | 12 +- tools/qdoc3/test/qt.qdocconf | 7 - 5 files changed, 820 insertions(+), 550 deletions(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 51440205fa..9f809212c8 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -1,6 +1,8 @@ @media screen { - html + +/* basic elements */ + html { color: #000000; background: #FFFFFF; @@ -18,6 +20,7 @@ fieldset, img { border: 0; + max-width:100%; } address, caption, cite, code, dfn, em, strong, th, var, optgroup { @@ -39,7 +42,6 @@ h1, h2, h3, h4, h5, h6 { font-size: 100%; -/* font-weight: normal; */ } q:before, q:after { @@ -50,11 +52,7 @@ border: 0; font-variant: normal; } - sup - { - vertical-align: baseline; - } - sub + sup, sub { vertical-align: baseline; } @@ -62,19 +60,6 @@ { word-spacing:5px; } - .heading - { - font: normal bold 16px/1.0 Arial; - padding-bottom: 15px; - } - .subtitle - { - font-size: 13px; - } - .small-subtitle - { - font-size: 13px; - } legend { color: #000000; @@ -90,9 +75,19 @@ { font-size: 100%; } + strong + { + font-weight: bold; + } + em + { + font-style: italic; + } + + /* adding Qt theme */ html { - background-color: #e5e5e5; + /* background-color: #e5e5e5;*/ } body { @@ -100,73 +95,115 @@ font: normal 13px/1.2 Verdana; color: #363534; } - strong + a { - font-weight: bold; + color: #00732f; + text-decoration: none; } - em + hr { - font-style: italic; + background-color: #E6E6E6; + border: 1px solid #E6E6E6; + height: 1px; + width: 100%; + text-align: left; + margin: 15px 0px 15px 0px; } - a + + pre { - color: #00732f; - text-decoration: none; + border: 1px solid #DDDDDD; + -moz-border-radius: 7px 7px 7px 7px; + margin: 0 20px 10px 10px; + padding: 20px 15px 20px 20px; + overflow-x: auto; } - .header, .footer, .wrapper + table, pre { - min-width: 600px; - max-width: 1500px; - margin: 0 30px; + -moz-border-radius: 7px 7px 7px 7px; + background-color: #F6F6F6; + border: 1px solid #E6E6E6; + border-collapse: separate; + font-size: 11px; + margin-bottom: 25px; } - .wrapper + pre.highlightedCode { + display: block; + overflow:hidden; + } + thead { - background: url(../images/bg_r.png) repeat-y 100% 0; + margin-top: 5px; + font:600 12px/1.2 Arial; } - .wrapper .hd + th { - padding-left: 216px; - height: 15px; - background: url(../images/page.png) no-repeat 0 0; - overflow: hidden; + padding: 5px 15px 5px 15px; + background-color: #E1E1E1; + border-left: 1px solid #E6E6E6; } - .offline .wrapper .hd + td { - background: url(../images/page.png) no-repeat 0 -15px; + padding: 3px 15px 3px 20px; } - .wrapper .hd span + tr.odd td:hover, tr.even td:hover {} + + td.rightAlign + { + padding: 3px 5px 3px 10px; + } + table tr.odd { - height: 15px; - display: block; - overflow: hidden; - background: url(../images/page.png) no-repeat 100% -30px; + border-left: 1px solid #E6E6E6; + background-color: #F6F6F6; + color: #66666E; } - .wrapper .bd + table tr.even { - background: url(../images/bg_l.png) repeat-y 0 0; - position: relative; + border-left: 1px solid #E6E6E6; + background-color: #ffffff; + color: #66666E; } - .offline .wrapper .bd + table tr.odd td:hover, table tr.even td:hover { - background: url(../images/bg_l_blank.png) repeat-y 0 0; + /* background-color: #E6E6E6;*/ /* disabled until further notice */ } - .wrapper .ft + + span.comment { - padding-left: 216px; - height: 15px; - background: url(../images/page.png) no-repeat 0 -75px; - overflow: hidden; + color: #8B0000; + font-style: italic; } - .offline .wrapper .ft + span.string, span.char { - background: url(../images/page.png) no-repeat 0 -90px; + color: #254117; } - .wrapper .ft span + + +/* end basic elements */ + +/* font style elements */ + .heading { - height: 15px; - display: block; - background: url(../images/page.png) no-repeat 100% -60px; - overflow: hidden; + font: normal bold 16px/1.0 Arial; + padding-bottom: 15px; + } + .subtitle + { + font-size: 13px; + } + .small-subtitle + { + font-size: 13px; + } +/* end font style elements */ + +/* global settings*/ + .header, .footer, .wrapper + { + min-width: 600px; + max-width: 1500px; + margin: 0 30px; } .header, .footer { @@ -174,6 +211,17 @@ clear: both; overflow: hidden; } + .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after + { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + +/* end global settings*/ +/* header elements */ .header { height: 115px; @@ -201,105 +249,332 @@ text-indent: -999em; background: url(../images/sprites-combined.png) no-repeat -78px -235px; } - - .sidebar + .content a:visited { - float: left; - margin-left: 5px; - width: 200px; - font-size: 11px; + color: #4c0033; + text-decoration: none; } - - .offline .sidebar, .offline .feedback, .offline .t_button, .offline #narrowsearch, .offline #narrowmenu + .content a:visited:hover { - display: none; + color: #4c0033; + text-decoration: underline; } - - .sidebar .searchlabel + + #nav-topright { - padding: 0 0 2px 17px; - font: normal bold 11px/1.2 Verdana; + height: 70px; } - .sidebar .search + #nav-topright ul { - padding: 0 15px 0 16px; + list-style-type: none; + float: right; + width: 370px; + margin-top: 11px; } - .sidebar .search form + #nav-topright li { - background: url(../images/sprites-combined.png) no-repeat -6px -348px; - height:21px; - padding:2px 0 0 5px; - width:167px; + display: inline-block; + margin-right: 20px; + float: left; } - .sidebar .search form input#pageType + #nav-topright li.nav-topright-last { - width: 158px; - height: 19px; - padding: 0; - border: 0px; - outline: none; - font: 13px/1.2 Verdana; + margin-right: 0; } - .sidebar .box + #nav-topright li a { - padding: 17px 15px 5px 16px; + background: transparent url(../images/sprites-combined.png) no-repeat; + height: 18px; + display: block; + overflow: hidden; + text-indent: -9999px; } - .sidebar .box .first + #nav-topright li.nav-topright-home a { - background-image: none; + width: 65px; + background-position: -2px -91px; } - .sidebar .box h2 + #nav-topright li.nav-topright-home a:hover { - font: bold 16px/1.2 Arial; - padding: 0; -/* min-height: 32px;*/ + background-position: -2px -117px; } - .sidebar .box h2 span + + + #nav-topright li.nav-topright-dev a { - overflow: hidden; - display: inline-block; + width: 30px; + background-position: -76px -91px; } - .sidebar .box#lookup h2 + + #nav-topright li.nav-topright-dev a:hover { - background-image: none; + background-position: -76px -117px; } - .sidebar #lookup.box h2 span + + + #nav-topright li.nav-topright-labs a { -/* background: url(../images/sprites-combined.png) no-repeat -6px -311px; - width: 27px; - height: 35px; - margin-right: 13px;*/ + width: 40px; + background-position: -114px -91px; } - .sidebar .box#topics h2 + + #nav-topright li.nav-topright-labs a:hover { - background-image: none; + background-position: -114px -117px; } - .sidebar #topics.box h2 span + + #nav-topright li.nav-topright-doc a { - /* background: url(../images/sprites-combined.png) no-repeat -94px -311px; - width: 27px; - height: 32px; - margin-right: 13px;*/ + width: 32px; + background-position: -162px -91px; } - .sidebar .box#examples h2 + + #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a { - background-image: none; + background-position: -162px -117px; } - .sidebar #examples.box h2 span + + #nav-topright li.nav-topright-blog a { - /* background: url(../images/sprites-combined.png) no-repeat -48px -311px; - width: 30px; - height: 31px; - margin-right: 9px;*/ + width: 40px; + background-position: -203px -91px; } - .sidebar .box .list + #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a + { + background-position: -203px -117px; + } + + #nav-topright li.nav-topright-shop a + { + width: 40px; + background-position: -252px -91px; + } + + #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a + { + background-position: -252px -117px; + } + + #nav-logo + { + background: transparent url(../images/sprites-combined.png ) no-repeat 0 -225px; + left: -3px; + position: absolute; + width: 75px; + height: 75px; + top: 13px; + } + #nav-logo a + { + width: 75px; + height: 75px; + display: block; + text-indent: -9999px; + overflow: hidden; + } + + + .shortCut-topleft-inactive + { + padding-left: 3px; + background: transparent url( ../images/sprites-combined.png) no-repeat 0px -58px; + height: 20px; + width: 47px; + } + .shortCut-topleft-inactive span + { + font-variant: normal; + } + .shortCut-topleft-inactive span a:hover, .shortCut-topleft-active a:hover + { + text-decoration:none; + } + #shortCut + { + padding-top: 10px; + font-weight: bolder; + color: #b0adab; + } + #shortCut ul + { + list-style-type: none; + float: left; + width: 347px; + margin-left: 100px; + } + #shortCut li + { + display: inline-block; + margin-right: 25px; + float: left; + white-space: nowrap; + } + #shortCut li a + { + color: #b0adab; + } + #shortCut li a:hover + { + color: #44a51c; + } + + + +/* end header elements */ +/* content and sidebar elements */ + .wrapper + { + background: url(../images/bg_r.png) repeat-y 100% 0; + } + .wrapper .hd + { + padding-left: 216px; + height: 15px; + background: url(../images/page.png) no-repeat 0 0; + overflow: hidden; + } + + + + + .wrapper .hd span + { + height: 15px; + display: block; + overflow: hidden; + background: url(../images/page.png) no-repeat 100% -30px; + } + .wrapper .bd + { + background: url(../images/bg_l.png) repeat-y 0 0; + position: relative; + } + + + + + .wrapper .ft + { + padding-left: 216px; + height: 15px; + background: url(../images/page.png) no-repeat 0 -75px; + overflow: hidden; + } + + + + + .wrapper .ft span + { + height: 15px; + display: block; + background: url(../images/page.png) no-repeat 100% -60px; + overflow: hidden; + } + .navTop{ + float:right; + display:block; + padding-right:15px; + + + } + + + +/* end content and sidebar elements */ +/* sidebar elements */ + .sidebar + { + float: left; + margin-left: 5px; + width: 200px; + font-size: 11px; + } + + + + + + + .sidebar .searchlabel + { + padding: 0 0 2px 17px; + font: normal bold 11px/1.2 Verdana; + } + + .sidebar .search + { + padding: 0 15px 0 16px; + } + + .sidebar .search form + { + background: url(../images/sprites-combined.png) no-repeat -6px -348px; + height:21px; + padding:2px 0 0 5px; + width:167px; + } + + .sidebar .search form input#pageType + { + width: 158px; + height: 19px; + padding: 0; + border: 0px; + outline: none; + font: 13px/1.2 Verdana; + } + + .sidebar .box + { + padding: 17px 15px 5px 16px; + } + + .sidebar .box .first + { + background-image: none; + } + + .sidebar .box h2 + { + font: bold 16px/1.2 Arial; + padding: 0; + } + .sidebar .box h2 span + { + overflow: hidden; + display: inline-block; + } + .sidebar .box#lookup h2 + { + background-image: none; + } + .sidebar #lookup.box h2 span + { + } + .sidebar .box#topics h2 + { + background-image: none; + } + .sidebar #topics.box h2 span + { + } + .sidebar .box#examples h2 + { + background-image: none; + } + .sidebar #examples.box h2 span + { + } + + .sidebar .box .list { display: block; max-height:200px; @@ -313,7 +588,6 @@ } .sidebar .box ul { - /*padding:10px;*/ padding-bottom:5px; padding-left:10px; padding-top:5px; @@ -340,16 +614,40 @@ color:#AAD2F0; font-style:italic; } + .sidebar .search form input.loading + { + background:url("../images/spinner.gif") no-repeat scroll right center transparent; + } + +.floatingResult{ + z-index:1; + position:relative; + padding-top:0px; + background-color:white; + border:solid 1px black; + height:250px; + width:600px; + overflow-x:hidden; + overflow-y:auto; +} + .floatingResult:hover{ + display:block; + } + .floatingResult:hover{ + } + +/* end sidebar elements */ +/* content elements */ .wrap { margin: 0 5px 0 208px; overflow: visible; } - .offline .wrap - { - margin: 0 5px 0 5px; - } + + + + .wrap .toolbar { background-color: #fafafa; @@ -435,11 +733,14 @@ color: #00732F; } - .offline .wrap .breadcrumb - { - } - .wrap .breadcrumb ul + .wrap .content + { + padding: 30px; + word-wrap:break-word; + } + + .wrap .breadcrumb ul { } .wrap .breadcrumb ul li @@ -464,30 +765,36 @@ padding-left: 0; margin-left: 0; } - .wrap .content - { - padding: 30px; - word-wrap:break-word; - } + + + + .wrap .content ol li { + background:none; + font:normal 10pt/1 Verdana; + + margin-bottom:10px; + margin-left:12px; + /*list-style-type:disc;*/ + } + .wrap .content li { - /*padding-left: 12px;*/ background: url(../images/bullet_sq.png) no-repeat 0 5px; font: normal 400 10pt/1 Verdana; - /* color: #44a51c;*/ margin-bottom: 10px; padding-left:12px; } - .content li:hover - { - /* text-decoration: underline;*/ - } - .offline .wrap .content - { - padding-top: 15px; - } + + + + + + + + + .content li:hover {} .wrap .content h1 { @@ -495,17 +802,14 @@ } .wrap .content h2 { - border-bottom:1px solid #DDDDDD; font:600 16px/1.2 Arial; margin-top:15px; - width:100%; - + width:100%; } .wrap .content h3 { font: bold 14px/1.2 Arial; - /*border-bottom:1px solid #DDDDDD;*/ font:600 16px/1.2 Arial; margin-top:15px; width:100%; @@ -514,320 +818,69 @@ { line-height: 20px; padding: 5px; - /* text-align:justify;*/ } .wrap .content table p { line-height: 20px; - padding: 0px; - } - .wrap .content ul - { - padding-left: 25px; - padding-top: 10px; - } - a:hover - { - color: #4c0033; - text-decoration: underline; - } - .content a:visited - { - color: #4c0033; - text-decoration: none; - } - .content a:visited:hover - { - color: #4c0033; - text-decoration: underline; - } .footer - { - min-height: 100px; - color: #797775; - font: normal 9px/1 Verdana; - text-align: center; - padding-top: 40px; - background-color: #E6E7E8; - margin: 0; - } - .feedback - { - float: none; - position: absolute; - right: 15px; - bottom: 10px; - font: normal 8px/1 Verdana; - color: #B0ADAB; - } - .feedback:hover - { - float: right; - font: normal 8px/1 Verdana; - color: #00732F; - text-decoration: underline; - } - .header:after, .footer:after, .breadcrumb:after, .wrap .content:after, .group:after - { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; - } - #nav-topright - { - height: 70px; - } - - #nav-topright ul - { - list-style-type: none; - float: right; - width: 370px; - margin-top: 11px; - } - - #nav-topright li - { - display: inline-block; - margin-right: 20px; - float: left; - } - - #nav-topright li.nav-topright-last - { - margin-right: 0; - } - - #nav-topright li a - { - background: transparent url(../images/sprites-combined.png) no-repeat; - height: 18px; - display: block; - overflow: hidden; - text-indent: -9999px; - } - - #nav-topright li.nav-topright-home a - { - width: 65px; - background-position: -2px -91px; - } - - #nav-topright li.nav-topright-home a:hover - { - background-position: -2px -117px; - } - - - #nav-topright li.nav-topright-dev a - { - width: 30px; - background-position: -76px -91px; - } - - #nav-topright li.nav-topright-dev a:hover - { - background-position: -76px -117px; - } - - - #nav-topright li.nav-topright-labs a - { - width: 40px; - background-position: -114px -91px; - } - - #nav-topright li.nav-topright-labs a:hover - { - background-position: -114px -117px; - } - - #nav-topright li.nav-topright-doc a - { - width: 32px; - background-position: -162px -91px; - } - - #nav-topright li.nav-topright-doc a:hover, #nav-topright li.nav-topright-doc-active a - { - background-position: -162px -117px; - } - - #nav-topright li.nav-topright-blog a - { - width: 40px; - background-position: -203px -91px; - } - - #nav-topright li.nav-topright-blog a:hover, #nav-topright li.nav-topright-blog-active a - { - background-position: -203px -117px; - } - - #nav-topright li.nav-topright-shop a - { - width: 40px; - background-position: -252px -91px; - } - - #nav-topright li.nav-topright-shop a:hover, #nav-topright li.nav-topright-shop-active a - { - background-position: -252px -117px; - } - - #nav-logo - { - background: transparent url(../images/sprites-combined.png ) no-repeat 0 -225px; - left: -3px; - position: absolute; - width: 75px; - height: 75px; - top: 13px; - } - #nav-logo a - { - width: 75px; - height: 75px; - display: block; - text-indent: -9999px; - overflow: hidden; - } - - - .shortCut-topleft-inactive - { - padding-left: 3px; - background: transparent url( ../images/sprites-combined.png) no-repeat 0px -58px; - height: 20px; - width: 47px; - } - .shortCut-topleft-inactive span - { - font-variant: normal; - } - .shortCut-topleft-inactive span a:hover, .shortCut-topleft-active a:hover - { - text-decoration:none; - } - #shortCut - { - padding-top: 10px; - font-weight: bolder; - color: #b0adab; - } - #shortCut ul - { - list-style-type: none; - float: left; - width: 347px; - margin-left: 100px; - } - #shortCut li - { - display: inline-block; - margin-right: 25px; - float: left; - white-space: nowrap; - } - #shortCut li a - { - color: #b0adab; - } - #shortCut li a:hover - { - color: #44a51c; - } - - hr - { - background-color: #E6E6E6; - border: 1px solid #E6E6E6; - height: 1px; - width: 100%; - text-align: left; - margin: 15px 0px 15px 0px; - } - - .content .alignedsummary - { - margin: 15px; - } - pre - { - border: 1px solid #DDDDDD; - -moz-border-radius: 7px 7px 7px 7px; - margin: 0 20px 10px 10px; - padding: 20px 15px 20px 20px; - overflow-x: auto; - } - table, pre - { - -moz-border-radius: 7px 7px 7px 7px; - background-color: #F6F6F6; - border: 1px solid #E6E6E6; - border-collapse: separate; - font-size: 11px; - /*min-width: 395px;*/ - margin-bottom: 25px; - /* display: inline-block;*/ - } - thead - { - margin-top: 5px; - font:600 12px/1.2 Arial; - } - th - { - padding: 5px 15px 5px 15px; - background-color: #E1E1E1; - /* border-bottom: 1px solid #E6E6E6;*/ - border-left: 1px solid #E6E6E6; - /* border-right: 1px solid #E6E6E6;*/ - } - td - { - padding: 3px 15px 3px 20px; - /* border-left: 1px solid #E6E6E6; - border-right: 1px solid #E6E6E6;*/ - } - tr.odd td:hover, tr.even td:hover - { - /* border-right: 1px solid #C3C3C3; - border-left: 1px solid #C3C3C3;*/ - } - - td.rightAlign - { - padding: 3px 5px 3px 10px; - } - table tr.odd + padding: 0px; + } + .wrap .content ul { - border-left: 1px solid #E6E6E6; - background-color: #F6F6F6; - color: #66666E; + padding-left: 25px; + padding-top: 10px; } - table tr.even + a:hover { - border-left: 1px solid #E6E6E6; - background-color: #ffffff; - color: #66666E; + color: #4c0033; + text-decoration: underline; } - table tr.odd td:hover, table tr.even td:hover + .feedback { - background-color: #E6E6E6; + float: none; + position: absolute; + right: 15px; + bottom: 10px; + font: normal 8px/1 Verdana; + color: #B0ADAB; } - - span.comment + .feedback:hover { - color: #8B0000; - font-style: italic; + float: right; + font: normal 8px/1 Verdana; + color: #00732F; + text-decoration: underline; } - span.string, span.char + .alphaChar{ + width:100%; + background-color:#F6F6F6; + border:1px solid #E6E6E6; + -moz-border-radius: 7px 7px 7px 7px; + font-size:12pt; + padding-left:10px; + margin-top:10px; + margin-bottom:10px; + } + .flowList{ + vertical-align:top; + } + + .flowList dl{ + } + .flowList dd{ + display:inline-block; + margin-left:10px; + width:250px; + } + .wrap .content .flowList p{ + padding:0px; + } + + .content .alignedsummary { - color: #254117; + margin: 15px; } + .qmltype { text-align: center; @@ -854,7 +907,6 @@ *.qmlitem p { } - #feedbackBox { display: none; @@ -936,12 +988,10 @@ } .generic{ - /*max-width:75%;*/ } .generic td{ padding:5px; } - .generic .alphaChar{ margin-top:5px; } @@ -989,6 +1039,16 @@ padding-left: 0px; } + .wrap .content .toc h3{ + border-bottom:0px; + margin-top:0px; + } + + .wrap .content .toc h3 a:hover{ + color:#00732F; + text-decoration:none; + } + .wrap .content .toc .level2 { @@ -1005,7 +1065,6 @@ font: normal 10px/1.2 Verdana; background: url(../images/bullet_dn.png) no-repeat 0 5px; } - .relpage { -moz-border-radius: 7px 7px 7px 7px; @@ -1069,6 +1128,24 @@ .functionIndex a{ display:inline-block; } + +/* end content elements */ +/* footer elements */ + + .footer + { + min-height: 100px; + color: #797775; + font: normal 9px/1 Verdana; + text-align: center; + padding-top: 40px; + background-color: #E6E7E8; + margin: 0; + } +/* end footer elements */ + + + /* start index box */ .indexbox @@ -1080,15 +1157,15 @@ .indexboxcont { display: block; - /* overflow: hidden;*/ + } .indexboxbar { background: transparent url(../images/horBar.png ) repeat-x left bottom; margin-bottom: 25px; - /* background-image: none; - border-bottom: 1px solid #e2e2e2;*/ + + } .indexboxcont .section @@ -1188,87 +1265,285 @@ visibility: hidden; } -.sidebar .search form input.loading -{ - background:url("../images/spinner.gif") no-repeat scroll right center transparent; -} - /* end of screen media */ - -.flowList{ -vertical-align:top; -} -.alphaChar{ -width:100%; -background-color:#F6F6F6; -border:1px solid #E6E6E6; --moz-border-radius: 7px 7px 7px 7px; -font-size:12pt; -padding-left:10px; -margin-top:10px; -margin-bottom:10px; -} -.flowList dl{ -} -.flowList dd{ -display:inline-block; -margin-left:10px; -width:250px; -} -.wrap .content .flowList p{ -padding:0px; -} -pre.highlightedCode { - display: block; - overflow:hidden; -} -.floatingResult{ - z-index:1; - position:relative; - padding-top:0px; - background-color:white; - border:solid 1px black; - height:250px; - width:600px; - overflow-x:hidden; - overflow-y:auto; -} +/* start of offline spec*/ + .offline .wrapper .hd + { + background: url(../images/page.png) no-repeat 0 -15px; + } + .offline .wrapper .bd + { + background: url(../images/bg_l_blank.png) repeat-y 0 0; + } + .offline .wrapper .ft + { + background: url(../images/page.png) no-repeat 0 -90px; + } + .offline .sidebar, + .offline .feedback, + .offline .t_button, + .offline #narrowsearch, + .offline #narrowmenu + { + display: none; + } + .offline .wrap + { + margin: 0 5px 0 5px; + } + .offline .wrap .breadcrumb + { + } - .floatingResult:hover{ - display:block; - } - .floatingResult:hover{ - /*display:none;*/ - } + .offline .wrap .content + { + padding-top: 15px; + } - .wrap .content ol li { - background:none; - font:400 10pt/1 Verdana; - margin-bottom:10px; - margin-left:12px; + +/* end of offline spec*/ + +/* start of creator spec*/ + .creator + { + margin-left:0px; + margin-right:0px; + padding-left:0px; + padding-right:0px; } - .wrap .content ol li { + .creator .wrap .content ol li { list-style-type:decimal; } - .navTop{ - float:right; - display:block; - padding-right:15px; - /*margin-top:10px;*/ + .creator .header .icon, + .creator .feedback, + .creator .t_button, + .creator .feedback, + .creator #feedbackBox, + .creator #feedback, + .creator #blurpage, + .creator .indexbox .indexIcon span, + .creator .wrapper .hd, + .creator .indexbox .indexIcon, + .creator .header #nav-logo, + .creator #offlinemenu, + .creator #offlinesearch, + .creator .header #nav-topright, + .creator .header #shortCut , + .creator .wrapper .hd, + .creator .wrapper .ft, + .creator .sidebar, + .creator .wrap .feedback + { + display:none; + } + + body.creator + { + background: none; + + font: normal 13px/1.2 Verdana; + color: #363534; + background-color: #FFFFFF; + } + + + + .creator .header, .footer, .wrapper + { + max-width: 1500px; + margin: 0px; + } + + .creator .wrapper + { + position:relative; + top:50px; + } + .creator .wrapper .bd + { + + background:#FFFFFF; } + + + .creator .header, .footer + { + display: block; + clear: both; + overflow: hidden; + } + .creator .wrap .content p + + { + line-height: 20px; + padding: 5px; + } + + .creator .header .qtref span + { + background:none; + } + + - .wrap .content .toc h3{ - border-bottom:0px; - margin-top:0px; + .creator .footer + { + border-top:1px solid #E5E5E5; + min-height: 100px; + margin:0px; + } + + .creator .wrap + { + + padding:0 5px 0 5px; + margin: 0px; + } + .creator .wrap .toolbar + { + + + border-bottom:1px solid #E5E5E5; + width:100%, + } + .creator .wrap .breadcrumb ul li a + { + /* color: #363534;*/ + color: #00732F; + } + + .creator .wrap .content + { + padding: 0px; + word-wrap:break-word; + } + + .creator .wrap .content ol li { + background:none; + font: inherit; + padding-left: 0px; + } + + .creator .wrap .content .descr ol li { + margin-left: 45px; + + } + .creator .content .alignedsummary + { + margin: 5px; + width:100%; + } + .creator .generic{ + max-width:75%; + } + .creator .generic td{ + padding:0; } + .creator .indexboxbar + { + border-bottom:1px solid #E5E5E5; + margin-bottom: 25px; + background: none; + } - .wrap .content .toc h3 a:hover{ - color:#00732F; - text-decoration:none; + + + .creator .header + { + width: 100%; + margin: 0; + height: auto; + background-color: #ffffff; + padding: 10px 0 5px 0; + overflow: visible; + border-bottom: solid #E5E5E5 1px; + z-index:1; + + + + + + + + + position:fixed; + } + + + .creator .header .content + { + } + .creator .header .qtref + { + color: #00732F; + position: static; + float: left; + margin-left: 5px; + font: bold 18px/1 Arial; + } + + .creator .header .qtref:visited + { + color: #00732F; + } + .creator .header .qtref:hover + { + color: #00732F; + text-decoration:none; + } + .creator .header .qtref span + { + background-image: none; + text-indent: 0; + text-decoration:none; + } + + + + + + + .creator .wrap .toolbar + { + display:block; + padding-top:0px; + } + + + + .creator .wrap .breadcrumb ul li { + font-weight: normal; + } + + .creator .wrap .breadcrumb ul li a { + /*color: #44a51c;*/ + } + + .creator .wrap .breadcrumb ul li.last a { + /*color: #363534;*/ + } + + .creator #narrowmenu ul + { + border-bottom:solid 1px #E5E5E5; + border-left:solid 1px #E5E5E5; + border-right:solid 1px #E5E5E5; } + + .creator #narrowmenu li ul { + margin-top:-15px; + } + + + .creator .toc { + margin:10px 20px 10px 10px; + } +/* end of creator spec*/ +} + /* end of screen media */ /* start of print media */ diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index c8218dc155..fc761e592c 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -277,7 +277,7 @@ void HtmlGenerator::initializeGenerator(const Config &config) project = config.getString(CONFIG_PROJECT); offlineDocs = !config.getBool(CONFIG_ONLINE); - creatorDocs = !config.getBool(CONFIG_CREATOR); + creatorDocs = false; //!config.getBool(CONFIG_CREATOR); projectDescription = config.getString(CONFIG_DESCRIPTION); if (projectDescription.isEmpty() && !project.isEmpty()) projectDescription = project + " Reference Documentation"; @@ -1785,7 +1785,7 @@ void HtmlGenerator::generateHeader(const QString& title, { out() << " "; // Only for Qt Creator out() << "\n"; - out() << "\n"; // offline for Creator + out() << "\n"; // offline for Creator } // Setting online doc configuration else diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 4b52992cc1..8d5fa895ea 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -17,7 +17,10 @@ qhp.Assistant.namespace = com.trolltech.assistant.470 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual qhp.Assistant.extraFiles = images/bg_l.png \ - images/bg_l_blank.png \ + images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ul_blank.png \ + images/header_bg.png \ images/bg_r.png \ images/box_bg.png \ images/breadcrumb.png \ @@ -25,24 +28,27 @@ qhp.Assistant.extraFiles = images/bg_l.png \ images/bullet_dn.png \ images/bullet_sq.png \ images/bullet_up.png \ + images/arrow_down.png \ images/feedbackground.png \ images/horBar.png \ images/page.png \ images/page_bg.png \ images/sprites-combined.png \ - images/arrow-down.png \ images/spinner.gif \ images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ images/coloreditorfactoryimage.png \ images/dynamiclayouts-example.png \ - scripts/functions.js \ - scripts/jquery.js \ - style/OfflineStyle.css \ - style/style_ie6.css \ - style/style_ie7.css \ - style/style_ie8.css \ - style/style.css + scripts/functions.js \ + scripts/jquery.js \ + scripts/narrow.js \ + scripts/superfish.js \ + style/narrow.css \ + style/superfish.css \ + style/style_ie6.css \ + style/style_ie7.css \ + style/style_ie8.css \ + style/style.css qhp.Assistant.filterAttributes = qt 4.7.0 tools assistant qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index 140b81fb29..4ac4f47e0f 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -24,6 +24,9 @@ qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.extraFiles = index.html \ images/bg_l.png \ images/bg_l_blank.png \ + images/bg_ll_blank.png \ + images/bg_ul_blank.png \ + images/header_bg.png \ images/bg_r.png \ images/box_bg.png \ images/breadcrumb.png \ @@ -31,12 +34,12 @@ qhp.Qt.extraFiles = index.html \ images/bullet_dn.png \ images/bullet_sq.png \ images/bullet_up.png \ + images/arrow_down.png \ images/feedbackground.png \ images/horBar.png \ images/page.png \ images/page_bg.png \ images/sprites-combined.png \ - images/arrow-down.png \ images/spinner.gif \ images/stylesheet-coffee-plastique.png \ images/taskmenuextension-example.png \ @@ -44,17 +47,10 @@ qhp.Qt.extraFiles = index.html \ images/dynamiclayouts-example.png \ scripts/functions.js \ scripts/jquery.js \ - scripts/shBrushCpp.js \ - scripts/shCore.js \ - scripts/shLegacy.js \ scripts/narrow.js \ scripts/superfish.js \ - style/shCore.css \ - style/shThemeDefault.css \ style/narrow.css \ style/superfish.css \ - style/superfish_skin.css \ - style/OfflineStyle.css \ style/style_ie6.css \ style/style_ie7.css \ style/style_ie8.css \ diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index d13277173a..5575b7ba57 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -51,17 +51,10 @@ qhp.Qt.extraFiles = index.html \ images/dynamiclayouts-example.png \ scripts/functions.js \ scripts/jquery.js \ - scripts/shBrushCpp.js \ - scripts/shCore.js \ - scripts/shLegacy.js \ scripts/narrow.js \ scripts/superfish.js \ - style/shCore.css \ - style/shThemeDefault.css \ style/narrow.css \ style/superfish.css \ - style/superfish_skin.css \ - style/OfflineStyle.css \ style/style_ie6.css \ style/style_ie7.css \ style/style_ie8.css \ -- cgit v1.2.1 From 4b6180908a52ada73288021c1380f06ae3f75707 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 7 Jul 2010 10:37:09 +0200 Subject: Compile fix for bearermonitor example --- examples/network/bearermonitor/sessionwidget.h | 2 +- .../network/bearermonitor/sessionwidget_maemo.ui | 48 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h index 5b5827bc7c..c92db4417c 100644 --- a/examples/network/bearermonitor/sessionwidget.h +++ b/examples/network/bearermonitor/sessionwidget.h @@ -41,12 +41,12 @@ #ifndef SESSIONWIDGET_H #define SESSIONWIDGET_H +#include #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) #include "ui_sessionwidget_maemo.h" #else #include "ui_sessionwidget.h" #endif -#include QT_USE_NAMESPACE diff --git a/examples/network/bearermonitor/sessionwidget_maemo.ui b/examples/network/bearermonitor/sessionwidget_maemo.ui index ca682463e7..8867509d01 100644 --- a/examples/network/bearermonitor/sessionwidget_maemo.ui +++ b/examples/network/bearermonitor/sessionwidget_maemo.ui @@ -214,6 +214,54 @@ + + + + + + 0 + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + Active Time: + + + + + + + + 0 + 0 + + + + 0 seconds + + + + + -- cgit v1.2.1 From 46175e55c8d053b61a45aea89a3e1b8371207dee Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 12 Jul 2010 10:47:00 +0200 Subject: fix build for -no-qt3support QString::lower() is QT3_SUPPORT, the correct method is QString::toLower(). --- src/network/ssl/qsslsocket_openssl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index a5da3915e4..8dc17433f1 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1106,11 +1106,11 @@ bool QSslSocketBackendPrivate::startHandshake() QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName); QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName); - if (!isMatchingHostname(commonName.lower(), peerName.lower())) { + if (!isMatchingHostname(commonName.toLower(), peerName.toLower())) { bool matched = false; foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { - if (isMatchingHostname(altName.lower(), peerName.lower())) { + if (isMatchingHostname(altName.toLower(), peerName.toLower())) { matched = true; break; } -- cgit v1.2.1 From c042003a831ace1ffe4cc399668293200ffe829f Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 12 Jul 2010 11:32:48 +0200 Subject: Added some asserts to avoid race conditions in networking. Task: QT-3358 RevBy: Markus Goetz --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index e86efb218e..c3e0808725 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -495,6 +495,8 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta start(); } + Q_ASSERT(QThread::currentThread() == this->thread()); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); Q_ASSERT(!m_AOStatuses.contains(notifier)); @@ -506,6 +508,8 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { + Q_ASSERT(QThread::currentThread() == this->thread()); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_AOStatuses.remove(notifier); @@ -515,6 +519,8 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) void QSelectThread::restart() { + Q_ASSERT(QThread::currentThread() == this->thread()); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_waitCond.wakeAll(); -- cgit v1.2.1 From 156193223ee9d58da66817ae6ffc0174bdf34e5b Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 12 Jul 2010 12:14:45 +0200 Subject: fix indentation Merge-request: 740 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 952d4e0ac7..0c450f056b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2439,7 +2439,7 @@ void Configure::generateOutputVars() qmakeFormatPlugins += "gif"; if (dictionary[ "TIFF" ] == "no") - qtConfig += "no-tiff"; + qtConfig += "no-tiff"; else if (dictionary[ "TIFF" ] == "plugin") qmakeFormatPlugins += "tiff"; if (dictionary[ "LIBTIFF" ] == "system") -- cgit v1.2.1 From 80ad34046e2d3d0b8bd5d8346cb1edb0c83c1585 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 12 Jul 2010 12:14:46 +0200 Subject: fixed built-in jpeg and tiff in configure.exe, QTBUG-12093 Merge-request: 740 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 0c450f056b..d3dec3c92b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2440,6 +2440,8 @@ void Configure::generateOutputVars() if (dictionary[ "TIFF" ] == "no") qtConfig += "no-tiff"; + else if (dictionary[ "TIFF" ] == "yes") + qtConfig += "tiff"; else if (dictionary[ "TIFF" ] == "plugin") qmakeFormatPlugins += "tiff"; if (dictionary[ "LIBTIFF" ] == "system") @@ -2447,6 +2449,8 @@ void Configure::generateOutputVars() if (dictionary[ "JPEG" ] == "no") qtConfig += "no-jpeg"; + else if (dictionary[ "JPEG" ] == "yes") + qtConfig += "jpeg"; else if (dictionary[ "JPEG" ] == "plugin") qmakeFormatPlugins += "jpeg"; if (dictionary[ "LIBJPEG" ] == "system") -- cgit v1.2.1 From 07321dfceed41c1851781841e03c4148da47e41e Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Mon, 12 Jul 2010 14:35:33 +0200 Subject: Calling setMinimumSize(0, 0) on a top-level window sometimes triggers a bug in the Compiz window manager which leads to the QML viewer mainwindow not being composited anymore (at least until the next resize). Since we need to somehow switch between fixed size and freely resizable views, we have to work around that bug using the layout constraint hints. Task-number: QTBUG-11771 Reviewed-by: kkoehne --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 26 +++++----- tools/qml/qmlruntime.cpp | 60 ++++++++++------------ tools/qml/qmlruntime.h | 4 +- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 695c038063..b08da0f3a4 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -113,7 +113,6 @@ void tst_QDeclarativeViewer::orientation() viewer->rotateOrientation(); qApp->processEvents(); - qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 300.0); QCOMPARE(rootItem->height(), 200.0); @@ -124,7 +123,6 @@ void tst_QDeclarativeViewer::orientation() viewer->rotateOrientation(); qApp->processEvents(); - qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); @@ -159,10 +157,10 @@ void tst_QDeclarativeViewer::loading() // window resized QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); - QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(400, 500)); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -176,7 +174,7 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->resize(QSize(400, 500)); @@ -184,10 +182,10 @@ void tst_QDeclarativeViewer::loading() // window resized again QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); - QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(400, 500)); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -201,7 +199,7 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); delete viewer; @@ -272,7 +270,7 @@ void tst_QDeclarativeViewer::resizing() QTRY_COMPARE(viewer->view()->size(), QSize(150, 200)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); - QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(150, 200 + MENUBAR_HEIGHT(viewer))); // do not size root object to view viewer->resize(QSize(180,250)); @@ -286,10 +284,10 @@ void tst_QDeclarativeViewer::resizing() qApp->processEvents(); QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); - QTRY_COMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QTRY_COMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(250, 350)); // do not size view to root object diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 03ca798a1f..951b187811 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -944,13 +944,7 @@ void QDeclarativeViewer::statusChanged() if (canvas->status() == QDeclarativeView::Ready) { initialSize = canvas->initialSize(); - if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - if (!isFullScreen() && !isMaximized()) { - canvas->setFixedSize(initialSize); - resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrink - QTimer::singleShot(0, this, SLOT(updateSizeHints())); - } - } + updateSizeHints(true); } } @@ -1075,13 +1069,9 @@ void QDeclarativeViewer::setRecordRate(int fps) record_rate = fps; } -void QDeclarativeViewer::sceneResized(QSize size) +void QDeclarativeViewer::sceneResized(QSize) { - if (size.width() > 0 && size.height() > 0) { - if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { - updateSizeHints(); - } - } + updateSizeHints(); } void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) @@ -1344,17 +1334,7 @@ void QDeclarativeViewer::changeOrientation(QAction *action) void QDeclarativeViewer::orientationChanged() { - if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - if (canvas->rootObject()) { - QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size(); - if (size() != rootObjectSize.toSize()) { - canvas->setMinimumSize(rootObjectSize.toSize()); - canvas->resize(rootObjectSize.toSize()); - resize(rootObjectSize.toSize()); - resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks - } - } - } + updateSizeHints(); } void QDeclarativeViewer::setDeviceKeys(bool on) @@ -1403,20 +1383,32 @@ void QDeclarativeViewer::setSizeToView(bool sizeToView) } } -void QDeclarativeViewer::updateSizeHints() +void QDeclarativeViewer::updateSizeHints(bool initial) { - if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { - QSize newWindowSize = canvas->sizeHint(); + static bool isRecursive = false; + + if (isRecursive) + return; + isRecursive = true; + + if (initial || (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject)) { + QSize newWindowSize = initial ? initialSize : canvas->sizeHint(); + //qWarning() << "USH:" << (initial ? "INIT:" : "V2R:") << "setting fixed size " << newWindowSize; if (!isFullScreen() && !isMaximized()) { - canvas->setMinimumSize(newWindowSize); - canvas->resize(newWindowSize); - resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks - canvas->setMinimumSize(QSize(0, 0)); + canvas->setFixedSize(newWindowSize); + resize(1, 1); + layout()->setSizeConstraint(QLayout::SetFixedSize); + layout()->activate(); } - } else { // QDeclarativeView::SizeRootObjectToView - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(16777215,16777215)); } + //qWarning() << "USH: R2V: setting free size "; + layout()->setSizeConstraint(QLayout::SetNoConstraint); + layout()->activate(); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + canvas->setMinimumSize(QSize(0,0)); + canvas->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + + isRecursive = false; } void QDeclarativeViewer::registerTypes() diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index e70e69fd3e..68d3452a2d 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -145,9 +145,9 @@ private slots: void warningsWidgetOpened(); void warningsWidgetClosed(); - void updateSizeHints(); - private: + void updateSizeHints(bool initial = false); + QString getVideoFileName(); LoggerWidget *loggerWindow; -- cgit v1.2.1 From 10039e4b5bb80e5a9705126e7c62c588039acde6 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Mon, 12 Jul 2010 16:32:01 +0200 Subject: Doc: Removed links to Qt3 support in QHostAddress Task-number: QTBUG-12004 --- src/network/kernel/qhostaddress.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 5ae3accb23..0bacf9095e 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -428,9 +428,9 @@ void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol prot QHostAddress is normally used with the QTcpSocket, QTcpServer, and QUdpSocket to connect to a host or to set up a server. - A host address is set with setAddress(), checked for its type - using isIPv4Address() or isIPv6Address(), and retrieved with - toIPv4Address(), toIPv6Address(), or toString(). + A host address is set with setAddress(), and retrieved with + toIPv4Address(), toIPv6Address(), or toString(). You can check the + type with protocol(). \note Please note that QHostAddress does not do DNS lookups. QHostInfo is needed for that. @@ -679,7 +679,8 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr) For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001). - This value is only valid if isIp4Addr() returns true. + This value is only valid if the Protocol() is + \l{QAbstractSocket::}{IPv4Protocol}. \sa toString() */ @@ -704,7 +705,8 @@ QAbstractSocket::NetworkLayerProtocol QHostAddress::protocol() const \snippet doc/src/snippets/code/src_network_kernel_qhostaddress.cpp 0 - This value is only valid if isIPv6Address() returns true. + This value is only valid if the protocol() is + \l{QAbstractSocket::}{IPv6Protocol}. \sa toString() */ -- cgit v1.2.1 From 446770c939b8c643c2a3bec73906055238cf3925 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 12 Jul 2010 16:37:36 +0200 Subject: QNAM: Add future enum attribute for Zerocopy QNAM Implementation will follow in 4.7.1 or 4.8, let's see. Reviewed-by: David Boddie Reviewed-by: Simon Hausmann Reviewed-by: Peter Hartmann --- src/network/access/qnetworkrequest.cpp | 8 ++++++++ src/network/access/qnetworkrequest.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index bccfec1dd8..fa592c22c0 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -230,6 +230,14 @@ QT_BEGIN_NAMESPACE \since 4.7 + \omitvalue MaximumDownloadBufferSizeAttribute + \since 4.7 + \internal + + \omitvalue DownloadBufferAttribute + \since 4.7 + \internal + \value User Special type. Additional information can be passed in QVariants with types ranging from User to UserMax. The default diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index d2945c40e6..cdadf0f69c 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -82,6 +82,8 @@ public: CookieLoadControlAttribute, AuthenticationReuseAttribute, CookieSaveControlAttribute, + MaximumDownloadBufferSizeAttribute, // internal + DownloadBufferAttribute, // internal User = 1000, UserMax = 32767 -- cgit v1.2.1 From 1e9348f52f06feb355245a9fffd786562e76e15f Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Mon, 12 Jul 2010 18:02:03 +0200 Subject: Timing fix for slow devices. Although the wait is only specified as 50ms, it might still take longer than that for Qt to deliver the actual mouse release event (especially on embedded devices). The problem here is that in the meantime the auto-repeat on the button might have been triggered. Reviewed-by: Dominik Holland --- tests/auto/qscrollbar/tst_qscrollbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qscrollbar/tst_qscrollbar.cpp b/tests/auto/qscrollbar/tst_qscrollbar.cpp index 735b2dd2d4..16d5b4242e 100644 --- a/tests/auto/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/qscrollbar/tst_qscrollbar.cpp @@ -130,7 +130,7 @@ void tst_QScrollBar::task_209492() QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, 0); QApplication::sendEvent(verticalScrollBar, &mousePressEvent); - QTest::qWait(50); + QTest::qWait(1); QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, 0); QApplication::sendEvent(verticalScrollBar, &mouseReleaseEvent); -- cgit v1.2.1 From ca1276ebca0f8fa47116994b97153899116c8b57 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 12 Jul 2010 20:18:37 +0200 Subject: make projects lupdate-friendly lupdate currently doesn't parse .qmake.cache, so it lacks QT_SOURCE_TREE. so use relative paths in include statements and (the relevant) include paths instead. --- tools/assistant/tools/assistant/assistant.pro | 2 +- tools/designer/src/components/lib/lib.pro | 10 +++++----- .../src/components/objectinspector/objectinspector.pri | 2 +- .../designer/src/components/propertyeditor/propertyeditor.pri | 4 ++-- tools/designer/src/designer/designer.pro | 4 ++-- tools/designer/src/lib/shared/shared.pri | 10 +++++----- tools/qvfb/qvfb.pro | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index eb8cc51d90..d9aff7a4da 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -1,4 +1,4 @@ -include($$QT_SOURCE_TREE/tools/shared/fontpanel/fontpanel.pri) +include(../../../shared/fontpanel/fontpanel.pri) TEMPLATE = app LANGUAGE = C++ TARGET = assistant diff --git a/tools/designer/src/components/lib/lib.pro b/tools/designer/src/components/lib/lib.pro index 8d0e69266a..0ada845f83 100644 --- a/tools/designer/src/components/lib/lib.pro +++ b/tools/designer/src/components/lib/lib.pro @@ -44,11 +44,11 @@ SOURCES += qdesigner_components.cpp } INCLUDEPATH += . .. \ - $$QT_SOURCE_TREE/tools/designer/src/lib/components \ - $$QT_SOURCE_TREE/tools/designer/src/lib/sdk \ - $$QT_SOURCE_TREE/tools/designer/src/lib/extension \ - $$QT_SOURCE_TREE/tools/designer/src/lib/uilib \ - $$QT_SOURCE_TREE/tools/designer/src/lib/shared + $$PWD/../../lib/components \ + $$PWD/../../lib/sdk \ + $$PWD/../../lib/extension \ + $$PWD/../../lib/uilib \ + $$PWD/../../lib/shared include(../propertyeditor/propertyeditor.pri) include(../objectinspector/objectinspector.pri) diff --git a/tools/designer/src/components/objectinspector/objectinspector.pri b/tools/designer/src/components/objectinspector/objectinspector.pri index 733c4b37ae..565f78bdcb 100644 --- a/tools/designer/src/components/objectinspector/objectinspector.pri +++ b/tools/designer/src/components/objectinspector/objectinspector.pri @@ -3,7 +3,7 @@ contains(CONFIG, static) { INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/findwidget } else { - include($$QT_SOURCE_TREE/tools/shared/findwidget/findwidget.pri) + include(../../../../shared/findwidget/findwidget.pri) } INCLUDEPATH += $$PWD diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.pri b/tools/designer/src/components/propertyeditor/propertyeditor.pri index a8ed37e81d..7d2e7cba6c 100644 --- a/tools/designer/src/components/propertyeditor/propertyeditor.pri +++ b/tools/designer/src/components/propertyeditor/propertyeditor.pri @@ -10,8 +10,8 @@ contains(CONFIG, static) { INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/qtpropertybrowser INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/qtgradienteditor } else { - include($$QT_SOURCE_TREE/tools/shared/qtpropertybrowser/qtpropertybrowser.pri) - include($$QT_SOURCE_TREE/tools/shared/qtgradienteditor/qtcolorbutton.pri) + include(../../../../shared/qtpropertybrowser/qtpropertybrowser.pri) + include(../../../../shared/qtgradienteditor/qtcolorbutton.pri) } FORMS += $$PWD/paletteeditor.ui \ diff --git a/tools/designer/src/designer/designer.pro b/tools/designer/src/designer/designer.pro index 8590c7b2c7..51842c508b 100644 --- a/tools/designer/src/designer/designer.pro +++ b/tools/designer/src/designer/designer.pro @@ -25,8 +25,8 @@ contains(CONFIG, static) { TARGET = designer -include($$QT_SOURCE_TREE/tools/shared/fontpanel/fontpanel.pri) -include($$QT_SOURCE_TREE/tools/shared/qttoolbardialog/qttoolbardialog.pri) +include(../../../shared/fontpanel/fontpanel.pri) +include(../../../shared/qttoolbardialog/qttoolbardialog.pri) HEADERS += \ qdesigner.h \ diff --git a/tools/designer/src/lib/shared/shared.pri b/tools/designer/src/lib/shared/shared.pri index 570b2080a0..828636082c 100644 --- a/tools/designer/src/lib/shared/shared.pri +++ b/tools/designer/src/lib/shared/shared.pri @@ -2,11 +2,11 @@ INCLUDEPATH += $$PWD contains(QT_CONFIG, script): QT += script -include($$QT_SOURCE_TREE/tools/shared/qtpropertybrowser/qtpropertybrowser.pri) -include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) -include($$QT_SOURCE_TREE/src/tools/rcc/rcc.pri) -include($$QT_SOURCE_TREE/tools/shared/findwidget/findwidget.pri) -include($$QT_SOURCE_TREE/tools/shared/qtgradienteditor/qtgradienteditor.pri) +include(../../../../shared/qtpropertybrowser/qtpropertybrowser.pri) +include(../../../../shared/deviceskin/deviceskin.pri) +include(../../../../../src/tools/rcc/rcc.pri) +include(../../../../shared/findwidget/findwidget.pri) +include(../../../../shared/qtgradienteditor/qtgradienteditor.pri) # Input FORMS += $$PWD/addlinkdialog.ui \ diff --git a/tools/qvfb/qvfb.pro b/tools/qvfb/qvfb.pro index dde7e8dc6a..c101d00a50 100644 --- a/tools/qvfb/qvfb.pro +++ b/tools/qvfb/qvfb.pro @@ -35,7 +35,7 @@ SOURCES = qvfb.cpp \ ../../src/gui/embedded/qlock.cpp \ ../../src/gui/embedded/qwssignalhandler.cpp -include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) +include(../shared/deviceskin/deviceskin.pri) contains(QT_CONFIG, opengl) { QT += opengl -- cgit v1.2.1 From 30bd9791c06bba8f70bcf129022808fd99be743d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 12 Jul 2010 20:21:31 +0200 Subject: remove redundand translations project files lupdate is now powerful enough to use the real project files. this avoids that the file lists run out of sync (which they did, though not as much as i expected). --- tools/assistant/lib/lib.pro | 13 +++ tools/assistant/tools/assistant/assistant.pro | 13 +++ tools/assistant/translations/qt_help.pro | 53 ---------- tools/assistant/translations/translations.pro | 54 ---------- tools/designer/designer.pro | 13 +++ tools/designer/src/designer/designer.pro | 1 - tools/designer/translations/translations.pro | 141 -------------------------- tools/qtconfig/qtconfig.pro | 8 ++ tools/qtconfig/translations/translations.pro | 16 --- tools/qvfb/qvfb.pro | 8 ++ tools/qvfb/translations/translations.pro | 35 ------- translations/translations.pri | 10 +- 12 files changed, 60 insertions(+), 305 deletions(-) delete mode 100644 tools/assistant/translations/qt_help.pro delete mode 100644 tools/assistant/translations/translations.pro delete mode 100644 tools/designer/translations/translations.pro delete mode 100644 tools/qtconfig/translations/translations.pro delete mode 100644 tools/qvfb/translations/translations.pro diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index 26d34562cf..e84cf31480 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -69,3 +69,16 @@ HEADERS += qhelpenginecore.h \ # access to clucene HEADERS += qhelpsearchindexwriter_clucene_p.h \ qhelpsearchindexreader_clucene_p.h + +TR_DIR = $$PWD/../../../translations +TRANSLATIONS = \ + $$TR_DIR/qt_help_cs.ts \ + $$TR_DIR/qt_help_da.ts \ + $$TR_DIR/qt_help_de.ts \ + $$TR_DIR/qt_help_hu.ts \ + $$TR_DIR/qt_help_ja.ts \ + $$TR_DIR/qt_help_pl.ts \ + $$TR_DIR/qt_help_ru.ts \ + $$TR_DIR/qt_help_zh_CN.ts \ + $$TR_DIR/qt_help_zh_TW.ts \ + $$TR_DIR/qt_help_fr.ts diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index d9aff7a4da..16a520e212 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -108,3 +108,16 @@ contains(CONFIG, static): { DEFINES += USE_STATIC_SQLITE_PLUGIN } } + +TR_DIR = $$PWD/../../../../translations +TRANSLATIONS = \ + $$TR_DIR/assistant_cs.ts \ + $$TR_DIR/assistant_da.ts \ + $$TR_DIR/assistant_de.ts \ + $$TR_DIR/assistant_fr.ts \ + $$TR_DIR/assistant_hu.ts \ + $$TR_DIR/assistant_ja.ts \ + $$TR_DIR/assistant_pl.ts \ + $$TR_DIR/assistant_ru.ts \ + $$TR_DIR/assistant_zh_CN.ts \ + $$TR_DIR/assistant_zh_TW.ts diff --git a/tools/assistant/translations/qt_help.pro b/tools/assistant/translations/qt_help.pro deleted file mode 100644 index 6f66876325..0000000000 --- a/tools/assistant/translations/qt_help.pro +++ /dev/null @@ -1,53 +0,0 @@ -# Include those manually as they do not contain any directory specification - -SOURCES += ../lib/qhelpcollectionhandler.cpp \ - ../lib/qhelpcontentwidget.cpp \ - ../lib/qhelpdatainterface.cpp \ - ../lib/qhelpdbreader.cpp \ - ../lib/qhelpengine.cpp \ - ../lib/qhelpenginecore.cpp \ - ../lib/qhelpgenerator.cpp \ - ../lib/qhelpindexwidget.cpp \ - ../lib/qhelpprojectdata.cpp \ - ../lib/qhelpsearchengine.cpp \ - ../lib/qhelpsearchindexreader_clucene.cpp \ - ../lib/qhelpsearchindexreader_default.cpp \ - ../lib/qhelpsearchindexwriter_clucene.cpp \ - ../lib/qhelpsearchindexwriter_default.cpp \ - ../lib/qhelpsearchindex_default.cpp \ - ../lib/qhelpsearchquerywidget.cpp \ - ../lib/qhelpsearchresultwidget.cpp - -HEADERS += ../lib/qhelpcollectionhandler_p.h \ - ../lib/qhelpcontentwidget.h \ - ../lib/qhelpdatainterface_p.h \ - ../lib/qhelpdbreader_p.h \ - ../lib/qhelpengine.h \ - ../lib/qhelpenginecore.h \ - ../lib/qhelpengine_p.h \ - ../lib/qhelpgenerator_p.h \ - ../lib/qhelpindexwidget.h \ - ../lib/qhelpprojectdata_p.h \ - ../lib/qhelpsearchengine.h \ - ../lib/qhelpsearchindexreader_clucene_p.h \ - ../lib/qhelpsearchindexreader_default_p.h \ - ../lib/qhelpsearchindexwriter_clucene_p.h \ - ../lib/qhelpsearchindexwriter_default_p.h \ - ../lib/qhelpsearchindex_default_p.h \ - ../lib/qhelpsearchquerywidget.h \ - ../lib/qhelpsearchresultwidget.h \ - ../lib/qhelp_global.h - - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/qt_help_cs.ts \ - $$TR_DIR/qt_help_da.ts \ - $$TR_DIR/qt_help_de.ts \ - $$TR_DIR/qt_help_hu.ts \ - $$TR_DIR/qt_help_ja.ts \ - $$TR_DIR/qt_help_pl.ts \ - $$TR_DIR/qt_help_ru.ts \ - $$TR_DIR/qt_help_zh_CN.ts \ - $$TR_DIR/qt_help_zh_TW.ts \ - $$TR_DIR/qt_help_fr.ts diff --git a/tools/assistant/translations/translations.pro b/tools/assistant/translations/translations.pro deleted file mode 100644 index c692262fea..0000000000 --- a/tools/assistant/translations/translations.pro +++ /dev/null @@ -1,54 +0,0 @@ -# Include those manually as they do not contain any directory specification - -FORMS += ../tools/assistant/filternamedialog.ui \ - ../tools/assistant/installdialog.ui \ - ../tools/assistant/preferencesdialog.ui \ - ../tools/assistant/topicchooser.ui \ - ../tools/assistant/bookmarkdialog.ui - -SOURCES += ../tools/assistant/aboutdialog.cpp \ - ../tools/assistant/bookmarkmanager.cpp \ - ../tools/assistant/centralwidget.cpp \ - ../tools/assistant/cmdlineparser.cpp \ - ../tools/assistant/contentwindow.cpp \ - ../tools/assistant/filternamedialog.cpp \ - ../tools/assistant/helpviewer.cpp \ - ../tools/assistant/indexwindow.cpp \ - ../tools/assistant/installdialog.cpp \ - ../tools/assistant/main.cpp \ - ../tools/assistant/mainwindow.cpp \ - ../tools/assistant/preferencesdialog.cpp \ - ../tools/assistant/remotecontrol.cpp \ - ../tools/assistant/searchwidget.cpp \ - ../tools/assistant/topicchooser.cpp \ - -SOURCES += ../../shared/fontpanel/fontpanel.cpp - -HEADERS += ../tools/assistant/aboutdialog.h \ - ../tools/assistant/bookmarkmanager.h \ - ../tools/assistant/centralwidget.h \ - ../tools/assistant/cmdlineparser.h \ - ../tools/assistant/contentwindow.h \ - ../tools/assistant/filternamedialog.h \ - ../tools/assistant/helpviewer.h \ - ../tools/assistant/indexwindow.h \ - ../tools/assistant/installdialog.h \ - ../tools/assistant/mainwindow.h \ - ../tools/assistant/preferencesdialog.h \ - ../tools/assistant/remotecontrol.h \ - ../tools/assistant/remotecontrol_win.h \ - ../tools/assistant/searchwidget.h \ - ../tools/assistant/topicchooser.h \ - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/assistant_cs.ts \ - $$TR_DIR/assistant_da.ts \ - $$TR_DIR/assistant_de.ts \ - $$TR_DIR/assistant_fr.ts \ - $$TR_DIR/assistant_hu.ts \ - $$TR_DIR/assistant_ja.ts \ - $$TR_DIR/assistant_pl.ts \ - $$TR_DIR/assistant_ru.ts \ - $$TR_DIR/assistant_zh_CN.ts \ - $$TR_DIR/assistant_zh_TW.ts diff --git a/tools/designer/designer.pro b/tools/designer/designer.pro index 721c4fc42e..31c8622272 100644 --- a/tools/designer/designer.pro +++ b/tools/designer/designer.pro @@ -3,3 +3,16 @@ TEMPLATE = subdirs CONFIG += qt SUBDIRS = src + +TR_DIR = $$PWD/../../translations +TRANSLATIONS = \ + $$TR_DIR/designer_cs.ts \ + $$TR_DIR/designer_de.ts \ + $$TR_DIR/designer_fr.ts \ + $$TR_DIR/designer_hu.ts \ + $$TR_DIR/designer_ja.ts \ + $$TR_DIR/designer_pl.ts \ + $$TR_DIR/designer_ru.ts \ + $$TR_DIR/designer_sl.ts \ + $$TR_DIR/designer_zh_CN.ts \ + $$TR_DIR/designer_zh_TW.ts diff --git a/tools/designer/src/designer/designer.pro b/tools/designer/src/designer/designer.pro index 51842c508b..8564e96cb7 100644 --- a/tools/designer/src/designer/designer.pro +++ b/tools/designer/src/designer/designer.pro @@ -88,4 +88,3 @@ INSTALLS += target include(../sharedcomponents.pri) unix:!mac:LIBS += -lm -TRANSLATIONS = designer_de.ts diff --git a/tools/designer/translations/translations.pro b/tools/designer/translations/translations.pro deleted file mode 100644 index 103c1fe6c0..0000000000 --- a/tools/designer/translations/translations.pro +++ /dev/null @@ -1,141 +0,0 @@ -include(../src/components/buddyeditor/buddyeditor.pri) -include(../src/components/component.pri) -include(../src/components/formeditor/formeditor.pri) -include(../src/components/objectinspector/objectinspector.pri) -include(../src/components/propertyeditor/propertyeditor.pri) -include(../src/components/signalsloteditor/signalsloteditor.pri) -include(../src/components/tabordereditor/tabordereditor.pri) -include(../src/components/taskmenu/taskmenu.pri) -include(../src/components/widgetbox/widgetbox.pri) -include(../src/lib/extension/extension.pri) -include(../src/lib/sdk/sdk.pri) -include(../src/lib/shared/shared.pri) -include(../src/lib/uilib/uilib.pri) -include(../../shared/qttoolbardialog/qttoolbardialog.pri) -include(../../shared/qtpropertybrowser/qtpropertybrowser.pri) -include(../../shared/qtgradienteditor/qtgradienteditor.pri) - -# Include ActiveQt plugin -SOURCES += ../src/plugins/activeqt/qaxwidgetextrainfo.cpp \ - ../src/plugins/activeqt/qaxwidgetplugin.cpp \ - ../src/plugins/activeqt/qaxwidgetpropertysheet.cpp \ - ../src/plugins/activeqt/qaxwidgettaskmenu.cpp \ - ../src/plugins/activeqt/qdesigneraxwidget.cpp - -HEADERS += ../src/plugins/activeqt/qaxwidgetextrainfo.h \ - ../src/plugins/activeqt/qaxwidgetplugin.h \ - ../src/plugins/activeqt/qaxwidgetpropertysheet.h \ - ../src/plugins/activeqt/qaxwidgettaskmenu.h \ - ../src/plugins/activeqt/qdesigneraxwidget.h \ - ../../../src/activeqt/shared/qaxtypes.h - - -# Include Qt3Support plugin - -SOURCES += ../src/plugins/widgets/qt3supportwidgets.cpp -HEADERS += ../src/plugins/widgets/q3iconview/q3iconview_extrainfo.h \ - ../src/plugins/widgets/q3iconview/q3iconview_plugin.h \ - ../src/plugins/widgets/q3listview/q3listview_extrainfo.h \ - ../src/plugins/widgets/q3listview/q3listview_plugin.h \ - ../src/plugins/widgets/q3mainwindow/q3mainwindow_container.h \ - ../src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h \ - ../src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h \ - ../src/plugins/widgets/q3toolbar/q3toolbar_plugin.h \ - ../src/plugins/widgets/q3widgetstack/q3widgetstack_container.h \ - ../src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.h \ - ../src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack_p.h \ - ../src/plugins/widgets/q3wizard/q3wizard_container.h \ - ../src/plugins/widgets/q3wizard/q3wizard_plugin.h \ - ../src/plugins/widgets/q3listbox/q3listbox_extrainfo.h \ - ../src/plugins/widgets/q3listbox/q3listbox_plugin.h \ - ../src/plugins/widgets/q3table/q3table_extrainfo.h \ - ../src/plugins/widgets/q3table/q3table_plugin.h \ - ../src/plugins/widgets/q3textedit/q3textedit_extrainfo.h \ - ../src/plugins/widgets/q3textedit/q3textedit_plugin.h \ - ../src/plugins/widgets/q3widgets/q3widget_plugins.h - -SOURCES += ../src/plugins/widgets/q3iconview/q3iconview_extrainfo.cpp \ - ../src/plugins/widgets/q3iconview/q3iconview_plugin.cpp \ - ../src/plugins/widgets/q3listview/q3listview_extrainfo.cpp \ - ../src/plugins/widgets/q3listview/q3listview_plugin.cpp \ - ../src/plugins/widgets/q3mainwindow/q3mainwindow_container.cpp \ - ../src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.cpp \ - ../src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.cpp \ - ../src/plugins/widgets/q3toolbar/q3toolbar_plugin.cpp \ - ../src/plugins/widgets/q3widgetstack/q3widgetstack_container.cpp \ - ../src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.cpp \ - ../src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack.cpp \ - ../src/plugins/widgets/q3wizard/q3wizard_container.cpp \ - ../src/plugins/widgets/q3wizard/q3wizard_plugin.cpp \ - ../src/plugins/widgets/q3listbox/q3listbox_extrainfo.cpp \ - ../src/plugins/widgets/q3listbox/q3listbox_plugin.cpp \ - ../src/plugins/widgets/q3table/q3table_extrainfo.cpp \ - ../src/plugins/widgets/q3table/q3table_plugin.cpp \ - ../src/plugins/widgets/q3textedit/q3textedit_extrainfo.cpp \ - ../src/plugins/widgets/q3textedit/q3textedit_plugin.cpp \ - ../src/plugins/widgets/q3widgets/q3widget_plugins.cpp - -# Include those manually as they do not contain any directory specification -APP_DIR=../src/designer -SOURCES += $$APP_DIR/appfontdialog.cpp \ - $$APP_DIR/assistantclient.cpp \ - $$APP_DIR/main.cpp \ - $$APP_DIR/mainwindow.cpp \ - $$APP_DIR/newform.cpp \ - $$APP_DIR/preferencesdialog.cpp \ - $$APP_DIR/qdesigner_actions.cpp \ - $$APP_DIR/qdesigner_appearanceoptions.cpp \ - $$APP_DIR/qdesigner.cpp \ - $$APP_DIR/qdesigner_formwindow.cpp \ - $$APP_DIR/qdesigner_server.cpp \ - $$APP_DIR/qdesigner_settings.cpp \ - $$APP_DIR/qdesigner_toolwindow.cpp \ - $$APP_DIR/qdesigner_workbench.cpp \ - $$APP_DIR/saveformastemplate.cpp \ - $$APP_DIR/versiondialog.cpp - -HEADERS+= $$APP_DIR/appfontdialog.h \ - $$APP_DIR/assistantclient.h \ - $$APP_DIR/designer_enums.h \ - $$APP_DIR/mainwindow.h \ - $$APP_DIR/newform.h \ - $$APP_DIR/preferencesdialog.h \ - $$APP_DIR/qdesigner_actions.h \ - $$APP_DIR/qdesigner_appearanceoptions.h \ - $$APP_DIR/qdesigner_formwindow.h \ - $$APP_DIR/qdesigner.h \ - $$APP_DIR/qdesigner_pch.h \ - $$APP_DIR/qdesigner_server.h \ - $$APP_DIR/qdesigner_settings.h \ - $$APP_DIR/qdesigner_toolwindow.h \ - $$APP_DIR/qdesigner_workbench.h \ - $$APP_DIR/saveformastemplate.h \ - $$APP_DIR/versiondialog.h - -FORMS += $$APP_DIR/preferencesdialog.ui \ - $$APP_DIR/qdesigner_appearanceoptions.ui \ - $$APP_DIR/saveformastemplate.ui - -# Shared solutions -SOURCES += ../../shared/fontpanel/fontpanel.cpp \ - ../../shared/deviceskin/deviceskin.cpp \ - ../../shared/findwidget/abstractfindwidget.cpp \ - ../../shared/findwidget/itemviewfindwidget.cpp \ - ../../shared/findwidget/texteditfindwidget.cpp \ - -HEADERS += ../../shared/findwidget/abstractfindwidget.h \ - ../../shared/findwidget/itemviewfindwidget.h \ - ../../shared/findwidget/texteditfindwidget.h - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/designer_cs.ts \ - $$TR_DIR/designer_de.ts \ - $$TR_DIR/designer_fr.ts \ - $$TR_DIR/designer_hu.ts \ - $$TR_DIR/designer_ja.ts \ - $$TR_DIR/designer_pl.ts \ - $$TR_DIR/designer_ru.ts \ - $$TR_DIR/designer_sl.ts \ - $$TR_DIR/designer_zh_CN.ts \ - $$TR_DIR/designer_zh_TW.ts diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index d1fd32020d..3a24e854a7 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -29,3 +29,11 @@ target.path=$$[QT_INSTALL_BINS] INSTALLS += target INCLUDEPATH += . DBFILE = qtconfig.db + +TR_DIR = $$PWD/../../translations +TRANSLATIONS = \ + $$TR_DIR/qtconfig_hu.ts \ + $$TR_DIR/qtconfig_pl.ts \ + $$TR_DIR/qtconfig_ru.ts \ + $$TR_DIR/qtconfig_zh_CN.ts \ + $$TR_DIR/qtconfig_zh_TW.ts diff --git a/tools/qtconfig/translations/translations.pro b/tools/qtconfig/translations/translations.pro deleted file mode 100644 index 5d35b6aac9..0000000000 --- a/tools/qtconfig/translations/translations.pro +++ /dev/null @@ -1,16 +0,0 @@ -# Include those manually as they do not contain any directory specification - -SOURCES += ../colorbutton.cpp ../main.cpp ../previewframe.cpp ../previewwidget.cpp ../mainwindow.cpp ../paletteeditoradvanced.cpp \ - ../mainwindowbase.cpp ../paletteeditoradvancedbase.cpp ../previewwidgetbase.cpp -HEADERS += ../colorbutton.h ../previewframe.h ../previewwidget.h ../mainwindow.h ../paletteeditoradvanced.h \ - ../mainwindowbase.h ../paletteeditoradvancedbase.h ../previewwidgetbase.h - -FORMS = ../mainwindowbase.ui ../paletteeditoradvancedbase.ui ../previewwidgetbase.ui - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/qtconfig_hu.ts \ - $$TR_DIR/qtconfig_pl.ts \ - $$TR_DIR/qtconfig_ru.ts \ - $$TR_DIR/qtconfig_zh_CN.ts \ - $$TR_DIR/qtconfig_zh_TW.ts diff --git a/tools/qvfb/qvfb.pro b/tools/qvfb/qvfb.pro index c101d00a50..df69817822 100644 --- a/tools/qvfb/qvfb.pro +++ b/tools/qvfb/qvfb.pro @@ -62,3 +62,11 @@ unix:x11 { } RESOURCES += qvfb.qrc + +TR_DIR = $$PWD/../../translations +TRANSLATIONS = \ + $$TR_DIR/qvfb_hu.ts \ + $$TR_DIR/qvfb_pl.ts \ + $$TR_DIR/qvfb_ru.ts \ + $$TR_DIR/qvfb_zh_CN.ts \ + $$TR_DIR/qvfb_zh_TW.ts diff --git a/tools/qvfb/translations/translations.pro b/tools/qvfb/translations/translations.pro deleted file mode 100644 index b0b1af4f43..0000000000 --- a/tools/qvfb/translations/translations.pro +++ /dev/null @@ -1,35 +0,0 @@ -# Include those manually as they do not contain any directory specification - -FORMS = ../config.ui -HEADERS = ../qvfb.h \ - ../qvfbview.h \ - ../qvfbratedlg.h \ - ../qanimationwriter.h \ - ../gammaview.h \ - ../qvfbprotocol.h \ - ../qvfbshmem.h \ - ../qvfbmmap.h \ - ../../../src/gui/embedded/qvfbhdr.h \ - ../../../src/gui/embedded/qlock_p.h \ - ../../../src/gui/embedded/qwssignalhandler_p.h \ - ../../shared/deviceskin/deviceskin.h - -SOURCES = ../qvfb.cpp \ - ../qvfbview.cpp \ - ../qvfbratedlg.cpp \ - ../main.cpp \ - ../qanimationwriter.cpp \ - ../qvfbprotocol.cpp \ - ../qvfbshmem.cpp \ - ../qvfbmmap.cpp \ - ../../../src/gui/embedded/qlock.cpp \ - ../../../src/gui/embedded/qwssignalhandler.cpp \ - ../../shared/deviceskin/deviceskin.cpp - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/qvfb_hu.ts \ - $$TR_DIR/qvfb_pl.ts \ - $$TR_DIR/qvfb_ru.ts \ - $$TR_DIR/qvfb_zh_CN.ts \ - $$TR_DIR/qvfb_zh_TW.ts diff --git a/translations/translations.pri b/translations/translations.pri index 9ab72fc277..f5e54ca98c 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -40,7 +40,7 @@ ts-qt.depends = sub-tools ###### Designer ts-designer.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/designer/translations/translations.pro) + ../tools/designer/designer.pro) ts-designer.depends = sub-tools ###### Linguist @@ -52,21 +52,21 @@ ts-linguist.depends = sub-tools ###### Assistant ts-assistant.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/assistant/translations/translations.pro \ + ../tools/assistant/tools/assistant/assistant.pro \ && $$LUPDATE \ - ../tools/assistant/translations/qt_help.pro) + ../tools/assistant/lib/lib.pro) ts-assistant.depends = sub-tools ###### Qtconfig ts-qtconfig.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/qtconfig/translations/translations.pro) + ../tools/qtconfig/qtconfig.pro) ts-qtconfig.depends = sub-tools ###### Qvfp ts-qvfb.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/qvfb/translations/translations.pro) + ../tools/qvfb/qvfb.pro) ts-qvfb.depends = sub-tools ###### Overall Rules -- cgit v1.2.1 From 686fca1c78e6d4d2ba597dd75d982c76647c7707 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 12 Jul 2010 16:21:34 +1000 Subject: wantsFocus should be based on FocusScope chain, not parent chain. Ancestors of the item with focus should only report wantsFocus as true when they are a FocusScope or a top-level item. Reviewed-by: Aaron Kennedy Reviewed-by: Yann Bodson --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 7 +++++- src/declarative/graphicsitems/qdeclarativeitem_p.h | 4 +++- .../qdeclarativefocusscope/data/chain.qml | 28 ++++++++++++++++++++++ .../qdeclarativefocusscope/data/forcefocus.qml | 4 ++-- .../qdeclarativefocusscope/data/test.qml | 2 +- .../qdeclarativefocusscope/data/test5.qml | 2 +- .../tst_qdeclarativefocusscope.cpp | 23 ++++++++++++++---- .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 7 ++---- 8 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativefocusscope/data/chain.qml diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index f5ea537493..62a32154ce 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2416,6 +2416,8 @@ QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const void QDeclarativeItemPrivate::focusChanged(bool flag) { Q_Q(QDeclarativeItem); + if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent) + emit q->wantsFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange() emit q->focusChanged(flag); } @@ -3107,7 +3109,10 @@ void QDeclarativeItem::setSize(const QSizeF &size) /*! \internal */ bool QDeclarativeItem::wantsFocus() const { - return focusItem() != 0; + Q_D(const QDeclarativeItem); + return focusItem() == this || + (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) || + (!parentItem() && focusItem() != 0); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index fb416c2fd2..84ae4ef83e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -286,7 +286,9 @@ public: // Reimplemented from QGraphicsItemPrivate virtual void subFocusItemChange() { - emit q_func()->wantsFocusChanged(subFocusItem != 0); + if (flags & QGraphicsItem::ItemIsFocusScope || !parent) + emit q_func()->wantsFocusChanged(subFocusItem != 0); + //see also QDeclarativeItemPrivate::focusChanged } // Reimplemented from QGraphicsItemPrivate diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml new file mode 100644 index 0000000000..6c39f20313 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +Rectangle { + id: root + width:300; height:400 + + property bool focus1: root.wantsFocus + property bool focus2: item1.wantsFocus + property bool focus3: fs1.wantsFocus + property bool focus4: fs2.wantsFocus + property bool focus5: theItem.wantsFocus + + Item { + id: item1 + FocusScope { + id: fs1 + focus: true + FocusScope { + id: fs2 + focus: true + Item { + id: theItem + focus: true + } + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml index 5904fd65a0..af9c420bd6 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml @@ -8,10 +8,10 @@ Rectangle { FocusScope { id: firstScope + objectName: "item0" focus: true Rectangle { - objectName: "item0" height: 120; width: 420 color: "transparent" @@ -44,9 +44,9 @@ Rectangle { FocusScope { id: secondScope + objectName: "item3" Rectangle { - objectName: "item3" y: 160; height: 120; width: 420 color: "transparent" diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml index 6b09c29d92..aa43ba8e49 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml @@ -9,12 +9,12 @@ Rectangle { FocusScope { id: myScope + objectName: "item0" focus: true Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { - objectName: "item0" height: 120 width: 420 diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index d67ec57534..cdb5164850 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -9,12 +9,12 @@ Rectangle { FocusScope { id: myScope + objectName: "item0" focus: true Keys.onReturnPressed: console.log("Error - FocusScope") Rectangle { - objectName: "item0" height: 120 width: 420 diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 7732e6dadb..2559087717 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -68,6 +68,7 @@ private slots: void noFocus(); void textEdit(); void forceFocus(); + void noParentFocus(); }; /* @@ -97,7 +98,7 @@ void tst_qdeclarativefocusscope::basic() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml")); - QDeclarativeRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); @@ -228,7 +229,7 @@ void tst_qdeclarativefocusscope::textEdit() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml")); - QDeclarativeRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); QDeclarativeTextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); QDeclarativeTextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); @@ -283,10 +284,10 @@ void tst_qdeclarativefocusscope::forceFocus() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml")); - QDeclarativeRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarativeFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); QDeclarativeRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); QDeclarativeRectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); QVERIFY(item0 != 0); @@ -333,6 +334,20 @@ void tst_qdeclarativefocusscope::forceFocus() delete view; } +void tst_qdeclarativefocusscope::noParentFocus() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml")); + QVERIFY(view->rootObject()); + + QVERIFY(view->rootObject()->property("focus1") == true); + QVERIFY(view->rootObject()->property("focus2") == false); + QVERIFY(view->rootObject()->property("focus3") == true); + QVERIFY(view->rootObject()->property("focus4") == true); + QVERIFY(view->rootObject()->property("focus5") == true); + + delete view; +} QTEST_MAIN(tst_qdeclarativefocusscope) diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 4a57def2d0..ffb2105429 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -703,11 +703,8 @@ void tst_QDeclarativeItem::propertyChanges() QCOMPARE(focusArguments.at(0).toBool(), true); QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(parentItem->wantsFocus(), true); - QCOMPARE(wantsFocusSpy.count(),1); - QList wantsFocusArguments = wantsFocusSpy.first(); - QVERIFY(wantsFocusArguments.count() == 1); - QCOMPARE(wantsFocusArguments.at(0).toBool(), true); + QCOMPARE(parentItem->wantsFocus(), false); + QCOMPARE(wantsFocusSpy.count(),0); delete canvas; } -- cgit v1.2.1 From bfa139ff61d1e5b495fe92be6073ccbdcdc91c77 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 12 Jul 2010 16:35:41 +1000 Subject: Private variable cleanup. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 22 +++++++++++----------- src/declarative/graphicsitems/qdeclarativeitem_p.h | 16 +++++++--------- src/imports/particles/qdeclarativeparticles.cpp | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 62a32154ce..7022fac815 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1609,7 +1609,7 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const bool QDeclarativeItem::isComponentComplete() const { Q_D(const QDeclarativeItem); - return d->_componentComplete; + return d->componentComplete; } void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty *prop, QObject *o) @@ -1750,7 +1750,7 @@ QRectF QDeclarativeItem::childrenRect() Q_D(QDeclarativeItem); if (!d->_contents) { d->_contents = new QDeclarativeContents(this); - if (d->_componentComplete) + if (d->componentComplete) d->_contents->complete(); } return d->_contents->rectF(); @@ -2154,19 +2154,19 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const qreal QDeclarativeItem::baselineOffset() const { Q_D(const QDeclarativeItem); - if (!d->_baselineOffset.isValid()) { + if (!d->baselineOffset.isValid()) { return 0.0; } else - return d->_baselineOffset; + return d->baselineOffset; } void QDeclarativeItem::setBaselineOffset(qreal offset) { Q_D(QDeclarativeItem); - if (offset == d->_baselineOffset) + if (offset == d->baselineOffset) return; - d->_baselineOffset = offset; + d->baselineOffset = offset; for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); @@ -2295,7 +2295,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) bool QDeclarativeItem::keepMouseGrab() const { Q_D(const QDeclarativeItem); - return d->_keepMouse; + return d->keepMouse; } /*! @@ -2319,7 +2319,7 @@ bool QDeclarativeItem::keepMouseGrab() const void QDeclarativeItem::setKeepMouseGrab(bool keep) { Q_D(QDeclarativeItem); - d->_keepMouse = keep; + d->keepMouse = keep; } /*! @@ -2592,7 +2592,7 @@ QDeclarativeListProperty QDeclarativeItem::transform() void QDeclarativeItem::classBegin() { Q_D(QDeclarativeItem); - d->_componentComplete = false; + d->componentComplete = false; if (d->_stateGroup) d->_stateGroup->classBegin(); if (d->_anchors) @@ -2610,7 +2610,7 @@ void QDeclarativeItem::classBegin() void QDeclarativeItem::componentComplete() { Q_D(QDeclarativeItem); - d->_componentComplete = true; + d->componentComplete = true; if (d->_stateGroup) d->_stateGroup->componentComplete(); if (d->_anchors) { @@ -2628,7 +2628,7 @@ QDeclarativeStateGroup *QDeclarativeItemPrivate::_states() Q_Q(QDeclarativeItem); if (!_stateGroup) { _stateGroup = new QDeclarativeStateGroup; - if (!_componentComplete) + if (!componentComplete) _stateGroup->classBegin(); QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)), q, SIGNAL(stateChanged(QString))); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 84ae4ef83e..bc5d80910d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -120,11 +120,11 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate public: QDeclarativeItemPrivate() : _anchors(0), _contents(0), - _baselineOffset(0), + baselineOffset(0), _anchorLines(0), _stateGroup(0), origin(QDeclarativeItem::Center), widthValid(false), heightValid(false), - _componentComplete(true), _keepMouse(false), + componentComplete(true), keepMouse(false), smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0), mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { @@ -144,12 +144,10 @@ public: QDeclarative_setParent_noEvent(q, parent); q->setParentItem(parent); } - _baselineOffset.invalidate(); + baselineOffset.invalidate(); mouseSetsFocus = false; } - QString _id; - // Private Properties qreal width() const; void setWidth(qreal); @@ -203,7 +201,7 @@ public: if (!_anchors) { Q_Q(QDeclarativeItem); _anchors = new QDeclarativeAnchors(q); - if (!_componentComplete) + if (!componentComplete) _anchors->classBegin(); } return _anchors; @@ -211,7 +209,7 @@ public: QDeclarativeAnchors *_anchors; QDeclarativeContents *_contents; - QDeclarativeNullableValue _baselineOffset; + QDeclarativeNullableValue baselineOffset; struct AnchorLines { AnchorLines(QGraphicsObject *); @@ -260,8 +258,8 @@ public: QDeclarativeItem::TransformOrigin origin:4; bool widthValid:1; bool heightValid:1; - bool _componentComplete:1; - bool _keepMouse:1; + bool componentComplete:1; + bool keepMouse:1; bool smooth:1; bool transformOriginDirty : 1; bool doneEventPreHandler : 1; diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index a7c445d498..e95dfc7f36 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -1232,7 +1232,7 @@ void QDeclarativeParticles::burst(int count, int emissionRate) void QDeclarativeParticlesPainter::updateSize() { - if (!d->_componentComplete) + if (!d->componentComplete) return; const int parentX = parentItem()->x(); -- cgit v1.2.1 From 5efd577b1aea64f422e08ca8d54e041fa4b20783 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 13 Jul 2010 09:45:30 +1000 Subject: Autotest for QTBUG-5491 (Animation in a Behavior doesn't update running) --- .../qdeclarativebehaviors/data/runningTrue.qml | 20 ++++++++++++++++++++ .../tst_qdeclarativebehaviors.cpp | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml new file mode 100644 index 0000000000..d439875630 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +Rectangle { + id: root + width:200; height:200 + + property real myValue: 0 + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 100 + color: "green" + smooth: true + rotation: myValue + Behavior on rotation { + RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 70739fb986..5c2c1455cb 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -78,6 +79,7 @@ private slots: void dontStart(); void startup(); void groupedPropertyCrash(); + void runningTrue(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -366,6 +368,22 @@ void tst_qdeclarativebehaviors::groupedPropertyCrash() QVERIFY(rect); //don't crash } +//QTBUG-5491 +void tst_qdeclarativebehaviors::runningTrue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml")); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeAbstractAnimation *animation = rect->findChild("rotAnim"); + QVERIFY(animation); + + QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); + rect->setProperty("myValue", 180); + QTRY_VERIFY(runningSpy.count() > 0); +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" -- cgit v1.2.1 From 400b0d43830dfdcefb2f8bd91440ab6f4130ce0f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 13 Jul 2010 10:03:22 +1000 Subject: Fix TextInput selectionColor or selectedTextColor -based animations Task-number: QTBUG-12115 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index f6af1f48b5..2a5d73d97a 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -275,6 +275,8 @@ void QDeclarativeTextInput::setSelectionColor(const QColor &color) QPalette p = d->control->palette(); p.setColor(QPalette::Highlight, d->selectionColor); d->control->setPalette(p); + clearCache(); + update(); emit selectionColorChanged(color); } @@ -299,6 +301,8 @@ void QDeclarativeTextInput::setSelectedTextColor(const QColor &color) QPalette p = d->control->palette(); p.setColor(QPalette::HighlightedText, d->selectedTextColor); d->control->setPalette(p); + clearCache(); + update(); emit selectedTextColorChanged(color); } -- cgit v1.2.1 From cb6472cb67511316f058b1eda4ffe71a1c4fe019 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 13 Jul 2010 15:50:22 +1000 Subject: Only support portrait and landscape orientations on Symbian when updating the runtime.orientation property Task-number: QTBUG-12036 Reviewed-by: Martin Jones --- tools/qml/deviceorientation_symbian.cpp | 12 ++++-------- tools/qml/main.cpp | 11 ++--------- tools/qml/qml.pro | 1 - 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tools/qml/deviceorientation_symbian.cpp b/tools/qml/deviceorientation_symbian.cpp index 48bfc72227..c305f942d5 100644 --- a/tools/qml/deviceorientation_symbian.cpp +++ b/tools/qml/deviceorientation_symbian.cpp @@ -118,18 +118,14 @@ private: data = dataBuf(); Orientation o = UnknownOrientation; switch (data.iDeviceOrientation) { - case TSensrvOrientationData::EOrientationDisplayRightUp: - o = LandscapeInverted; - break; case TSensrvOrientationData::EOrientationDisplayUp: o = Portrait; break; - case TSensrvOrientationData::EOrientationDisplayDown: - o = PortraitInverted; - break; - case TSensrvOrientationData::EOrientationDisplayLeftUp: + case TSensrvOrientationData::EOrientationDisplayRightUp: o = Landscape; break; + case TSensrvOrientationData::EOrientationDisplayLeftUp: + case TSensrvOrientationData::EOrientationDisplayDown: case TSensrvOrientationData::EOrientationUndefined: case TSensrvOrientationData::EOrientationDisplayUpwards: case TSensrvOrientationData::EOrientationDisplayDownwards: @@ -137,7 +133,7 @@ private: break; } - if (m_current != o) { + if (m_current != o && o != UnknownOrientation) { m_current = o; emit orientationChanged(); } diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index dfd172652c..4b1162e22d 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -56,9 +56,7 @@ QT_USE_NAMESPACE QtMsgHandler systemMsgOutput = 0; -#if defined(Q_WS_S60) -#include // For locking app to portrait -#endif + #if defined (Q_OS_SYMBIAN) #include @@ -211,12 +209,7 @@ int main(int argc, char ** argv) app.setOrganizationName("Nokia"); app.setOrganizationDomain("nokia.com"); -#if defined(Q_WS_S60) - CAknAppUi *appUi = static_cast(CEikonEnv::Static()->AppUi()); - if (appUi) { - appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); - } -#endif + QDeclarativeViewer::registerTypes(); QDeclarativeTester::registerTypes(); diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 0a51c0b8d3..bb69e8a63e 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -39,7 +39,6 @@ symbian { TARGET.CAPABILITY = NetworkServices ReadUserData !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { LIBS += -lsensrvclient -lsensrvutil - contains(QT_CONFIG, s60): LIBS += -lavkon -lcone } } mac { -- cgit v1.2.1 From 181749ff7dcfbeb5eb64026e80353f27013af833 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 13 Jul 2010 16:12:26 +1000 Subject: Ensure the section header isn't shown twice. Happened when currentItem was on a section boundary. Task-number: QTBUG-12089 --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 91e9995ca3..cd26472ea7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -494,7 +494,7 @@ public: QSmoothedAnimation *highlightSizeAnimator; QDeclarativeViewSection *sectionCriteria; QString currentSection; - static const int sectionCacheSize = 3; + static const int sectionCacheSize = 4; QDeclarativeItem *sectionCache[sectionCacheSize]; qreal spacing; qreal highlightMoveSpeed; @@ -1029,6 +1029,11 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) } currentItem->item->setFocus(true); currentItem->attached->setIsCurrentItem(true); + // 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 (currentItem->section) + currentItem->section->setVisible(false); } updateHighlight(); emit q->currentIndexChanged(); -- cgit v1.2.1 From 69910bc33dc448a9aa81eb00ed45be6d0488e447 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 13 Jul 2010 09:43:08 +0200 Subject: qdoc: Fixed breadcrumbs for QML examples. Task-number: QTBUG-11679 --- tools/qdoc3/htmlgenerator.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index fc761e592c..f3a95894df 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1702,8 +1702,9 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, } } else if (node->subType() == Node::Page) { - if (fn->name() == QString("examples.html")) { - out() << "
  • Examples
  • "; + if (fn->name() == QString("qdeclarativeexamples.html")) { + out() << "
  • Examples
  • "; + out() << "
  • QML Examples & Demos
  • "; } else if (fn->name().startsWith("examples-")) { out() << "
  • Examples
  • "; @@ -1723,10 +1724,14 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, else if (node->subType() == Node::Example) { out() << "
  • Examples
  • "; QStringList sl = fn->name().split('/'); - QString name = "examples-" + sl.at(0) + ".html"; - QString t = CodeParser::titleFromName(name); - out() << "
  • " - << t << "
  • "; + if (sl.contains("declarative")) + out() << "
  • QML Examples & Demos
  • "; + else { + QString name = "examples-" + sl.at(0) + ".html"; + QString t = CodeParser::titleFromName(name); + out() << "
  • " + << t << "
  • "; + } out() << "
  • " << title << "
  • "; } } -- cgit v1.2.1 From 2c48de46fdfeb935d1f31ae18f13add52c162ac8 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 13 Jul 2010 10:02:54 +0200 Subject: QSslSocket: fix documentation for QSslSocket::setPeerVerifyMode() --- src/network/ssl/qsslsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index f85fa8449b..f73068eb8b 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -574,7 +574,7 @@ void QSslSocket::setProtocol(QSsl::SslProtocol protocol) certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients and QueryPeer for servers. \sa setPeerVerifyMode(), peerVerifyDepth(), mode() */ @@ -594,7 +594,7 @@ QSslSocket::PeerVerifyMode QSslSocket::peerVerifyMode() const certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients and QueryPeer for servers. Setting this mode after encryption has started has no effect on the current connection. -- cgit v1.2.1 From 1d3aa6681423d7a39a8ed375448a9418ef33a1f5 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 13 Jul 2010 10:18:39 +0200 Subject: qdoc: Fixed several
    elements that had the "/>" ending. --- tools/qdoc3/htmlgenerator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index f3a95894df..8699cb2e69 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1347,7 +1347,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, if (!inner->doc().isEmpty()) { //out() << "
    \n" - out() << "
    \n" // QTBUG-9504 + out() << "
    \n" // QTBUG-9504 << "

    " << "Detailed Description" << "

    \n"; generateBody(inner, marker); out() << "
    \n"; // QTBUG-9504 @@ -1359,7 +1359,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, while (s != sections.end()) { //out() << "
    \n"; if (!(*s).divClass.isEmpty()) - out() << "
    \n"; // QTBUG-9504 + out() << "
    \n"; // QTBUG-9504 out() << "

    " << protectEnc((*s).name) << "

    \n"; NodeList::ConstIterator m = (*s).members.begin(); @@ -1596,11 +1596,11 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) Text brief = fake->doc().briefText(); if (fake->subType() == Node::Module && !brief.isEmpty()) { out() << "
    \n"; - out() << "
    \n"; // QTBUG-9504 + out() << "
    \n"; // QTBUG-9504 out() << "

    " << "Detailed Description" << "

    \n"; } else - out() << "
    \n"; // QTBUG-9504 + out() << "
    \n"; // QTBUG-9504 generateBody(fake, marker); out() << "
    \n"; // QTBUG-9504 -- cgit v1.2.1 From 7d09f690d5b4c56699092444665d1879deb86a6e Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 9 Jul 2010 16:28:18 +0200 Subject: Fixes crash in QGraphicsScene::addItem(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Crashed because tabFocusFirst could end up being a dangling pointer when removing an item from the scene before deleting it. When setting tabFocusFirst in fixFocusChainBeforeReparenting, we now check that the item is in the scene. If it is not, tabFocusFirst is set to 0. Autotest included. Task-number: QTBUG-12056 Reviewed-by: Alexis Ménard --- src/gui/graphicsview/qgraphicswidget_p.cpp | 4 ++-- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 28070da86c..f7850cad80 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -761,7 +761,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new QGraphicsWidget *firstOld = 0; bool wasPreviousNew = true; - + while (w != q) { bool isCurrentNew = q->isAncestorOf(w); if (isCurrentNew) { @@ -796,7 +796,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new newScene = newParent->scene(); if (oldScene && newScene != oldScene) - oldScene->d_func()->tabFocusFirst = firstOld; + oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->scene() == oldScene) ? firstOld : 0; QGraphicsItem *topLevelItem = newParent ? newParent->topLevelItem() : 0; QGraphicsWidget *topLevel = 0; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index ed8ff04cdc..a771332b31 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -176,6 +176,7 @@ private slots: void task243004_setStyleCrash(); void task250119_shortcutContext(); void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems(); + void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems(); }; @@ -3089,6 +3090,25 @@ void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() //This should not crash } +void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems() +{ + QGraphicsScene scene; + QGraphicsWidget* item1 = new QGraphicsWidget; + QGraphicsWidget* item2 = new QGraphicsWidget; + QGraphicsWidget* item3 = new QGraphicsWidget; + + scene.addItem(item1); + scene.addItem(item2); + + scene.removeItem(item2); + scene.removeItem(item1); + delete item2; + delete item1; + + scene.addItem(item3); + + //This should not crash +} QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" -- cgit v1.2.1 From c25c7c9bdfade6b906f37ac8bad44f6f0de57597 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 12 Jul 2010 18:32:06 +0200 Subject: QSslSocket: Improve error handling Reviewed-by: Markus Goetz Task-number: QT-3567 --- src/network/ssl/qsslsocket_openssl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 8dc17433f1..c297eea54b 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -971,8 +971,20 @@ void QSslSocketBackendPrivate::transmit() #endif plainSocket->disconnectFromHost(); break; + case SSL_ERROR_SYSCALL: // some IO error + case SSL_ERROR_SSL: // error in the SSL library + // we do not know exactly what the error is, nor whether we can recover from it, + // so just return to prevent an endless loop in the outer "while" statement + q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(SSL_ERRORSTR())); + q->setSocketError(QAbstractSocket::UnknownSocketError); + emit q->error(QAbstractSocket::UnknownSocketError); + return; default: - // ### Handle errors better. + // SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT: can only happen with a + // BIO_s_connect() or BIO_s_accept(), which we do not call. + // SSL_ERROR_WANT_X509_LOOKUP: can only happen with a + // SSL_CTX_set_client_cert_cb(), which we do not call. + // So this default case should never be triggered. q->setErrorString(QSslSocket::tr("Error while reading: %1").arg(SSL_ERRORSTR())); q->setSocketError(QAbstractSocket::UnknownSocketError); emit q->error(QAbstractSocket::UnknownSocketError); -- cgit v1.2.1 From 1199be3aa31bfe1d55799c6362b3e59601f99a8f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 13 Jul 2010 13:07:25 +0200 Subject: doc: Fixed several qdoc warnings. --- src/corelib/global/qnamespace.qdoc | 5 +++-- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index ed2ae6ef13..5cd7f0e35d 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -470,6 +470,7 @@ \value TextIncludeTrailingSpaces Same as IncludeTrailingSpaces \value TextJustificationForced Ensures that text lines are justified. + \omitvalue TextBypassShaping \omitvalue BreakAnywhere \omitvalue DontClip \omitvalue DontPrint @@ -1730,7 +1731,7 @@ \value Key_MediaLast \value Key_unknown - \value Key_Call A key to answer or initiate a call (see \l Key_ToggleCallHangup for a key to toggle current call state) + \value Key_Call A key to answer or initiate a call (see Qt::Key_ToggleCallHangup for a key to toggle current call state) \value Key_Camera A key to activate the camera shutter \value Key_CameraFocus A key to focus the camera \value Key_Context1 @@ -1738,7 +1739,7 @@ \value Key_Context3 \value Key_Context4 \value Key_Flip - \value Key_Hangup A key to end an ongoing call (see \l Key_ToggleCallHangup for a key to toggle current call state) + \value Key_Hangup A key to end an ongoing call (see Qt::Key_ToggleCallHangup for a key to toggle current call state) \value Key_No \value Key_Select \value Key_Yes diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 57f79a0f2f..b2cf49b67b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6954,7 +6954,7 @@ bool QString::isRightToLeft() const /*! \fn bool QString::isRightToLeft() const - \internal + Returns true if the string is read right to left. */ -- cgit v1.2.1 From b2a4c7f0142a48f60e7ec4fc5866917e3da8b7c3 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 2 Jul 2010 19:31:51 +0200 Subject: Fix an Assert in QTextTable The problem was caused by the fragment id being inserted in front of a cell spanning over several rows instead of the next logical cell (or fragment_end) in the cells structure. Task-number: QTBUG-11282 Reviewed-by: Simon Hausmann --- src/gui/text/qtexttable.cpp | 28 ++++++++++++++--- tests/auto/qtexttable/tst_qtexttable.cpp | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 5100176bad..e3985cede9 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -754,19 +754,39 @@ void QTextTable::insertColumns(int pos, int num) QTextFormatCollection *c = p->formatCollection(); p->beginEditBlock(); + QList extendedSpans; for (int i = 0; i < d->nRows; ++i) { int cell; if (i == d->nRows - 1 && pos == d->nCols) cell = d->fragment_end; else cell = d->grid[i*d->nCols + pos]; - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) { // cell spans the insertion place, extend it - fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); - p->setCharFormat(it.position(), 1, fmt); + if (!extendedSpans.contains(cell)) { + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); + fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); + p->setCharFormat(it.position(), 1, fmt); + d->dirty = true; + extendedSpans << cell; + } } else { + /* If the next cell is spanned from the row above, we need to find the right position + to insert to */ + if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) { + int gridIndex = i*d->nCols + pos; + const int gridEnd = d->nRows * d->nCols - 1; + while (gridIndex < gridEnd && cell == d->grid[gridIndex]) { + ++gridIndex; + } + if (gridIndex == gridEnd) + cell = d->fragment_end; + else + cell = d->grid[gridIndex]; + } + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); fmt.setTableCellRowSpan(1); fmt.setTableCellColumnSpan(1); Q_ASSERT(fmt.objectIndex() == objectIndex()); diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp index 2e6007e2f6..b0cb34d1d1 100644 --- a/tests/auto/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/qtexttable/tst_qtexttable.cpp @@ -48,9 +48,14 @@ #include #include #include +#include +#include //TESTED_FILES= +typedef QList IntList; +Q_DECLARE_METATYPE(IntList) + QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextTable : public QObject @@ -78,6 +83,7 @@ private slots: void insertRows(); void deleteInTable(); void mergeCells(); + void mergeAndInsert(); void splitCells(); void blocksForTableShouldHaveEmptyFormat(); void removeTableByRemoveRows(); @@ -93,6 +99,8 @@ private slots: void removeColumns3(); void removeColumns4(); void removeColumns5(); + void QTBUG11282_insertBeforeMergedEnding_data(); + void QTBUG11282_insertBeforeMergedEnding(); private: QTextTable *create2x2Table(); @@ -586,6 +594,16 @@ void tst_QTextTable::mergeCells() QVERIFY(table->cellAt(0, 1) == table->cellAt(1, 1)); } +void tst_QTextTable::mergeAndInsert() +{ + QTextTable *table = cursor.insertTable(4,3); + table->mergeCells(0,1,3,2); + table->mergeCells(3,0,1,3); + //Don't crash ! + table->insertColumns(1,2); + QCOMPARE(table->columns(), 5); +} + void tst_QTextTable::splitCells() { QTextTable *table = create4x4Table(); @@ -931,5 +949,41 @@ void tst_QTextTable::removeColumns5() QCOMPARE(table->cellAt(3, 2).firstPosition(), 11); } +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding_data() +{ + QTest::addColumn("rows"); + QTest::addColumn("columns"); + QTest::addColumn >("merge"); + QTest::addColumn >("insert"); + + QTest::newRow("2x3, merge two, insert one") << 2 << 3 << (QList() << 1 << 2 << 2) + << (QList() << 1 << 1) ; + QTest::newRow("3x4, merge three, insert one") << 3 << 4 << (QList() << 1 << 3 << 3) + << (QList() << 1 << 1) ; + QTest::newRow("4x3, merge two, insert two") << 4 << 3 << (QList() << 1 << 4 << 2) + << (QList() << 1 << 2) ; + QTest::newRow("4x4, merge middle two, insert one") << 4 << 4 << (QList() << 1 << 4 << 2) + << (QList() << 1 << 1) ; +} + +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding() +{ + QFETCH(int, rows); + QFETCH(int, columns); + QFETCH(QList, merge); + QFETCH(QList, insert); + QTextTable *table = cursor.insertTable(rows, columns); + QTextEdit *textEdit = new QTextEdit; + textEdit->setDocument(doc); + textEdit->show(); + QTest::qWaitForWindowShown(textEdit); + table->mergeCells(0,merge.at(0), merge.at(1), merge.at(2)); + //Don't crash ! + table->insertColumns(insert.at(0), insert.at(1)); + //Check that the final size is what we expected + QCOMPARE(table->rows(), rows); + QCOMPARE(table->columns(), columns + insert.at(1)); +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" -- cgit v1.2.1 From b5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 13 Jul 2010 14:21:44 +0200 Subject: Fixes QGraphicsItem::focusItem() returning incorrect value. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting focus on an item, subfocus chain was previously updated only for items with a common ancestor. We now make sure that this chain is updated also for the previously focused item (possibly not sharing any common ancestor with the newly focused item). Autotest included. Task-number: QTBUG-12112 Reviewed-by: Alexis Ménard --- src/gui/graphicsview/qgraphicsitem.cpp | 6 ++++-- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 848de2cb22..fe2a84ea4f 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3257,6 +3257,8 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim } // Update the child focus chain. + if (scene && scene->focusItem()) + scene->focusItem()->d_ptr->clearSubFocus(); f->d_ptr->setSubFocus(); // Update the scene's focus item. @@ -7637,9 +7639,9 @@ int QGraphicsItemPrivate::children_count(QDeclarativeListProperty *list, int index) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast(list->object)); - if (index >= 0 && index < d->children.count()) + if (index >= 0 && index < d->children.count()) return d->children.at(index)->toGraphicsObject(); - else + else return 0; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 1ae3ecffa8..3634ce990a 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -463,6 +463,7 @@ private slots: void sortItemsWhileAdding(); void doNotMarkFullUpdateIfNotInScene(); void itemDiesDuringDraggingOperation(); + void QTBUG_12112_focusItem(); private: QList paintedItems; @@ -10724,5 +10725,31 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() delete item; QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0); } + +void tst_QGraphicsItem::QTBUG_12112_focusItem() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, 20, 20); + item1->setFlag(QGraphicsItem::ItemIsFocusable); + QGraphicsRectItem *item2 = new QGraphicsRectItem(20, 20, 20, 20); + item2->setFlag(QGraphicsItem::ItemIsFocusable); + item1->setFocus(); + scene.addItem(item2); + scene.addItem(item1); + + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QVERIFY(item1->focusItem()); + QVERIFY(!item2->focusItem()); + + item2->setFocus(); + QVERIFY(!item1->focusItem()); + QVERIFY(item2->focusItem()); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v1.2.1 From 079a4105aff9c63d4107762aec478ade9900c7c2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 13 Jul 2010 15:28:14 +0200 Subject: doc: Fixed several qdoc warnings. --- doc/src/classes/phonon-api.qdoc | 12 +----------- doc/src/platforms/symbian-introduction.qdoc | 17 +++++++++++++++++ src/corelib/io/qprocess.cpp | 4 ++-- src/gui/text/qtextcursor.cpp | 6 +++--- src/network/socket/qtcpserver.cpp | 2 +- src/opengl/qgl.cpp | 14 ++++++++++---- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/doc/src/classes/phonon-api.qdoc b/doc/src/classes/phonon-api.qdoc index 641b9362ae..6fe022359b 100644 --- a/doc/src/classes/phonon-api.qdoc +++ b/doc/src/classes/phonon-api.qdoc @@ -1577,7 +1577,6 @@ \since 4.4 \brief The MediaObject class provides an interface for media playback. - The media object manages a \l{Phonon::}{MediaSource}, which supplies the media object with multimedia content, e.g., from a file. A playback in Phonon is always started by calling the @@ -1651,17 +1650,8 @@ playback of the current source, but it is possible to try with a different one. A user readable error message is given by errorString(). - \section1 Symbian Platform Security Requirements - - On Symbian, processes which access media via the network must - have the \c NetworkServices platform security capability. If the client - process lacks this capability, operations will result in errors. - This failure is indicated by a state() of Phonon::ErrorState. - - Platform security capabilities are added via the - \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} - qmake variable. + \sa {Symbian Platform Security Requirements} \sa Phonon::MediaSource, Phonon::AudioOutput, VideoWidget, {Music Player Example}, {Phonon Overview}, Phonon::VideoPlayer, Phonon::createPlayer(), {Phonon Module} diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index 22d858fb95..afb17c416b 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -51,6 +51,7 @@ \o \l {Exception Safety with Symbian} \o \l {Platform Notes - Symbian} {Qt for the Symbian platform - state of support} \o \l {qmake Platform Notes#Symbian platform} {Qt for Symbian extensions for qmake} + \o \l {Symbian Platform Security Requirements} {Symbian Platform Security Requirements} \endlist \o \list @@ -59,6 +60,22 @@ \endtable */ +/*! + \page symbian-platform-security-requirements.html + + \title Symbian Platform Security Requirements + \ingroup qtsymbian + + On Symbian, processes that access media via the network must + have the \c NetworkServices platform security capability. If the client + process lacks this capability, operations will result in errors. + This failure is indicated by a state() of Phonon::ErrorState. + + Platform security capabilities are added via the + \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} + qmake variable. +*/ + /*! \page symbian-with-qt-introduction.html diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 9bc406362f..739ac4dbd4 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1399,10 +1399,10 @@ QString QProcess::nativeArguments() const \since 4.7 \overload - Sets additional native command line arguments for the program. + Sets additional native command line \a arguments for the program. On operating systems where the system API for passing command line - arguments to a subprocess natively uses a single string, one can + \a arguments to a subprocess natively uses a single string, one can conceive command lines which cannot be passed via QProcess's portable list-based API. In such cases this function must be used to set a string which is \e appended to the string composed from the usual diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index daa40a1aac..769ab2fb66 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1283,7 +1283,7 @@ void QTextCursor::setVisualNavigation(bool b) /*! \since 4.7 - Sets the visual x position for vertical cursor movements. + Sets the visual x position for vertical cursor movements to \a x. The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a @@ -1335,8 +1335,8 @@ bool QTextCursor::keepPositionOnInsert() const Defines whether the cursor should keep its current position when text gets inserted at the current position of the cursor. - If \b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. - If \b is false, the cursor moves along with the inserted text. + If \a b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. + If \a b is false, the cursor moves along with the inserted text. The default is false. diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 55f926d3f9..0640c7cccd 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -577,7 +577,7 @@ void QTcpServer::incomingConnection(int socketDescriptor) /*! This function is called by QTcpServer::incomingConnection() - to add a socket to the list of pending incoming connections. + to add the \a socket to the list of pending incoming connections. \note Don't forget to call this member from reimplemented incomingConnection() if you do not want to break the diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index fc28a73202..2fa33bf0c7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1334,6 +1334,10 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. + \value OpenGL_Version_3_3 OpenGL version 3.3 or higher is present. + + \value OpenGL_Version_4_0 OpenGL version 4.0 or higher is present. + \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. @@ -5037,8 +5041,9 @@ void QGLWidget::deleteTexture(QMacCompatGLuint id) /*! \since 4.4 - Calls the corresponding QGLContext::drawTexture() on - this widget's context. + Calls the corresponding QGLContext::drawTexture() with + \a target, \a textureId, and \a textureTarget for this + widget's context. */ void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) { @@ -5058,8 +5063,9 @@ void QGLWidget::drawTexture(const QRectF &target, QMacCompatGLuint textureId, QM /*! \since 4.4 - Calls the corresponding QGLContext::drawTexture() on - this widget's context. + Calls the corresponding QGLContext::drawTexture() with + \a point, \a textureId, and \a textureTarget for this + widget's context. */ void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) { -- cgit v1.2.1 From 61daa2f419696881ccdbc1cde2dc197eaf028ff6 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 12 Jul 2010 19:45:54 +0200 Subject: Fixed a network hanging bug on Symbian. The problem happened because of a race condition in the way Qt cancelled the select call from Open C. Under high network loads, a network request could come in, causing the select call to end. Afterwards, the pipe normally used to cancel the select call would be emptied (although it was already empty). If a context switch happened after the pipe was emptied, but before the lock was released in waitCond.wait(), the main thread could try to grab the lock and write to the pipe because it was unsuccessful. This would in turn cause the next call to select to terminate immediately, and without work to do, the select thread would go straight down to waitCond.wait() and get stuck there. Fixed by moving the pipe draining loop from the select thread to the main thread, right after the lock grab. This guarantees that the select thread is empty when returning to the select call. Task: QT-3358 AutoTest: Passed RevBy: Markus Goetz --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index c3e0808725..7da1b6901e 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -100,16 +100,19 @@ static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, class QSelectMutexGrabber { public: - QSelectMutexGrabber(int fd, QMutex *mutex) + QSelectMutexGrabber(int writeFd, int readFd, QMutex *mutex) : m_mutex(mutex) { if (m_mutex->tryLock()) return; char dummy = 0; - qt_pipe_write(fd, &dummy, 1); + qt_pipe_write(writeFd, &dummy, 1); m_mutex->lock(); + + char buffer; + while (::read(readFd, &buffer, 1) > 0) {} } ~QSelectMutexGrabber() @@ -403,10 +406,6 @@ void QSelectThread::run() ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); savedSelectErrno = errno; - char buffer; - - while (::read(m_pipeEnds[0], &buffer, 1) > 0) {} - if(ret == 0) { // do nothing } else if (ret < 0) { @@ -497,7 +496,7 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta Q_ASSERT(QThread::currentThread() == this->thread()); - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); + QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex); Q_ASSERT(!m_AOStatuses.contains(notifier)); @@ -510,7 +509,7 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { Q_ASSERT(QThread::currentThread() == this->thread()); - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); + QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex); m_AOStatuses.remove(notifier); @@ -521,7 +520,7 @@ void QSelectThread::restart() { Q_ASSERT(QThread::currentThread() == this->thread()); - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); + QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex); m_waitCond.wakeAll(); } -- cgit v1.2.1 From fc260f7ce9c139da93e005b2b51ef37c4d23998d Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 12 Jul 2010 20:06:14 +0200 Subject: Fixed a possible hanging bug in the Symbian networking. I haven't seen the bug happening in practice, but I decided to be safe rather than sorry. The rationale is that if a network request comes in, the select thread will signal the active object in the main thread, remove the socket from the set of monitored sockets, and then go to sleep in the waitCond.wait() call, waiting for reactivation by the QSelectMutexGrabber. However, in QEventDispatcherSymbian::socketFired(), if the event causes the socket to be deleted, reactivateSocketNotifier will never be called, and therefore the wait condition will never be terminated. Fixed by only entering the wait condition if a grabber has already written to the pipe, signalling that it wants the lock. AutoTest: Passed RevBy: Markus Goetz --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 7da1b6901e..1b0c31b672 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -480,7 +480,8 @@ void QSelectThread::run() updateActivatedNotifiers(QSocketNotifier::Write, &writefds); } - m_waitCond.wait(&m_mutex); + if (FD_ISSET(m_pipeEnds[0], &readfds)) + m_waitCond.wait(&m_mutex); } m_mutex.unlock(); -- cgit v1.2.1 From 64f66cbfb924ed1810b120950273c2f58e3a2077 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 12 Jul 2010 20:24:11 +0200 Subject: Revert "Adding some error checking for setdefaultif" This reverts commit 0b56799601690a747c42dfbbefe95f18e837eb3f. Should not be necessary anymore after 61daa2f41969688. --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 1b0c31b672..ea207f0594 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -585,9 +585,7 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set // on some devices we do get exception // close all exiting sockets // and reset default IAP - if(::setdefaultif(0) != KErrNone) // well we can't do much about it - qWarning("setdefaultif(0) failed"); - + ::setdefaultif(0); toRemove.append(i.key()); TRequestStatus *status = i.value(); QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); -- cgit v1.2.1 From b47ab877e8632f0ab2508f67d00986a0e344b7ba Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 12 Jul 2010 20:25:44 +0200 Subject: Revert "Making network reconnect happen after teardown." This reverts commit 1e91d6b79cba488fa5c6f7d954de611903837f76. Should not be necessary anymore after 61daa2f41969688. --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index ea207f0594..2a52044d8e 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -47,8 +47,6 @@ #include #include -#include - QT_BEGIN_NAMESPACE #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS @@ -577,15 +575,13 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set * check if socket is in exception set * then signal RequestComplete for it */ - qWarning("exception on %d [will do setdefaultif(0) - hack]", i.key()->socket()); + qWarning("exception on %d [will close the socket handle - hack]", i.key()->socket()); // quick fix; there is a bug // when doing read on socket // errors not preoperly mapped // after offline-ing the device // on some devices we do get exception - // close all exiting sockets - // and reset default IAP - ::setdefaultif(0); + ::close(i.key()->socket()); toRemove.append(i.key()); TRequestStatus *status = i.value(); QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); -- cgit v1.2.1 From 1404c38ad9d1bf5412ca49da7b2b50295d0ce0fb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 13 Jul 2010 18:19:35 +0200 Subject: fix macx not having UNICODE in DEFINES any more and make the cascade a bit nicer on the way ... --- src/sql/drivers/odbc/qsql_odbc.pri | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.pri b/src/sql/drivers/odbc/qsql_odbc.pri index 839401203c..66a8d51af0 100644 --- a/src/sql/drivers/odbc/qsql_odbc.pri +++ b/src/sql/drivers/odbc/qsql_odbc.pri @@ -1,13 +1,13 @@ HEADERS += $$PWD/qsql_odbc.h SOURCES += $$PWD/qsql_odbc.cpp -mac { - !contains(LIBS, .*odbc.*):LIBS += -liodbc -} else:unix { +unix { DEFINES += UNICODE - !contains(LIBS, .*odbc.*):LIBS += $$QT_LFLAGS_ODBC -} else:win32-borland { - LIBS *= $(BCB)/lib/PSDK/odbc32.lib + !contains(LIBS, .*odbc.*) { + macx:LIBS += -liodbc + else:LIBS += $$QT_LFLAGS_ODBC + } } else { - LIBS *= -lodbc32 + win32-borland:LIBS *= $(BCB)/lib/PSDK/odbc32.lib + else:LIBS *= -lodbc32 } -- cgit v1.2.1 From 7bd9e6c5805ab78c68161bec20c225965ea59ddb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Jul 2010 10:09:41 +1000 Subject: Enter key performs same action as Return key in QML demos. N900 has an Enter key, not a return key --- demos/declarative/flickr/mobile/TitleBar.qml | 1 + demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml | 4 ++++ demos/declarative/twitter/TwitterCore/AuthView.qml | 2 ++ demos/declarative/twitter/TwitterCore/HomeTitleBar.qml | 1 + demos/declarative/twitter/TwitterCore/TitleBar.qml | 1 + 5 files changed, 9 insertions(+) diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index c7e1a5325a..335c315e4e 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -109,6 +109,7 @@ Item { Item { id: returnKey Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() Keys.onEscapePressed: titleBar.state = "" } } diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml index 6109535b95..be7dfa430e 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml @@ -64,6 +64,10 @@ Item { 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 diff --git a/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml index 4f757778aa..0d05debe7d 100644 --- a/demos/declarative/twitter/TwitterCore/AuthView.qml +++ b/demos/declarative/twitter/TwitterCore/AuthView.qml @@ -115,6 +115,7 @@ Item { KeyNavigation.tab: guest KeyNavigation.backtab: passIn Keys.onReturnPressed: login.doLogin(); + Keys.onEnterPressed: login.doLogin(); Keys.onSelectPressed: login.doLogin(); Keys.onSpacePressed: login.doLogin(); onClicked: login.doLogin(); @@ -135,6 +136,7 @@ Item { KeyNavigation.tab: nameIn KeyNavigation.backtab: login Keys.onReturnPressed: guest.doGuest(); + Keys.onEnterPressed: guest.doGuest(); Keys.onSelectPressed: guest.doGuest(); Keys.onSpacePressed: guest.doGuest(); onClicked: guest.doGuest(); diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml index b26f7b3131..56f31b13c3 100644 --- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml @@ -136,6 +136,7 @@ Item { Item { id: returnKey Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() Keys.onEscapePressed: titleBar.state = "" } } diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml index 6cd0a5059d..558bc180ff 100644 --- a/demos/declarative/twitter/TwitterCore/TitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml @@ -98,6 +98,7 @@ Item { Item { id: returnKey Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() Keys.onEscapePressed: titleBar.state = "" } } -- cgit v1.2.1 From 237bc693a527f9cb2b6bbe7c518018cbf56b0eb6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 14 Jul 2010 11:51:04 +1000 Subject: Fix test for get() to check for undefined return values Task-number: QTBUG-10658 --- .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index f15ac8ffba..858c26d188 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -193,8 +193,9 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << ""; - QTest::newRow("get2") << "{get(-1)}" << 0 << ""; + QTest::newRow("get1") << "{get(0) === undefined}" << 1 << ""; + QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << ""; + QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << ""; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -292,8 +293,6 @@ void tst_qdeclarativelistmodel::dynamic() if (e.hasError()) qDebug() << e.error(); // errors not expected - if (QTest::currentDataTag() != QLatin1String("clear3") && QTest::currentDataTag() != QLatin1String("remove3")) - QVERIFY(!e.hasError()); QCOMPARE(actual,result); } @@ -308,6 +307,9 @@ void tst_qdeclarativelistmodel::dynamic_worker() QFETCH(int, result); QFETCH(QString, warning); + // This is same as dynamic() except it applies the test to a ListModel called + // from a WorkerScript (i.e. testing the internal NestedListModel class) + QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); -- cgit v1.2.1 From 07ebc9161263c04dc072b9fc2a922b9665cbe7be Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 14 Jul 2010 11:51:22 +1000 Subject: improvements to docs and examples --- doc/src/declarative/anchor-layout.qdoc | 5 +- doc/src/declarative/basictypes.qdoc | 3 + doc/src/images/qml-mousearea-example.png | Bin 5527 -> 6969 bytes doc/src/images/qml-xmllistmodel-example.png | Bin 0 -> 5252 bytes doc/src/snippets/declarative/mousearea.qml | 13 +++-- .../cppextensions/imageprovider/imageprovider.cpp | 2 +- .../mousearea/mousearea-example.qml | 64 ++++++++++++--------- .../graphicsitems/qdeclarativeimage.cpp | 59 +++++++++---------- src/declarative/graphicsitems/qdeclarativeitem.cpp | 6 +- .../graphicsitems/qdeclarativemousearea.cpp | 10 +++- src/declarative/qml/qdeclarativeimageprovider.cpp | 16 ++++-- .../util/qdeclarativestateoperations.cpp | 2 +- src/declarative/util/qdeclarativexmllistmodel.cpp | 17 ++++-- 13 files changed, 115 insertions(+), 82 deletions(-) create mode 100644 doc/src/images/qml-xmllistmodel-example.png diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index 9c217e1128..5c025e5765 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -33,7 +33,10 @@ In addition to the more traditional \l Grid, \l Row, and \l Column, QML also provides a way to layout items using the concept of \e anchors. Each item can be thought of as having a set of 7 invisible "anchor lines": -\e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, \e baseline, and \e bottom. +\l {Item::anchors.left}{left}, \l {Item::anchors.horizontalCenter}{horizontalCenter}, +\l {Item::anchors.right}{right}, \l {Item::anchors.top}{top}, +\l {Item::anchors.verticalCenter}{verticalCenter}, \l {Item::anchors.baseline}{baseline}, +and \l {Item::anchors.bottom}{bottom}. \image edges_qml.png diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 109e6d580c..e327d4a34f 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -107,6 +107,9 @@ Text { text: "Hello world!" } \endqml + Strings have a \c length attribute that holds the number of + characters in the string. + \sa {QML Basic Types} */ diff --git a/doc/src/images/qml-mousearea-example.png b/doc/src/images/qml-mousearea-example.png index c6e52d62f4..c0eef7f9c7 100644 Binary files a/doc/src/images/qml-mousearea-example.png and b/doc/src/images/qml-mousearea-example.png differ diff --git a/doc/src/images/qml-xmllistmodel-example.png b/doc/src/images/qml-xmllistmodel-example.png new file mode 100644 index 0000000000..be2d15d342 Binary files /dev/null and b/doc/src/images/qml-xmllistmodel-example.png differ diff --git a/doc/src/snippets/declarative/mousearea.qml b/doc/src/snippets/declarative/mousearea.qml index 8e7c73766d..fb6cba0694 100644 --- a/doc/src/snippets/declarative/mousearea.qml +++ b/doc/src/snippets/declarative/mousearea.qml @@ -83,17 +83,18 @@ Rectangle { id: container width: 600; height: 200 - Image { - id: pic - source: "pics/qt.png" - opacity: (600.0 - pic.x) / 600 + Rectangle { + id: rect + width: 50; height: 50 + color: "red" + opacity: (600.0 - rect.x) / 600 MouseArea { anchors.fill: parent - drag.target: pic + drag.target: rect drag.axis: Drag.XAxis drag.minimumX: 0 - drag.maximumX: container.width - pic.width + drag.maximumX: container.width - rect.width } } } diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp index 995192a17e..18d027e689 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp @@ -54,7 +54,7 @@ class ColorImageProvider : public QDeclarativeImageProvider { public: ColorImageProvider() - : QDeclarativeImageProvider(Pixmap) + : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) { } diff --git a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml index 64f72a9a2a..85ea2dcd21 100644 --- a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml +++ b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml @@ -44,59 +44,69 @@ Rectangle { id: box width: 350; height: 250 - function showInfo(text) { - statusText.text = text - } - Rectangle { + id: redSquare width: 80; height: 80 + 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 + anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed: box.showInfo('Pressed (x=' + mouse.x + ' y=' + mouse.y + ' button=' - + (mouse.button == Qt.RightButton ? 'right' : 'left') - + ' Shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') - onReleased: box.showInfo('Released (x=' + mouse.x + ' y=' + mouse.y - + ' isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')') - onClicked: box.showInfo('Clicked (x=' + mouse.x + ' y=' + mouse.y + ' wasHeld=' + mouse.wasHeld + ')') - onDoubleClicked: box.showInfo('Double clicked (x=' + mouse.x + ' y=' + mouse.y + ')') - onPressAndHold: box.showInfo('Press and hold') - onEntered: box.showInfo('Entered (pressed=' + pressed + ')') - onExited: box.showInfo('Exited (pressed=' + pressed + ')') + onEntered: info.text = 'Entered' + onExited: info.text = 'Exited (pressed=' + pressed + ')' + + onPressed: { + info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left') + + ' 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: { + info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' + posInfo.text = '' + } + + onPressAndHold: info.text = 'Press and hold' + onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' + onDoubleClicked: info.text = 'Double clicked' } } Rectangle { - width: 80; height: 80; anchors.right: parent.right + id: blueSquare + width: 80; height: 80 + 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: parent - drag.axis: Drag.XAxis + drag.target: blueSquare + drag.axis: Drag.XandYAxis drag.minimumX: 0 - drag.maximumX: 150 - - onPressed: box.showInfo('Pressed') - onReleased: box.showInfo('Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')') - onClicked: box.showInfo('Clicked' + ' (wasHeld=' + mouse.wasHeld + ')') - onDoubleClicked: box.showInfo('Double clicked') - onPressAndHold: box.showInfo('Press and hold') + drag.maximumX: box.width - parent.width + drag.minimumY: 0 + drag.maximumY: box.height - parent.width } } Text { - id: statusText - anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 + id: info + anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 onTextChanged: console.log(text) } + + Text { + id: posInfo + anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 + } } diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 34d33f52d0..90738c8e2d 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -324,17 +324,34 @@ qreal QDeclarativeImage::paintedHeight() const /*! \qmlproperty QSize Image::sourceSize - This property holds the size of the loaded image, in pixels. + This property holds the actual width and height of the loaded image. - This is used to control the storage used by a loaded image. Unlike - the width and height properties, which scale the painting of the image, this property - affects the number of pixels stored. + Unlike the \l {Item::}{width} and \l {Item::}{height} properties, which scale + the painting of the image, this property sets the actual number of pixels + stored for the loaded image so that large images do not use more + memory than necessary. For example, this ensures the image is memory is no + larger than 1024x1024 pixels, regardless of the Image's \l {Item::}{width} and + \l {Item::}{height} values: + + \code + Rectangle { + width: ... + height: ... + + Image { + anchors.fill: parent + source: "reallyBigImage.jpg" + sourceSize.width: 1024 + sourceSize.height: 1024 + } + } + \endcode If the image's actual size is larger than the sourceSize, the image is scaled down. If only one dimension of the size is set to greater than 0, the other dimension is set in proportion to preserve the source image's aspect ratio. (The \l fillMode is independent of this.) - + If the source is an instrinsically scalable image (eg. SVG), this property determines the size of the loaded image regardless of intrinsic size. Avoid changing this property dynamically; rendering an SVG is \e slow compared @@ -344,34 +361,8 @@ qreal QDeclarativeImage::paintedHeight() const be no greater than this property specifies. For some formats (currently only JPEG), the whole image will never actually be loaded into memory. - \note \e{Changing this property dynamically will lead to the image source being reloaded, - potentially even from the network if it is not in the disk cache.} - - Here is an example that ensures the size of the image in memory is - no larger than 1024x1024 pixels, regardless of the size of the Image element. - - \code - Image { - anchors.fill: parent - source: "images/reallyBigImage.jpg" - sourceSize.width: 1024 - sourceSize.height: 1024 - } - \endcode - - The example below ensures the memory used by the image is no more than necessary - to display the image at the size of the Image element. - Of course if the Image element is resized a costly reload will be required, so - use this technique \e only when the Image size is fixed. - - \code - Image { - anchors.fill: parent - source: "images/reallyBigImage.jpg" - sourceSize.width: width - sourceSize.height: height - } - \endcode + \note \e {Changing this property dynamically causes the image source to be reloaded, + potentially even from the network, if it is not in the disk cache.} */ void QDeclarativeImage::updatePaintedGeometry() @@ -415,6 +406,8 @@ void QDeclarativeImage::geometryChanged(const QRectF &newGeometry, const QRectF Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. The URL may be absolute, or relative to the URL of the component. + + \sa QDeclarativeImageProvider */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 7022fac815..190b22cbec 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2097,7 +2097,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const relationship with other items. Margins apply to top, bottom, left, right, and fill anchors. - The margins property can be used to set all of the various margins at once, to the same value. + The \c anchors.margins property can be used to set all of the various margins at once, to the same value. Offsets apply for horizontal center, vertical center, and baseline anchors. @@ -2132,10 +2132,12 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const \endqml \endtable - anchors.fill provides a convenient way for one item to have the + \c anchors.fill provides a convenient way for one item to have the same geometry as another item, and is equivalent to connecting all four directional anchors. + To clear an anchor value, set it to \c undefined. + \note You can only anchor an item to siblings or a parent. For more information see \l {anchor-layout}{Anchor Layouts}. diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 7b65ca7e63..b7b0c9e186 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -767,10 +767,16 @@ QDeclarativeDrag *QDeclarativeMouseArea::drag() \i \c drag.minimum and \c drag.maximum limit how far the target can be dragged along the corresponding axes. \endlist - The following example displays an image that can be dragged along the X-axis. The opacity - of the image is reduced when it is dragged to the right. + The following example displays a \l Rectangle that can be dragged along the X-axis. The opacity + of the rectangle is reduced when it is dragged to the right. \snippet doc/src/snippets/declarative/mousearea.qml drag + + \note Items cannot be dragged if they are anchored for the requested + \c drag.axis. For example, if \c anchors.left or \c anchors.right was set + for \c rect in the above example, it cannot be dragged along the X-axis. + This can be avoided by settng the anchor value to \c undefined in + an \l onPressed handler. */ QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index f38da4e350..a294c386cb 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -180,9 +180,13 @@ QDeclarativeImageProvider::ImageType QDeclarativeImageProvider::imageType() cons Implement this method to return the image with \a id. The default implementation returns an empty image. - If \a requestedSize is a valid size, the image returned should be of that size. + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by + an Image element. If \a requestedSize is a valid size, the image + returned should be of that size. - In all cases, \a size must be set to the original size of the image. + In all cases, \a size must be set to the original size of the image. This + is used to set the \l {Item::}{width} and \l {Item::}{height} of image + elements that should be automatically sized to the loaded image. \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. @@ -201,9 +205,13 @@ QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, c Implement this method to return the pixmap with \a id. The default implementation returns an empty pixmap. - If \a requestedSize is a valid size, the image returned should be of that size. + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by + an Image element. If \a requestedSize is a valid size, the image + returned should be of that size. - In all cases, \a size must be set to the original size of the image. + In all cases, \a size must be set to the original size of the image. This + is used to set the \l {Item::}{width} and \l {Item::}{height} of image + elements that should be automatically sized to the loaded image. \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 51e6f992e4..55904495b6 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1039,7 +1039,7 @@ public: /*! \qmlproperty Item AnchorChanges::target - This property holds the Item whose anchors will change + This property holds the \l Item for which the anchor changes will be applied. */ QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 00169db812..9895ff2b84 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -508,8 +508,8 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty - Item A + A blog post Sat, 07 Sep 2010 10:00:01 GMT - Item B + Another blog post Sat, 07 Sep 2010 15:35:01 GMT @@ -560,10 +560,17 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Wed, 14 Jul 2010 12:24:38 +1000 Subject: Split responsibilities in QDeclarativeExpression more cleanly --- src/declarative/qml/qdeclarativebinding.cpp | 139 ++++--- src/declarative/qml/qdeclarativebinding_p_p.h | 28 +- src/declarative/qml/qdeclarativecontext_p.h | 1 + src/declarative/qml/qdeclarativeengine.cpp | 2 +- src/declarative/qml/qdeclarativeengine_p.h | 1 - src/declarative/qml/qdeclarativeexpression.cpp | 478 ++++++++++++++----------- src/declarative/qml/qdeclarativeexpression_p.h | 83 +++-- 7 files changed, 401 insertions(+), 331 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 882e981555..e3b33c07a9 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -54,27 +54,20 @@ QT_BEGIN_NAMESPACE -QDeclarativeBindingData::QDeclarativeBindingData() -: updating(false), enabled(false) +void QDeclarativeBindingPrivate::refresh() { + Q_Q(QDeclarativeBinding); + q->update(); } -QDeclarativeBindingData::~QDeclarativeBindingData() -{ - removeError(); -} - -void QDeclarativeBindingData::refresh() +QDeclarativeBindingPrivate::QDeclarativeBindingPrivate() +: updating(false), enabled(false), deleted(0) { - if (enabled && !updating && q) { - QDeclarativeBinding *b = static_cast(QDeclarativeExpressionPrivate::get(q)); - b->update(); - } } -QDeclarativeBindingPrivate::QDeclarativeBindingPrivate() -: QDeclarativeExpressionPrivate(new QDeclarativeBindingData) +QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate() { + if (deleted) *deleted = true; } QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, QObject *obj, @@ -109,7 +102,7 @@ QDeclarativeBinding::~QDeclarativeBinding() void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop) { Q_D(QDeclarativeBinding); - d->bindingData()->property = prop; + d->property = prop; update(); } @@ -117,50 +110,53 @@ void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop) QDeclarativeProperty QDeclarativeBinding::property() const { Q_D(const QDeclarativeBinding); - return d->bindingData()->property; + return d->property; } void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) { Q_D(QDeclarativeBinding); - QDeclarativeBindingData *data = d->bindingData(); - - if (!data->enabled || !data->context() || !data->context()->isValid()) + if (!d->enabled || !d->context() || !d->context()->isValid()) return; - data->addref(); + if (!d->updating) { + d->updating = true; + bool wasDeleted = false; + d->deleted = &wasDeleted; - if (!data->updating) { - data->updating = true; + if (d->property.propertyType() == qMetaTypeId()) { - if (data->property.propertyType() == qMetaTypeId()) { - - int idx = data->property.index(); + int idx = d->property.index(); Q_ASSERT(idx != -1); - QDeclarativeBinding *t = this; int status = -1; void *a[] = { &t, 0, &status, &flags }; - QMetaObject::metacall(data->property.object(), + QMetaObject::metacall(d->property.object(), QMetaObject::WriteProperty, idx, a); + if (wasDeleted) + return; + } else { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context()->engine); + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine); bool isUndefined = false; QVariant value; QScriptValue scriptValue = d->scriptValue(0, &isUndefined); - if (data->property.propertyTypeCategory() == QDeclarativeProperty::List) { + if (wasDeleted) + return; + + if (d->property.propertyTypeCategory() == QDeclarativeProperty::List) { value = ep->scriptValueToVariant(scriptValue, qMetaTypeId >()); } else if (scriptValue.isNull() && - data->property.propertyTypeCategory() == QDeclarativeProperty::Object) { + d->property.propertyTypeCategory() == QDeclarativeProperty::Object) { value = QVariant::fromValue((QObject *)0); } else { - value = ep->scriptValueToVariant(scriptValue, data->property.propertyType()); + value = ep->scriptValueToVariant(scriptValue, d->property.propertyType()); if (value.userType() == QMetaType::QObjectStar && !qvariant_cast(value)) { // If the object is null, we extract the predicted type. While this isn't // 100% reliable, in many cases it gives us better error messages if we @@ -172,73 +168,72 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } - if (data->error.isValid()) { + if (d->error.isValid()) { - } else if (isUndefined && data->property.isResettable()) { + } else if (isUndefined && d->property.isResettable()) { - data->property.reset(); + d->property.reset(); - } else if (isUndefined && data->property.propertyType() == qMetaTypeId()) { + } else if (isUndefined && d->property.propertyType() == qMetaTypeId()) { - QDeclarativePropertyPrivate::write(data->property, QVariant(), flags); + QDeclarativePropertyPrivate::write(d->property, QVariant(), flags); } else if (isUndefined) { - QUrl url = QUrl(data->url); - int line = data->line; + QUrl url = QUrl(d->url); + int line = d->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); - data->error.setUrl(url); - data->error.setLine(line); - data->error.setColumn(-1); - data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") - + QLatin1String(QMetaType::typeName(data->property.propertyType())) - + QLatin1String(" ") + data->property.name()); + d->error.setUrl(url); + d->error.setLine(line); + d->error.setColumn(-1); + d->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + + QLatin1String(QMetaType::typeName(d->property.propertyType())) + + QLatin1String(" ") + d->property.name()); } else if (!scriptValue.isRegExp() && scriptValue.isFunction()) { - QUrl url = QUrl(data->url); - int line = data->line; + QUrl url = QUrl(d->url); + int line = d->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); - data->error.setUrl(url); - data->error.setLine(line); - data->error.setColumn(-1); - data->error.setDescription(QLatin1String("Unable to assign a function to a property.")); + d->error.setUrl(url); + d->error.setLine(line); + d->error.setColumn(-1); + d->error.setDescription(QLatin1String("Unable to assign a function to a property.")); - } else if (data->property.object() && - !QDeclarativePropertyPrivate::write(data->property, value, flags)) { + } else if (d->property.object() && + !QDeclarativePropertyPrivate::write(d->property, value, flags)) { - QUrl url = QUrl(data->url); - int line = data->line; + QUrl url = QUrl(d->url); + int line = d->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); const char *valueType = 0; if (value.userType() == QVariant::Invalid) valueType = "null"; else valueType = QMetaType::typeName(value.userType()); - data->error.setUrl(url); - data->error.setLine(line); - data->error.setColumn(-1); - data->error.setDescription(QLatin1String("Unable to assign ") + - QLatin1String(valueType) + - QLatin1String(" to ") + - QLatin1String(QMetaType::typeName(data->property.propertyType()))); + d->error.setUrl(url); + d->error.setLine(line); + d->error.setColumn(-1); + d->error.setDescription(QLatin1String("Unable to assign ") + + QLatin1String(valueType) + + QLatin1String(" to ") + + QLatin1String(QMetaType::typeName(d->property.propertyType()))); } - if (data->error.isValid()) { - if (!data->addError(ep)) ep->warning(this->error()); + if (d->error.isValid()) { + if (!d->addError(ep)) ep->warning(this->error()); } else { - data->removeError(); + d->removeError(); } } - data->updating = false; + d->updating = false; + d->deleted = 0; } else { - qmlInfo(data->property.object()) << tr("Binding loop detected for property \"%1\"").arg(data->property.name()); + qmlInfo(d->property.object()) << tr("Binding loop detected for property \"%1\"").arg(d->property.name()); } - - data->release(); } void QDeclarativeBindingPrivate::emitValueChanged() @@ -250,13 +245,13 @@ void QDeclarativeBindingPrivate::emitValueChanged() void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags) { Q_D(QDeclarativeBinding); - d->bindingData()->enabled = e; + d->enabled = e; setNotifyOnValueChanged(e); QDeclarativeAbstractBinding::setEnabled(e, flags); if (e) { - addToObject(d->bindingData()->property.object()); + addToObject(d->property.object()); update(flags); } else { removeFromObject(); @@ -266,14 +261,14 @@ void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteF int QDeclarativeBinding::propertyIndex() { Q_D(QDeclarativeBinding); - return QDeclarativePropertyPrivate::bindingIndex(d->bindingData()->property); + return QDeclarativePropertyPrivate::bindingIndex(d->property); } bool QDeclarativeBinding::enabled() const { Q_D(const QDeclarativeBinding); - return d->bindingData()->enabled; + return d->enabled; } QString QDeclarativeBinding::expression() const diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h index 617ec4bd73..6926158edb 100644 --- a/src/declarative/qml/qdeclarativebinding_p_p.h +++ b/src/declarative/qml/qdeclarativebinding_p_p.h @@ -60,30 +60,24 @@ QT_BEGIN_NAMESPACE -class QDeclarativeBindingData : public QDeclarativeExpressionData -{ -public: - QDeclarativeBindingData(); - virtual ~QDeclarativeBindingData(); - - bool updating:1; - bool enabled:1; - - QDeclarativeProperty property; - - virtual void refresh(); -}; - class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate { Q_DECLARE_PUBLIC(QDeclarativeBinding) public: QDeclarativeBindingPrivate(); - - QDeclarativeBindingData *bindingData() { return static_cast(data); } - const QDeclarativeBindingData *bindingData() const { return static_cast(data); } + ~QDeclarativeBindingPrivate(); virtual void emitValueChanged(); + +protected: + virtual void refresh(); + +private: + bool updating:1; + bool enabled:1; + QDeclarativeProperty property; + + bool *deleted; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index 1f5aaf1cae..c5a039a3c9 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -198,6 +198,7 @@ public: // context QDeclarativeComponentAttached *componentAttached; + // Return the outermost id for obj, if any. QString findObjectId(const QObject *obj) const; static QDeclarativeContextData *get(QDeclarativeContext *context) { diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 00bc1b7aef..97ef99c1cf 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -219,7 +219,7 @@ of their use. QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) -: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), +: captureProperties(false), rootContext(0), isDebugging(false), outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0), diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index f457b536e2..a5c8c388d1 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -162,7 +162,6 @@ public: QPODVector capturedProperties; QDeclarativeContext *rootContext; - QDeclarativeExpression *currentExpression; bool isDebugging; bool outputWarningsToStdErr; diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 96cdec15e9..9935e384a7 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -71,109 +71,95 @@ bool QDeclarativeDelayedError::addError(QDeclarativeEnginePrivate *e) return true; } -QDeclarativeExpressionData::QDeclarativeExpressionData() -: q(0), dataRef(0), expressionFunctionValid(false), expressionRewritten(false), me(0), - trackChange(false), isShared(false), line(-1), guardList(0), guardListLength(0) +QDeclarativeQtScriptExpression::QDeclarativeQtScriptExpression() +: dataRef(0), expressionFunctionMode(ExplicitContext), scopeObject(0), trackChange(false), + guardList(0), guardListLength(0), guardObject(0), guardObjectNotifyIndex(-1), deleted(0) { } -QDeclarativeExpressionData::~QDeclarativeExpressionData() +QDeclarativeQtScriptExpression::~QDeclarativeQtScriptExpression() { if (guardList) { delete [] guardList; guardList = 0; } if (dataRef) dataRef->release(); + if (deleted) *deleted = true; } QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate() -: data(new QDeclarativeExpressionData) +: expressionFunctionValid(true), line(-1) { - data->q = this; -} - -QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate(QDeclarativeExpressionData *d) -: data(d) -{ - data->q = this; } QDeclarativeExpressionPrivate::~QDeclarativeExpressionPrivate() { - if (data) { - delete [] data->guardList; - data->guardList = 0; - data->guardListLength = 0; - data->q = 0; - data->release(); - data = 0; - } } void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr, QObject *me) { - data->expression = expr; + expression = expr; - data->QDeclarativeAbstractExpression::setContext(ctxt); - data->me = me; + QDeclarativeAbstractExpression::setContext(ctxt); + scopeObject = me; + expressionFunctionValid = false; } -void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *expr, QDeclarativeRefCount *rc, - QObject *me, const QString &url, int lineNumber) +void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *expr, + QDeclarativeRefCount *rc, + QObject *me, const QString &srcUrl, int lineNumber) { - data->url = url; - data->line = lineNumber; + url = srcUrl; + line = lineNumber; - if (data->dataRef) data->dataRef->release(); - data->dataRef = rc; - if (data->dataRef) data->dataRef->addref(); + if (dataRef) dataRef->release(); + dataRef = rc; + if (dataRef) dataRef->addref(); quint32 *exprData = (quint32 *)expr; QDeclarativeCompiledData *dd = (QDeclarativeCompiledData *)rc; - data->expressionRewritten = true; - data->expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]); + expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]); int progIdx = *(exprData); - bool isShared = progIdx & 0x80000000; + bool isSharedProgram = progIdx & 0x80000000; progIdx &= 0x7FFFFFFF; QDeclarativeEngine *engine = ctxt->engine; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); - if (isShared) { + if (isSharedProgram) { if (!dd->cachedClosures.at(progIdx)) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(ep->contextClass->newSharedContext()); scriptContext->pushScope(ep->globalClass->staticGlobalObject()); - dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line)); + dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(expression, url, line)); scriptEngine->popContext(); } - data->expressionFunction = *dd->cachedClosures.at(progIdx); - data->isShared = true; - data->expressionFunctionValid = true; + expressionFunction = *dd->cachedClosures.at(progIdx); + expressionFunctionMode = SharedContext; + expressionFunctionValid = true; } else { #if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work? if (!dd->cachedPrograms.at(progIdx)) { - dd->cachedPrograms[progIdx] = - new QScriptProgram(data->expression, data->url, data->line); + dd->cachedPrograms[progIdx] = new QScriptProgram(expression, url, line); } - data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx), - &data->expressionContext); + expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx), + &expressionContext); #else - data->expressionFunction = evalInObjectScope(ctxt, me, data->expression, - &data->expressionContext); + expressionFunction = evalInObjectScope(ctxt, me, expression, &expressionContext); #endif - data->expressionFunctionValid = true; + expressionFunctionMode = ExplicitContext; + expressionFunctionValid = true; } - data->QDeclarativeAbstractExpression::setContext(ctxt); - data->me = me; + QDeclarativeAbstractExpression::setContext(ctxt); + scopeObject = me; } QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContextData *context, QObject *object, @@ -240,6 +226,8 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex \endcode */ +static int QDeclarativeExpression_notifyIdx = -1; + /*! Create an invalid QDeclarativeExpression. @@ -249,6 +237,11 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex QDeclarativeExpression::QDeclarativeExpression() : QObject(*new QDeclarativeExpressionPrivate, 0) { + Q_D(QDeclarativeExpression); + + if (QDeclarativeExpression_notifyIdx == -1) + QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); + d->setNotifyObject(this, QDeclarativeExpression_notifyIdx); } /*! \internal */ @@ -260,6 +253,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, vo { Q_D(QDeclarativeExpression); d->init(ctxt, expr, rc, me, url, lineNumber); + + if (QDeclarativeExpression_notifyIdx == -1) + QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); + d->setNotifyObject(this, QDeclarativeExpression_notifyIdx); } /*! @@ -277,6 +274,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, { Q_D(QDeclarativeExpression); d->init(QDeclarativeContextData::get(ctxt), expression, scope); + + if (QDeclarativeExpression_notifyIdx == -1) + QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); + d->setNotifyObject(this, QDeclarativeExpression_notifyIdx); } /*! @@ -288,6 +289,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO { Q_D(QDeclarativeExpression); d->init(ctxt, expression, scope); + + if (QDeclarativeExpression_notifyIdx == -1) + QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); + d->setNotifyObject(this, QDeclarativeExpression_notifyIdx); } /*! \internal */ @@ -297,6 +302,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO { Q_D(QDeclarativeExpression); d->init(ctxt, expression, scope); + + if (QDeclarativeExpression_notifyIdx == -1) + QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); + d->setNotifyObject(this, QDeclarativeExpression_notifyIdx); } /*! @@ -313,7 +322,7 @@ QDeclarativeExpression::~QDeclarativeExpression() QDeclarativeEngine *QDeclarativeExpression::engine() const { Q_D(const QDeclarativeExpression); - return d->data->context()?d->data->context()->engine:0; + return d->context()?d->context()->engine:0; } /*! @@ -323,7 +332,7 @@ QDeclarativeEngine *QDeclarativeExpression::engine() const QDeclarativeContext *QDeclarativeExpression::context() const { Q_D(const QDeclarativeExpression); - QDeclarativeContextData *data = d->data->context(); + QDeclarativeContextData *data = d->context(); return data?data->asQDeclarativeContext():0; } @@ -333,7 +342,7 @@ QDeclarativeContext *QDeclarativeExpression::context() const QString QDeclarativeExpression::expression() const { Q_D(const QDeclarativeExpression); - return d->data->expression; + return d->expression; } /*! @@ -343,12 +352,10 @@ void QDeclarativeExpression::setExpression(const QString &expression) { Q_D(QDeclarativeExpression); - d->clearGuards(); - - d->data->expression = expression; - d->data->expressionFunctionValid = false; - d->data->expressionRewritten = false; - d->data->expressionFunction = QScriptValue(); + d->resetNotifyOnChange(); + d->expression = expression; + d->expressionFunctionValid = false; + d->expressionFunction = QScriptValue(); } void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine, @@ -378,59 +385,108 @@ void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine } } -QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool *isUndefined) +bool QDeclarativeQtScriptExpression::notifyOnValueChange() const { - QDeclarativeExpressionData *data = this->data; - QDeclarativeEngine *engine = data->context()->engine; - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + return trackChange; +} - QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); +void QDeclarativeQtScriptExpression::setNotifyOnValueChange(bool notify) +{ + trackChange = notify; + if (!notify && guardList) + clearGuards(); +} - if (!data->expressionFunctionValid) { +void QDeclarativeQtScriptExpression::resetNotifyOnChange() +{ + clearGuards(); +} - QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); - data->expressionContext = ep->contextClass->newContext(data->context(), data->me); - scriptContext->pushScope(data->expressionContext); - scriptContext->pushScope(ep->globalClass->staticGlobalObject()); +void QDeclarativeQtScriptExpression::setNotifyObject(QObject *object, int notifyIndex) +{ + if (guardList) clearGuards(); + + if (!object || notifyIndex == -1) { + guardObject = 0; + notifyIndex = -1; + } else { + guardObject = object; + guardObjectNotifyIndex = notifyIndex; + + } +} + +QScriptValue QDeclarativeQtScriptExpression::scriptValue(QObject *secondaryScope, bool *isUndefined) +{ + Q_ASSERT(context() && context()->engine); + Q_ASSERT(!trackChange || (guardObject && guardObjectNotifyIndex != -1)); + + if (!expressionFunction.isValid()) { + if (isUndefined) *isUndefined = true; + return QScriptValue(); + } + + DeleteWatcher watcher(this); + + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine); + + bool lastCaptureProperties = ep->captureProperties; + QPODVector lastCapturedProperties; + ep->captureProperties = trackChange; + ep->capturedProperties.copyAndClear(lastCapturedProperties); + + QScriptValue value = eval(secondaryScope, isUndefined); + + if (!watcher.wasDeleted() && trackChange) { + if (ep->capturedProperties.count() == 0) { + + if (guardList) clearGuards(); - if (data->expressionRewritten) { - data->expressionFunction = scriptEngine->evaluate(data->expression, - data->url, data->line); } else { - QDeclarativeRewrite::RewriteBinding rewriteBinding; - bool ok = true; - const QString code = rewriteBinding(data->expression, &ok); - if (!ok) { - scriptEngine->popContext(); - return QScriptValue(); - } - data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line); - } + updateGuards(ep->capturedProperties); - scriptEngine->popContext(); - data->expressionFunctionValid = true; + } } + lastCapturedProperties.copyAndClear(ep->capturedProperties); + ep->captureProperties = lastCaptureProperties; + + return value; +} + +QScriptValue QDeclarativeQtScriptExpression::eval(QObject *secondaryScope, bool *isUndefined) +{ + Q_ASSERT(context() && context()->engine); + + DeleteWatcher watcher(this); + + QDeclarativeEngine *engine = context()->engine; + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + QDeclarativeContextData *oldSharedContext = 0; QObject *oldSharedScope = 0; QObject *oldOverride = 0; - if (data->isShared) { + bool isShared = (expressionFunctionMode == SharedContext); + + if (isShared) { oldSharedContext = ep->sharedContext; oldSharedScope = ep->sharedScope; - ep->sharedContext = data->context(); - ep->sharedScope = data->me; + ep->sharedContext = context(); + ep->sharedScope = scopeObject; } else { - oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope); + oldOverride = ep->contextClass->setOverrideObject(expressionContext, secondaryScope); } - QScriptValue svalue = data->expressionFunction.call(); + QScriptValue svalue = expressionFunction.call(); // This could cause this to be deleted - if (data->isShared) { + if (isShared) { ep->sharedContext = oldSharedContext; ep->sharedScope = oldSharedScope; - } else { - ep->contextClass->setOverrideObject(data->expressionContext, oldOverride); + } else if (!watcher.wasDeleted()) { + ep->contextClass->setOverrideObject(expressionContext, oldOverride); } if (isUndefined) @@ -438,63 +494,134 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool * // Handle exception if (scriptEngine->hasUncaughtException()) { - exceptionToError(scriptEngine, data->error); + if (!watcher.wasDeleted()) + QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error); + scriptEngine->clearExceptions(); return QScriptValue(); } else { - data->error = QDeclarativeError(); + if (!watcher.wasDeleted()) + error = QDeclarativeError(); + return svalue; } } -QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, bool *isUndefined) +void QDeclarativeQtScriptExpression::updateGuards(const QPODVector &properties) { - Q_Q(QDeclarativeExpression); - Q_ASSERT(q->engine()); + Q_ASSERT(guardObject); + Q_ASSERT(guardObjectNotifyIndex != -1); - if (data->expression.isEmpty()) - return QScriptValue(); + if (properties.count() != guardListLength) { + QDeclarativeNotifierEndpoint *newGuardList = new QDeclarativeNotifierEndpoint[properties.count()]; - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine()); + for (int ii = 0; ii < qMin(guardListLength, properties.count()); ++ii) + guardList[ii].copyAndClear(newGuardList[ii]); - QDeclarativeExpression *lastCurrentExpression = ep->currentExpression; - bool lastCaptureProperties = ep->captureProperties; - QPODVector lastCapturedProperties; - ep->capturedProperties.copyAndClear(lastCapturedProperties); + delete [] guardList; + guardList = newGuardList; + guardListLength = properties.count(); + } - ep->currentExpression = q; - ep->captureProperties = data->trackChange; + bool outputWarningHeader = false; + bool noChanges = true; + for (int ii = 0; ii < properties.count(); ++ii) { + QDeclarativeNotifierEndpoint &guard = guardList[ii]; + const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii); - // This object might be deleted during the eval - QDeclarativeExpressionData *localData = data; - localData->addref(); + guard.target = guardObject; + guard.targetMethod = guardObjectNotifyIndex; - QScriptValue value = eval(secondaryScope, isUndefined); + if (property.notifier != 0) { - ep->currentExpression = lastCurrentExpression; - ep->captureProperties = lastCaptureProperties; + if (!noChanges && guard.isConnected(property.notifier)) { + // Nothing to do - // Check if we were deleted - if (localData->q) { - if ((!data->trackChange || !ep->capturedProperties.count()) && data->guardList) { - clearGuards(); - } else if(data->trackChange) { - updateGuards(ep->capturedProperties); + } else { + noChanges = false; + + bool existing = false; + for (int jj = 0; !existing && jj < ii; ++jj) + if (guardList[jj].isConnected(property.notifier)) + existing = true; + + if (existing) { + // duplicate + guard.disconnect(); + } else { + guard.connect(property.notifier); + } + } + + + } else if (property.notifyIndex != -1) { + + if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) { + // Nothing to do + + } else { + noChanges = false; + + bool existing = false; + for (int jj = 0; !existing && jj < ii; ++jj) + if (guardList[jj].isConnected(property.object, property.notifyIndex)) + existing = true; + + if (existing) { + // duplicate + guard.disconnect(); + } else { + guard.connect(property.object, property.notifyIndex); + } + } + + } else { + if (!outputWarningHeader) { + outputWarningHeader = true; + qWarning() << "QDeclarativeExpression: Expression" << expression + << "depends on non-NOTIFYable properties:"; + } + + const QMetaObject *metaObj = property.object->metaObject(); + QMetaProperty metaProp = metaObj->property(property.coreIndex); + + qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name(); } } +} - localData->release(); +QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, bool *isUndefined) +{ + if (!expressionFunctionValid) { + QDeclarativeEngine *engine = context()->engine; + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - lastCapturedProperties.copyAndClear(ep->capturedProperties); + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); - return value; + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); + expressionContext = ep->contextClass->newContext(context(), scopeObject); + scriptContext->pushScope(expressionContext); + scriptContext->pushScope(ep->globalClass->staticGlobalObject()); + + QDeclarativeRewrite::RewriteBinding rewriteBinding; + bool ok = true; + const QString code = rewriteBinding(expression, &ok); + if (ok) + expressionFunction = scriptEngine->evaluate(code, url, line); + + scriptEngine->popContext(); + expressionFunctionMode = ExplicitContext; + expressionFunctionValid = true; + } + + return QDeclarativeQtScriptExpression::scriptValue(secondaryScope, isUndefined); } QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) { Q_Q(QDeclarativeExpression); - if (!data || !data->context() || !data->context()->isValid()) { + if (!context() || !context()->isValid()) { qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context"); return QVariant(); } @@ -526,7 +653,7 @@ value changes. bool QDeclarativeExpression::notifyOnValueChanged() const { Q_D(const QDeclarativeExpression); - return d->data->trackChange; + return d->notifyOnValueChange(); } /*! @@ -548,7 +675,7 @@ bool QDeclarativeExpression::notifyOnValueChanged() const void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange) { Q_D(QDeclarativeExpression); - d->data->trackChange = notifyOnChange; + d->setNotifyOnValueChange(notifyOnChange); } /*! @@ -558,7 +685,7 @@ void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange) QString QDeclarativeExpression::sourceFile() const { Q_D(const QDeclarativeExpression); - return d->data->url; + return d->url; } /*! @@ -568,7 +695,7 @@ QString QDeclarativeExpression::sourceFile() const int QDeclarativeExpression::lineNumber() const { Q_D(const QDeclarativeExpression); - return d->data->line; + return d->line; } /*! @@ -578,8 +705,8 @@ int QDeclarativeExpression::lineNumber() const void QDeclarativeExpression::setSourceLocation(const QString &url, int line) { Q_D(QDeclarativeExpression); - d->data->url = url; - d->data->line = line; + d->url = url; + d->line = line; } /*! @@ -591,7 +718,7 @@ void QDeclarativeExpression::setSourceLocation(const QString &url, int line) QObject *QDeclarativeExpression::scopeObject() const { Q_D(const QDeclarativeExpression); - return d->data->me; + return d->scopeObject; } /*! @@ -603,7 +730,7 @@ QObject *QDeclarativeExpression::scopeObject() const bool QDeclarativeExpression::hasError() const { Q_D(const QDeclarativeExpression); - return d->data->error.isValid(); + return d->error.isValid(); } /*! @@ -615,7 +742,7 @@ bool QDeclarativeExpression::hasError() const void QDeclarativeExpression::clearError() { Q_D(QDeclarativeExpression); - d->data->error = QDeclarativeError(); + d->error = QDeclarativeError(); } /*! @@ -628,7 +755,7 @@ void QDeclarativeExpression::clearError() QDeclarativeError QDeclarativeExpression::error() const { Q_D(const QDeclarativeExpression); - return d->data->error; + return d->error; } /*! \internal */ @@ -637,98 +764,11 @@ void QDeclarativeExpressionPrivate::_q_notify() emitValueChanged(); } -void QDeclarativeExpressionPrivate::clearGuards() -{ - delete [] data->guardList; - data->guardList = 0; - data->guardListLength = 0; -} - -void QDeclarativeExpressionPrivate::updateGuards(const QPODVector &properties) +void QDeclarativeQtScriptExpression::clearGuards() { - Q_Q(QDeclarativeExpression); - - static int notifyIdx = -1; - if (notifyIdx == -1) - notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()"); - - if (properties.count() != data->guardListLength) { - QDeclarativeNotifierEndpoint *newGuardList = - new QDeclarativeNotifierEndpoint[properties.count()]; - - for (int ii = 0; ii < qMin(data->guardListLength, properties.count()); ++ii) - data->guardList[ii].copyAndClear(newGuardList[ii]); - - delete [] data->guardList; - data->guardList = newGuardList; - data->guardListLength = properties.count(); - } - - bool outputWarningHeader = false; - bool noChanges = true; - for (int ii = 0; ii < properties.count(); ++ii) { - QDeclarativeNotifierEndpoint &guard = data->guardList[ii]; - const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii); - - guard.target = q; - guard.targetMethod = notifyIdx; - - if (property.notifier != 0) { - - if (!noChanges && guard.isConnected(property.notifier)) { - // Nothing to do - - } else { - noChanges = false; - - bool existing = false; - for (int jj = 0; !existing && jj < ii; ++jj) - if (data->guardList[jj].isConnected(property.notifier)) - existing = true; - - if (existing) { - // duplicate - guard.disconnect(); - } else { - guard.connect(property.notifier); - } - } - - - } else if (property.notifyIndex != -1) { - - if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) { - // Nothing to do - - } else { - noChanges = false; - - bool existing = false; - for (int jj = 0; !existing && jj < ii; ++jj) - if (data->guardList[jj].isConnected(property.object, property.notifyIndex)) - existing = true; - - if (existing) { - // duplicate - guard.disconnect(); - } else { - guard.connect(property.object, property.notifyIndex); - } - } - - } else { - if (!outputWarningHeader) { - outputWarningHeader = true; - qWarning() << "QDeclarativeExpression: Expression" << q->expression() - << "depends on non-NOTIFYable properties:"; - } - - const QMetaObject *metaObj = property.object->metaObject(); - QMetaProperty metaProp = metaObj->property(property.coreIndex); - - qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name(); - } - } + delete [] guardList; + guardList = 0; + guardListLength = 0; } /*! diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index 4ff3162af7..b629e204f1 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -107,56 +107,73 @@ private: QDeclarativeDelayedError **prevError; }; -class QDeclarativeExpressionData : public QDeclarativeAbstractExpression, public QDeclarativeDelayedError, public QDeclarativeRefCount +class QDeclarativeQtScriptExpression : public QDeclarativeAbstractExpression, + public QDeclarativeDelayedError { public: - QDeclarativeExpressionData(); - virtual ~QDeclarativeExpressionData(); + enum Mode { SharedContext, ExplicitContext }; - QDeclarativeExpressionPrivate *q; + QDeclarativeQtScriptExpression(); + virtual ~QDeclarativeQtScriptExpression(); QDeclarativeRefCount *dataRef; + QString expression; - bool expressionFunctionValid:1; - bool expressionRewritten:1; + + Mode expressionFunctionMode; QScriptValue expressionFunction; - QScriptValue expressionContext; - QObject *me; - bool trackChange; + QScriptValue expressionContext; // Only used in ExplicitContext + QObject *scopeObject; // Only used in SharedContext - bool isShared; + bool notifyOnValueChange() const; + void setNotifyOnValueChange(bool); + void resetNotifyOnChange(); + void setNotifyObject(QObject *, int ); - QString url; // This is a QString for a reason. QUrls are slooooooow... - int line; + QScriptValue scriptValue(QObject *secondaryScope, bool *isUndefined); + + class DeleteWatcher { + public: + inline DeleteWatcher(QDeclarativeQtScriptExpression *data); + inline ~DeleteWatcher(); + inline bool wasDeleted() const; + private: + bool *m_wasDeleted; + bool m_wasDeletedStorage; + QDeclarativeQtScriptExpression *m_d; + }; + +private: + void clearGuards(); + QScriptValue eval(QObject *secondaryScope, bool *isUndefined); + void updateGuards(const QPODVector &properties); + + bool trackChange; QDeclarativeNotifierEndpoint *guardList; int guardListLength; + + QObject *guardObject; + int guardObjectNotifyIndex; + bool *deleted; }; class QDeclarativeExpression; class QString; -class QDeclarativeExpressionPrivate : public QObjectPrivate +class QDeclarativeExpressionPrivate : public QObjectPrivate, public QDeclarativeQtScriptExpression { Q_DECLARE_PUBLIC(QDeclarativeExpression) public: QDeclarativeExpressionPrivate(); - QDeclarativeExpressionPrivate(QDeclarativeExpressionData *); ~QDeclarativeExpressionPrivate(); void init(QDeclarativeContextData *, const QString &, QObject *); void init(QDeclarativeContextData *, void *, QDeclarativeRefCount *, QObject *, const QString &, int); - QDeclarativeExpressionData *data; - QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0); QScriptValue scriptValue(QObject *secondaryScope = 0, bool *isUndefined = 0); - QScriptValue eval(QObject *secondaryScope, bool *isUndefined = 0); - - void updateGuards(const QPODVector &properties); - void clearGuards(); - static QDeclarativeExpressionPrivate *get(QDeclarativeExpression *expr) { return static_cast(QObjectPrivate::get(expr)); } @@ -172,8 +189,32 @@ public: int, QScriptValue *); static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QScriptProgram &, QScriptValue *); + + bool expressionFunctionValid:1; + + QString url; // This is a QString for a reason. QUrls are slooooooow... + int line; }; +QDeclarativeQtScriptExpression::DeleteWatcher::DeleteWatcher(QDeclarativeQtScriptExpression *data) +: m_wasDeletedStorage(false), m_d(data) +{ + if (!m_d->deleted) + m_d->deleted = &m_wasDeletedStorage; + m_wasDeleted = m_d->deleted; +} + +QDeclarativeQtScriptExpression::DeleteWatcher::~DeleteWatcher() +{ + if (false == *m_wasDeleted && m_wasDeleted == m_d->deleted) + m_d->deleted = 0; +} + +bool QDeclarativeQtScriptExpression::DeleteWatcher::wasDeleted() const +{ + return *m_wasDeleted; +} + QT_END_NAMESPACE #endif // QDECLARATIVEEXPRESSION_P_H -- cgit v1.2.1 From 05971cf88bf03f2cbf563cb194ebee62bb907394 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 14 Jul 2010 13:51:17 +1000 Subject: Attempt to fix build failure with msvc200{5,8} on Windows XP. --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 4c651bf3ab..93b1891d6e 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1082,7 +1082,7 @@ void tst_QFileInfo::isHidden_data() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QVERIFY(QDir("./hidden-directory").exists() || QDir().mkdir("./hidden-directory")); - QVERIFY(SetFileAttributesW(QString("./hidden-directory").utf16(),FILE_ATTRIBUTE_HIDDEN)); + QVERIFY(SetFileAttributesW(reinterpret_cast(QString("./hidden-directory").utf16()),FILE_ATTRIBUTE_HIDDEN)); QTest::newRow("C:/path/to/hidden-directory") << QDir::currentPath() + QString::fromLatin1("/hidden-directory") << true; QTest::newRow("C:/path/to/hidden-directory/.") << QDir::currentPath() + QString::fromLatin1("/hidden-directory/.") << true; #endif -- cgit v1.2.1 From b2002d0814e18f7a50bdbf8d17c4bc1662fa70ee Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 14 Jul 2010 13:52:48 +1000 Subject: Revert "Fix an Assert in QTextTable" This reverts commit b2a4c7f0142a48f60e7ec4fc5866917e3da8b7c3. Unit test tst_qtexttable::QTBUG11282_insertBeforeMergedEnding fails on mac and Linux, reverting for now. --- src/gui/text/qtexttable.cpp | 28 +++-------------- tests/auto/qtexttable/tst_qtexttable.cpp | 54 -------------------------------- 2 files changed, 4 insertions(+), 78 deletions(-) diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index e3985cede9..5100176bad 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -754,39 +754,19 @@ void QTextTable::insertColumns(int pos, int num) QTextFormatCollection *c = p->formatCollection(); p->beginEditBlock(); - QList extendedSpans; for (int i = 0; i < d->nRows; ++i) { int cell; if (i == d->nRows - 1 && pos == d->nCols) cell = d->fragment_end; else cell = d->grid[i*d->nCols + pos]; + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) { // cell spans the insertion place, extend it - if (!extendedSpans.contains(cell)) { - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); - fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); - p->setCharFormat(it.position(), 1, fmt); - d->dirty = true; - extendedSpans << cell; - } + fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); + p->setCharFormat(it.position(), 1, fmt); } else { - /* If the next cell is spanned from the row above, we need to find the right position - to insert to */ - if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) { - int gridIndex = i*d->nCols + pos; - const int gridEnd = d->nRows * d->nCols - 1; - while (gridIndex < gridEnd && cell == d->grid[gridIndex]) { - ++gridIndex; - } - if (gridIndex == gridEnd) - cell = d->fragment_end; - else - cell = d->grid[gridIndex]; - } - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); fmt.setTableCellRowSpan(1); fmt.setTableCellColumnSpan(1); Q_ASSERT(fmt.objectIndex() == objectIndex()); diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp index b0cb34d1d1..2e6007e2f6 100644 --- a/tests/auto/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/qtexttable/tst_qtexttable.cpp @@ -48,14 +48,9 @@ #include #include #include -#include -#include //TESTED_FILES= -typedef QList IntList; -Q_DECLARE_METATYPE(IntList) - QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextTable : public QObject @@ -83,7 +78,6 @@ private slots: void insertRows(); void deleteInTable(); void mergeCells(); - void mergeAndInsert(); void splitCells(); void blocksForTableShouldHaveEmptyFormat(); void removeTableByRemoveRows(); @@ -99,8 +93,6 @@ private slots: void removeColumns3(); void removeColumns4(); void removeColumns5(); - void QTBUG11282_insertBeforeMergedEnding_data(); - void QTBUG11282_insertBeforeMergedEnding(); private: QTextTable *create2x2Table(); @@ -594,16 +586,6 @@ void tst_QTextTable::mergeCells() QVERIFY(table->cellAt(0, 1) == table->cellAt(1, 1)); } -void tst_QTextTable::mergeAndInsert() -{ - QTextTable *table = cursor.insertTable(4,3); - table->mergeCells(0,1,3,2); - table->mergeCells(3,0,1,3); - //Don't crash ! - table->insertColumns(1,2); - QCOMPARE(table->columns(), 5); -} - void tst_QTextTable::splitCells() { QTextTable *table = create4x4Table(); @@ -949,41 +931,5 @@ void tst_QTextTable::removeColumns5() QCOMPARE(table->cellAt(3, 2).firstPosition(), 11); } -void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding_data() -{ - QTest::addColumn("rows"); - QTest::addColumn("columns"); - QTest::addColumn >("merge"); - QTest::addColumn >("insert"); - - QTest::newRow("2x3, merge two, insert one") << 2 << 3 << (QList() << 1 << 2 << 2) - << (QList() << 1 << 1) ; - QTest::newRow("3x4, merge three, insert one") << 3 << 4 << (QList() << 1 << 3 << 3) - << (QList() << 1 << 1) ; - QTest::newRow("4x3, merge two, insert two") << 4 << 3 << (QList() << 1 << 4 << 2) - << (QList() << 1 << 2) ; - QTest::newRow("4x4, merge middle two, insert one") << 4 << 4 << (QList() << 1 << 4 << 2) - << (QList() << 1 << 1) ; -} - -void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding() -{ - QFETCH(int, rows); - QFETCH(int, columns); - QFETCH(QList, merge); - QFETCH(QList, insert); - QTextTable *table = cursor.insertTable(rows, columns); - QTextEdit *textEdit = new QTextEdit; - textEdit->setDocument(doc); - textEdit->show(); - QTest::qWaitForWindowShown(textEdit); - table->mergeCells(0,merge.at(0), merge.at(1), merge.at(2)); - //Don't crash ! - table->insertColumns(insert.at(0), insert.at(1)); - //Check that the final size is what we expected - QCOMPARE(table->rows(), rows); - QCOMPARE(table->columns(), columns + insert.at(1)); -} - QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" -- cgit v1.2.1 From d7a1e01e9970bef56f647873bb2a3496893b775a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 14 Jul 2010 15:02:33 +1000 Subject: Distinguish Qt Quick, Qt Declarative and QML on the landing page Task-number: QTBUG-11916 --- doc/src/declarative/declarativeui.qdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index cd27c40c7f..217e37271a 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -37,7 +37,9 @@ custom user interfaces from a rich set of \l {QML Elements}{QML elements}. Qt Quick helps programmers and designers collaborate to build the fluid user interfaces that are becoming common in portable consumer devices, such as mobile phones, media players, set-top boxes -and netbooks. +and netbooks. Qt Quick consists of the QtDeclarative C++ module, QML, and +the integration of both of these into the Qt Creator IDE. Using the QtDeclarative +C++ module, you can load and interact with QML files from your Qt application. QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} @@ -58,7 +60,7 @@ complete internet-enabled applications like a \l Qt Quick builds on \l {QML for Qt programmers}{Qt's existing strengths}. QML can be be used to incrementally extend an existing application or to build completely new applications. QML is fully \l -{Extending QML in C++}{extensible from C++}. +{Extending QML in C++}{extensible from C++} through the QtDeclarative Module. \section1 Getting Started -- cgit v1.2.1 From 2ba0dfd82a3d82e98a70aeda3b142e0a870eeb0d Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 14 Jul 2010 15:03:35 +1000 Subject: Finish QML for Qt Programmers section I don't think I kept the same style as the rest of the section, so this may need to be refactored a little. But it's not incomplete anymore, content-wise. Task-number: QTBUG-11918 --- doc/src/declarative/qtprogrammers.qdoc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index ae54d58f2f..68d56bf1c3 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -27,8 +27,6 @@ /*! - INCOMPLETE - \page qtprogrammers.html \target qtprogrammers \title QML for Qt programmers @@ -146,4 +144,14 @@ transition from an arbitrary Text item, or characters within a Text item, so you item would need to be sufficiently flexible to allow such animation. \section1 QML Items Compared With QGraphicsWidgets + +The main difference between QML items and QGraphicsWidgets is how they are intended to be used. The technical implementation details are much the same, but in practice they are different because QML items are made for declarative and compositional use, and QGraphicsWidgets are made for imperative and more integrated use. Both QML items and QGraphicsWidgets inherit from QGraphicsObject, and can co-exist. The differences are in the layouting system and the interfacing with other components. Note that, as QGraphicsWidgets tend more to be all-in-one packages, the equivalent of a QGraphicsWidget may be many QML items composed across several QML files, but it can still be loaded and used as a single QGraphicsObject from C++. + +QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML does not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid UIs, so the geometry interface is one of the main differences. When writing QML elements, you allow the designers to place their bounding rectangle using absolute geometry, bindings or anchors (all setup for you when you inherit QDeclarativeItem) and you do not use layouts or size hints. If size hints are appropriate, then place them in the QML documentation so that the designers know how to use the item best, but still have complete control over the look and feel. + +The other main difference is that QGraphicsWidgets tend to follow the widget model, in that they are a self-contained bundle of UI and logic. In contrast, QML primitives are usually a single purpose item that does not fulfill a use case on its own, but is composed into the equivalent of the widget inside the QML file. So when writing QML Items, try to avoid doing UI logic or composing visual elements inside the items. Try instead to write more general purpose primitives, so that the look and feel (which involves the UI logic) can be written in QML. + +Both differences are caused by the different method of interaction. QGraphicsWidget is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development from QML easier. The difference therefore is primarily one of the interface exposed, and the design of the items that come with it (the Declarative primitives for QML and the nothing for QGraphicsWidget, because you need to write your own UI logic into the subclass). + +If you wish to use both QML and C++ to write the UI, for example to ease the transition period, it is recommended to use QDeclarativeItem subclasses (although you can use QGraphicsWidgets as well). To allow for easier use from C++ make the root item of each C++ component a LayoutItem, and load individual 'widgets' of QML (possibly comprised of multiple files, and containing a self-contained bundle of UI and logic) into your scene to replace individual QGraphicsWidgets one at a time. */ -- cgit v1.2.1 From 2d4876330e292253a9133b0197e573097ecfa5bb Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 14 Jul 2010 15:05:02 +1000 Subject: Clean up particle motion documentation Task-number: QTBUG-11917 --- src/imports/particles/qdeclarativeparticles.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index e95dfc7f36..8fe8a9fb25 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -158,6 +158,11 @@ void QDeclarativeParticleMotion::destroy(QDeclarativeParticle &particle) \brief The ParticleMotionLinear object moves particles linearly. \sa Particles + + This is the default motion, and moves the particles according to the + properties specified in the Particles element. + + It has no further properties. */ /*! @@ -178,6 +183,13 @@ void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int inte \since 4.7 \brief The ParticleMotionGravity object moves particles towards a point. + This motion attracts the particles to the specified point with the specified acceleration. + To mimic earth gravity, set yattractor to -6360000 and acceleration to 9.8. + + The defaults are all 0, not earth gravity, and so no motion will occur without setting + at least the acceleration property. + + \sa Particles */ @@ -186,6 +198,7 @@ void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int inte \class QDeclarativeParticleMotionGravity \ingroup group_effects \brief The QDeclarativeParticleMotionGravity class moves the particles towards a point. + */ /*! @@ -305,14 +318,14 @@ Rectangle { */ /*! - \qmlproperty real QDeclarativeParticleMotionWander::xvariance - \qmlproperty real QDeclarativeParticleMotionWander::yvariance + \qmlproperty real ParticleMotionWander::xvariance + \qmlproperty real ParticleMotionWander::yvariance These properties set the amount to wander in the x and y directions. */ /*! - \qmlproperty real QDeclarativeParticleMotionWander::pace + \qmlproperty real ParticleMotionWander::pace This property holds how quickly the paricles will move from side to side. */ -- cgit v1.2.1 From 9adc85fdfa0af2b6948408932188ee1b79247fa6 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 14 Jul 2010 15:32:32 +1000 Subject: Position GridView and ListView footer correctly when model cleared. Task-number: QTBUG-12167 --- .../graphicsitems/qdeclarativegridview.cpp | 5 ++- .../graphicsitems/qdeclarativelistview.cpp | 7 ++-- .../qdeclarativegridview/data/footer.qml | 32 +++++++++++++++++ .../tst_qdeclarativegridview.cpp | 41 ++++++++++++++++++++++ .../qdeclarativelistview/data/footer.qml | 30 ++++++++++++++++ .../tst_qdeclarativelistview.cpp | 32 +++++++++++++++++ 6 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativegridview/data/footer.qml create mode 100644 tests/auto/declarative/qdeclarativelistview/data/footer.qml diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index dce6f0e40a..14a4f08d6f 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2438,8 +2438,11 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) if (removedVisible && d->visibleItems.isEmpty()) { d->timeline.clear(); d->setPosition(0); - if (d->itemCount == 0) + if (d->itemCount == 0) { + d->updateHeader(); + d->updateFooter(); update(); + } } emit countChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index cd26472ea7..110c970ff4 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1077,7 +1077,7 @@ void QDeclarativeListViewPrivate::updateFooter() } if (footer) { if (visibleItems.count()) { - qreal endPos = endPosition(); + qreal endPos = endPosition() + 1; if (lastVisibleIndex() == model->count()-1) { footer->setPosition(endPos); } else { @@ -2893,8 +2893,11 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) d->visiblePos = d->header ? d->header->size() : 0; d->timeline.clear(); d->setPosition(0); - if (d->itemCount == 0) + if (d->itemCount == 0) { + d->updateHeader(); + d->updateFooter(); update(); + } } emit countChanged(); diff --git a/tests/auto/declarative/qdeclarativegridview/data/footer.qml b/tests/auto/declarative/qdeclarativegridview/data/footer.qml new file mode 100644 index 0000000000..170b2b505d --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/footer.qml @@ -0,0 +1,32 @@ +import Qt 4.7 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: 80 + height: 60 + border.color: "blue" + Text { + text: index + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + } + } + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + footer: Text { objectName: "footer"; text: "Footer"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index a67c56f55c..1a28b7148b 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -81,6 +81,7 @@ private slots: void enforceRange(); void QTBUG_8456(); void manualHighlight(); + void footer(); private: QDeclarativeView *createView(); @@ -147,6 +148,14 @@ public: emit dataChanged(index(idx,0), index(idx,0)); } + void clear() { + int count = list.count(); + emit beginRemoveRows(QModelIndex(), 0, count-1); + list.clear(); + emit endRemoveRows(); + } + + private: QList > list; }; @@ -1162,6 +1171,38 @@ void tst_QDeclarativeGridView::manualHighlight() QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); } +void tst_QDeclarativeGridView::footer() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 7; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + + QCOMPARE(footer->y(), 180.0); + + model.removeItem(2); + QTRY_COMPARE(footer->y(), 120.0); + + model.clear(); + QTRY_COMPARE(footer->y(), 0.0); +} + QDeclarativeView *tst_QDeclarativeGridView::createView() { diff --git a/tests/auto/declarative/qdeclarativelistview/data/footer.qml b/tests/auto/declarative/qdeclarativelistview/data/footer.qml new file mode 100644 index 0000000000..11cbe1630a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/footer.qml @@ -0,0 +1,30 @@ +import Qt 4.7 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 20 + width: 240 + Text { + text: index + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + } + } + ListView { + id: list + objectName: "list" + focus: true + width: 240 + height: 320 + model: testModel + delegate: myDelegate + footer: Text { objectName: "footer"; text: "Footer"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index e13bd94870..9c24e036c1 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -97,6 +97,7 @@ private slots: void QTBUG_9791(); void manualHighlight(); void QTBUG_11105(); + void footer(); private: template void items(); @@ -1558,6 +1559,37 @@ void tst_QDeclarativeListView::QTBUG_11105() delete canvas; } +void tst_QDeclarativeListView::footer() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 3; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + QCOMPARE(footer->y(), 60.0); + + model.removeItem(1); + QTRY_COMPARE(footer->y(), 40.0); + + model.clear(); + QTRY_COMPARE(footer->y(), 0.0); +} + void tst_QDeclarativeListView::qListModelInterface_items() { items(); -- cgit v1.2.1 From bf40668cf05e6bb09ee0c7eca26c59f84fa14437 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 14 Jul 2010 16:23:10 +1000 Subject: Check for binding having been deleted in more places --- src/declarative/qml/qdeclarativebinding.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index e3b33c07a9..e096305c97 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -205,6 +205,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } else if (d->property.object() && !QDeclarativePropertyPrivate::write(d->property, value, flags)) { + if (wasDeleted) + return; + QUrl url = QUrl(d->url); int line = d->line; if (url.isEmpty()) url = QUrl(QLatin1String("")); @@ -222,6 +225,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) QLatin1String(QMetaType::typeName(d->property.propertyType()))); } + if (wasDeleted) + return; + if (d->error.isValid()) { if (!d->addError(ep)) ep->warning(this->error()); } else { -- cgit v1.2.1 From d3a6f124dde7732311ad9312ebf41997712fc6bb Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 2 Jul 2010 19:31:51 +0200 Subject: Fix an Assert in QTextTable The problem was caused by the fragment id being inserted in front of a cell spanning over several rows instead of the next logical cell (or fragment_end) in the cells structure. Task-number: QTBUG-11282 Reviewed-by: Simon Hausmann --- src/gui/text/qtexttable.cpp | 28 +++++++++++++--- tests/auto/qtexttable/tst_qtexttable.cpp | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 5100176bad..e3985cede9 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -754,19 +754,39 @@ void QTextTable::insertColumns(int pos, int num) QTextFormatCollection *c = p->formatCollection(); p->beginEditBlock(); + QList extendedSpans; for (int i = 0; i < d->nRows; ++i) { int cell; if (i == d->nRows - 1 && pos == d->nCols) cell = d->fragment_end; else cell = d->grid[i*d->nCols + pos]; - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) { // cell spans the insertion place, extend it - fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); - p->setCharFormat(it.position(), 1, fmt); + if (!extendedSpans.contains(cell)) { + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); + fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); + p->setCharFormat(it.position(), 1, fmt); + d->dirty = true; + extendedSpans << cell; + } } else { + /* If the next cell is spanned from the row above, we need to find the right position + to insert to */ + if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) { + int gridIndex = i*d->nCols + pos; + const int gridEnd = d->nRows * d->nCols - 1; + while (gridIndex < gridEnd && cell == d->grid[gridIndex]) { + ++gridIndex; + } + if (gridIndex == gridEnd) + cell = d->fragment_end; + else + cell = d->grid[gridIndex]; + } + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); fmt.setTableCellRowSpan(1); fmt.setTableCellColumnSpan(1); Q_ASSERT(fmt.objectIndex() == objectIndex()); diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp index 2e6007e2f6..9dcc369645 100644 --- a/tests/auto/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/qtexttable/tst_qtexttable.cpp @@ -48,9 +48,14 @@ #include #include #include +#include +#include //TESTED_FILES= +typedef QList IntList; +Q_DECLARE_METATYPE(IntList) + QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextTable : public QObject @@ -78,6 +83,7 @@ private slots: void insertRows(); void deleteInTable(); void mergeCells(); + void mergeAndInsert(); void splitCells(); void blocksForTableShouldHaveEmptyFormat(); void removeTableByRemoveRows(); @@ -93,6 +99,8 @@ private slots: void removeColumns3(); void removeColumns4(); void removeColumns5(); + void QTBUG11282_insertBeforeMergedEnding_data(); + void QTBUG11282_insertBeforeMergedEnding(); private: QTextTable *create2x2Table(); @@ -586,6 +594,16 @@ void tst_QTextTable::mergeCells() QVERIFY(table->cellAt(0, 1) == table->cellAt(1, 1)); } +void tst_QTextTable::mergeAndInsert() +{ + QTextTable *table = cursor.insertTable(4,3); + table->mergeCells(0,1,3,2); + table->mergeCells(3,0,1,3); + //Don't crash ! + table->insertColumns(1,2); + QCOMPARE(table->columns(), 5); +} + void tst_QTextTable::splitCells() { QTextTable *table = create4x4Table(); @@ -931,5 +949,42 @@ void tst_QTextTable::removeColumns5() QCOMPARE(table->cellAt(3, 2).firstPosition(), 11); } +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding_data() +{ + QTest::addColumn("rows"); + QTest::addColumn("columns"); + QTest::addColumn >("merge"); + QTest::addColumn >("insert"); + + QTest::newRow("2x3, merge two, insert one") << 2 << 3 << (QList() << 1 << 2 << 2) + << (QList() << 1 << 1) ; + QTest::newRow("3x4, merge three, insert one") << 3 << 4 << (QList() << 1 << 3 << 3) + << (QList() << 1 << 1) ; + QTest::newRow("4x3, merge two, insert two") << 4 << 3 << (QList() << 1 << 4 << 2) + << (QList() << 1 << 2) ; + QTest::newRow("4x4, merge middle two, insert one") << 4 << 4 << (QList() << 1 << 4 << 2) + << (QList() << 1 << 1) ; +} + +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding() +{ + QFETCH(int, rows); + QFETCH(int, columns); + QFETCH(QList, merge); + QFETCH(QList, insert); + QTextTable *table = cursor.insertTable(rows, columns); + QTextEdit *textEdit = new QTextEdit; + textEdit->setDocument(doc); + textEdit->show(); + QTest::qWaitForWindowShown(textEdit); + table->mergeCells(0,merge.at(0), merge.at(1), merge.at(2)); + //Don't crash ! + table->insertColumns(insert.at(0), insert.at(1)); + //Check that the final size is what we expected + QCOMPARE(table->rows(), rows); + QCOMPARE(table->columns(), columns + insert.at(1)); + delete textEdit; +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" -- cgit v1.2.1 From 852ba9a62f65a27e42648d4b28b68c76b1589e75 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 14 Jul 2010 10:46:46 +0200 Subject: Silence warning when building with MSVC 2005 Reviewed-by: Eskil --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index ee49a3d00c..d3f6a295e4 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1128,7 +1128,7 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) d->fill(path); } -extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp +extern Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) -- cgit v1.2.1 From d3f67bfe7cd1cc39d25e6a7371b2b185591008c4 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 14 Jul 2010 10:47:58 +0200 Subject: qdoc: Removed navigation arrow that was causing display problems. Task-number: QTBUG-12157, QTBUG-12148, QTBUG-12146 --- tools/qdoc3/htmlgenerator.cpp | 30 ++++++++++++++++++------------ tools/qdoc3/htmlgenerator.h | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 8699cb2e69..f281fd4fd4 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -63,6 +63,12 @@ QT_BEGIN_NAMESPACE int HtmlGenerator::id = 0; bool HtmlGenerator::debugging_on = false; +#if 0 +QString HtmlGenerator::divNavTop = "
    "; +#endif + +QString HtmlGenerator::divNavTop = ""; + QString HtmlGenerator::sinceTitles[] = { " New Namespaces", @@ -1055,11 +1061,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, } sectionNumber.last() = QString::number(sectionNumber.last().toInt() + 1); } - out() << "
    \n"; + out() << "" << divNavTop << "\n"; } #else out() << "
    \n"; + << "\">" << divNavTop << "\n"; #endif break; case Atom::SectionRight: @@ -1307,7 +1313,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, // out() << "
    \n"; out() << "
    \n"; + << "\">" << divNavTop << "\n"; out() << "

    " << protectEnc((*s).name) << "

    \n"; generateSection(s->members, inner, marker, CodeMarker::Summary); } @@ -1316,7 +1322,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, // out() << "
    \n"; out() << "
    \n"; + << "\">" << divNavTop << "\n"; out() << "

    " << protectEnc(name) << "

    \n"; generateSection(s->reimpMembers, inner, marker, CodeMarker::Summary); } @@ -1343,7 +1349,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, out() << "\n"; } - out() << "
    \n"; + out() << "" << divNavTop << "\n"; if (!inner->doc().isEmpty()) { //out() << "
    \n" @@ -1483,12 +1489,12 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) generateStatus(fake, marker); if (moduleNamespaceMap.contains(fake->name())) { - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "

    Namespaces

    \n"; generateAnnotatedList(fake, marker, moduleNamespaceMap[fake->name()]); } if (moduleClassMap.contains(fake->name())) { - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "

    Classes

    \n"; generateAnnotatedList(fake, marker, moduleClassMap[fake->name()]); } @@ -1551,13 +1557,13 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) sections = marker->qmlSections(qml_cn,CodeMarker::Summary); s = sections.begin(); while (s != sections.end()) { - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "

    " << protectEnc((*s).name) << "

    \n"; generateQmlSummary(*s,fake,marker); ++s; } - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "

    " << "Detailed Description" << "

    \n"; generateBody(fake, marker); if (cn) @@ -1587,7 +1593,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) sections = marker->sections(fake, CodeMarker::Summary, CodeMarker::Okay); s = sections.begin(); while (s != sections.end()) { - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "

    " << protectEnc((*s).name) << "

    \n"; generateSectionList(*s, fake, marker, CodeMarker::Summary); ++s; @@ -1595,7 +1601,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) Text brief = fake->doc().briefText(); if (fake->subType() == Node::Module && !brief.isEmpty()) { - out() << "
    \n"; + out() << "" << divNavTop << "\n"; out() << "
    \n"; // QTBUG-9504 out() << "

    " << "Detailed Description" << "

    \n"; } @@ -3481,7 +3487,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, out() << "

    "; out() << ""; generateSynopsis(node, relative, marker, CodeMarker::Detailed); - out() << "

    \n"; + out() << "" << divNavTop << "\n"; } generateStatus(node, marker); diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index abfca6043f..54032d3b30 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -324,6 +324,7 @@ class HtmlGenerator : public PageGenerator static int id; public: static bool debugging_on; + static QString divNavTop; }; #define HTMLGENERATOR_ADDRESS "address" -- cgit v1.2.1 From 9c68bdf3ed66564bce3064a49ca80b7889c35952 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Wed, 14 Jul 2010 11:31:11 +0200 Subject: Added symbian defs for e55781212532e2abcdd1cef8548b146fb14f0713 Reviewed-by: Jason McDonald Submitted-by: Alessandro Portale --- src/s60installs/bwins/QtDeclarativeu.def | 1 + src/s60installs/eabi/QtDeclarativeu.def | 1 + 2 files changed, 2 insertions(+) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index e96f83fd96..8fdd72c218 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -1675,4 +1675,5 @@ EXPORTS ?setBindingForObject@QDeclarativeEngineDebug@@QAE_NHABVQString@@ABVQVariant@@_N@Z @ 1674 NONAME ; bool QDeclarativeEngineDebug::setBindingForObject(int, class QString const &, class QVariant const &, bool) ??0QDeclarativeImageProvider@@QAE@W4ImageType@0@@Z @ 1675 NONAME ; QDeclarativeImageProvider::QDeclarativeImageProvider(enum QDeclarativeImageProvider::ImageType) ?setMethodBody@QDeclarativeEngineDebug@@QAE_NHABVQString@@0@Z @ 1676 NONAME ; bool QDeclarativeEngineDebug::setMethodBody(int, class QString const &, class QString const &) + ?resetBindingForObject@QDeclarativeEngineDebug@@QAE_NHABVQString@@@Z @ 1677 NONAME ; bool QDeclarativeEngineDebug::resetBindingForObject(int, class QString const &) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 083e07f30d..dd5103fe3c 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1706,4 +1706,5 @@ EXPORTS _ZN25QDeclarativeImageProviderC1ENS_9ImageTypeE @ 1705 NONAME _ZN25QDeclarativeImageProviderC2ENS_9ImageTypeE @ 1706 NONAME _ZNK25QDeclarativeImageProvider9imageTypeEv @ 1707 NONAME + _ZN23QDeclarativeEngineDebug21resetBindingForObjectEiRK7QString @ 1708 NONAME -- cgit v1.2.1 From ea6a5146397b668bf535ee7249bd4262d6185234 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 14 Jul 2010 12:02:08 +0200 Subject: Work around memory leak issue in grid and linear layouts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These classes create a new QWidget and assign it to a static pointer which is never cleaned up. Using Q_GLOBAL_STATIC ensures that they are deleted on library unload. This is really just a cosmetic change that removes a leak warning - the real fix should be to find a way to not use a new QWidget like this. It seems odd that QGraphicsLayouts, which don't use QWidget in any other way, should depend on QWidget like this. Task-number: QTBUG-10768 Merge-request: 741 Reviewed-by: Jan-Arve Sæther --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 7 +++---- src/gui/graphicsview/qgraphicslinearlayout.cpp | 7 +++---- tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 7 +++++++ tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 7 +++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 83db3ec124..062b5ac5f9 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -94,14 +94,13 @@ public: #endif }; +Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget); + QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const { - static QWidget *wid = 0; - if (!wid) - wid = new QWidget; QGraphicsItem *item = parentItem(); QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : QApplication::style(); - return QLayoutStyleInfo(style, wid); + return QLayoutStyleInfo(style, globalStyleInfoWidget()); } /*! diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index b82872240c..37408efc69 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -171,14 +171,13 @@ int QGraphicsLinearLayoutPrivate::gridColumn(int index) const return int(qMin(uint(index), uint(engine.columnCount()))); } +Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget) + QLayoutStyleInfo QGraphicsLinearLayoutPrivate::styleInfo() const { - static QWidget *wid = 0; - if (!wid) - wid = new QWidget; QGraphicsItem *item = parentItem(); QStyle *style = (item && item->isWidget()) ? static_cast(item)->style() : QApplication::style(); - return QLayoutStyleInfo(style, wid); + return QLayoutStyleInfo(style, globalStyleInfoWidget()); } /*! diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index b9a5c66edd..d1d6860ba8 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -105,6 +105,7 @@ private slots: void geometries_data(); void geometries(); void avoidRecursionInInsertItem(); + void styleInfoLeak(); void task236367_maxSizeHint(); }; @@ -2196,6 +2197,12 @@ void tst_QGraphicsGridLayout::avoidRecursionInInsertItem() QCOMPARE(layout->count(), 0); } +void tst_QGraphicsGridLayout::styleInfoLeak() +{ + QGraphicsGridLayout grid; + grid.horizontalSpacing(); +} + void tst_QGraphicsGridLayout::task236367_maxSizeHint() { QGraphicsWidget *widget = new QGraphicsWidget; diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index c26e5d4aec..6107fa11e7 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -102,6 +102,7 @@ private slots: void layoutDirection(); void removeLayout(); void avoidRecursionInInsertItem(); + void styleInfoLeak(); // Task specific tests void task218400_insertStretchCrash(); @@ -1443,6 +1444,12 @@ void tst_QGraphicsLinearLayout::avoidRecursionInInsertItem() QCOMPARE(layout->count(), 0); } +void tst_QGraphicsLinearLayout::styleInfoLeak() +{ + QGraphicsLinearLayout layout; + layout.spacing(); +} + void tst_QGraphicsLinearLayout::task218400_insertStretchCrash() { QGraphicsScene *scene = new QGraphicsScene; -- cgit v1.2.1 From b7f55ac9c1c6b87083c9dca3b5cbca211fdecaef Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Jul 2010 11:53:07 +0200 Subject: fix warning directive on gnuc --- bin/syncqt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/syncqt b/bin/syncqt index 11b1d7210a..c8cba30b48 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -843,7 +843,7 @@ foreach (@modules_to_sync) { my $warning_msg = 'Inclusion of header files from include/Qt is deprecated.'; $header_content = "#ifndef QT_NO_QT_INCLUDE_WARN\n" . " #if defined(__GNUC__)\n" . - " #pragma warning \"$warning_msg\"\n" . + " #warning \"$warning_msg\"\n" . " #elif defined(_MSC_VER)\n" . " #pragma message \"WARNING: $warning_msg\"\n" . " #endif\n". -- cgit v1.2.1 From 74d0482c1690211a20bdfc996aa0ad30fdb9bb28 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Jul 2010 11:55:27 +0200 Subject: fix qconfig.h aliased header creation don't have configure create the forwarding headers (or symlinks on unix) for qconfig.h, but instead have syncqt create forwarding headers for not yet existing files. Reviewed-by: joerg --- bin/syncqt | 2 ++ configure | 5 ----- tools/configure/configureapp.cpp | 10 ---------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index c8cba30b48..fb5c8d8c7b 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -691,6 +691,7 @@ my @ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dis my @ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h" ); my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtDesigner}", "$modules{QtUiTools}", "$modules{QtDBus}", "$modules{phonon}" ); my %colliding_headers = (); +my %inject_headers = ( "$basedir/src/corelib/global" => ( "qconfig.h" ) ); foreach (@modules_to_sync) { #iteration info @@ -800,6 +801,7 @@ foreach (@modules_to_sync) { foreach (@subdirs) { my $subdir = "$_"; my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); + push @headers, $inject_headers{$subdir} if (defined $inject_headers{$subdir}); foreach (@headers) { my $header = "$_"; $header = 0 if("$header" =~ /^ui_.*.h/); diff --git a/configure b/configure index 166f2013f4..62e0863a6c 100755 --- a/configure +++ b/configure @@ -4481,11 +4481,6 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; fi mv -f "$QMAKE_QCONFIG_H" "$QCONFIG_H" - for conf in "$outpath/include/QtCore/qconfig.h" "$outpath/include/Qt/qconfig.h"; do - if [ '!' -f "$conf" ]; then - ln -s "$QCONFIG_H" "$conf" - fi - done #mkspecs/default is used as a (gasp!) default mkspec so QMAKESPEC needn't be set once configured rm -f mkspecs/default diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index d3dec3c92b..7f2d53bd44 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3164,16 +3164,6 @@ void Configure::generateConfigfiles() QFile::remove(outName); tmpFile.copy(outName); tmpFile.close(); - - if (!QFile::exists(buildPath + "/include/QtCore/qconfig.h")) { - if (!writeToFile("#include \"../../src/corelib/global/qconfig.h\"\n", - buildPath + "/include/QtCore/qconfig.h") - || !writeToFile("#include \"../../src/corelib/global/qconfig.h\"\n", - buildPath + "/include/Qt/qconfig.h")) { - dictionary["DONE"] = "error"; - return; - } - } } // Copy configured mkspec to default directory, but remove the old one first, if there is any -- cgit v1.2.1 From 56e24c99ee7a1b5b127b93cbab98f88e008ec9b8 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 14 Jul 2010 13:03:48 +0200 Subject: Crash while runnig tst_QMdiSubWindow::emittingOfSignals test on Cocoa We were assuming that the native windows we create will always have a corresponding QWidget. This is not the case for qt_root_win. Reviewed-by: Carlos Duclos --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 86528160eb..679514946c 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -85,6 +85,8 @@ QT_END_NAMESPACE - (BOOL)canBecomeKeyWindow { QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; + if (!widget) + return NO; // This should happen only for qt_root_win bool isToolTip = (widget->windowType() == Qt::ToolTip); bool isPopup = (widget->windowType() == Qt::Popup); @@ -94,6 +96,8 @@ QT_END_NAMESPACE - (BOOL)canBecomeMainWindow { QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; + if (!widget) + return NO; // This should happen only for qt_root_win bool isToolTip = (widget->windowType() == Qt::ToolTip); bool isPopup = (widget->windowType() == Qt::Popup); -- cgit v1.2.1 From 247e3637c41cc14d174a1170957274fb8a9400b4 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 14 Jul 2010 13:52:39 +0200 Subject: Drag and drop cursor doesnot change on invalid drop areas (Cocoa) Previos versions of Mac OS X (< 10.6) didn't have support for such 'Not Allowed' cursors. 10.6 introduced a new method for NSCursor called operationNotAllowedCursor. This fix uses the new cusor on available platforms. Task-number: QTBUG-5186 Reviewed-by: Denis --- src/gui/kernel/qcocoaview_mac.mm | 38 +++++++++++++++++++++++++++++++++++--- src/gui/kernel/qcocoaview_mac_p.h | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 5c90e2ece5..1935531736 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -269,6 +269,28 @@ static int qCocoaViewCount = 0; dropData = new QCocoaDropData(dropPasteboard); } +- (void)changeDraggingCursor:(NSDragOperation)newOperation +{ + static SEL action = nil; + static bool operationSupported = false; + if (action == nil) { + action = NSSelectorFromString(@"operationNotAllowedCursor"); + if ([NSCursor respondsToSelector:action]) { + operationSupported = true; + } + } + if (operationSupported) { + NSCursor *notAllowedCursor = [NSCursor performSelector:action]; + bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor); + if (newOperation == NSDragOperationNone && !isNotAllowedCursor) { + [notAllowedCursor push]; + } else if (newOperation != NSDragOperationNone && isNotAllowedCursor) { + [notAllowedCursor pop]; + } + + } +} + - (NSDragOperation)draggingEntered:(id )sender { // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly @@ -300,6 +322,7 @@ static int qCocoaViewCount = 0; if (!qDEEvent.isAccepted()) { // widget is not interested in this drag, so ignore this drop data. [self removeDropData]; + [self changeDraggingCursor:NSDragOperationNone]; return NSDragOperationNone; } else { // save the mouse position, used by draggingExited handler. @@ -321,6 +344,7 @@ static int qCocoaViewCount = 0; nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction()); } QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent); + [self changeDraggingCursor:nsActions]; return nsActions; } } @@ -335,16 +359,21 @@ static int qCocoaViewCount = 0; if (dragEnterSequence != [sender draggingSequenceNumber]) [self draggingEntered:sender]; // drag enter event was rejected, so ignore the move event. - if (dropData == 0) + if (dropData == 0) { + [self changeDraggingCursor:NSDragOperationNone]; return NSDragOperationNone; + } // return last value, if we are still in the answerRect. NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; NSDragOperation nsActions = [sender draggingSourceOperationMask]; QPoint posDrag(localPoint.x, localPoint.y); if (qt_mac_mouse_inside_answer_rect(posDrag) - && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) - return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); + && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) { + NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); + [self changeDraggingCursor:operation]; + return operation; + } // send drag move event to the widget QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions); @@ -373,6 +402,7 @@ static int qCocoaViewCount = 0; qDMEvent.setDropAction(Qt::IgnoreAction); } qt_mac_copy_answer_rect(qDMEvent); + [self changeDraggingCursor:operation]; return operation; } @@ -388,6 +418,8 @@ static int qCocoaViewCount = 0; QApplication::sendEvent(qwidget, &de); [self removeDropData]; } + [self changeDraggingCursor:NSDragOperationEvery]; + } - (BOOL)performDragOperation:(id )sender diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index 33aaa24f8b..b6b63ca3ca 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -106,6 +106,7 @@ Q_GUI_EXPORT - (void) qt_clearQWidget; - (BOOL)qt_leftButtonIsRightButton; - (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped; +- (void)changeDraggingCursor:(NSDragOperation)newOperation; + (DnDParams*)currentMouseEvent; @end -- cgit v1.2.1 From 21fbfdb2acdc368c047d14004373d2d0baa6c0b1 Mon Sep 17 00:00:00 2001 From: Leandro Melo Date: Wed, 14 Jul 2010 16:33:49 +0200 Subject: Docs: HTML comments marks so Creator can extract data efficiently. Reviewed-by: Martin Smith --- tools/qdoc3/htmlgenerator.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++- tools/qdoc3/htmlgenerator.h | 7 ++++++ tools/qdoc3/node.cpp | 18 ++++++++++++++++ tools/qdoc3/node.h | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 89b1e9853c..16c5eb2d61 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1382,12 +1382,14 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, out() << "
    \n"; if (!inner->doc().isEmpty()) { + generateExtractionMark(inner, DetailedDescriptionMark); //out() << "
    \n" out() << "
    \n" // QTBUG-9504 << "

    " << "Detailed Description" << "

    \n"; generateBody(inner, marker); out() << "
    \n"; // QTBUG-9504 generateAlsoList(inner, marker); + generateExtractionMark(inner, EndMark); } sections = marker->sections(inner, CodeMarker::Detailed, CodeMarker::Okay); @@ -1593,12 +1595,14 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) ++s; } + generateExtractionMark(fake, DetailedDescriptionMark); out() << "
    \n"; out() << "

    " << "Detailed Description" << "

    \n"; generateBody(fake, marker); if (cn) generateQmlText(cn->doc().body(), cn, marker, fake->name()); generateAlsoList(fake, marker); + generateExtractionMark(fake, EndMark); //out() << "
    \n"; sections = marker->qmlSections(qml_cn,CodeMarker::Detailed); @@ -1631,16 +1635,20 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) Text brief = fake->doc().briefText(); if (fake->subType() == Node::Module && !brief.isEmpty()) { + generateExtractionMark(fake, DetailedDescriptionMark); out() << "
    \n"; out() << "
    \n"; // QTBUG-9504 out() << "

    " << "Detailed Description" << "

    \n"; } - else + else { + generateExtractionMark(fake, DetailedDescriptionMark); out() << "
    \n"; // QTBUG-9504 + } generateBody(fake, marker); out() << "
    \n"; // QTBUG-9504 generateAlsoList(fake, marker); + generateExtractionMark(fake, EndMark); if (!fake->groupMembers().isEmpty()) { NodeMap groupMembersMap; @@ -1913,6 +1921,7 @@ void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, { Text brief = node->doc().briefText(); if (!brief.isEmpty()) { + generateExtractionMark(node, BriefMark); out() << "

    "; generateText(brief, node, marker); if (!relative || node == relative) @@ -1920,6 +1929,7 @@ void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, else out() << " More...

    \n"; + generateExtractionMark(node, EndMark); } } @@ -3504,6 +3514,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, #ifdef GENERATE_MAC_REFS generateMacRef(node, marker); #endif + generateExtractionMark(node, MemberMark); if (node->type() == Node::Enum && (enume = static_cast(node))->flagsType()) { #ifdef GENERATE_MAC_REFS @@ -3566,6 +3577,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, } } generateAlsoList(node, marker); + generateExtractionMark(node, EndMark); } void HtmlGenerator::findAllClasses(const InnerNode *node) @@ -4148,6 +4160,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, #ifdef GENERATE_MAC_REFS generateMacRef(node, marker); #endif + generateExtractionMark(node, MemberMark); out() << "
    "; if (node->subType() == Node::QmlPropertyGroup) { const QmlPropGroupNode* qpgn = static_cast(node); @@ -4219,6 +4232,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, generateAlsoList(node, marker); out() << "
    "; out() << "
    "; + generateExtractionMark(node, EndMark); } /*! @@ -4457,6 +4471,40 @@ void HtmlGenerator::generatePageIndex(const QString& fileName, CodeMarker* marke file.close(); } +void HtmlGenerator::generateExtractionMark(const Node *node, ExtractionMarkType markType) +{ + if (markType != EndMark) { + out() << "\n"; + } else { + out() << "\n"; + } +} + #endif #if 0 // fossil removed for new doc format MWS 19/04/2010 diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 80341def61..c8ede634bc 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -123,6 +123,12 @@ class HtmlGenerator : public PageGenerator private: enum SubTitleSize { SmallSubTitle, LargeSubTitle }; + enum ExtractionMarkType { + BriefMark, + DetailedDescriptionMark, + MemberMark, + EndMark + }; const QPair anchorForNode(const Node *node); const Node *findNodeForTarget(const QString &target, @@ -268,6 +274,7 @@ class HtmlGenerator : public PageGenerator CodeMarker* marker) const; void generatePageIndex(const QString& fileName, CodeMarker* marker) const; + void generateExtractionMark(const Node *node, ExtractionMarkType markType); #if 0 NavigationBar currentNavigationBar; diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index b0770740ac..af129eda7b 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1245,6 +1245,24 @@ QStringList FunctionNode::parameterNames() const return names; } +/*! + Returns a raw list of parameters. If \a names is true, the + names are included. If \a values is true, the default values + are included, if any are present. + */ +QString FunctionNode::rawParameters(bool names, bool values) const +{ + QString raw; + foreach (const Parameter ¶meter, parameters()) { + raw += parameter.leftType() + parameter.rightType(); + if (names) + raw += parameter.name(); + if (values) + raw += parameter.defaultValue(); + } + return raw; +} + /*! Returns the list of reconstructed parameters. If \a values is true, the default values are included, if any are present. diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index e9f2d74605..121b818179 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -616,6 +616,7 @@ class FunctionNode : public LeafNode int numOverloads() const; const QList& parameters() const { return params; } QStringList parameterNames() const; + QString rawParameters(bool names = false, bool values = false) const; const FunctionNode* reimplementedFrom() const { return rf; } const QList &reimplementedBy() const { return rb; } const PropertyNode* associatedProperty() const { return ap; } -- cgit v1.2.1 From 00b7befbc003682a351c18d90436010efd26ece5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Jul 2010 16:26:19 +0200 Subject: fix qconfig.h reference for shadow builds Reviewed-by: joerg --- bin/syncqt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/syncqt b/bin/syncqt index fb5c8d8c7b..03659d3b74 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -691,7 +691,7 @@ my @ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dis my @ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h" ); my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtDesigner}", "$modules{QtUiTools}", "$modules{QtDBus}", "$modules{phonon}" ); my %colliding_headers = (); -my %inject_headers = ( "$basedir/src/corelib/global" => ( "qconfig.h" ) ); +my %inject_headers = ( "$basedir/src/corelib/global" => ( "*qconfig.h" ) ); foreach (@modules_to_sync) { #iteration info @@ -804,6 +804,7 @@ foreach (@modules_to_sync) { push @headers, $inject_headers{$subdir} if (defined $inject_headers{$subdir}); foreach (@headers) { my $header = "$_"; + my $shadow = ($header =~ s/^\*//); $header = 0 if("$header" =~ /^ui_.*.h/); foreach (@ignore_headers) { $header = 0 if("$header" eq "$_"); @@ -821,6 +822,7 @@ foreach (@modules_to_sync) { } my $iheader = $subdir . "/" . $header; + $iheader =~ s/^\Q$basedir\E/$out_basedir/ if ($shadow); my @classes = $public_header ? classNames($iheader) : (); if($showonly) { print "$header [$lib]\n"; -- cgit v1.2.1 From 4e2eb2945dbc3865e2901f12d663ed89e8f0dfbf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 14 Jul 2010 18:35:09 +0200 Subject: Compile with QT_NO_DEBUG_STREAM Task-number: QTBUG-11510 --- src/gui/styles/qstyle.cpp | 4 ++-- src/gui/styles/qstyle.h | 2 ++ src/gui/styles/qstyleoption.cpp | 6 ++---- src/gui/styles/qstyleoption.h | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 4cfa93f88f..676483e494 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -2421,9 +2421,9 @@ QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, QStyle::State state) { -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyle::State("; QStringList states; @@ -2455,9 +2455,9 @@ QDebug operator<<(QDebug debug, QStyle::State state) qSort(states); debug << states.join(QLatin1String(" | ")); debug << ')'; -#endif return debug; } +#endif /*! \since 4.6 diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index 439d62618a..1ee262d5c3 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -878,7 +878,9 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls) +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state); +#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index c057a2b2ea..eeab316785 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -5419,9 +5419,9 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T Returns a T or 0 depending on the type of \a hint. */ +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) { -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) switch (optionType) { case QStyleOption::SO_Default: debug << "SO_Default"; break; @@ -5482,21 +5482,19 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) case QStyleOption::SO_GraphicsItem: debug << "SO_GraphicsItem"; break; } -#endif return debug; } QDebug operator<<(QDebug debug, const QStyleOption &option) { -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyleOption("; debug << QStyleOption::OptionType(option.type); debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); debug << ',' << option.state; debug << ',' << option.rect; debug << ')'; -#endif return debug; } +#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index 95de8d50ac..005b36afa5 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -958,8 +958,10 @@ T qstyleoption_cast(QStyleHintReturn *hint) return 0; } +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType); Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option); +#endif QT_END_NAMESPACE -- cgit v1.2.1 From 6536b6f16ff26579f191543e5d468a6382211a29 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 14 Jul 2010 23:43:58 +0200 Subject: Add unit tests for QMimeData. Merge-request: 2428 Reviewed-by: Andreas Kling --- tests/auto/gui.pro | 1 + tests/auto/qmimedata/qmimedata.pro | 4 + tests/auto/qmimedata/tst_qmimedata.cpp | 343 +++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 tests/auto/qmimedata/qmimedata.pro create mode 100644 tests/auto/qmimedata/tst_qmimedata.cpp diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index cfaa3fa0bf..2d9ea937a2 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -112,6 +112,7 @@ SUBDIRS=\ qmdisubwindow \ qmessagebox \ qmetaobject \ + qmimedata \ qmouseevent_modal \ qmovie \ qnetworkaccessmanager_and_qprogressdialog \ diff --git a/tests/auto/qmimedata/qmimedata.pro b/tests/auto/qmimedata/qmimedata.pro new file mode 100644 index 0000000000..13fbe65edc --- /dev/null +++ b/tests/auto/qmimedata/qmimedata.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qmimedata.cpp + + diff --git a/tests/auto/qmimedata/tst_qmimedata.cpp b/tests/auto/qmimedata/tst_qmimedata.cpp new file mode 100644 index 0000000000..be7a654f84 --- /dev/null +++ b/tests/auto/qmimedata/tst_qmimedata.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include + +class tst_QMimeData : public QObject +{ + Q_OBJECT +public: + tst_QMimeData() + { + } + +private slots: + void clear() const; + void colorData() const; + void data() const; + void formats() const; + void hasColor() const; + void hasFormat() const; + void hasHtml() const; + void hasImage() const; + // hasText() covered by setText() + // hasUrls() covered by setUrls() + // html() covered by setHtml() + void imageData() const; + void removeFormat() const; + // setColorData() covered by hasColor() + // setData() covered in a few different tests + void setHtml() const; + // setImageData() covered in a few tests + void setText() const; + void setUrls() const; + // text() covered in setText() + // urls() covered by setUrls() +}; + +void tst_QMimeData::clear() const +{ + QMimeData mimeData; + + // set, clear, verify empty + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasText()); + mimeData.clear(); + QVERIFY(mimeData.hasText() == false); + + // repopulate, verify not empty + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasText()); +} + +void tst_QMimeData::colorData() const +{ + QMimeData mimeData; + QColor red = Qt::red; + QColor blue = Qt::blue; + + // set, verify + mimeData.setColorData(red); + QVERIFY(mimeData.hasColor()); + QCOMPARE(qvariant_cast(mimeData.colorData()), red); + + // change, verify + mimeData.setColorData(Qt::blue); + QVERIFY(mimeData.hasColor()); + QCOMPARE(qvariant_cast(mimeData.colorData()), blue); +} + +void tst_QMimeData::data() const +{ + QMimeData mimeData; + + // set text, verify + mimeData.setData("text/plain", "pirates"); + QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); + QVERIFY(mimeData.data("text/html").length() == 0); + + // html time + mimeData.setData("text/html", "ninjas"); + QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas")); + QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); // make sure text not damaged + QCOMPARE(mimeData.data("text/html"), mimeData.html().toLatin1()); +} + +void tst_QMimeData::formats() const +{ + QMimeData mimeData; + + // set text, verify + mimeData.setData("text/plain", "pirates"); + QCOMPARE(mimeData.formats(), QStringList() << "text/plain"); + + // set html, verify + mimeData.setData("text/html", "ninjas"); + QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html"); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.formats(), QStringList()); + + // set an odd format, verify + mimeData.setData("foo/bar", "somevalue"); + QCOMPARE(mimeData.formats(), QStringList() << "foo/bar"); +} + +void tst_QMimeData::hasColor() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasColor() == false); + + // set, verify + mimeData.setColorData(QColor(Qt::red)); + QVERIFY(mimeData.hasColor()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasColor() == false); + + // set something else, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasColor() == false); +} + +void tst_QMimeData::hasFormat() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasFormat("text/plain") == false); + + // add, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasFormat("text/plain")); + QVERIFY(mimeData.hasFormat("text/html") == false); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html") == false); +} + +void tst_QMimeData::hasHtml() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasHtml() == false); + + // add plain, verify false + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasHtml() == false); + + // add html, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasHtml()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasHtml() == false); + + // readd, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasHtml()); +} + +void tst_QMimeData::hasImage() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasImage() == false); + + // add text, verify false + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasImage() == false); + + // add image + mimeData.setImageData(QImage()); + QVERIFY(mimeData.hasImage()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasImage() == false); +} + +void tst_QMimeData::imageData() const +{ + QMimeData mimeData; + + // initial state + QCOMPARE(mimeData.imageData(), QVariant()); + + // set, test + mimeData.setImageData(QImage()); + QVERIFY(mimeData.hasImage()); + QCOMPARE(mimeData.imageData(), QVariant(QImage())); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.imageData(), QVariant()); +} + +void tst_QMimeData::removeFormat() const +{ + QMimeData mimeData; + + // add, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasFormat("text/plain")); + + // add another, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasFormat("text/html")); + + // remove, verify + mimeData.removeFormat("text/plain"); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html")); + + // remove, verify + mimeData.removeFormat("text/html"); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html") == false); +} + +void tst_QMimeData::setHtml() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasHtml() == false); + + // add html, verify + mimeData.setHtml("ninjas"); + QVERIFY(mimeData.hasHtml()); + QCOMPARE(mimeData.html(), QLatin1String("ninjas")); + + // reset html + mimeData.setHtml("pirates"); + QVERIFY(mimeData.hasHtml()); + QCOMPARE(mimeData.html(), QLatin1String("pirates")); +} + +void tst_QMimeData::setText() const +{ + QMimeData mimeData; + + // verify initial state + QCOMPARE(mimeData.text(), QLatin1String("")); + QVERIFY(mimeData.hasText() == false); + + // set, verify + mimeData.setText("pirates"); + QVERIFY(mimeData.hasText()); + QCOMPARE(mimeData.text(), QLatin1String("pirates")); + QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain")); + + // reset, verify + mimeData.setText("ninjas"); + QVERIFY(mimeData.hasText()); + QCOMPARE(mimeData.text(), QLatin1String("ninjas")); + QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain")); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.text(), QLatin1String("")); + QVERIFY(mimeData.hasText() == false); +} + +void tst_QMimeData::setUrls() const +{ + QMimeData mimeData; + QList shortUrlList; + QList longUrlList; + + // set up + shortUrlList += QUrl("http://qt.nokia.com"); + longUrlList = shortUrlList; + longUrlList += QUrl("http://www.google.com"); + + // verify initial state + QVERIFY(mimeData.hasUrls() == false); + + // set a few, verify + mimeData.setUrls(shortUrlList); + QCOMPARE(mimeData.urls(), shortUrlList); + + // change them, verify + mimeData.setUrls(longUrlList); + QCOMPARE(mimeData.urls(), longUrlList); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasUrls() == false); +} + + +QTEST_MAIN(tst_QMimeData) +#include "tst_qmimedata.moc" -- cgit v1.2.1 From adbdb6c4b52d72e77d1cb4ff23573e957a7c9e14 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 15 Jul 2010 12:18:58 +1000 Subject: Performance docs. --- doc/src/declarative/qdeclarativeperformance.qdoc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc index 26c1e8959c..be8c029aef 100644 --- a/doc/src/declarative/qdeclarativeperformance.qdoc +++ b/doc/src/declarative/qdeclarativeperformance.qdoc @@ -115,4 +115,25 @@ provide an image that includes the frame and the shadow. Avoid running JavaScript during animation. For example, running a complex JavaScript expression for each frame of an x property animation. +\section1 Rendering + +Often using a different graphics system will give superior performance to the native +graphics system (this is especially the case on X11). This can be configured using +QApplication::setGraphicsSystem() or via the command line using the \c -graphicssystem +switch. + +You can enable OpenGL acceleration using the \c opengl graphics system, or by setting a +QGLWidget as the viewport of your QDeclarativeView. + +You may need to try various options to find what works the best for your application. +For embedded X11-based devices one recommended combination is to use the raster graphics +system with a QGLWidget for the viewport. While this doesn't guarantee the \bold fastest +performance for all use-cases, it typically has \bold{consistently good} performance for +all use-cases. In contrast, only using the raster paint engine may result in very good +performance for parts of your application and very poor performance elsewhere. + +The QML Viewer uses the raster graphics system by default for X11 and OS X. It also +includes a \c -opengl command line option which sets a QGLWidget as the viewport of the +view. On OS X, a QGLWidget is always used. + */ -- cgit v1.2.1 From 8ed72a96bc5c3af283f8ca4460adae9d4b466479 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Jul 2010 09:48:45 +1000 Subject: Text element does not clip even with clip=true Task: QTBUG-12201 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- src/declarative/graphicsitems/qdeclarativetext.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 190b22cbec..ddaeb05305 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2503,7 +2503,7 @@ QDeclarativeListProperty QDeclarativeItemPrivate::transi \qmlproperty bool Item::clip This property holds whether clipping is enabled. - if clipping is enabled, an item will clip its own painting, as well + If clipping is enabled, an item will clip its own painting, as well as the painting of its children, to its bounding rectangle. Non-rectangular clipping regions are not supported for performance reasons. diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 9a281e59b7..ba4fa21ed0 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -1127,6 +1127,15 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } +/*! + \qmlproperty bool Text::clip + This property holds whether the text is clipped. + + Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. + + If you want to display potentially long text in a limited space, you probably want to use \c elide instead. +*/ + void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); @@ -1146,13 +1155,10 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid bool needClip = clip() && (d->imgCache.width() > width() || d->imgCache.height() > height()); - if (needClip) { - p->save(); - p->setClipRect(boundingRect(), Qt::IntersectClip); - } - p->drawPixmap(br.x(), br.y(), d->imgCache); if (needClip) - p->restore(); + p->drawPixmap(0, 0, width(), height(), d->imgCache, -br.x(), -br.y(), width(), height()); + else + p->drawPixmap(br.x(), br.y(), d->imgCache); if (d->smooth) { p->setRenderHint(QPainter::Antialiasing, oldAA); @@ -1166,7 +1172,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid if (needClip) { p->save(); - p->setClipRect(boundingRect(), Qt::IntersectClip); + p->setClipRect(0, 0, width(), height(), Qt::IntersectClip); } if (d->richText) { QAbstractTextDocumentLayout::PaintContext context; -- cgit v1.2.1 From b78e46817e5e2d9bd6a8d83b1447a6c4e941a5b3 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 13:00:45 +1000 Subject: Change tutorial from using "Musician" etc. types to using "PieChart" etc. types to make a more practical example that shows how to do painting as well. Also includes some tutorial improvments. --- doc/src/declarative/extending-tutorial.qdoc | 255 ++++++++++++--------- .../tutorials/extending/chapter1-basics/app.qml | 18 +- .../extending/chapter1-basics/chapter1-basics.pro | 4 +- .../tutorials/extending/chapter1-basics/main.cpp | 4 +- .../extending/chapter1-basics/musician.cpp | 66 ------ .../tutorials/extending/chapter1-basics/musician.h | 68 ------ .../extending/chapter1-basics/piechart.cpp | 81 +++++++ .../tutorials/extending/chapter1-basics/piechart.h | 71 ++++++ .../tutorials/extending/chapter2-methods/app.qml | 24 +- .../chapter2-methods/chapter2-methods.pro | 4 +- .../tutorials/extending/chapter2-methods/main.cpp | 4 +- .../extending/chapter2-methods/musician.cpp | 74 ------ .../extending/chapter2-methods/musician.h | 81 ------- .../extending/chapter2-methods/piechart.cpp | 87 +++++++ .../extending/chapter2-methods/piechart.h | 84 +++++++ .../tutorials/extending/chapter3-bindings/app.qml | 42 ++-- .../chapter3-bindings/chapter3-bindings.pro | 4 +- .../tutorials/extending/chapter3-bindings/main.cpp | 4 +- .../extending/chapter3-bindings/musician.cpp | 76 ------ .../extending/chapter3-bindings/musician.h | 82 ------- .../extending/chapter3-bindings/piechart.cpp | 89 +++++++ .../extending/chapter3-bindings/piechart.h | 84 +++++++ .../extending/chapter4-customPropertyTypes/app.qml | 18 +- .../chapter4-customPropertyTypes.pro | 8 +- .../chapter4-customPropertyTypes/instrument.cpp | 56 ----- .../chapter4-customPropertyTypes/instrument.h | 63 ----- .../chapter4-customPropertyTypes/main.cpp | 8 +- .../chapter4-customPropertyTypes/musician.cpp | 67 ------ .../chapter4-customPropertyTypes/musician.h | 78 ------- .../chapter4-customPropertyTypes/piechart.cpp | 72 ++++++ .../chapter4-customPropertyTypes/piechart.h | 78 +++++++ .../chapter4-customPropertyTypes/pieslice.cpp | 68 ++++++ .../chapter4-customPropertyTypes/pieslice.h | 66 ++++++ .../tutorials/extending/chapter5-plugins/app.qml | 16 +- .../chapter5-plugins/chapter5-plugins.pro | 12 +- .../extending/chapter5-plugins/chartsplugin.cpp | 54 +++++ .../extending/chapter5-plugins/chartsplugin.h | 55 +++++ .../extending/chapter5-plugins/instrument.cpp | 56 ----- .../extending/chapter5-plugins/instrument.h | 61 ----- .../extending/chapter5-plugins/musician.cpp | 67 ------ .../extending/chapter5-plugins/musician.h | 68 ------ .../extending/chapter5-plugins/musicplugin.cpp | 54 ----- .../extending/chapter5-plugins/musicplugin.h | 55 ----- .../extending/chapter5-plugins/piechart.cpp | 68 ++++++ .../extending/chapter5-plugins/piechart.h | 68 ++++++ .../extending/chapter5-plugins/pieslice.cpp | 67 ++++++ .../extending/chapter5-plugins/pieslice.h | 64 ++++++ 47 files changed, 1401 insertions(+), 1252 deletions(-) delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/musician.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/musician.h create mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/musician.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/musician.h create mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/musician.h create mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h create mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h create mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp create mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/instrument.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/musician.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/piechart.h create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index 2cf00b9425..9170c5c94f 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -59,61 +59,94 @@ Tutorial chapters: \example declarative/tutorials/extending/chapter1-basics -Let's create a new QML type called "Musician" that has two properties: a name -and an instrument. We will make it available in a \l {Modules}{module} called "Music", with +A common task when extending QML is to provide a new QML type that supports some + custom functionality beyond what is provided by the built-in \l {QML Elements}. +For example, this could be done to implement particular data models, or provide +elements with custom painting and drawing capabilities, or access system features +like network programming that are not accessible through built-in QML features. + +In this tutorial, we will show how to use the C++ classes in the QtDeclarative +module to extend QML. The end result will be a simple Pie Chart display implemented by +several custom QML types connected together through QML features like bindings and +signals, and made available to the QML runtime through a plugin. + +To begin with, let's create a new QML type called "PieChart" that has two properties: a name +and a color. We will make it available in a \l {Modules}{module} called "Charts", with a module version of 1.0. -We want this \c Musician type to be usable from QML like this: + +We want this \c PieChart type to be usable from QML like this: \code - import Music 1.0 + import Charts 1.0 - Musician { - name: "Reddy the Rocker" - instrument: "Guitar" + PieChart { + width: 100; height: 100 + name: "A simple pie chart" + color: "red" } \endcode -To do this, we need a C++ class that encapsulates this \c Musician type and its two -properties. Since QML relies heavily on Qt's \l{Meta-Object System}{meta object system}, +To do this, we need a C++ class that encapsulates this \c PieChart type and its two +properties. Since QML makes extensive use of Qt's \l{Meta-Object System}{meta object system}, this new class must: \list -\o inherit from QObject -\o declare its properties using the Q_PROPERTY() macro +\o Inherit from QObject +\o Declare its properties using the Q_PROPERTY macro \endlist -Here is our \c Musician class, defined in \c musician.h: +Here is our \c PieChart class, defined in \c piechart.h: + +\snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 -\snippet declarative/tutorials/extending/chapter1-basics/musician.h 0 +The class inherits from QDeclarativeItem because we want to override +QDeclarativeItem::paint() in order to draw. If the class just represented some +data type and was not an item that actually needed to be displayed, it could simply inherit +from QObject. Or, if we want to extend the functionality of an existing QObject-based +class, it could inherit from that class instead. -It defines the two properties, \c name and \c instrument, with the Q_PROPERTY() macro. -The class implementation in \c musician.cpp simply sets and returns the \c m_name and -\c m_instrument values as appropriate. +The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, +and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp +simply sets and returns the \c m_name and \c m_color values as appropriate, and +implements \c paint() to draw a simple pie chart. It also turns off the +QGraphicsItem::ItemHasNoContents flag to enable painting: -Our QML file, \c app.qml, creates a \c Musician item and display the musician's details +\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 0 +\dots 0 +\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 1 + +Now that we have defined the \c PieChart type, we will use it from QML. The \c app.qml +file creates a \c PieChart item and display the pie chart's details using a standard QML \l Text item: \snippet declarative/tutorials/extending/chapter1-basics/app.qml 0 +Notice that although the color is specified as a string in QML, it is automatically +converted to a QColor object for the PieChart \c color property. Automatic conversions are +provided for various other \l {QML Basic Types}{basic types}; for example, a string +like "640x480" can be automatically converted to a QSize value. + We'll also create a C++ application that uses a QDeclarativeView to run and -display \c app.qml. The application must register the \c Musician type +display \c app.qml. The application must register the \c PieChart type using the qmlRegisterType() function, to allow it to be used from QML. If -you don't register the type, \c app.qml won't be able to create a \c Musician. +you don't register the type, \c app.qml won't be able to create a \c PieChart. Here is the application \c main.cpp: \snippet declarative/tutorials/extending/chapter1-basics/main.cpp 0 -This call to qmlRegisterType() registers the \c Musician type as a type called "Musician", in a module named "Music", +This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", in a module named "Charts", with a module version of 1.0. Lastly, we write a \c .pro project file that includes the files and the \c declarative library: \quotefile declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro -Now we can build and run the application. Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory. +Now we can build and run the application: -\example declarative/tutorials/extending/chapter1-basics +\image extending-tutorial-chapter1.png + +Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory. At the moment, the \c app.qml is run from within a C++ application. This may seem odd if you're used to running QML files with the \l {QML Viewer}. @@ -128,39 +161,40 @@ Later on, we'll show how to create a plugin so that you can run \c app.qml using \example declarative/tutorials/extending/chapter2-methods -Suppose we want \c Musician to have a "perform" method that prints a message -to the console and then emits a "performanceEnded" signal. -Other elements would be able to call \c perform() and receive -\c performanceEnded() signals like this: +Suppose we want \c PieChart to have a "clearChart()" method that erases the +chart and then emits a "chartCleared" signal. Our \c app.qml would be able +to call \c clearChart() and receive \c chartCleared() signals like this: \snippet declarative/tutorials/extending/chapter2-methods/app.qml 0 -To do this, we add a \c perform() method and a \c performanceEnded() signal +\image extending-tutorial-chapter2.png + +To do this, we add a \c clearChart() method and a \c chartCleared() signal to our C++ class: -\snippet declarative/tutorials/extending/chapter2-methods/musician.h 0 +\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 0 \dots -\snippet declarative/tutorials/extending/chapter2-methods/musician.h 1 +\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 1 \dots -\snippet declarative/tutorials/extending/chapter2-methods/musician.h 2 +\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 2 \dots -\snippet declarative/tutorials/extending/chapter2-methods/musician.h 3 +\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 3 -The use of Q_INVOKABLE makes the \c perform() method available to the +The use of Q_INVOKABLE makes the \c clearChart() method available to the Qt Meta-Object system, and in turn, to QML. Note that it could have been declared as as a Qt slot instead of using Q_INVOKABLE, as slots are also callable from QML. Both of these approaches are valid. -The \c perform() method simply prints a message to the console and -then emits \c performanceEnded(): +The \c clearChart() method simply changes the color to Qt::transparent, +repaints the chart, then emits the \c chartCleared() signal: -\snippet declarative/tutorials/extending/chapter2-methods/musician.cpp 0 +\snippet declarative/tutorials/extending/chapter2-methods/piechart.cpp 0 -Now when we run the application and click the window, the application outputs: +Now when we run the application and click the window, the pie chart +disappears, and the application outputs: \code - "Reddy the Rocker" is playing the "Guitar" - The performance has now ended + The chart has been cleared \endcode Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory. @@ -174,45 +208,49 @@ Try out the example yourself with the updated code in Qt's \c examples/tutorials Property bindings is a powerful feature of QML that allows values of different elements to be synchronized automatically. It uses signals to notify and update -other elements' values when property values change. +other elements' values when property values are changed. -Let's enable property bindings for the \c instrument property. That means +Let's enable property bindings for the \c color property. That means if we have code like this: \snippet declarative/tutorials/extending/chapter3-bindings/app.qml 0 -The "instrument: reddy.instrument" statement binds the \c instrument value of -\c craig to the \c instrument of \c reddy. -Whenever \c reddy's \c instrument value changes, \c craig's \c instrument value -updates to the same value. When the window is clicked, the application outputs: +\image extending-tutorial-chapter3.png -\code - "Reddy the Rocker" is playing the "Guitar" - "Craig the Copycat" is playing the "Guitar" - "Reddy the Rocker" is playing the "Drums" - "Craig the Copycat" is playing the "Drums" -\endcode +The "color: chartA.color" statement binds the \c color value of +\c chartB to the \c color of \c chartA. +Whenever \c chartA's \c color value changes, \c chartB's \c color value +updates to the same value. When the window is clicked, the \c onClicked +handler in the MouseArea changes the color of \c chartA, thereby changing +both charts to the color blue. -It's easy to enable property binding for the \c instrument property. -We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "instrumentChanged" signal +It's easy to enable property binding for the \c color property. +We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "colorChanged" signal is emitted whenever the value changes. -\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 0 +\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 0 \dots -\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 1 +\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 1 \dots -\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 2 +\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 2 \dots -\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 3 +\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 3 -Then, we emit this signal in \c setInstrument(): +Then, we emit this signal in \c setPieSlice(): -\snippet declarative/tutorials/extending/chapter3-bindings/musician.cpp 0 +\snippet declarative/tutorials/extending/chapter3-bindings/piechart.cpp 0 -It's important for \c setInstrument() to check that the instrument value has actually changed -before emitting \c instrumentChanged(). This ensures the signal is not emitted unnecessarily and +It's important for \c setColor() to check that the color value has actually changed +before emitting \c colorChanged(). This ensures the signal is not emitted unnecessarily and also prevents loops when other elements respond to the value change. +The use of bindings is essential to QML. You should always add NOTIFY +signals for properties if they are able to be implemented, so that your +properties can be used in bindings. Properties that cannot be bound cannot be +automatically updated and cannot be used as flexibly in QML. Also, since +bindings are invoked so often and relied upon in QML usage, users of your +custom QML types may see unexpected behavior if bindings are not implemented. + */ /*! @@ -220,19 +258,19 @@ also prevents loops when other elements respond to the value change. \example declarative/tutorials/extending/chapter4-customPropertyTypes -The \c Musician type currently has two properties that are both strings. -It could have all sorts of other properties. For example, we could add an -integer-type property to store the age of each musician: +The \c PieChart type currently has a string-type property and a color-type property. +It could have many other types of properties. For example, we could add an +integer-type property to store an identifier for each pie chart: \code - class Musician : public QObject + class PieChart : public QDeclarativeItem { ... - Q_PROPERTY(int age READ age WRITE setAge) + Q_PROPERTY(int id READ id WRITE setId) public: ... - int age() const; - void setAge(int age); + int id() const; + void setId(int id); ... }; \endcode @@ -257,31 +295,39 @@ types: If we want to create a property whose type is not supported by QML by default, we need to register the type with QML. -For example, let's change the type of the \c instrument property from a string to a -new type called "Instrument". Instead of assigning a string value to \c instrument, -we assign an \c Instrument value: +For example, let's replace the use of the \c property with a type called +"PieSlice" that has a \c color property. Instead of assigning a color, +we assign an \c PieSlice value which itself contains a \c color: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0 -Like \c Musician, this new \c Instrument type has to inherit from QObject and declare +Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares its properties with Q_PROPERTY(): -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h 0 +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0 -To use it from \c Musician, we modify the \c instrument property declaration +To use it in \c PieChart, we modify the \c color property declaration and associated method signatures: -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 0 +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 0 \dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 1 +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 1 \dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 2 +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 2 \dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 3 +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 3 + +There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice +is a visual item, so it must be set as a child of the \c PieChart using +QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child +item when its contents are drawn: -Like the \c Musician type, the \c Instrument type has to be registered -using qmlRegisterType() to be used from QML. As with \c Musician, we'll add the -type to the "Music" module, version 1.0: +\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0 + + +Like the \c PieChart type, the \c PieSlice type has to be registered +using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the +type to the "Charts" module, version 1.0: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0 \dots @@ -298,10 +344,10 @@ Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-custom \example declarative/tutorials/extending/chapter5-plugins -Currently the \c Musician and \c Instrument types are used by \c app.qml, +Currently the \c PieChart and \c PieSlice types are used by \c app.qml, which is displayed using a QDeclarativeView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available -to the QML engine. This means we could load \c app.qml using the \l {QML Viewer} +to the QML engine. This allows us to load \c app.qml using the \l {QML Viewer} (or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and loading our own C++ application. @@ -313,17 +359,17 @@ To create a plugin library, we need: \o A "qmldir" file that tells the QML engine to load the plugin \endlist -First, we create a plugin class named \c MusicPlugin. It subclasses QDeclarativeExtensionPlugin +First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. -Here is the \c MusicPlugin definition in \c musicplugin.h: +Here is the \c ChartsPlugin definition in \c chartsplugin.h: -\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.h 0 +\snippet declarative/tutorials/extending/chapter5-plugins/chartsplugin.h 0 -And its implementation in \c musicplugin.cpp: +And its implementation in \c chartsplugin.cpp: -\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp 0 +\snippet declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp 0 Then, we write a \c .pro project file that defines the project as a plugin library and specifies with DESTDIR that library files should be built into a "lib" subdirectory: @@ -345,9 +391,9 @@ the project and then load the QML file in the \l {QML Viewer}: (On Mac OS X, you can launch the "QMLViewer" application instead.) -Notice the "import Music 1.0" statement has disappeared from \c app.qml. This is +Notice the "import Charts 1.0" statement has disappeared from \c app.qml. This is because the \c qmldir file is in the same directory as \c app.qml: this is equivalent to -having Musician.qml and Instrument.qml files inside the project directory, which could both +having PieChart.qml and PieSlice.qml files inside the project directory, which could both be used by \c app.qml without import statements. */ @@ -367,42 +413,39 @@ In this tutorial, we've shown the basic steps for creating a QML extension: The \l {Extending QML in C++} reference documentation shows other useful features that can be added to -QML extensions. For example, we could use \l{Object and List Property Types}{list properties} to allow multiple instruments for a \c Musician: +QML extensions. For example, we could use \l{Object and List Property Types}{list properties} to allow multiple slices for a \c PieChart: \code - Musician { - instruments: [ - Instrument { type: "Guitar" } - Instrument { type: "Drums" } - Instrument { type: "Keyboard" } + PieChart { + slices: [ + PieSlice { color: "red" } + PieSlice { color: "blue" } + PieSlice { color: "yellow" } ] } \endcode Or use \l{Default Property}{default properties} and avoid an -\c instruments property altogether: +\c slices property altogether: \code - Musician { - Instrument { type: "Guitar" } - Instrument { type: "Drums" } - Instrument { type: "Keyboard" } + PieChart { + PieSlice { color: "red" } + PieSlice { color: "blue" } + PieSlice { color: "yellow" } } \endcode -Or even change the \c instrument of a \c Musician from time to time using \l{Property Value Sources}{property value sources}: +Or even change the \c color of a \c PieChart from time to time using \l{Property Value Sources}{property value sources}: \code - Musician { - InstrumentRandomizer on instrument {} + PieChart { + PieSliceRandomizer on color {} } \endcode See the \l{Extending QML in C++}{reference documentation} for more information. -Additionally, \l {Integrating QML with existing Qt UI code} shows how to create -and integrate with QML extensions that have drawing and graphical capabilities (through QGraphicsWidget). - */ diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml index 9af155cdc1..ada088d6d9 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml @@ -38,21 +38,23 @@ ** ****************************************************************************/ //![0] -import Music 1.0 +import Charts 1.0 import Qt 4.7 -Rectangle { +Item { width: 300; height: 200 - Musician { - id: aMusician - name: "Reddy the Rocker" - instrument: "Guitar" + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + name: "A simple pie chart" + color: "red" } Text { - anchors.fill: parent - text: aMusician.name + " plays the " + aMusician.instrument + 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 index bd05ebe2cc..0f0416718c 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -1,5 +1,5 @@ QT += declarative -HEADERS += musician.h -SOURCES += musician.cpp \ +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 index 8ef6965ea8..a5dbab32d2 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp +++ b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ //![0] -#include "musician.h" +#include "piechart.h" #include #include #include @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - qmlRegisterType("Music", 1, 0, "Musician"); + qmlRegisterType("Charts", 1, 0, "PieChart"); QDeclarativeView view; view.setSource(QUrl::fromLocalFile("app.qml")); diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp deleted file mode 100644 index 6c42f310b9..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musician.h" - -Musician::Musician(QObject *parent) - : QObject(parent) -{ -} - -QString Musician::name() const -{ - return m_name; -} - -void Musician::setName(const QString &name) -{ - m_name = name; -} - -QString Musician::instrument() const -{ - return m_instrument; -} - -void Musician::setInstrument(const QString &instrument) -{ - m_instrument = instrument; -} - diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.h b/examples/declarative/tutorials/extending/chapter1-basics/musician.h deleted file mode 100644 index f9a0537502..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/musician.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICIAN_H -#define MUSICIAN_H - -//![0] -#include - -class Musician : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString instrument READ instrument WRITE setInstrument) - -public: - Musician(QObject *parent = 0); - - QString name() const; - void setName(const QString &name); - - QString instrument() const; - void setInstrument(const QString &instrument); - -private: - QString m_name; - QString m_instrument; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp new file mode 100644 index 0000000000..3b9ef7160a --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} +//![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, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..aae7b26dd3 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieChart(QDeclarativeItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +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 index 02d33c2f1b..0b55f7c02a 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -38,23 +38,29 @@ ** ****************************************************************************/ //![0] -import Music 1.0 +import Charts 1.0 import Qt 4.7 -Rectangle { - width: 200; height: 200 +Item { + width: 300; height: 200 - Musician { - id: aMusician - name: "Reddy the Rocker" - instrument: "Guitar" + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + color: "red" - onPerformanceEnded: console.log("The performance has now ended") + onChartCleared: console.log("The chart has been cleared") } MouseArea { anchors.fill: parent - onClicked: aMusician.perform() + 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 index bd05ebe2cc..0f0416718c 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -1,5 +1,5 @@ QT += declarative -HEADERS += musician.h -SOURCES += musician.cpp \ +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 index 8ef6965ea8..a5dbab32d2 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp +++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ //![0] -#include "musician.h" +#include "piechart.h" #include #include #include @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - qmlRegisterType("Music", 1, 0, "Musician"); + qmlRegisterType("Charts", 1, 0, "PieChart"); QDeclarativeView view; view.setSource(QUrl::fromLocalFile("app.qml")); diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp deleted file mode 100644 index 0ce0022251..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musician.h" -#include - -Musician::Musician(QObject *parent) - : QObject(parent) -{ -} - -QString Musician::name() const -{ - return m_name; -} - -void Musician::setName(const QString &name) -{ - m_name = name; -} - -QString Musician::instrument() const -{ - return m_instrument; -} - -void Musician::setInstrument(const QString &instrument) -{ - m_instrument = instrument; -} - -//![0] -void Musician::perform() -{ - qWarning() << m_name << "is playing the" << m_instrument; - emit performanceEnded(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.h b/examples/declarative/tutorials/extending/chapter2-methods/musician.h deleted file mode 100644 index 86849ba237..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/musician.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICIAN_H -#define MUSICIAN_H - -#include - -//![0] -class Musician : public QObject -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString instrument READ instrument WRITE setInstrument) - -//![1] -public: -//![1] - - Musician(QObject *parent = 0); - - QString name() const; - void setName(const QString &name); - - QString instrument() const; - void setInstrument(const QString &instrument); - -//![2] - Q_INVOKABLE void perform(); - -signals: - void performanceEnded(); -//![2] - -private: - QString m_name; - QString m_instrument; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp new file mode 100644 index 0000000000..11ff7c8bff --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include + +PieChart::PieChart(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +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, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..246fd9f929 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +//![1] +public: +//![1] + + PieChart(QDeclarativeItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +//![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 index 8bf6ecfaf6..2ff6ae1965 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml @@ -38,35 +38,37 @@ ** ****************************************************************************/ //![0] -import Music 1.0 +import Charts 1.0 import Qt 4.7 -Rectangle { - width: 200; height: 200 +Item { + width: 300; height: 200 - Musician { - id: reddy - name: "Reddy the Rocker" - instrument: "Guitar" - } + Row { + anchors.centerIn: parent + spacing: 20 + + PieChart { + id: chartA + width: 100; height: 100 + color: "red" + } - Musician { - id: craig - name: "Craig the Copycat" - instrument: reddy.instrument + PieChart { + id: chartB + width: 100; height: 100 + color: chartA.color + } } MouseArea { anchors.fill: parent - onClicked: { - reddy.perform() - craig.perform() - - reddy.instrument = "Drums" + onClicked: { chartA.color = "blue" } + } - reddy.perform() - craig.perform() - } + 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 index bd05ebe2cc..0f0416718c 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -1,5 +1,5 @@ QT += declarative -HEADERS += musician.h -SOURCES += musician.cpp \ +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 index 8ef6965ea8..a5dbab32d2 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp +++ b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ //![0] -#include "musician.h" +#include "piechart.h" #include #include #include @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - qmlRegisterType("Music", 1, 0, "Musician"); + qmlRegisterType("Charts", 1, 0, "PieChart"); QDeclarativeView view; view.setSource(QUrl::fromLocalFile("app.qml")); diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp deleted file mode 100644 index 5f9ead4bfe..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musician.h" -#include - -Musician::Musician(QObject *parent) - : QObject(parent) -{ -} - -QString Musician::name() const -{ - return m_name; -} - -void Musician::setName(const QString &name) -{ - m_name = name; -} - -QString Musician::instrument() const -{ - return m_instrument; -} - -//![0] -void Musician::setInstrument(const QString &instrument) -{ - if (instrument != m_instrument) { - m_instrument = instrument; - emit instrumentChanged(); - } -} -//![0] - -void Musician::perform() -{ - qWarning() << m_name << "is playing the" << m_instrument; -} diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.h b/examples/declarative/tutorials/extending/chapter3-bindings/musician.h deleted file mode 100644 index 0b0addb997..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/musician.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICIAN_H -#define MUSICIAN_H - -#include - -//![0] -class Musician : public QObject -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString instrument READ instrument WRITE setInstrument) - -//![1] - Q_PROPERTY(QString instrument READ instrument WRITE setInstrument NOTIFY instrumentChanged) -public: -//![1] - - Musician(QObject *parent = 0); - - QString name() const; - void setName(const QString &name); - - QString instrument() const; - void setInstrument(const QString &instrument); - - Q_INVOKABLE void perform(); - -//![2] -signals: - void instrumentChanged(); -//![2] - -private: - QString m_name; - QString m_instrument; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp new file mode 100644 index 0000000000..85a9762994 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include + +PieChart::PieChart(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +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, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..164cebb65e --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ +//![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(QDeclarativeItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + + 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 index d76f80120f..fcd38068c5 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -38,17 +38,23 @@ ** ****************************************************************************/ //![0] -import Music 1.0 +import Charts 1.0 import Qt 4.7 Item { + width: 300; height: 200 - Musician { - id: reddy - name: "Reddy the Rocker" - instrument: Instrument { type: "Guitar" } + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } } - Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type) + 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 index aea07a0ef5..c3f5402aea 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -1,7 +1,7 @@ QT += declarative -HEADERS += musician.h \ - instrument.h -SOURCES += musician.cpp \ - instrument.cpp \ +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ main.cpp diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp deleted file mode 100644 index 9ca96f6386..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "instrument.h" - -Instrument::Instrument(QObject *parent) - : QObject(parent) -{ -} - -QString Instrument::type() const -{ - return m_type; -} - -void Instrument::setType(const QString &type) -{ - m_type = type; -} - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h deleted file mode 100644 index 9971207f0f..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 INSTRUMENT_H -#define INSTRUMENT_H - -#include - -//![0] -class Instrument : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString type READ type WRITE setType) - -public: - Instrument(QObject *parent = 0); - - QString type() const; - void setType(const QString &type); - -private: - QString m_type; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp index d94cb036cb..fd518a255a 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -37,8 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "musician.h" -#include "instrument.h" +#include "piechart.h" +#include "pieslice.h" #include #include @@ -50,10 +50,10 @@ int main(int argc, char *argv[]) //![0] QApplication app(argc, argv); - qmlRegisterType("Music", 1, 0, "Musician"); + qmlRegisterType("Charts", 1, 0, "PieChart"); //![1] - qmlRegisterType("Music", 1, 0, "Instrument"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); //![1] QDeclarativeView view; diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp deleted file mode 100644 index e62efb197d..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musician.h" -#include "instrument.h" - -Musician::Musician(QObject *parent) - : QObject(parent) -{ -} - -QString Musician::name() const -{ - return m_name; -} - -void Musician::setName(const QString &name) -{ - m_name = name; -} - -Instrument *Musician::instrument() const -{ - return m_instrument; -} - -void Musician::setInstrument(Instrument *instrument) -{ - m_instrument = instrument; -} - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h deleted file mode 100644 index 8f67f61cc0..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICIAN_H -#define MUSICIAN_H - -#include - -class Instrument; - -//![0] -class Musician : public QObject -{ - Q_OBJECT - Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - - Musician(QObject *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - Instrument *instrument() const; - void setInstrument(Instrument *instrument); -//![2] - -private: - QString m_name; - Instrument *m_instrument; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp new file mode 100644 index 0000000000..70988542d3 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // this doesn't need to disable QGraphicsItem::ItemHasNoContents + // anymore since the drawing is now done in PieSlice +} + +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 new file mode 100644 index 0000000000..448ca7b67b --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + + PieChart(QDeclarativeItem *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 new file mode 100644 index 0000000000..7a420fd285 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..085a9b8fe6 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QDeclarativeItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +private: + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml index 9c050b873c..b06e399fef 100644 --- a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml +++ b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml @@ -41,13 +41,19 @@ import Qt 4.7 Item { + width: 300; height: 200 - Musician { - id: reddy - name: "Reddy the Rocker" - instrument: Instrument { type: "Guitar" } + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } } - Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type) + Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) } diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro index 483da8fc9a..1ffbf29925 100644 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro +++ b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro @@ -6,13 +6,13 @@ DESTDIR = lib OBJECTS_DIR = tmp MOC_DIR = tmp -HEADERS += musician.h \ - instrument.h \ - musicplugin.h +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h -SOURCES += musician.cpp \ - instrument.cpp \ - musicplugin.cpp +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..5aa2a4bcbe --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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"); +} + +Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); +//![0] + diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h new file mode 100644 index 0000000000..797d1e7a85 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +public: + void registerTypes(const char *uri); +}; +//![0] + +#endif + diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp deleted file mode 100644 index 9ca96f6386..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "instrument.h" - -Instrument::Instrument(QObject *parent) - : QObject(parent) -{ -} - -QString Instrument::type() const -{ - return m_type; -} - -void Instrument::setType(const QString &type) -{ - m_type = type; -} - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h deleted file mode 100644 index ce1e7ce808..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 INSTRUMENT_H -#define INSTRUMENT_H - -#include - -class Instrument : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString type READ type WRITE setType) - -public: - Instrument(QObject *parent = 0); - - QString type() const; - void setType(const QString &type); - -private: - QString m_type; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp deleted file mode 100644 index e62efb197d..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musician.h" -#include "instrument.h" - -Musician::Musician(QObject *parent) - : QObject(parent) -{ -} - -QString Musician::name() const -{ - return m_name; -} - -void Musician::setName(const QString &name) -{ - m_name = name; -} - -Instrument *Musician::instrument() const -{ - return m_instrument; -} - -void Musician::setInstrument(Instrument *instrument) -{ - m_instrument = instrument; -} - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.h b/examples/declarative/tutorials/extending/chapter5-plugins/musician.h deleted file mode 100644 index b92063131c..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/musician.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICIAN_H -#define MUSICIAN_H - -#include - -class Instrument; - -class Musician : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument) - -public: - Musician(QObject *parent = 0); - - QString name() const; - void setName(const QString &name); - - Instrument *instrument() const; - void setInstrument(Instrument *instrument); - -private: - QString m_name; - Instrument *m_instrument; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp deleted file mode 100644 index 76acf0144d..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "musicplugin.h" -//![0] -#include "musician.h" -#include "instrument.h" -#include - -void MusicPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 1, 0, "Musician"); - qmlRegisterType(uri, 1, 0, "Instrument"); -} - -Q_EXPORT_PLUGIN2(musicplugin, MusicPlugin); -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h deleted file mode 100644 index d6a5392431..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 MUSICPLUGIN_H -#define MUSICPLUGIN_H - -//![0] -#include - -class MusicPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp new file mode 100644 index 0000000000..2d7acf70ec --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +PieSlice *PieChart::pieSlice() const +{ + return m_pieSlice; +} + +void PieChart::setPieSlice(PieSlice *pieSlice) +{ + m_pieSlice = pieSlice; + m_pieSlice->setParentItem(this); +} + diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h new file mode 100644 index 0000000000..a8b5b6ed97 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) + +public: + PieChart(QDeclarativeItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + PieSlice *pieSlice() const; + void setPieSlice(PieSlice *pieSlice); + +private: + QString m_name; + PieSlice *m_pieSlice; +}; + +#endif + diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp new file mode 100644 index 0000000000..a312da3b7e --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h new file mode 100644 index 0000000000..677473174f --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QDeclarativeItem *parent = 0); + + QColor color() const; + void setColor(const QColor &QColor); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +private: + QColor m_color; +}; + +#endif + -- cgit v1.2.1 From fb8869e00da635be7660d845d4cb631d230bed6e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 13:23:26 +1000 Subject: fix spelling --- src/declarative/qml/qdeclarativelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp index 7c89672da5..9598d98292 100644 --- a/src/declarative/qml/qdeclarativelist.cpp +++ b/src/declarative/qml/qdeclarativelist.cpp @@ -306,7 +306,7 @@ int QDeclarativeListReference::count() const /*! \class QDeclarativeListProperty \since 4.7 -\brief The QDeclarativeListProperty class allows applications to explose list-like +\brief The QDeclarativeListProperty class allows applications to expose list-like properties to QML. QML has many list properties, where more than one object value can be assigned. -- cgit v1.2.1 From 7d0b62158471d46db9902ce0d0d7b7244c743cce Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 15:29:20 +1000 Subject: Add chapter on creating list property types --- doc/src/declarative/extending-tutorial.qdoc | 103 ++++++++++++++------- .../pics/extending-tutorial-chapter1.png | Bin 0 -> 6687 bytes .../pics/extending-tutorial-chapter2.png | Bin 0 -> 7318 bytes .../pics/extending-tutorial-chapter3.png | Bin 0 -> 8145 bytes .../pics/extending-tutorial-chapter5.png | Bin 0 -> 5557 bytes .../tutorials/extending/chapter5-plugins/app.qml | 59 ------------ .../chapter5-plugins/chapter5-plugins.pro | 20 ---- .../extending/chapter5-plugins/chartsplugin.cpp | 54 ----------- .../extending/chapter5-plugins/chartsplugin.h | 55 ----------- .../extending/chapter5-plugins/piechart.cpp | 68 -------------- .../extending/chapter5-plugins/piechart.h | 68 -------------- .../extending/chapter5-plugins/pieslice.cpp | 67 -------------- .../extending/chapter5-plugins/pieslice.h | 64 ------------- .../tutorials/extending/chapter5-plugins/qmldir | 1 - .../tutorials/extending/chapter6-plugins/app.qml | 68 ++++++++++++++ .../chapter6-plugins/chapter6-plugins.pro | 20 ++++ .../extending/chapter6-plugins/chartsplugin.cpp | 54 +++++++++++ .../extending/chapter6-plugins/chartsplugin.h | 55 +++++++++++ .../extending/chapter6-plugins/piechart.cpp | 71 ++++++++++++++ .../extending/chapter6-plugins/piechart.h | 69 ++++++++++++++ .../extending/chapter6-plugins/pieslice.cpp | 88 ++++++++++++++++++ .../extending/chapter6-plugins/pieslice.h | 74 +++++++++++++++ .../tutorials/extending/chapter6-plugins/qmldir | 1 + 23 files changed, 572 insertions(+), 487 deletions(-) create mode 100644 doc/src/declarative/pics/extending-tutorial-chapter1.png create mode 100644 doc/src/declarative/pics/extending-tutorial-chapter2.png create mode 100644 doc/src/declarative/pics/extending-tutorial-chapter3.png create mode 100644 doc/src/declarative/pics/extending-tutorial-chapter5.png delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-plugins/qmldir create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/app.qml create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.h create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/qmldir diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index 9170c5c94f..cc93e86a8a 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -48,8 +48,9 @@ Tutorial chapters: \o \l{declarative/tutorials/extending/chapter2-methods}{Connecting to C++ Methods and Signals} \o \l{declarative/tutorials/extending/chapter3-bindings}{Adding Property Bindings} \o \l{declarative/tutorials/extending/chapter4-customPropertyTypes}{Using Custom Property Types} -\o \l{declarative/tutorials/extending/chapter5-plugins}{Writing an Extension Plugin} -\o \l{qml-extending-tutorial6.html}{In Summary} +\o \l{declarative/tutorials/extending/chapter5-listproperties}{Using List Property Types} +\o \l{declarative/tutorials/extending/chapter6-plugins}{Writing an Extension Plugin} +\o \l{qml-extending-tutorial7.html}{In Summary} \endlist */ @@ -339,15 +340,65 @@ Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-custom */ + +/*! +\title Chapter 5: Using List Property Types + +\example declarative/tutorials/extending/chapter5-listproperties + +Right now, a \c PieChart can only have one \c PieSlice. Ideally a chart would +have multiple slices, with different colors and sizes. To do this, we could +have a \c slices property that accepts a list of \c PieSlice items: + +\snippet declarative/tutorials/extending/chapter5-listproperties/app.qml 0 + +\image extending-tutorial-chapter5.png + +To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, +declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the +creation of list properties in QML extensions. We replace the \c pieSlice() +function with a \c slices() function that returns a list of slices, and add +an internal \c append_slice() function (discussed below). We also use a QList to +store the internal list of slices as \c m_slices: + +\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 0 +\dots +\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 1 +\dots +\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2 + +Although the \c slices property does not have an associated \c WRITE function, +it is still modifiable because of the way QDeclarativeListProperty works. +In the \c PieChart implementation, we implement \c PieChart::slices() to +return a QDeclarativeListProperty value and indicate that the internal +\c PieChart::append_slice() function is to be called whenever a request is made from QML +to add items to the list: + +\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.cpp 0 + +The \c append_slice() function simply sets the parent item as before, +and adds the new item to the \c m_slices list. As you can see, the append function for a +QDeclarativeListProperty is called with two arguments: the list property, and +the item that is to be appended. + +The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan +properties and to draw the slice according to these values. This is a straightforward +modification if you have read the previous pages in this tutorial, so the code is not shown here. + +The complete code can be seen in the updated \c examples/tutorials/extending/chapter5-listproperties directory. + +*/ + + /*! -\title Chapter 5: Writing an Extension Plugin +\title Chapter 6: Writing an Extension Plugin -\example declarative/tutorials/extending/chapter5-plugins +\example declarative/tutorials/extending/chapter6-plugins Currently the \c PieChart and \c PieSlice types are used by \c app.qml, which is displayed using a QDeclarativeView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available -to the QML engine. This allows us to load \c app.qml using the \l {QML Viewer} +to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer} (or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and loading our own C++ application. @@ -365,22 +416,22 @@ Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. Here is the \c ChartsPlugin definition in \c chartsplugin.h: -\snippet declarative/tutorials/extending/chapter5-plugins/chartsplugin.h 0 +\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.h 0 And its implementation in \c chartsplugin.cpp: -\snippet declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp 0 +\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp 0 Then, we write a \c .pro project file that defines the project as a plugin library and specifies with DESTDIR that library files should be built into a "lib" subdirectory: -\quotefile declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro +\quotefile declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro Finally, we add a \c qmldir file that is automatically parsed by the QML engine. -Here, we specify that a plugin named "chapter5-plugin" (the name +Here, we specify that a plugin named "chapter6-plugin" (the name of the example project) can be found in the "lib" subdirectory: -\quotefile declarative/tutorials/extending/chapter5-plugins/qmldir +\quotefile declarative/tutorials/extending/chapter6-plugins/qmldir Now we have a plugin, and instead of having a main.cpp and an executable, we can build the project and then load the QML file in the \l {QML Viewer}: @@ -397,9 +448,10 @@ having PieChart.qml and PieSlice.qml files inside the project directory, which c be used by \c app.qml without import statements. */ + /*! -\page qml-extending-tutorial6.html -\title Chapter 6: In Summary +\page qml-extending-tutorial7.html +\title Chapter 7: In Summary In this tutorial, we've shown the basic steps for creating a QML extension: @@ -408,39 +460,28 @@ In this tutorial, we've shown the basic steps for creating a QML extension: \o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax \o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals \o Define custom property types if the built-in types are not sufficient +\o Define list property types using QDeclarativeListProperty \o Create a plugin library by defining a Qt plugin and writing a \c qmldir file \endlist The \l {Extending QML in C++} reference documentation shows other useful features that can be added to -QML extensions. For example, we could use \l{Object and List Property Types}{list properties} to allow multiple slices for a \c PieChart: - -\code - PieChart { - slices: [ - PieSlice { color: "red" } - PieSlice { color: "blue" } - PieSlice { color: "yellow" } - ] - } -\endcode - -Or use \l{Default Property}{default properties} and avoid an -\c slices property altogether: +QML extensions. For example, we could use \l{Default Property}{default properties} to allow +slices to be added without using the \c slices property: \code PieChart { - PieSlice { color: "red" } - PieSlice { color: "blue" } - PieSlice { color: "yellow" } + PieSlice { ... } + PieSlice { ... } + PieSlice { ... } } \endcode -Or even change the \c color of a \c PieChart from time to time using \l{Property Value Sources}{property value sources}: +Or randomly add and remove slices from time to time using \l{Property Value Sources}{property value sources}: \code PieChart { - PieSliceRandomizer on color {} + PieSliceRandomizer on slices {} } \endcode diff --git a/doc/src/declarative/pics/extending-tutorial-chapter1.png b/doc/src/declarative/pics/extending-tutorial-chapter1.png new file mode 100644 index 0000000000..9f5836b09c Binary files /dev/null and b/doc/src/declarative/pics/extending-tutorial-chapter1.png differ diff --git a/doc/src/declarative/pics/extending-tutorial-chapter2.png b/doc/src/declarative/pics/extending-tutorial-chapter2.png new file mode 100644 index 0000000000..5c8f222aad Binary files /dev/null and b/doc/src/declarative/pics/extending-tutorial-chapter2.png differ diff --git a/doc/src/declarative/pics/extending-tutorial-chapter3.png b/doc/src/declarative/pics/extending-tutorial-chapter3.png new file mode 100644 index 0000000000..825553fc5f Binary files /dev/null and b/doc/src/declarative/pics/extending-tutorial-chapter3.png differ diff --git a/doc/src/declarative/pics/extending-tutorial-chapter5.png b/doc/src/declarative/pics/extending-tutorial-chapter5.png new file mode 100644 index 0000000000..0c2e69e1b4 Binary files /dev/null and b/doc/src/declarative/pics/extending-tutorial-chapter5.png differ diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml deleted file mode 100644 index b06e399fef..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 Qt 4.7 - -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) -} - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro deleted file mode 100644 index 1ffbf29925..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = lib -OBJECTS_DIR = tmp -MOC_DIR = tmp - -HEADERS += piechart.h \ - pieslice.h \ - chartsplugin.h - -SOURCES += piechart.cpp \ - pieslice.cpp \ - chartsplugin.cpp - -symbian { - include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - TARGET.EPOCALLOWDLLDATA = 1 -} diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp deleted file mode 100644 index 5aa2a4bcbe..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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"); -} - -Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h deleted file mode 100644 index 797d1e7a85..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chartsplugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp deleted file mode 100644 index 2d7acf70ec..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -PieSlice *PieChart::pieSlice() const -{ - return m_pieSlice; -} - -void PieChart::setPieSlice(PieSlice *pieSlice) -{ - m_pieSlice = pieSlice; - m_pieSlice->setParentItem(this); -} - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h b/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h deleted file mode 100644 index a8b5b6ed97..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/piechart.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) - -public: - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - PieSlice *pieSlice() const; - void setPieSlice(PieSlice *pieSlice); - -private: - QString m_name; - PieSlice *m_pieSlice; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp deleted file mode 100644 index a312da3b7e..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h b/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h deleted file mode 100644 index 677473174f..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/pieslice.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieSlice(QDeclarativeItem *parent = 0); - - QColor color() const; - void setColor(const QColor &QColor); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QColor m_color; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/qmldir b/examples/declarative/tutorials/extending/chapter5-plugins/qmldir deleted file mode 100644 index c3afd6b054..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-plugins/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin chapter5-plugins lib diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml new file mode 100644 index 0000000000..38ceefa356 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 Qt 4.7 + +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 new file mode 100644 index 0000000000..1ffbf29925 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative + +DESTDIR = lib +OBJECTS_DIR = tmp +MOC_DIR = tmp + +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h + +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCALLOWDLLDATA = 1 +} diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..5aa2a4bcbe --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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"); +} + +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 new file mode 100644 index 0000000000..797d1e7a85 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +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 new file mode 100644 index 0000000000..4e6ee5c698 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(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 new file mode 100644 index 0000000000..d6e443993a --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeListProperty slices READ slices) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + PieChart(QDeclarativeItem *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 new file mode 100644 index 0000000000..65120f53e3 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +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, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..a3afd25d60 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + 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(QDeclarativeItem *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, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/qmldir b/examples/declarative/tutorials/extending/chapter6-plugins/qmldir new file mode 100644 index 0000000000..a83bf85ddb --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/qmldir @@ -0,0 +1 @@ +plugin chapter6-plugins lib -- cgit v1.2.1 From 5be65b4ce744945ba31f110660a4cf58c123742b Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 16:36:26 +1000 Subject: fix doc link --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 110c970ff4..fa422fd7e1 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1732,7 +1732,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) highlight is not moved by the view, and any movement must be implemented by the highlight. - Here is a highlight with its motion defined by a \l {SpringAniamtion} item: + Here is a highlight with its motion defined by a \l {SpringAnimation} item: \snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem -- cgit v1.2.1 From 14ad729f1e2f07a46cdb41f01a6e5267084b8816 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 16:46:22 +1000 Subject: Add files missing from last commit --- .../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 | 88 ++++++++++++++++++++++ .../extending/chapter5-listproperties/pieslice.h | 76 +++++++++++++++++++ 7 files changed, 446 insertions(+) create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/app.qml create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp create mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml new file mode 100644 index 0000000000..f759bc90e5 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import Qt 4.7 + +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 new file mode 100644 index 0000000000..c3f5402aea --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -0,0 +1,7 @@ +QT += declarative + +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 new file mode 100644 index 0000000000..f73c49fd24 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); + + QDeclarativeView view; + 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 new file mode 100644 index 0000000000..2515b64280 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(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 new file mode 100644 index 0000000000..44242513c0 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeListProperty slices READ slices) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + PieChart(QDeclarativeItem *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 new file mode 100644 index 0000000000..65120f53e3 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + // need to disable this flag to draw inside a QDeclarativeItem + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +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, const QStyleOptionGraphicsItem *, QWidget *) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, 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 new file mode 100644 index 0000000000..7cd0c7474d --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 QDeclarativeItem +{ + 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(QDeclarativeItem *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, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + -- cgit v1.2.1 From 5893e05aa453f1ecbc0ee35d5fca5d671828dfc2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Jul 2010 16:48:30 +1000 Subject: Fix .pro file --- examples/declarative/tutorials/extending/extending.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro index 0c86fed2d1..967473fda0 100644 --- a/examples/declarative/tutorials/extending/extending.pro +++ b/examples/declarative/tutorials/extending/extending.pro @@ -5,5 +5,6 @@ SUBDIRS += \ chapter2-methods \ chapter3-bindings \ chapter4-customPropertyTypes \ - chapter5-plugins + chapter5-listproperties \ + chapter6-plugins -- cgit v1.2.1 From 920980c77269325cc94efd2ff10347bd2745736d Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 14 Jul 2010 08:38:04 +0200 Subject: Fixed install docs for Qt for Symbian on Linux. --- doc/src/snippets/code/doc_src_installation.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/code/doc_src_installation.qdoc b/doc/src/snippets/code/doc_src_installation.qdoc index 985f3da7f1..c46159ce19 100644 --- a/doc/src/snippets/code/doc_src_installation.qdoc +++ b/doc/src/snippets/code/doc_src_installation.qdoc @@ -263,7 +263,7 @@ make //! [40] //! [41] -cd src/s60installs +cd src make sis //! [41] -- cgit v1.2.1 From dcfa4125625c028165c424b5d95cb0795194d6f2 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 14 Jul 2010 08:38:30 +0200 Subject: Removed README.s60-mkspec. The instructions are old, and should now be found in the qdoc docs. --- README.s60-mkspec | 99 ------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 README.s60-mkspec diff --git a/README.s60-mkspec b/README.s60-mkspec deleted file mode 100644 index af500e1377..0000000000 --- a/README.s60-mkspec +++ /dev/null @@ -1,99 +0,0 @@ -How to build Qt for Symbian using the Linux makespec. - -Prerequisites: - - - Working RVCT 2.2 native Linux compiler. The new publicly - available RVCT 4.0 compiler may work, but it hasn't been tested - yet. - - - A working GnuPoc environment. See this page for details: - http://www.martin.st/symbian/ - Download the latest version, unpack it and run the 'install_eka2_tools' script as - described in the last part under the EKA2 part. The part about the your own gcc - are not needed as we use the rvct compiler. - Make sure you do the part about Wine setup as well. - - - Anderson Lizardo's patches for GnuPoc. Look for the - qt_s60_gnupoc_v10.patch on this page: - http://lizardo.wordpress.com/2009/09/24/installing-qt-for-s60-daily-snapshots-on-linux/ - and carry out the instructions under point 8: Installing Open C. - -Compiling: - - 1. First a few environment variables need to be set: - - export RVCT22LIB=/lib/armlib - export EPOCROOT= - export PATH=$PATH:/epoc32/tools:/bin - export PATH=$PATH:/bin - - Replace the s60-root with the installation directory of your SDK, - and the qt-root with the root of your Qt repository. - These are good candidates for putting in a script somewhere. - - 2. Run configure. It needs a bit more switches than usual, so here's - the full line: - - ./configure -developer-build -platform linux-g++ -xplatform \ - symbian/linux-armcc -little-endian -host-little-endian \ - -arch symbian - - 3. Compile Qt - - cd src - make - - and then wait for a while. - - 4. Package and install Qt - - cd s60installs - - Edit Qt_template.pkg and change the first 0x2xxxxxxx to - 0xExxxxxxx. Then execute: - - makesis Qt_template.pkg - signsis Qt_template.sis Qt_template.sisx selfsigned.cer selfsigned.key - - Then put Qt_template.sisx on a memory card and install it from - the phone file manager. - - Alternatively, you can use the runonphone tool found in the tools - directory of Qt. To build, this requires a separately configured - Qt installation for Linux, unfortunately. To use it, you also - need have App TRK running on the phone. At the time of writing, - only bleeding edge Linux kernels are able to autodetect the USB - serial port on the phone, but you can force detection by running: - - modprobe usbserial vendor=0xXXXX product=0xXXXX - - The XXXXs should be replaced with the two values listed for your - device when executing "lsusb". In most distributions, this will - lead to the creation of two devices: /dev/ttyUSB0 and - /dev/ttyUSB1. The latter is usually the one that App TRK responds - to. Then execute: - - runonphone -p /dev/ttyUSB1 -s Qt_template.sisx dummy.exe - - The dummy.exe argument is irrelevant, since we are not executing - anything yet. - - 5. Compile some helloworld application (I leave the details to you - ;-) - - qmake - make - - 6. Package, install and run application. - - makesis helloworld_template.pkg - signsis helloworld_template.sis helloworld_template.sisx \ - /src/s60installs/selfsigned.cer \ - /src/s60installs/selfsigned.key - - Then either install by memory card, or install and run like this: - - runonphone -p /dev/ttyUSB1 -s helloworld_template.sisx \ - helloworld.exe - - 7. Enjoy "hello world" on the phone! -- cgit v1.2.1 From 12b6275a21076df582e80c422b31560d8ee995d0 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 14 Jul 2010 08:39:46 +0200 Subject: Allow commenting of individual files in generated pkg files. RevBy: Jason Barron --- bin/patch_capabilities.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index 501939afc2..7d6f5dc163 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -186,7 +186,7 @@ if (@ARGV) } # If the line specifies a file, parse the source and destination locations. - if ($line =~ m|\"([^\"]+)\"\s*\-\s*\"([^\"]+)\"|) + if ($line =~ m|^ *\"([^\"]+)\"\s*\-\s*\"([^\"]+)\"|) { my $sourcePath = $1; -- cgit v1.2.1 From 511985fa173daa9b8462dbb72c45a74626e8cba4 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 15 Jul 2010 10:18:02 +0200 Subject: Fix for tst_qmdisubwindow::fixedMinMaxSize failure on Cocoa We need to respect the size restrictions for all QWidgets. Previously this was only applied to top levels. Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qwidget_mac.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index e57ec77177..c7887113f9 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4389,6 +4389,13 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM data.window_state = data.window_state & ~Qt::WindowMaximized; const bool visible = q->isVisible(); + // Apply size restrictions, applicable for Windows & Widgets. + if (QWExtra *extra = extraData()) { + w = qMin(w, extra->maxw); + h = qMin(h, extra->maxh); + w = qMax(w, extra->minw); + h = qMax(h, extra->minh); + } data.crect = QRect(x, y, w, h); if (realWindow) { -- cgit v1.2.1 From 633349982422fec92df4ed06da5d2becf788c494 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 15 Jul 2010 10:39:40 +0200 Subject: Amend previous commit 4e2eb2945dbc3865e2901f12d663ed89e8f0dfbf to fix compilation with QT_NO_DEBUG_STREAM Qt in debug need to stay binary compatible with Qt in release. See also commit cbbd7e084c7e46fd906db26b13032b8368c59093 that introduced the problem Task-number: QTBUG-11510 --- src/gui/styles/qstyle.cpp | 4 +++- src/gui/styles/qstyle.h | 2 +- src/gui/styles/qstyleoption.cpp | 6 +++++- src/gui/styles/qstyleoption.h | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 676483e494..687e587365 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -2421,9 +2421,10 @@ QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, QStyle::State state) { +#if !defined(QT_NO_DEBUG) debug << "QStyle::State("; QStringList states; @@ -2455,6 +2456,7 @@ QDebug operator<<(QDebug debug, QStyle::State state) qSort(states); debug << states.join(QLatin1String(" | ")); debug << ')'; +#endif return debug; } #endif diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index 1ee262d5c3..439901a8f9 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -878,7 +878,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls) -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state); #endif diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index eeab316785..4780edfbc0 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -5419,9 +5419,10 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T Returns a T or 0 depending on the type of \a hint. */ -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) { +#if !defined(QT_NO_DEBUG) switch (optionType) { case QStyleOption::SO_Default: debug << "SO_Default"; break; @@ -5482,17 +5483,20 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) case QStyleOption::SO_GraphicsItem: debug << "SO_GraphicsItem"; break; } +#endif return debug; } QDebug operator<<(QDebug debug, const QStyleOption &option) { +#if !defined(QT_NO_DEBUG) debug << "QStyleOption("; debug << QStyleOption::OptionType(option.type); debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); debug << ',' << option.state; debug << ',' << option.rect; debug << ')'; +#endif return debug; } #endif diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index 005b36afa5..e79d9a4203 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -958,7 +958,7 @@ T qstyleoption_cast(QStyleHintReturn *hint) return 0; } -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType); Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option); #endif -- cgit v1.2.1 From 518a8ab0fe67965555973788e3eea643882cb80c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 15 Jul 2010 10:36:18 +0200 Subject: fix for looping crash log on data abort When a thread panics, calling resume allows the thread to proceed to the exit handler and shut down. When a thread takes an exception, calling resume continues from the same point so the exception happens again. To avoid this, we add crashed thread ids to a list. If we see the same thread crash again, we terminate the process without trying to fetch the call stack a second time. Reviewed-by: Jason Barron --- tools/runonphone/trksignalhandler.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index b6d446f420..898692a75d 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -71,8 +71,10 @@ private: QFile crashlogtextfile; QFile crashstackfile; QList queuedCrashes; + QList dyingThreads; QString crashlogPath; bool crashlog; + bool terminateNeeded; }; void TrkSignalHandler::copyingStarted() @@ -201,15 +203,23 @@ void TrkSignalHandler::stopped(uint pc, uint pid, uint tid, const QString& reaso cs.crashPC = pc; cs.crashReason = reason; - d->queuedCrashes.append(cs); - - if (d->queuedCrashes.count() == 1) { - d->err << "Fetching registers and stack..." << endl; - emit getRegistersAndCallStack(pid, tid); + if (d->dyingThreads.contains(tid)) { + if(d->queuedCrashes.isEmpty()) + emit terminate(); + else + d->terminateNeeded = true; + } else { + d->queuedCrashes.append(cs); + d->dyingThreads.append(tid); + + if (d->queuedCrashes.count() == 1) { + d->err << "Fetching registers and stack..." << endl; + emit getRegistersAndCallStack(pid, tid); + } } } else - emit resume(pid, tid); + emit terminate(); } void TrkSignalHandler::registersAndCallStackReadComplete(const QList& registers, const QByteArray& stack) @@ -307,6 +317,8 @@ void TrkSignalHandler::registersAndCallStackReadComplete(const QList& regi d->err << "Fetching registers and stack..." << endl; emit getRegistersAndCallStack(cs.pid, cs.tid); } + else if (d->terminateNeeded) + emit terminate(); } @@ -333,7 +345,8 @@ TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : out(stdout), err(stderr), loglevel(0), - lastpercent(0) + lastpercent(0), + terminateNeeded(false) { } -- cgit v1.2.1 From 910b8fe6222011b8f94259f165bcf4d4002172c0 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 15 Jul 2010 11:08:17 +0200 Subject: QFileDialog : Fix completer showing up on the MyComputer view. Only complete if there is a text to complete Reviewed-by:janarve --- src/gui/util/qcompleter.cpp | 4 +++- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 1abc2d9250..04d6de937f 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -154,6 +154,7 @@ #include "QtGui/qevent.h" #include "QtGui/qheaderview.h" #include "QtGui/qdesktopwidget.h" +#include "QtGui/qlineedit.h" QT_BEGIN_NAMESPACE @@ -920,8 +921,9 @@ void QCompleterPrivate::showPopup(const QRect& rect) void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path) { Q_Q(QCompleter); + QLineEdit *lineEdit = qobject_cast(widget); //the path given by QFileSystemModel does not end with / - if (!q->completionPrefix().isEmpty() && q->completionPrefix() != path + QLatin1Char('/')) + if (lineEdit && !lineEdit->text().isEmpty() && !q->completionPrefix().isEmpty() && q->completionPrefix() != path + QLatin1Char('/')) q->complete(); } diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index eee495fc33..6299c24e9b 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -140,6 +140,7 @@ private slots: void QTBUG4419_lineEditSelectAll(); void QTBUG6558_showDirsOnly(); void QTBUG4842_selectFilterWithHideNameFilterDetails(); + void dontShowCompleterOnRoot(); private: QByteArray userSettings; @@ -1194,5 +1195,26 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() } +void tst_QFileDialog2::dontShowCompleterOnRoot() +{ + QNonNativeFileDialog fd(0, "TestFileDialog"); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.show(); + + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&fd)); + + fd.setDirectory(""); + QLineEdit *lineEdit = qFindChild(&fd, "fileNameEdit"); + QTRY_VERIFY(lineEdit->text().isEmpty()); + + //The gatherer thread will then return the result + QApplication::processEvents(); + + QTRY_VERIFY(lineEdit->completer()->popup()->isHidden()); +} + QTEST_MAIN(tst_QFileDialog2) #include "tst_qfiledialog2.moc" -- cgit v1.2.1 From 73473634b706548d603dafe22c9424a007d1bf3b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 15 Jul 2010 11:20:07 +0200 Subject: Revert BIC change "Build Qt with option -Zc:wchar_t under MSVC" This reverts commit a9c8decc741d8c2b340f38d7a854ef206672ab3e. Postponed for Qt5. Or different makespecs. --- mkspecs/win32-msvc2005/qmake.conf | 2 +- mkspecs/win32-msvc2008/qmake.conf | 2 +- mkspecs/win32-msvc2010/qmake.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/win32-msvc2005/qmake.conf b/mkspecs/win32-msvc2005/qmake.conf index a5999cc084..0406fd03d6 100644 --- a/mkspecs/win32-msvc2005/qmake.conf +++ b/mkspecs/win32-msvc2005/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD diff --git a/mkspecs/win32-msvc2008/qmake.conf b/mkspecs/win32-msvc2008/qmake.conf index 1aab8e1a5f..9805e906b4 100644 --- a/mkspecs/win32-msvc2008/qmake.conf +++ b/mkspecs/win32-msvc2008/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD diff --git a/mkspecs/win32-msvc2010/qmake.conf b/mkspecs/win32-msvc2010/qmake.conf index 34a7782c63..28d4d3cc41 100644 --- a/mkspecs/win32-msvc2010/qmake.conf +++ b/mkspecs/win32-msvc2010/qmake.conf @@ -16,7 +16,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- QMAKE_CFLAGS_WARN_ON = -W3 QMAKE_CFLAGS_WARN_OFF = -W0 QMAKE_CFLAGS_RELEASE = -O2 -MD -- cgit v1.2.1 From 367aa34cbcfa109926087e89d49f9223c1409d44 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jul 2010 13:23:56 +0200 Subject: Add a QAuthenticatorPrivate parsing for the headers without QHttpResponseHeader Reviewed-by: Markus Goetz --- src/network/access/qhttpnetworkconnection.cpp | 9 ++----- src/network/kernel/qauthenticator.cpp | 39 ++++++++++++++++++--------- src/network/kernel/qauthenticator_p.h | 1 + 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1afabecf74..9e2b85ed68 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -286,13 +286,8 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket resend = false; //create the response header to be used with QAuthenticatorPrivate. - QHttpResponseHeader responseHeader; QList > fields = reply->header(); - QList >::const_iterator it = fields.constBegin(); - while (it != fields.constEnd()) { - responseHeader.addValue(QString::fromLatin1(it->first), QString::fromUtf8(it->second)); - it++; - } + //find out the type of authentication protocol requested. QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy); if (authMethod != QAuthenticatorPrivate::None) { @@ -310,7 +305,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket if (auth->isNull()) auth->detach(); QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth); - priv->parseHttpResponse(responseHeader, isProxy); + priv->parseHttpResponse(fields, isProxy); if (priv->phase == QAuthenticatorPrivate::Done) { if ((isProxy && pendingProxyAuthSignal) ||(!isProxy && pendingAuthSignal)) { diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index e7442c0f35..0ea4fd4a8e 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -241,7 +241,20 @@ QAuthenticatorPrivate::QAuthenticatorPrivate() #ifndef QT_NO_HTTP void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, bool isProxy) { - QList > values = header.values(); + const QList > values = header.values(); + QList > rawValues; + + QList >::const_iterator it, end; + for (it = values.constBegin(), end = values.constEnd(); it != end; ++it) + rawValues.append(qMakePair(it->first.toLatin1(), it->second.toUtf8())); + + // continue in byte array form + parseHttpResponse(rawValues, isProxy); +} +#endif + +void QAuthenticatorPrivate::parseHttpResponse(const QList > &values, bool isProxy) +{ const char *search = isProxy ? "proxy-authenticate" : "www-authenticate"; method = None; @@ -255,24 +268,25 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, authentication parameters. */ - QString headerVal; + QByteArray headerVal; for (int i = 0; i < values.size(); ++i) { - const QPair ¤t = values.at(i); - if (current.first.toLower() != QLatin1String(search)) + const QPair ¤t = values.at(i); + if (current.first.toLower() != search) continue; - QString str = current.second; - if (method < Basic && str.startsWith(QLatin1String("Basic"), Qt::CaseInsensitive)) { - method = Basic; headerVal = str.mid(6); - } else if (method < Ntlm && str.startsWith(QLatin1String("NTLM"), Qt::CaseInsensitive)) { + QByteArray str = current.second.toLower(); + if (method < Basic && str.startsWith("basic")) { + method = Basic; + headerVal = current.second.mid(6); + } else if (method < Ntlm && str.startsWith("ntlm")) { method = Ntlm; - headerVal = str.mid(5); - } else if (method < DigestMd5 && str.startsWith(QLatin1String("Digest"), Qt::CaseInsensitive)) { + headerVal = current.second.mid(5); + } else if (method < DigestMd5 && str.startsWith("digest")) { method = DigestMd5; - headerVal = str.mid(7); + headerVal = current.second.mid(7); } } - challenge = headerVal.trimmed().toLatin1(); + challenge = headerVal.trimmed(); QHash options = parseDigestAuthenticationChallenge(challenge); switch(method) { @@ -300,7 +314,6 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, phase = Invalid; } } -#endif QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMethod, const QByteArray &path) { diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index e9ce9ac161..abb1cdaf26 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -102,6 +102,7 @@ public: #ifndef QT_NO_HTTP void parseHttpResponse(const QHttpResponseHeader &, bool isProxy); #endif + void parseHttpResponse(const QList >&, bool isProxy); }; -- cgit v1.2.1 From 69027cdb2ab9b89673edf29d5034bed33e614a05 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jul 2010 12:58:04 +0200 Subject: Expose the QAuthenticator map of options in the API. Task-number: QT-3573 Reviewed-By: Markus Goetz --- src/network/kernel/qauthenticator.cpp | 45 +++++++++++++++++++++++++++++++++-- src/network/kernel/qauthenticator.h | 5 ++++ src/network/kernel/qauthenticator_p.h | 3 ++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 0ea4fd4a8e..ca8ec1cab5 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -140,7 +140,8 @@ bool QAuthenticator::operator==(const QAuthenticator &other) const return d->user == other.d->user && d->password == other.d->password && d->realm == other.d->realm - && d->method == other.d->method; + && d->method == other.d->method + && d->options == other.d->options; } /*! @@ -218,9 +219,49 @@ QString QAuthenticator::realm() const return d ? d->realm : QString(); } +/*! + \since 4.7 + Returns the value related to option \a opt if it was set by the server. + See \l{QAuthenticator#Options} for more information on incoming options. + If option \a opt isn't found, an invalid QVariant will be returned. + + \sa options(), QAuthenticator#Options +*/ +QVariant QAuthenticator::option(const QString &opt) const +{ + return d ? d->options.value(opt) : QVariant(); +} + +/*! + \since 4.7 + Returns all incoming options set in this QAuthenticator object by parsing + the server reply. See \l{QAuthenticator#Options} for more information + on incoming options. + + \sa option(), QAuthenticator#Options +*/ +QVariantHash QAuthenticator::options() const +{ + return d ? d->options : QVariantHash(); +} + +/*! + \since 4.7 + + Sets the outgoing option \a opt to value \a value. + See \l{QAuthenticator#Options} for more information on outgoing options. + + \sa options(), option(), QAuthenticator#Options +*/ +void QAuthenticator::setOption(const QString &opt, const QVariant &value) +{ + detach(); + d->options.insert(opt, value); +} + /*! - returns true if the authenticator is null. + Returns true if the authenticator is null. */ bool QAuthenticator::isNull() const { diff --git a/src/network/kernel/qauthenticator.h b/src/network/kernel/qauthenticator.h index 13ce593496..983b7c0214 100644 --- a/src/network/kernel/qauthenticator.h +++ b/src/network/kernel/qauthenticator.h @@ -43,6 +43,7 @@ #define QAUTHENTICATOR_H #include +#include QT_BEGIN_HEADER @@ -73,6 +74,10 @@ public: QString realm() const; + QVariant option(const QString &opt) const; + QVariantHash options() const; + void setOption(const QString &opt, const QVariant &value); + bool isNull() const; void detach(); private: diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index abb1cdaf26..665afef55e 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -57,6 +57,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -71,7 +72,7 @@ public: QAtomicInt ref; QString user; QString password; - QHash options; + QVariantHash options; Method method; QString realm; QByteArray challenge; -- cgit v1.2.1 From 1af3362a321dd055798173737d3aede367a1d30c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jul 2010 13:01:33 +0200 Subject: Add documentation for the QAuthenticator options. Task-number: QT-3573 Reviewed-by: Markus Goetz --- src/network/kernel/qauthenticator.cpp | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index ca8ec1cab5..d61c6863ea 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -85,6 +85,44 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas Note that, in particular, NTLM version 2 is not supported. + \section1 Options + + In addition to the username and password required for authentication, a + QAuthenticator object can also contain additional options. The + options() function can be used to query incoming options sent by + the server; the setOption() function can + be used to set outgoing options, to be processed by the authenticator + calculation. The options accepted and provided depend on the authentication + type (see method()). + + The following tables list known incoming options as well as accepted + outgoing options. The list of incoming options is not exhaustive, since + servers may include additional information at any time. The list of + outgoing options is exhaustive, however, and no unknown options will be + treated or sent back to the server. + + \section2 Basic + + \table + \header \o Option \o Direction \o Description + \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() + \endtable + + The Basic authentication mechanism supports no outgoing options. + + \section2 NTLM version 1 + + The NTLM authentication mechanism currently supports no incoming or outgoing options. + + \section2 Digest-MD5 + + \table + \header \o Option \o Direction \o Description + \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() + \endtable + + The Digest-MD5 authentication mechanism supports no outgoing options. + \sa QSslSocket */ @@ -333,7 +371,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QListoptions[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); if (user.isEmpty()) phase = Done; break; @@ -342,7 +380,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QListoptions[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); if (options.value("stale").toLower() == "true") phase = Start; if (user.isEmpty()) -- cgit v1.2.1 From 648f8a05abac5fbf851fff18d1c34ff7c4a7a027 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jul 2010 17:21:25 +0200 Subject: Autotest: add a small, boring test for QAuthenticator --- src/network/kernel/qauthenticator_p.h | 2 +- tests/auto/qauthenticator/qauthenticator.pro | 5 + tests/auto/qauthenticator/tst_qauthenticator.cpp | 155 +++++++++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qauthenticator/qauthenticator.pro create mode 100644 tests/auto/qauthenticator/tst_qauthenticator.cpp diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index 665afef55e..10966014b9 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE class QHttpResponseHeader; -class QAuthenticatorPrivate +class Q_AUTOTEST_EXPORT QAuthenticatorPrivate { public: enum Method { None, Basic, Plain, Login, Ntlm, CramMd5, DigestMd5 }; diff --git a/tests/auto/qauthenticator/qauthenticator.pro b/tests/auto/qauthenticator/qauthenticator.pro new file mode 100644 index 0000000000..05f83bc166 --- /dev/null +++ b/tests/auto/qauthenticator/qauthenticator.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +requires(contains(QT_CONFIG,private_tests)) +QT = core network +SOURCES += tst_qauthenticator.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qauthenticator/tst_qauthenticator.cpp b/tests/auto/qauthenticator/tst_qauthenticator.cpp new file mode 100644 index 0000000000..37d6774e3e --- /dev/null +++ b/tests/auto/qauthenticator/tst_qauthenticator.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +#include + +class tst_QAuthenticator : public QObject +{ + Q_OBJECT + +public: + tst_QAuthenticator(); + +private Q_SLOTS: + void basicAuth(); + void basicAuth_data(); + + void ntlmAuth_data(); + void ntlmAuth(); +}; + +tst_QAuthenticator::tst_QAuthenticator() +{ +} + +void tst_QAuthenticator::basicAuth_data() +{ + QTest::addColumn("data"); + QTest::addColumn("realm"); + QTest::addColumn("user"); + QTest::addColumn("password"); + QTest::addColumn("expectedReply"); + + QTest::newRow("just-user") << "" << "" << "foo" << "" << QByteArray("foo:").toBase64(); + QTest::newRow("user-password") << "" << "" << "foo" << "bar" << QByteArray("foo:bar").toBase64(); + QTest::newRow("user-password-realm") << "realm=\"secure area\"" << "secure area" << "foo" << "bar" << QByteArray("foo:bar").toBase64(); +} + +void tst_QAuthenticator::basicAuth() +{ + QFETCH(QString, data); + QFETCH(QString, realm); + QFETCH(QString, user); + QFETCH(QString, password); + QFETCH(QByteArray, expectedReply); + + QAuthenticator auth; + auth.detach(); + QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QList > headers; + headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); + priv->parseHttpResponse(headers, /*isProxy = */ false); + + QCOMPARE(auth.realm(), realm); + QCOMPARE(auth.option("realm").toString(), realm); + + auth.setUser(user); + auth.setPassword(password); + + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QCOMPARE(priv->calculateResponse("GET", "/").constData(), ("Basic " + expectedReply).constData()); +} + +void tst_QAuthenticator::ntlmAuth_data() +{ + QTest::addColumn("data"); + QTest::addColumn("realm"); + + QTest::newRow("no-realm") << "TlRMTVNTUAACAAAAHAAcADAAAAAFAoEATFZ3OLRQADIAAAAAAAAAAJYAlgBMAAAAUQBUAC0AVABFAFMAVAAtAEQATwBNAEEASQBOAAIAHABRAFQALQBUAEUAUwBUAC0ARABPAE0AQQBJAE4AAQAcAFEAVAAtAFQARQBTAFQALQBTAEUAUgBWAEUAUgAEABYAcQB0AC0AdABlAHMAdAAtAG4AZQB0AAMANABxAHQALQB0AGUAcwB0AC0AcwBlAHIAdgBlAHIALgBxAHQALQB0AGUAcwB0AC0AbgBlAHQAAAAAAA==" << ""; + QTest::newRow("with-realm") << "TlRMTVNTUAACAAAADAAMADgAAAAFAoECWCZkccFFAzwAAAAAAAAAAL4AvgBEAAAABQLODgAAAA9NAEcARABOAE8ASwACAAwATQBHAEQATgBPAEsAAQAcAE4ATwBLAC0AQQBNAFMAUwBTAEYARQAtADAAMQAEACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQADAD4AbgBvAGsALQBhAG0AcwBzAHMAZgBlAC0AMAAxAC4AbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAFACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAAAAAA" << "NOE"; +} + +void tst_QAuthenticator::ntlmAuth() +{ + QFETCH(QString, data); + QFETCH(QString, realm); + + QAuthenticator auth; + auth.detach(); + QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QList > headers; + + // NTLM phase 1: negotiate + // This phase of NTLM contains no information, other than what we're willing to negotiate + // Current implementation uses flags: + // NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET + headers << qMakePair("WWW-Authenticate", "NTLM"); + priv->parseHttpResponse(headers, /*isProxy = */ false); + QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABQIAAAAAAAAAAAAAAAAAAAAAAAA="); + + // NTLM phase 2: challenge + headers.clear(); + headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); + priv->parseHttpResponse(headers, /*isProxy = */ false); + + QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue); + QCOMPARE(auth.realm(), realm); + + auth.setUser("unimportant"); + auth.setPassword("unimportant"); + + QVERIFY(!priv->calculateResponse("GET", "/").isEmpty()); +} + +QTEST_MAIN(tst_QAuthenticator); + +#include "tst_qauthenticator.moc" -- cgit v1.2.1 From 01978218333aab792e32d7c69bbaea849b3b8d15 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jul 2010 17:19:27 +0200 Subject: Autotest: reenable the NTLM proxy test on tst_QTcpSocket --- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 31cae403dd..e3b2ca53a6 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -275,7 +275,7 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; -// QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; + QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; #ifndef QT_NO_OPENSSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; @@ -284,7 +284,7 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; -// QTest::newRow("WithHttpProxyNtlmAuth SSL") << true << int(HttpProxy | AuthNtlm) << true; + QTest::newRow("WithHttpProxyNtlmAuth SSL") << true << int(HttpProxy | AuthNtlm) << true; #endif } -- cgit v1.2.1 From b9c2853a0fd1876f30a410fe8dac5c477cef9d0e Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 15 Jul 2010 14:08:20 +0200 Subject: Add a testcase for QTBUG-11213 to prevent future regressions. Merge-request: 2427 Reviewed-by: Bradley T. Hughes --- tests/auto/quuid/quuid.pro | 9 ++-- tests/auto/quuid/test/test.pro | 29 ++++++++++ tests/auto/quuid/testProcessUniqueness/main.cpp | 62 ++++++++++++++++++++++ .../testProcessUniqueness.pro | 8 +++ tests/auto/quuid/tst_quuid.cpp | 29 ++++++++++ 5 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 tests/auto/quuid/test/test.pro create mode 100644 tests/auto/quuid/testProcessUniqueness/main.cpp create mode 100644 tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro diff --git a/tests/auto/quuid/quuid.pro b/tests/auto/quuid/quuid.pro index f7608fa377..25e24561ae 100644 --- a/tests/auto/quuid/quuid.pro +++ b/tests/auto/quuid/quuid.pro @@ -1,3 +1,6 @@ -load(qttest_p4) -QT = core -SOURCES += tst_quuid.cpp +TEMPLATE = subdirs + +SUBDIRS = testProcessUniqueness + +SUBDIRS += test + diff --git a/tests/auto/quuid/test/test.pro b/tests/auto/quuid/test/test.pro new file mode 100644 index 0000000000..123aa50e4e --- /dev/null +++ b/tests/auto/quuid/test/test.pro @@ -0,0 +1,29 @@ +load(qttest_p4) + +QT = core +SOURCES += ../tst_quuid.cpp +TARGET = tst_quuid + +CONFIG(debug_and_release_target) { + CONFIG(debug, debug|release) { + DESTDIR = ../debug + } else { + DESTDIR = ../release + } +} else { + DESTDIR = .. +} + +wince* { + addFile_processUniqueness.sources = $$OUT_PWD/../testProcessUniqueness/testProcessUniqueness.exe + addFile_processUniqueness.path = testProcessUniqueness + + DEPLOYMENT += addFile_processUniqueness +} + +symbian { + binDep.sources = testProcessUniqueness.exe + binDep.path = \\sys\\bin + + DEPLOYMENT += binDep +} diff --git a/tests/auto/quuid/testProcessUniqueness/main.cpp b/tests/auto/quuid/testProcessUniqueness/main.cpp new file mode 100644 index 0000000000..4d33c84abb --- /dev/null +++ b/tests/auto/quuid/testProcessUniqueness/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +// This is a testcase for QTBUG-11213 +int main(int argc, char **argv) +{ + Q_UNUSED(argc) + Q_UNUSED(argv) + + // First, break QUuid. + qrand(); + + // Now print a few uuids. + printf("%s", qPrintable(QUuid::createUuid().toString())); + printf("%s", qPrintable(QUuid::createUuid().toString())); + printf("%s", qPrintable(QUuid::createUuid().toString())); + + // Done + return 0; +} + diff --git a/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro b/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro new file mode 100644 index 0000000000..88df1a25d7 --- /dev/null +++ b/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp +CONFIG += console + +DESTDIR = ./ + +# no install rule for application used by test +INSTALLS = + diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 47f356a8b7..409d8cf2c0 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -73,6 +73,7 @@ private slots: void versions(); void threadUniqueness(); + void processUniqueness(); public: // Variables @@ -196,5 +197,33 @@ void tst_QUuid::threadUniqueness() qDeleteAll(threads); } +void tst_QUuid::processUniqueness() +{ + QProcess process; + QString processOneOutput; + QString processTwoOutput; + + // Start it once +#ifdef Q_OS_MAC + process.start("testProcessUniqueness/testProcessUniqueness.app"); +#else + process.start("testProcessUniqueness/testProcessUniqueness"); +#endif + QVERIFY(process.waitForFinished()); + processOneOutput = process.readAllStandardOutput(); + + // Start it twice +#ifdef Q_OS_MAC + process.start("testProcessUniqueness/testProcessUniqueness.app"); +#else + process.start("testProcessUniqueness/testProcessUniqueness"); +#endif + QVERIFY(process.waitForFinished()); + processTwoOutput = process.readAllStandardOutput(); + + // They should be *different*! + QVERIFY(processOneOutput != processTwoOutput); +} + QTEST_MAIN(tst_QUuid) #include "tst_quuid.moc" -- cgit v1.2.1 From 1c34bf050da3c4d6c303e1dd1dad9eb99e7ccbf4 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 15 Jul 2010 14:56:54 +0200 Subject: QNAM HTTP: Fix problem with cached files and metaDataChanged() Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index a6c5c02bfb..f617244b17 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -944,10 +944,10 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m checkForRedirect(status); - emit metaDataChanged(); - - // invoke this asynchronously, else Arora/QtDemoBrowser don't like cached downloads - // see task 250221 / 251801 + // This needs to be emitted in the event loop because it can be reached at + // the direct code path of qnam.get(...) before the user has a chance + // to connect any signals. + QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); qRegisterMetaType("QIODevice*"); QMetaObject::invokeMethod(this, "writeDownstreamData", Qt::QueuedConnection, Q_ARG(QIODevice*, contents)); -- cgit v1.2.1 From 30630cf2bf8c7604efc3a52f74983c2237f309c3 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 15 Jul 2010 16:50:28 +0200 Subject: Unbreak the Maemo 5 build after the Symbian fix Reviewed-by: Robert Griebl --- tools/qml/qml.pri | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index fcd0c33f88..80afb45cae 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -17,16 +17,16 @@ SOURCES += $$PWD/qmlruntime.cpp \ $$PWD/loggerwidget.cpp RESOURCES = $$PWD/qmlruntime.qrc -maemo5 { +symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { + SOURCES += $$PWD/deviceorientation_symbian.cpp + FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui +} else:maemo5 { QT += dbus HEADERS += $$PWD/texteditautoresizer_maemo5.h SOURCES += $$PWD/deviceorientation_maemo5.cpp FORMS = $$PWD/recopts_maemo5.ui \ $$PWD/proxysettings_maemo5.ui -} symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { - SOURCES += $$PWD/deviceorientation_symbian.cpp - FORMS = $$PWD/recopts.ui \ - $$PWD/proxysettings.ui } else { SOURCES += $$PWD/deviceorientation.cpp FORMS = $$PWD/recopts.ui \ -- cgit v1.2.1 From b863daec96868731412bd8f89b960bc7395911ae Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 13 Jul 2010 11:34:44 +0200 Subject: split qt_help out into an own ts target the combined target would be too hard to transform in the next commit --- translations/translations.pri | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/translations/translations.pri b/translations/translations.pri index f5e54ca98c..6a13dfffa0 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -52,11 +52,15 @@ ts-linguist.depends = sub-tools ###### Assistant ts-assistant.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/assistant/tools/assistant/assistant.pro \ - && $$LUPDATE \ - ../tools/assistant/lib/lib.pro) + ../tools/assistant/tools/assistant/assistant.pro) ts-assistant.depends = sub-tools +###### Qt Help Lib + +ts-qt_help.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ + ../tools/assistant/lib/lib.pro) +ts-qt_help.depends = sub-tools + ###### Qtconfig ts-qtconfig.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ @@ -71,10 +75,10 @@ ts-qvfb.depends = sub-tools ###### Overall Rules -ts.depends = ts-qt ts-designer ts-linguist ts-assistant ts-qtconfig ts-qvfb +ts.depends = ts-qt ts-designer ts-linguist ts-assistant ts-qt_help ts-qtconfig ts-qvfb check-ts.commands = (cd $$PWD && perl check-ts.pl) check-ts.depends = ts -QMAKE_EXTRA_TARGETS += ts-qt ts-designer ts-linguist ts-assistant ts-qtconfig ts-qvfb \ +QMAKE_EXTRA_TARGETS += ts-qt ts-designer ts-linguist ts-assistant ts-qt_help ts-qtconfig ts-qvfb \ ts check-ts -- cgit v1.2.1 From 807bc3aca8a0b07ee1dfe1e398044d32756e5de0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 13 Jul 2010 12:55:31 +0200 Subject: more fine-grained ts targets there are now per-language ts-- and ts- targets to update only the files relevant for a given language. there is also a ts-all target which does what the old ts target did. the ts- targets are now named ts--all and should not be used manually - they exist for the convenience of the ts-all target. the ts target is now only a help blurb. --- tools/assistant/lib/lib.pro | 13 --- tools/assistant/tools/assistant/assistant.pro | 13 --- tools/designer/designer.pro | 13 --- tools/linguist/linguist/linguist.pro | 12 --- tools/qtconfig/qtconfig.pro | 8 -- tools/qvfb/qvfb.pro | 8 -- translations/translations.pri | 132 +++++++++++--------------- 7 files changed, 56 insertions(+), 143 deletions(-) diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index e84cf31480..26d34562cf 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -69,16 +69,3 @@ HEADERS += qhelpenginecore.h \ # access to clucene HEADERS += qhelpsearchindexwriter_clucene_p.h \ qhelpsearchindexreader_clucene_p.h - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/qt_help_cs.ts \ - $$TR_DIR/qt_help_da.ts \ - $$TR_DIR/qt_help_de.ts \ - $$TR_DIR/qt_help_hu.ts \ - $$TR_DIR/qt_help_ja.ts \ - $$TR_DIR/qt_help_pl.ts \ - $$TR_DIR/qt_help_ru.ts \ - $$TR_DIR/qt_help_zh_CN.ts \ - $$TR_DIR/qt_help_zh_TW.ts \ - $$TR_DIR/qt_help_fr.ts diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 16a520e212..d9aff7a4da 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -108,16 +108,3 @@ contains(CONFIG, static): { DEFINES += USE_STATIC_SQLITE_PLUGIN } } - -TR_DIR = $$PWD/../../../../translations -TRANSLATIONS = \ - $$TR_DIR/assistant_cs.ts \ - $$TR_DIR/assistant_da.ts \ - $$TR_DIR/assistant_de.ts \ - $$TR_DIR/assistant_fr.ts \ - $$TR_DIR/assistant_hu.ts \ - $$TR_DIR/assistant_ja.ts \ - $$TR_DIR/assistant_pl.ts \ - $$TR_DIR/assistant_ru.ts \ - $$TR_DIR/assistant_zh_CN.ts \ - $$TR_DIR/assistant_zh_TW.ts diff --git a/tools/designer/designer.pro b/tools/designer/designer.pro index 31c8622272..721c4fc42e 100644 --- a/tools/designer/designer.pro +++ b/tools/designer/designer.pro @@ -3,16 +3,3 @@ TEMPLATE = subdirs CONFIG += qt SUBDIRS = src - -TR_DIR = $$PWD/../../translations -TRANSLATIONS = \ - $$TR_DIR/designer_cs.ts \ - $$TR_DIR/designer_de.ts \ - $$TR_DIR/designer_fr.ts \ - $$TR_DIR/designer_hu.ts \ - $$TR_DIR/designer_ja.ts \ - $$TR_DIR/designer_pl.ts \ - $$TR_DIR/designer_ru.ts \ - $$TR_DIR/designer_sl.ts \ - $$TR_DIR/designer_zh_CN.ts \ - $$TR_DIR/designer_zh_TW.ts diff --git a/tools/linguist/linguist/linguist.pro b/tools/linguist/linguist/linguist.pro index 4f7ed8a77e..ce8d5854f1 100644 --- a/tools/linguist/linguist/linguist.pro +++ b/tools/linguist/linguist/linguist.pro @@ -94,15 +94,3 @@ FORMS += statistics.ui \ translationsettings.ui \ finddialog.ui RESOURCES += linguist.qrc - -TR_DIR = $$PWD/../../../translations -TRANSLATIONS = \ - $$TR_DIR/linguist_cs.ts \ - $$TR_DIR/linguist_de.ts \ - $$TR_DIR/linguist_fr.ts \ - $$TR_DIR/linguist_hu.ts \ - $$TR_DIR/linguist_ja.ts \ - $$TR_DIR/linguist_pl.ts \ - $$TR_DIR/linguist_ru.ts \ - $$TR_DIR/linguist_zh_CN.ts \ - $$TR_DIR/linguist_zh_TW.ts diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index 3a24e854a7..d1fd32020d 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -29,11 +29,3 @@ target.path=$$[QT_INSTALL_BINS] INSTALLS += target INCLUDEPATH += . DBFILE = qtconfig.db - -TR_DIR = $$PWD/../../translations -TRANSLATIONS = \ - $$TR_DIR/qtconfig_hu.ts \ - $$TR_DIR/qtconfig_pl.ts \ - $$TR_DIR/qtconfig_ru.ts \ - $$TR_DIR/qtconfig_zh_CN.ts \ - $$TR_DIR/qtconfig_zh_TW.ts diff --git a/tools/qvfb/qvfb.pro b/tools/qvfb/qvfb.pro index df69817822..c101d00a50 100644 --- a/tools/qvfb/qvfb.pro +++ b/tools/qvfb/qvfb.pro @@ -62,11 +62,3 @@ unix:x11 { } RESOURCES += qvfb.qrc - -TR_DIR = $$PWD/../../translations -TRANSLATIONS = \ - $$TR_DIR/qvfb_hu.ts \ - $$TR_DIR/qvfb_pl.ts \ - $$TR_DIR/qvfb_ru.ts \ - $$TR_DIR/qvfb_zh_CN.ts \ - $$TR_DIR/qvfb_zh_TW.ts diff --git a/translations/translations.pri b/translations/translations.pri index 6a13dfffa0..b41f2a0fad 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -1,84 +1,64 @@ -defineReplace(prependAll) { - prepend = $$1 - arglist = $$2 - append = $$3 - for(a,arglist) { - result += $${prepend}$${a}$${append} - } - return ($$result) -} - qtPrepareTool(LUPDATE, lupdate) LUPDATE += -locations relative -no-ui-lines -###### Qt Libraries - -QT_TS = ar cs da de es fr he hu ja pl pt ru sk sl sv uk zh_CN zh_TW - -ts-qt.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - -I../include -I../include/Qt \ - 3rdparty/phonon \ - 3rdparty/webkit \ - activeqt \ - corelib \ - declarative \ - gui \ - multimedia \ - network \ - opengl \ - plugins \ - qt3support \ - script \ - scripttools \ - sql \ - svg \ - xml \ - xmlpatterns \ - -ts $$prependAll($$QT_SOURCE_TREE/translations/qt_,$$QT_TS,.ts)) -ts-qt.depends = sub-tools - -###### Designer - -ts-designer.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/designer/designer.pro) -ts-designer.depends = sub-tools - -###### Linguist - -ts-linguist.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/linguist/linguist/linguist.pro) -ts-linguist.depends = sub-tools - -###### Assistant - -ts-assistant.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/assistant/tools/assistant/assistant.pro) -ts-assistant.depends = sub-tools - -###### Qt Help Lib - -ts-qt_help.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/assistant/lib/lib.pro) -ts-qt_help.depends = sub-tools - -###### Qtconfig - -ts-qtconfig.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/qtconfig/qtconfig.pro) -ts-qtconfig.depends = sub-tools - -###### Qvfp - -ts-qvfb.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ - ../tools/qvfb/qvfb.pro) -ts-qvfb.depends = sub-tools +TS_TARGETS = + +# meta target name, target name, lupdate base options, files +defineTest(addTsTarget) { + cv = $${2}.commands + dv = $${2}.depends + $$cv = cd $$QT_SOURCE_TREE/src && $$LUPDATE $$3 -ts $$4 + $$dv = sub-tools + export($$cv) + export($$dv) + dv = $${1}.depends + $$dv += $$2 + export($$dv) + TS_TARGETS += $$1 $$2 + export(TS_TARGETS) +} -###### Overall Rules +# target basename, lupdate base options +defineTest(addTsTargets) { + files = $$files($$PWD/$${1}_??.ts) $$files($$PWD/$${1}_??_??.ts) + for(file, files) { + lang = $$replace(file, .*_((.._)?..)\\.ts$, \\1) + addTsTarget(ts-$$lang, ts-$$1-$$lang, $$2, $$file) + } + addTsTarget(ts-all, ts-$$1-all, $$2, $$files) +} -ts.depends = ts-qt ts-designer ts-linguist ts-assistant ts-qt_help ts-qtconfig ts-qvfb +addTsTargets(qt, -I../include -I../include/Qt \ + 3rdparty/phonon \ + 3rdparty/webkit \ + activeqt \ + corelib \ + declarative \ + gui \ + multimedia \ + network \ + opengl \ + plugins \ + qt3support \ + script \ + scripttools \ + sql \ + svg \ + xml \ + xmlpatterns \ +) +addTsTargets(designer, ../tools/designer/designer.pro) +addTsTargets(linguist, ../tools/linguist/linguist/linguist.pro) +addTsTargets(assistant, ../tools/assistant/tools/assistant/assistant.pro) +addTsTargets(qt_help, ../tools/assistant/lib/lib.pro) +addTsTargets(qtconfig, ../tools/qtconfig/qtconfig.pro) +addTsTargets(qvfb, ../tools/qvfb/qvfb.pro) check-ts.commands = (cd $$PWD && perl check-ts.pl) -check-ts.depends = ts +check-ts.depends = ts-all + +ts.commands = \ + @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \ + echo \"Use \'ts--\' or \'ts-\' instead.\" -QMAKE_EXTRA_TARGETS += ts-qt ts-designer ts-linguist ts-assistant ts-qt_help ts-qtconfig ts-qvfb \ - ts check-ts +QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts check-ts -- cgit v1.2.1 From 511a838afdb1d028bf184bb56c9ead39312987ca Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 13 Jul 2010 12:57:07 +0200 Subject: (re-)add 'untranslated' ts targets these files are not meant for commit, but it's good to have a quick way to create templates. --- .gitignore | 1 + translations/check-ts.pl | 2 +- translations/translations.pri | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fdb68435f3..4d5aa9b2ff 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ tools/qtestlib/chart/chart* tools/qtestlib/updater/updater* tools/activeqt/testcon/testcon.tlb translations/*.qm +translations/*_untranslated.ts qrc_*.cpp # xemacs temporary files diff --git a/translations/check-ts.pl b/translations/check-ts.pl index 5f38703fe0..0ff9d175da 100755 --- a/translations/check-ts.pl +++ b/translations/check-ts.pl @@ -49,7 +49,7 @@ my @groups = ("assistant", "designer", "linguist", "qt_help", "qtconfig", "qvfb" my %scores = (); my %langs = (); -my $files = join("\n", <*.ts>); +my $files = join("\n", <*_??.ts>); my $res = `xmlpatterns -param files=\"$files\" check-ts.xq`; for my $i (split(/ /, $res)) { $i =~ /^([^.]+).ts:(.*)$/; diff --git a/translations/translations.pri b/translations/translations.pri index b41f2a0fad..735411e592 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -25,7 +25,8 @@ defineTest(addTsTargets) { lang = $$replace(file, .*_((.._)?..)\\.ts$, \\1) addTsTarget(ts-$$lang, ts-$$1-$$lang, $$2, $$file) } - addTsTarget(ts-all, ts-$$1-all, $$2, $$files) + addTsTarget(ts-untranslated, ts-$$1-untranslated, $$2, $$PWD/$${1}_untranslated.ts) + addTsTarget(ts-all, ts-$$1-all, $$2, $$PWD/$${1}_untranslated.ts $$files) } addTsTargets(qt, -I../include -I../include/Qt \ @@ -59,6 +60,7 @@ check-ts.depends = ts-all ts.commands = \ @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \ - echo \"Use \'ts--\' or \'ts-\' instead.\" + echo \"Use \'ts--\' or \'ts-\' instead. To add a language,\" && \ + echo \"use \'untranslated\' for , rename the files and re-run \'qmake\'.\" QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts check-ts -- cgit v1.2.1 From 468eb186427067549191f3b921c9f9d75a6947ef Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 13 Jul 2010 20:39:37 +0200 Subject: add commit-ts target to commit ts files without line number info it is pretty pointless to commit the extracted line number information, as it needs to be refreshed after pulling source code changes anyway. on top of it, it bloats the repository. --- translations/translations.pri | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/translations/translations.pri b/translations/translations.pri index 735411e592..c27e9557d1 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -1,3 +1,4 @@ +qtPrepareTool(LCONVERT, lconvert) qtPrepareTool(LUPDATE, lupdate) LUPDATE += -locations relative -no-ui-lines @@ -58,9 +59,25 @@ addTsTargets(qvfb, ../tools/qvfb/qvfb.pro) check-ts.commands = (cd $$PWD && perl check-ts.pl) check-ts.depends = ts-all +isEqual(QMAKE_DIR_SEP, /) { + commit-ts.commands = \ + cd $$PWD/..; \ + for f in `git diff-files --name-only translations/*_??.ts`; do \ + $$LCONVERT -locations none -i \$\$f -o \$\$f; \ + done; \ + git add translations/*_??.ts && git commit +} else { + wd = $$replace(PWD, /, \\)\\.. + commit-ts.commands = \ + cd $$wd && \ + for /f usebackq %%f in (`git diff-files --name-only translations/*_??.ts`) do \ + $$LCONVERT -locations none -i %%f -o %%f $$escape_expand(\\n\\t) \ + cd $$wd && git add translations/*_??.ts && git commit +} + ts.commands = \ @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \ echo \"Use \'ts--\' or \'ts-\' instead. To add a language,\" && \ echo \"use \'untranslated\' for , rename the files and re-run \'qmake\'.\" -QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts check-ts +QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts commit-ts check-ts -- cgit v1.2.1 From 63f1fc5e7aac3b9b088b90577a2c5208be571183 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Jul 2010 11:21:11 +0200 Subject: remove dependency of ts targets on sub-tools it is pretty pointless, really. these are manual targets, so if they fail because of missing tools, the user can just make sub-tools manually. way better than wasting time waiting for make to run through the whole qt tree each time. --- translations/translations.pri | 3 --- 1 file changed, 3 deletions(-) diff --git a/translations/translations.pri b/translations/translations.pri index c27e9557d1..fbc1596023 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -7,11 +7,8 @@ TS_TARGETS = # meta target name, target name, lupdate base options, files defineTest(addTsTarget) { cv = $${2}.commands - dv = $${2}.depends $$cv = cd $$QT_SOURCE_TREE/src && $$LUPDATE $$3 -ts $$4 - $$dv = sub-tools export($$cv) - export($$dv) dv = $${1}.depends $$dv += $$2 export($$dv) -- cgit v1.2.1 From 4fc1008163907459d921c4089512268495245976 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 15 Jul 2010 18:42:28 +0200 Subject: cosmetics: quote the dot in the regexp --- translations/check-ts.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/check-ts.pl b/translations/check-ts.pl index 0ff9d175da..500be1590b 100755 --- a/translations/check-ts.pl +++ b/translations/check-ts.pl @@ -52,7 +52,7 @@ my %langs = (); my $files = join("\n", <*_??.ts>); my $res = `xmlpatterns -param files=\"$files\" check-ts.xq`; for my $i (split(/ /, $res)) { - $i =~ /^([^.]+).ts:(.*)$/; + $i =~ /^([^.]+)\.ts:(.*)$/; my ($fn, $pc) = ($1, $2); for my $g (@groups) { if ($fn =~ /^${g}_(.*)$/) { -- cgit v1.2.1 From 40d2b2e30a526b46b17072ba8bdc38f30cd3c624 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 15 Jul 2010 18:44:18 +0200 Subject: remove nasty hack by using a stricter regexp (for language codes) --- translations/check-ts.pl | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/translations/check-ts.pl b/translations/check-ts.pl index 500be1590b..067cad87af 100755 --- a/translations/check-ts.pl +++ b/translations/check-ts.pl @@ -43,8 +43,7 @@ use strict; -# "qt" must come last to avoid prefix matching. -my @groups = ("assistant", "designer", "linguist", "qt_help", "qtconfig", "qvfb", "qt"); +my @groups = ("qt", "assistant", "designer", "linguist", "qt_help", "qtconfig", "qvfb"); my %scores = (); my %langs = (); @@ -55,7 +54,7 @@ for my $i (split(/ /, $res)) { $i =~ /^([^.]+)\.ts:(.*)$/; my ($fn, $pc) = ($1, $2); for my $g (@groups) { - if ($fn =~ /^${g}_(.*)$/) { + if ($fn =~ /^${g}_((.._)?..)$/) { my $lang = $1; $scores{$g}{$lang} = $pc; $langs{$lang} = 1; @@ -64,10 +63,6 @@ for my $i (split(/ /, $res)) { } } -# now we move "qt" to the front, as it should be the first column. -pop @groups; -unshift @groups, "qt"; - my $code = ""; print "L10n "; -- cgit v1.2.1 From 062a504010534d5e899f042b27c8ace82b556426 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 16 Jul 2010 09:56:19 +1000 Subject: Fixed tst_maketestselftest::tests_pro_files failure Add qauthenticator to tests/auto/network.pro --- tests/auto/network.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/network.pro b/tests/auto/network.pro index 4f205fe049..e1898f1b85 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -7,6 +7,7 @@ SUBDIRS=\ networkselftest \ qabstractnetworkcache \ qabstractsocket \ + qauthenticator \ qeventloop \ qftp \ qhostaddress \ @@ -36,6 +37,7 @@ SUBDIRS=\ qsslsocket \ contains(QT_CONFIG, private_tests): SUBDIRS -= \ + qauthenticator \ qhttpnetworkconnection \ qhttpnetworkreply \ qnativesocketengine \ -- cgit v1.2.1 From 3a51462bfb3cca8c90e1c690cf045b371d2ab393 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 16 Jul 2010 11:17:02 +1000 Subject: Fixes the Oracle invalid date bug when date is greater or equal to 2800 By converting the char into unsigned char to avoid the overflow when getting the century from a char for years greater or equal to 2800. Task-number: QTBUG-8210 Reviewed-by: Michael Goddard --- src/sql/drivers/oci/qsql_oci.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index 2f0cfdce58..c56b9955b5 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -648,7 +648,7 @@ QByteArray qMakeOraDate(const QDateTime& dt) QDateTime qMakeDate(const char* oraDate) { - int century = oraDate[0]; + int century = uchar(oraDate[0]); if(century >= 100){ int year = uchar(oraDate[1]); year = ((century-100)*100) + (year-100); -- cgit v1.2.1 From 7a0b487ec10abd71bda6053021749740dc0ac545 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 16 Jul 2010 10:15:49 +0200 Subject: unused struct DIBINFO removed from qguifunctions_wince.cpp Reviewed-by: Martin Petersson --- src/gui/kernel/qguifunctions_wince.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index f5004b09ff..cafddbf612 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -131,15 +131,6 @@ static void resolveAygLibs() } } -struct DIBINFO : public BITMAPINFO -{ - RGBQUAD arColors[255]; - - operator LPBITMAPINFO() { return (LPBITMAPINFO) this; } - operator LPBITMAPINFOHEADER() { return &bmiHeader; } - RGBQUAD* ColorTable() { return bmiColors; } -}; - int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint) { if (!lpvBits) { -- cgit v1.2.1 From 5f76c2b168ded91835d5d161b738a5dc03556cf6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 16 Jul 2010 10:17:32 +0200 Subject: Windows mobile: show the [X] button in the taskbar when maximizing We're now showing the cancel button explicitly in the taskbar on maximize, if the widget does not have the widget flags CancelButtonHint and OKButtonHint. Task-number: QTBUG-8408 Reviewed-by: Martin Petersson --- src/gui/kernel/qguifunctions_wince.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index cafddbf612..bdaed654e6 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -314,6 +314,8 @@ void qt_wince_maximize(QWidget *widget) shidi.dwFlags |= SHIDIF_CANCELBUTTON; if (widget->windowFlags() & Qt::WindowOkButtonHint) shidi.dwFlags |= SHIDIF_DONEBUTTON; + if (!(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) + shidi.dwFlags |= SHIDIF_CANCELBUTTON; resolveAygLibs(); if (ptrAygInitDialog) ptrAygInitDialog(&shidi); -- cgit v1.2.1 From 2c1aafa47b8915ea8aae8da229d65086e42543b3 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 16 Jul 2010 10:37:58 +0200 Subject: Windows mobile: the [X] button in the taskbar minimizes the widget The [X] or cancel button in the task bar shall just "minimize" the widget on Windows mobile. A press on this button results in a WM_COMMAND, IDCANCEL message. Before this patch we just sent a QCloseEvent to the widget, which had basically no effect. Now, we're calling showMinimzed(), which is the desired behaviour. Task-number: QTBUG-8408 Reviewed-by: Martin Petersson --- src/gui/kernel/qapplication_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 9e8a128676..ec26e812f4 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2485,7 +2485,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa if (OkCommand) QApplication::postEvent(widget, new QEvent(QEvent::OkRequest)); if (CancelCommand) - QApplication::postEvent(widget, new QEvent(QEvent::Close)); + widget->showMinimized(); else #ifndef QT_NO_MENUBAR QMenuBar::wceCommands(LOWORD(wParam)); -- cgit v1.2.1 From ad4aff6e2d188d88a2c6b4b692932adb08491d22 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 16 Jul 2010 10:43:14 +0200 Subject: Windows mobile: hide [X] button in task bar on unmaximize When calling showNormal on a window that was maximized, we must remove the [X] button from the task bar. But only if it was added by qt_wince_maximize. Task-number: QTBUG-8408 Reviewed-by: Martin Petersson --- src/gui/kernel/qguifunctions_wince.cpp | 17 +++++++++++++++++ src/gui/kernel/qwidget_win.cpp | 1 + src/gui/kernel/qwidget_wince.cpp | 1 + 3 files changed, 19 insertions(+) diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index bdaed654e6..377dfe3187 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -76,6 +76,10 @@ struct AygSIPINFO #define SHIDIF_SIZEDLGFULLSCREEN 0x0004 #endif +#ifndef SHDB_HIDE +#define SHDB_HIDE 0x0002 +#endif + #ifndef SHFS_SHOWTASKBAR #define SHFS_SHOWTASKBAR 0x0001 #endif @@ -112,10 +116,12 @@ struct AygSIPINFO typedef BOOL (*AygInitDialog)(AygSHINITDLGINFO*); typedef BOOL (*AygFullScreen)(HWND, DWORD); typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT); +typedef BOOL (*AygSHDoneButton)(HWND, DWORD); static AygInitDialog ptrAygInitDialog = 0; static AygFullScreen ptrAygFullScreen = 0; static AygSHSipInfo ptrAygSHSipInfo = 0; +static AygSHDoneButton ptrAygSHDoneButton = 0; static bool aygResolved = false; static void resolveAygLibs() @@ -128,6 +134,7 @@ static void resolveAygLibs() ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog"); ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen"); ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo"); + ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton"); } } @@ -327,6 +334,16 @@ void qt_wince_maximize(QWidget *widget) } } +void qt_wince_unmaximize(QWidget *widget) +{ + if (ptrAygSHDoneButton && qt_wince_is_mobile() + && !(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) + { + // Hide the [X] button, we've added in qt_wince_maximize. + ptrAygSHDoneButton(widget->winId(), SHDB_HIDE); + } +} + void qt_wince_minimize(HWND hwnd) { #ifdef Q_OS_WINCE_WM diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 0f05c6b694..23f57dad24 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -70,6 +70,7 @@ #include "qguifunctions_wince.h" QT_USE_NAMESPACE extern void qt_wince_maximize(QWidget *widget); //defined in qguifunctions_wince.cpp +extern void qt_wince_unmaximize(QWidget *widget); //defined in qguifunctions_wince.cpp extern void qt_wince_minimize(HWND hwnd); //defined in qguifunctions_wince.cpp extern void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf); //defined in qguifunctions_wince.cpp extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp index fc1e52caf9..76532ed791 100644 --- a/src/gui/kernel/qwidget_wince.cpp +++ b/src/gui/kernel/qwidget_wince.cpp @@ -498,6 +498,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION; SetWindowLong(internalWinId(), GWL_STYLE, style); SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG); + qt_wince_unmaximize(this); } if (isVisible() && newstate & Qt::WindowMaximized) qt_wince_maximize(this); -- cgit v1.2.1
    ConstantValue
    ConstantValue

    "; + out() << "

    "; generateFullName(node, relative, marker); out() << "

    "; + out() << "

    "; generateText(brief, node, marker); out() << "

    "; + out() << "

    "; out() << protectEnc(node->doc().briefText().toString()); out() << "

    "; + out() << "

    "; out() << ""; if (!qpn->isWritable()) @@ -4097,7 +4099,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << "

    "; + out() << "

    "; out() << ""; generateSynopsis(qsn,relative,marker,CodeMarker::Detailed,false); //generateQmlItem(qsn,relative,marker,false); @@ -4114,7 +4116,7 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << "

    "; + out() << "

    "; out() << ""; generateSynopsis(qmn,relative,marker,CodeMarker::Detailed,false); out() << "