From 05145be7e502d4330ced88d3e55207a99c0a841b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 14 Aug 2009 14:35:44 +0200 Subject: Fixed coverity warnings Some dead code removed Some member not initialized missing --- src/gui/dialogs/qfiledialog.cpp | 2 +- src/gui/itemviews/qabstractitemview.cpp | 2 +- src/gui/itemviews/qitemdelegate.cpp | 2 -- src/gui/itemviews/qitemselectionmodel_p.h | 2 +- src/gui/itemviews/qlistwidget_p.h | 1 - src/gui/itemviews/qstandarditemmodel_p.h | 1 + src/gui/itemviews/qtreewidget.cpp | 2 ++ src/gui/itemviews/qtreewidgetitemiterator_p.h | 3 ++- src/gui/kernel/qwidget.cpp | 5 ++--- src/gui/kernel/qx11info_x11.cpp | 3 ++- src/gui/styles/qstyleoption.cpp | 6 +++--- src/gui/text/qcssparser_p.h | 14 +++++++------- src/gui/text/qzip.cpp | 2 +- src/gui/widgets/qcalendarwidget.cpp | 3 +-- src/network/ssl/qsslcertificate.cpp | 2 +- src/scripttools/debugging/qscriptstdmessagehandler.cpp | 13 +------------ 16 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 8299f69..f548912 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2696,7 +2696,7 @@ void QFileDialogPrivate::_q_updateOkButton() if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) { button->setEnabled(true); if (acceptMode == QFileDialog::AcceptSave) - button->setText(isOpenDirectory ? QFileDialog::tr("&Open") : acceptLabel); + button->setText(acceptLabel); return; } diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 4f32ecc..7b51483 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -584,7 +584,7 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) "QAbstractItemView::setModel", "The parent of a top level index should be invalid"); - if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) { + if (d->model != QAbstractItemModelPrivate::staticEmptyModel()) { connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 2cbde51..1e36f72 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -722,8 +722,6 @@ void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &o //let's add the last line (after the last QChar::LineSeparator) elided += option.fontMetrics.elidedText(text.mid(start), option.textElideMode, textRect.width()); - if (end != -1) - elided += QChar::LineSeparator; } d->textLayout.setText(elided); textLayoutSize = d->doTextLayout(textRect.width()); diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h index 6e1046c..e9e6bb1 100644 --- a/src/gui/itemviews/qitemselectionmodel_p.h +++ b/src/gui/itemviews/qitemselectionmodel_p.h @@ -65,7 +65,7 @@ public: QItemSelectionModelPrivate() : model(0), currentCommand(QItemSelectionModel::NoUpdate), - tableSelected(false) {} + tableSelected(false), tableColCount(0), tableRowCount(0) {} QItemSelection expandSelection(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) const; diff --git a/src/gui/itemviews/qlistwidget_p.h b/src/gui/itemviews/qlistwidget_p.h index 124222c..0851e20 100644 --- a/src/gui/itemviews/qlistwidget_p.h +++ b/src/gui/itemviews/qlistwidget_p.h @@ -163,7 +163,6 @@ class QListWidgetItemPrivate public: QListWidgetItemPrivate(QListWidgetItem *item) : q(item), theid(-1) {} QListWidgetItem *q; - int id; QVector values; int theid; }; diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/gui/itemviews/qstandarditemmodel_p.h index e21ac9c..5984a59 100644 --- a/src/gui/itemviews/qstandarditemmodel_p.h +++ b/src/gui/itemviews/qstandarditemmodel_p.h @@ -75,6 +75,7 @@ public: parent(0), rows(0), columns(0), + q_ptr(0), lastIndexOf(2) { } virtual ~QStandardItemPrivate(); diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index ee7cea3..025f83c 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -2074,6 +2074,8 @@ QList QTreeWidgetItem::takeChildren() void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool climb) { QTreeModel *model = (q->view ? qobject_cast(q->view->model()) : 0); + if (!model) + return; model->sortItems(&q->children, column, order); if (climb) { QList::iterator it = q->children.begin(); diff --git a/src/gui/itemviews/qtreewidgetitemiterator_p.h b/src/gui/itemviews/qtreewidgetitemiterator_p.h index 3ffe823..ee0808c 100644 --- a/src/gui/itemviews/qtreewidgetitemiterator_p.h +++ b/src/gui/itemviews/qtreewidgetitemiterator_p.h @@ -73,7 +73,8 @@ public: } QTreeWidgetItemIteratorPrivate(const QTreeWidgetItemIteratorPrivate& other) - : m_currentIndex(other.m_currentIndex), m_model(other.m_model), m_parentIndex(other.m_parentIndex) + : m_currentIndex(other.m_currentIndex), m_model(other.m_model), + m_parentIndex(other.m_parentIndex), q_ptr(other.q_ptr) { } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index cc41f73..c00f953 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2747,7 +2747,7 @@ void QWidget::showNormal() bool QWidget::isEnabledTo(QWidget* ancestor) const { const QWidget * w = this; - while (w && !w->testAttribute(Qt::WA_ForceDisabled) + while (!w->testAttribute(Qt::WA_ForceDisabled) && !w->isWindow() && w->parentWidget() && w->parentWidget() != ancestor) @@ -7239,8 +7239,7 @@ bool QWidget::isVisibleTo(QWidget* ancestor) const if (!ancestor) return isVisible(); const QWidget * w = this; - while (w - && !w->isHidden() + while (!w->isHidden() && !w->isWindow() && w->parentWidget() && w->parentWidget() != ancestor) diff --git a/src/gui/kernel/qx11info_x11.cpp b/src/gui/kernel/qx11info_x11.cpp index 786d48d..136f7f8 100644 --- a/src/gui/kernel/qx11info_x11.cpp +++ b/src/gui/kernel/qx11info_x11.cpp @@ -179,6 +179,7 @@ QX11InfoData* QX11Info::getX11Data(bool def) const QX11InfoData* res = 0; if (def) { res = new QX11InfoData; + res->ref = 0; res->screen = appScreen(); res->depth = appDepth(); res->cells = appCells(); @@ -189,8 +190,8 @@ QX11InfoData* QX11Info::getX11Data(bool def) const } else if (x11data) { res = new QX11InfoData; *res = *x11data; + res->ref = 0; } - res->ref = 0; return res; } diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 38abd95..98996e2 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -954,7 +954,7 @@ QStyleOptionViewItemV2 &QStyleOptionViewItemV2::operator=(const QStyleOptionView Constructs a QStyleOptionViewItemV3 object. */ QStyleOptionViewItemV3::QStyleOptionViewItemV3() - : QStyleOptionViewItemV2(Version) + : QStyleOptionViewItemV2(Version), widget(0) { } @@ -962,7 +962,7 @@ QStyleOptionViewItemV3::QStyleOptionViewItemV3() Constructs a copy of \a other. */ QStyleOptionViewItemV3::QStyleOptionViewItemV3(const QStyleOptionViewItem &other) - : QStyleOptionViewItemV2(Version) + : QStyleOptionViewItemV2(Version), widget(0) { (void)QStyleOptionViewItemV3::operator=(other); } @@ -991,7 +991,7 @@ QStyleOptionViewItemV3 &QStyleOptionViewItemV3::operator = (const QStyleOptionVi \internal */ QStyleOptionViewItemV3::QStyleOptionViewItemV3(int version) - : QStyleOptionViewItemV2(version) + : QStyleOptionViewItemV2(version), widget(0) { } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 2d21bc2..732164c 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -368,18 +368,18 @@ struct Q_GUI_EXPORT Value }; struct ColorData { - ColorData() : type(Invalid) {} - ColorData(const QColor &col) : color(col) , type(Color) {} - ColorData(QPalette::ColorRole r) : role(r) , type(Role) {} + ColorData() : role(QPalette::NoRole), type(Invalid) {} + ColorData(const QColor &col) : role(QPalette::NoRole), color(col), type(Color) {} + ColorData(QPalette::ColorRole r) : role(r), type(Role) {} QColor color; QPalette::ColorRole role; enum { Invalid, Color, Role} type; }; struct BrushData { - BrushData() : type(Invalid) {} - BrushData(const QBrush &br) : brush(br) , type(Brush) {} - BrushData(QPalette::ColorRole r) : role(r) , type(Role) {} + BrushData() : role(QPalette::NoRole), type(Invalid) {} + BrushData(const QBrush &br) : brush(br), role(QPalette::NoRole), type(Brush) {} + BrushData(QPalette::ColorRole r) : role(r), type(Role) {} QBrush brush; QPalette::ColorRole role; enum { Invalid, Brush, Role, DependsOnThePalette } type; @@ -726,7 +726,7 @@ enum TokenType { struct Q_GUI_EXPORT Symbol { - inline Symbol() : start(0), len(-1) {} + inline Symbol() : token(NONE), start(0), len(-1) {} TokenType token; QString text; int start, len; diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index edef816..9fd13cd 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -771,7 +771,7 @@ QList QZipReader::fileInfoList() const { d->scanFiles(); QList files; - for (int i = 0; d && i < d->fileHeaders.size(); ++i) { + for (int i = 0; i < d->fileHeaders.size(); ++i) { QZipReader::FileInfo fi; d->fillFileInfo(i, fi); files.append(fi); diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp index 31da850..8d5d0c7 100644 --- a/src/gui/widgets/qcalendarwidget.cpp +++ b/src/gui/widgets/qcalendarwidget.cpp @@ -332,10 +332,9 @@ QString QCalendarMonthValidator::text(const QDate &date, int repeat) const return str + QString::number(date.month()); } else if (repeat == 3) { return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat); - } else if (repeat >= 4) { + } else /*if (repeat >= 4)*/ { return m_locale.standaloneMonthName(date.month(), QLocale::LongFormat); } - return QString(); } ////////////////////////////////// diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 43f9301..7e4bd7f 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -693,7 +693,7 @@ static bool matchLineFeed(const QByteArray &pem, int *offset) ch = pem.at(++*offset); if (ch == '\n') { - *offset++; + *offset += 1; return true; } if (ch == '\r' && pem.size() > (*offset + 1) && pem.at(*offset + 1) == '\n') { diff --git a/src/scripttools/debugging/qscriptstdmessagehandler.cpp b/src/scripttools/debugging/qscriptstdmessagehandler.cpp index bed04ec..5fb2db9 100644 --- a/src/scripttools/debugging/qscriptstdmessagehandler.cpp +++ b/src/scripttools/debugging/qscriptstdmessagehandler.cpp @@ -92,18 +92,7 @@ void QScriptStdMessageHandler::message(QtMsgType type, const QString &text, } msg.append(text); - FILE *fp = 0; - switch (type) { - case QtDebugMsg: - fp = stdout; - break; - case QtWarningMsg: - case QtCriticalMsg: - case QtFatalMsg: - fp = stderr; - break; - } - + FILE *fp = (type == QtDebugMsg) ? stdout : stderr; fprintf(fp, "%s\n", msg.toLatin1().constData()); fflush(fp); } -- cgit v0.12 From 32824094837dfe5e4c22189daeb0a5663c786070 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 14 Aug 2009 15:04:44 +0200 Subject: QCssParser: reordering initializers to match declaration --- src/gui/text/qcssparser_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 732164c..c685b08 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -369,7 +369,7 @@ struct Q_GUI_EXPORT Value struct ColorData { ColorData() : role(QPalette::NoRole), type(Invalid) {} - ColorData(const QColor &col) : role(QPalette::NoRole), color(col), type(Color) {} + ColorData(const QColor &col) : color(col), role(QPalette::NoRole), type(Color) {} ColorData(QPalette::ColorRole r) : role(r), type(Role) {} QColor color; QPalette::ColorRole role; -- cgit v0.12 From a835ec7dc2d618b9023067e4c6e7c6d122e06c8f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 14 Aug 2009 15:16:19 +0200 Subject: Removing some unused variables. --- src/gui/styles/qcleanlooksstyle.cpp | 5 ----- src/gui/styles/qplastiquestyle.cpp | 1 - src/gui/styles/qwindowscestyle.cpp | 1 - src/gui/styles/qwindowsmobilestyle.cpp | 5 ----- src/gui/styles/qwindowsstyle.cpp | 2 -- src/gui/styles/qwindowsxpstyle.cpp | 2 -- 6 files changed, 16 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index fa6aeb2..0a82c9c 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -84,14 +84,9 @@ enum Direction { // from windows style static const int windowsItemFrame = 2; // menu item frame width -static const int windowsSepHeight = 6; // separator item height static const int windowsItemHMargin = 3; // menu item hor text margin static const int windowsItemVMargin = 8; // menu item ver text margin -static const int windowsArrowHMargin = 6; // arrow horizontal margin -static const int windowsTabSpacing = 12; // space between text and tab -static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark static const int windowsRightBorder = 15; // right border on windows -static const int windowsCheckMarkWidth = 12; // checkmarks width on windows /* XPM */ static const char * const dock_widget_close_xpm[] = { diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 89d4ca5..04559dc 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -98,7 +98,6 @@ static const int windowsItemHMargin = 3; // menu item hor text margin static const int windowsItemVMargin = 2; // menu item ver text margin static const int windowsArrowHMargin = 6; // arrow horizontal margin static const int windowsTabSpacing = 12; // space between text and tab -static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark static const int windowsRightBorder = 15; // right border on windows static const int windowsCheckMarkWidth = 12; // checkmarks width on windows diff --git a/src/gui/styles/qwindowscestyle.cpp b/src/gui/styles/qwindowscestyle.cpp index 4817da0..bf97984 100644 --- a/src/gui/styles/qwindowscestyle.cpp +++ b/src/gui/styles/qwindowscestyle.cpp @@ -56,7 +56,6 @@ QT_BEGIN_NAMESPACE static const int windowsItemFrame = 2; // menu item frame width -static const int windowsSepHeight = 9; // separator item height static const int windowsItemHMargin = 3; // menu item hor text margin static const int windowsItemVMargin = 2; // menu item ver text margin static const int windowsArrowHMargin = 6; // arrow horizontal margin diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 09d345a..f3dcee1 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -83,11 +83,6 @@ extern bool qt_wince_is_windows_mobile_65(); //defined in qguifunctions_wince.cp QT_BEGIN_NAMESPACE static const int windowsItemFrame = 1; // menu item frame width -static const int windowsItemHMargin = 2; // menu item hor text margin -static const int windowsItemVMargin = 2; // menu item ver text margin -static const int windowsArrowHMargin = 6; // arrow horizontal margin -static const int windowsRightBorder = 15; // right border on windows -static const int windowsCheckMarkWidth = 14; // checkmarks width on windows static const int windowsMobileitemViewCheckBoxSize = 13; static const int windowsMobileFrameGroupBoxOffset = 9; diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 91dce4a..6b2dc70 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -121,8 +121,6 @@ static const int windowsSepHeight = 9; // separator item height static const int windowsItemHMargin = 3; // menu item hor text margin static const int windowsItemVMargin = 2; // menu item ver text margin static const int windowsArrowHMargin = 6; // arrow horizontal margin -static const int windowsTabSpacing = 12; // space between text and tab -static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark static const int windowsRightBorder = 15; // right border on windows static const int windowsCheckMarkWidth = 12; // checkmarks width on windows diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 5da1e4e..191b71e 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -125,11 +125,9 @@ static PtrIsThemeBackgroundPartiallyTransparent pIsThemeBackgroundPartiallyTrans // General const values static const int windowsItemFrame = 2; // menu item frame width -static const int windowsSepHeight = 9; // separator item height static const int windowsItemHMargin = 3; // menu item hor text margin static const int windowsItemVMargin = 0; // menu item ver text margin static const int windowsArrowHMargin = 6; // arrow horizontal margin -static const int windowsCheckMarkHMargin = 0; // horiz. margins of check mark static const int windowsRightBorder = 12; // right border on windows // External function calls -- cgit v0.12 From 533807d5c06be28694665fc889ec1942c59ab705 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 14 Aug 2009 16:43:14 +0200 Subject: Fixed Coverity defect CID 1528. Reviewed-by: Olivier --- src/gui/kernel/qapplication_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 3b1a581..db349f0 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -4579,6 +4579,7 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet // Do event compression. Skip over tablet+mouse move events if there are newer ones. qt_tablet_motion_data tabletMotionData; tabletMotionData.tabletMotionType = tablet->xinput_motion; + XEvent dummy; while (true) { // Find first mouse event since we expect them in pairs inside Qt tabletMotionData.error =false; @@ -4591,7 +4592,6 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet } // Now discard any duplicate tablet events. - XEvent dummy; tabletMotionData.error = false; tabletMotionData.timestamp = mouseMotionEvent.xmotion.time; while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { -- cgit v0.12 From 3c8f4512df30dee4a867a498fff6d2b27b881e4b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 14 Aug 2009 17:04:42 +0200 Subject: QVariant: more work on avoinding conversion between float and doubles we call QVariant::toReal instead of toDouble when needed --- src/3rdparty/phonon/ds9/effect.cpp | 3 +-- src/3rdparty/phonon/phonon/effectwidget.cpp | 13 +++++++------ src/gui/text/qtexthtmlparser.cpp | 5 ++--- src/svg/qsvghandler.cpp | 7 +++---- src/xmlpatterns/data/qatomicvalue.cpp | 4 +++- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/3rdparty/phonon/ds9/effect.cpp b/src/3rdparty/phonon/ds9/effect.cpp index dc4ac3d..104a3c1 100644 --- a/src/3rdparty/phonon/ds9/effect.cpp +++ b/src/3rdparty/phonon/ds9/effect.cpp @@ -138,8 +138,7 @@ namespace Phonon ComPointer params(filter, IID_IMediaParams); Q_ASSERT(params); - MP_DATA data = float(v.toDouble()); - params->SetParam(p.id(), data); + params->SetParam(p.id(), v.toFloat()); } } diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 99478f7..8f105f2 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -111,7 +111,7 @@ void EffectWidgetPrivate::autogenerateUi() #endif QWidget *control = 0; - switch (para.type()) { + switch (para.userType()) { case QVariant::String: { QComboBox *cb = new QComboBox(q); @@ -157,19 +157,20 @@ void EffectWidgetPrivate::autogenerateUi() QObject::connect(sb, SIGNAL(valueChanged(int)), q, SLOT(_k_setIntParameter(int))); } break; + case QMetaType::Float: case QVariant::Double: { - const double minValue = (para.minimumValue().type() == QVariant::Double ? - para.minimumValue().toDouble() : DEFAULT_MIN); - const double maxValue = (para.maximumValue().type() == QVariant::Double ? - para.maximumValue().toDouble() : DEFAULT_MAX); + const qreal minValue = para.minimumValue().canConvert(QVariant::Double) ? + para.minimumValue().toReal(&ok) : DEFAULT_MIN; + const qreal maxValue = para.maximumValue().canConvert(QVariant::Double) ? + para.maximumValue().toReal(&ok) : DEFAULT_MAX; if (minValue == -1. && maxValue == 1.) { //Special case values between -1 and 1.0 to use a slider for improved usability QSlider *slider = new QSlider(Qt::Horizontal, q); control = slider; slider->setRange(-SLIDER_RANGE, +SLIDER_RANGE); - slider->setValue(int(SLIDER_RANGE * value.toDouble())); + slider->setValue(int(SLIDER_RANGE * value.toReal())); slider->setTickPosition(QSlider::TicksBelow); slider->setTickInterval(TICKINTERVAL); QObject::connect(slider, SIGNAL(valueChanged(int)), q, SLOT(_k_setSliderParameter(int))); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 8910394..92b2d4e 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1443,14 +1443,13 @@ static bool setFloatAttribute(qreal *destination, const QString &value) static void setWidthAttribute(QTextLength *width, QString value) { - qreal realVal; bool ok = false; - realVal = value.toDouble(&ok); + qreal realVal = value.toDouble(&ok); if (ok) { *width = QTextLength(QTextLength::FixedLength, realVal); } else { value = value.trimmed(); - if (!value.isEmpty() && value.at(value.length() - 1) == QLatin1Char('%')) { + if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) { value.chop(1); realVal = value.toDouble(&ok); if (ok) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 3b5bd0d..5e07181 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1740,14 +1740,13 @@ static void parseOpacity(QSvgNode *node, const QSvgAttributes &attributes, QSvgHandler *) { - QString value = attributes.value(QLatin1String("opacity")).toString(); - value = value.trimmed(); + const QString value = attributes.value(QLatin1String("opacity")).toString().trimmed(); bool ok = false; - qreal op = value.toDouble(&ok); + qreal op = value.toReal(&ok); if (ok) { - QSvgOpacityStyle *opacity = new QSvgOpacityStyle(qMin(qreal(1.0), qMax(qreal(0.0), op))); + QSvgOpacityStyle *opacity = new QSvgOpacityStyle(qBound(qreal(0.0), op, qreal(1.0))); node->appendStyleProperty(opacity, someId(attributes)); } } diff --git a/src/xmlpatterns/data/qatomicvalue.cpp b/src/xmlpatterns/data/qatomicvalue.cpp index 24f1a01..8559c80 100644 --- a/src/xmlpatterns/data/qatomicvalue.cpp +++ b/src/xmlpatterns/data/qatomicvalue.cpp @@ -134,7 +134,7 @@ Item AtomicValue::toXDM(const QVariant &value) Q_ASSERT_X(value.isValid(), Q_FUNC_INFO, "QVariants sent to Patternist must be valid."); - switch(value.type()) + switch(value.userType()) { case QVariant::Char: /* Fallthrough. A single codepoint is a string in XQuery. */ @@ -166,6 +166,8 @@ Item AtomicValue::toXDM(const QVariant &value) return Date::fromDateTime(QDateTime(value.toDate(), QTime(), Qt::UTC)); case QVariant::DateTime: return DateTime::fromDateTime(value.toDateTime()); + case QMetaType::Float: + return Item(Double::fromValue(value.toFloat())); case QVariant::Double: return Item(Double::fromValue(value.toDouble())); default: -- cgit v0.12 From e9d32707afeddfdd2906af7bed60c375b1035dd6 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 14 Aug 2009 17:18:01 +0200 Subject: Doc: Included type information for the Qt::ItemDataRole enum. Task-number: 257116 Reviewed-by: Trust Me --- doc/src/classes/qnamespace.qdoc | 39 +++++++++++++++++++++---------------- doc/src/model-view-programming.qdoc | 2 ++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/doc/src/classes/qnamespace.qdoc b/doc/src/classes/qnamespace.qdoc index 2ccc639..6f28504 100644 --- a/doc/src/classes/qnamespace.qdoc +++ b/doc/src/classes/qnamespace.qdoc @@ -2464,44 +2464,46 @@ Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate - to the model which type of data it needs. + to the model which type of data it needs. Custom models should return + data in these types. - The general purpose roles are: + The general purpose roles (and the associated types) are: - \value DisplayRole The key data to be rendered in the form of text. + \value DisplayRole The key data to be rendered in the form of text. (QString) \value DecorationRole The data to be rendered as a decoration in the form - of an icon. + of an icon. (QColor) \value EditRole The data in a form suitable for editing in an - editor. - \value ToolTipRole The data displayed in the item's tooltip. - \value StatusTipRole The data displayed in the status bar. + editor. (QString) + \value ToolTipRole The data displayed in the item's tooltip. (QString) + \value StatusTipRole The data displayed in the status bar. (QString) \value WhatsThisRole The data displayed for the item in "What's This?" - mode. + mode. (QString) \value SizeHintRole The size hint for the item that will be supplied - to views. + to views. (QSize) - Roles describing appearance and meta data: + Roles describing appearance and meta data (with associated types): \value FontRole The font used for items rendered with the default - delegate. + delegate. (QFont) \value TextAlignmentRole The alignment of the text for items rendered with the - default delegate. + default delegate. (Qt::AlignmentFlag) \value BackgroundRole The background brush used for items rendered with - the default delegate. + the default delegate. (QBrush) \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead. \value ForegroundRole The foreground brush (text color, typically) used for items rendered with the default delegate. + (QBrush) \value TextColorRole This role is obsolete. Use ForegroundRole instead. \value CheckStateRole This role is used to obtain the checked state of - an item (see \l Qt::CheckState). + an item. (Qt::CheckState) - Accessibility roles: + Accessibility roles (with associated types): \value AccessibleTextRole The text to be used by accessibility extensions and plugins, such as screen - readers. + readers. (QString) \value AccessibleDescriptionRole A description of the item for accessibility - purposes. + purposes. (QString) User roles: @@ -2512,6 +2514,9 @@ \omitvalue ToolTipPropertyRole \omitvalue StatusTipPropertyRole \omitvalue WhatsThisPropertyRole + + For user roles, it is up to the developer to decide which types to use and ensure that + components use the correct types when accessing and setting data. */ /*! diff --git a/doc/src/model-view-programming.qdoc b/doc/src/model-view-programming.qdoc index 49214e0..13f5e5a 100644 --- a/doc/src/model-view-programming.qdoc +++ b/doc/src/model-view-programming.qdoc @@ -2148,6 +2148,8 @@ need to supply data for Qt::DisplayRole and any application-specific user roles, but it is also good practice to provide data for Qt::ToolTipRole, Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole. + See the Qt::ItemDataRole enum documentation for information about the types + associated with each role. \row \o \l{QAbstractItemModel::headerData()}{headerData()} \o Provides views with information to show in their headers. The information is only retrieved by views that can display header information. -- cgit v0.12 From a931fac02fe0430439a351dacc5167ddeca1d4d0 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 14 Aug 2009 17:16:34 +0200 Subject: Perform license checks on source files. Previously we only checked headers, but we actually care about source files too. This detects about 50 errors all over Qt. Discussed with Thiago. --- tests/auto/headers/tst_headers.cpp | 84 +++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 51e3a55..f5a11f4 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -50,7 +50,7 @@ public: private slots: void initTestCase(); - void licenseCheck_data() { allHeadersData(); } + void licenseCheck_data() { allSourceFilesData(); } void licenseCheck(); void privateSlots_data() { allHeadersData(); } @@ -60,11 +60,19 @@ private slots: void macros(); private: + static QStringList getFiles(const QString &path, + const QStringList dirFilters, + const QRegExp &exclude); + static QStringList getHeaders(const QString &path); + static QStringList getSourceFiles(const QString &path); + + void allSourceFilesData(); void allHeadersData(); QStringList headers; const QRegExp copyrightPattern; const QRegExp licensePattern; const QRegExp moduleTest; + QString qtSrcDir; }; tst_Headers::tst_Headers() : @@ -74,29 +82,41 @@ tst_Headers::tst_Headers() : { } -QStringList getHeaders(const QString &path) +QStringList tst_Headers::getFiles(const QString &path, + const QStringList dirFilters, + const QRegExp &excludeReg) { - QStringList headers; - - QDir dir(path); - QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + const QDir dir(path); + const QStringList dirs(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)); + QStringList result; foreach (QString subdir, dirs) - headers += getHeaders(path + "/" + subdir); + result += getFiles(path + "/" + subdir, dirFilters, excludeReg); - QStringList entries = dir.entryList(QStringList("*.h"), QDir::Files); - QRegExp reg("^(?!ui_)"); - entries = entries.filter(reg); + QStringList entries = dir.entryList(dirFilters, QDir::Files); + entries = entries.filter(excludeReg); foreach (QString entry, entries) - headers += path + "/" + entry; + result += path + "/" + entry; - return headers; + return result; +} + +QStringList tst_Headers::getHeaders(const QString &path) +{ + return getFiles(path, QStringList("*.h"), QRegExp("^(?!ui_)")); +} + +QStringList tst_Headers::getSourceFiles(const QString &path) +{ + return getFiles(path, QStringList("*.cpp"), QRegExp("^(?!(moc_|qrc_))")); } void tst_Headers::initTestCase() { - QString qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty() - ? qgetenv("QTDIR") : qgetenv("QTSRCDIR")); + qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty() + ? qgetenv("QTDIR") + : qgetenv("QTSRCDIR")); + headers = getHeaders(qtSrcDir + "/src"); #ifndef Q_OS_WINCE @@ -108,6 +128,30 @@ void tst_Headers::initTestCase() QVERIFY(licensePattern.isValid()); } +void tst_Headers::allSourceFilesData() +{ + QTest::addColumn("sourceFile"); + + const QStringList sourceFiles(getSourceFiles(qtSrcDir)); + + foreach (QString sourceFile, sourceFiles) { + if (sourceFile.contains("/3rdparty/") + || sourceFile.contains("/config.tests/") + || sourceFile.contains("/snippets/") + || sourceFile.contains("linguist/lupdate/testdata") + || sourceFile.contains("/fulltextsearch/")) + continue; + + // This test is crude, but if a file contains this string, we skip it. + QFile file(sourceFile); + QVERIFY(file.open(QIODevice::ReadOnly)); + if (file.readAll().contains("This file was generated by")) + continue; + + QTest::newRow(qPrintable(sourceFile)) << sourceFile; + } +} + void tst_Headers::allHeadersData() { QTest::addColumn("header"); @@ -125,12 +169,14 @@ void tst_Headers::allHeadersData() void tst_Headers::licenseCheck() { - QFETCH(QString, header); + QFETCH(QString, sourceFile); - if (header.endsWith("/qgifhandler.h") || header.endsWith("/qconfig.h")) + if (sourceFile.endsWith("/qgifhandler.h") + || sourceFile.endsWith("/qconfig.h") + || sourceFile.endsWith("/qconfig.cpp")) return; - QFile f(header); + QFile f(sourceFile); QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n"); @@ -138,8 +184,8 @@ void tst_Headers::licenseCheck() if (content.first().contains("generated")) content.takeFirst(); - QVERIFY(licensePattern.exactMatch(content.at(7)) || - licensePattern.exactMatch(content.at(4))); + QVERIFY(licensePattern.exactMatch(content.value(7)) || + licensePattern.exactMatch(content.value(4))); QString licenseType = licensePattern.cap(1); int i = 0; -- cgit v0.12 From 78fbb9cf6ef5e8440f0453ef60bd7845ce418745 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 Aug 2009 15:04:30 +0200 Subject: Reimplement qSwap and Q_DECLARE_SHARED differently. This enables the use of Q_DECLARE_SHARED with d-pointers that are QExplicitlySharedDataPointer. Also, this enables swapping atomically QSharedPointers. Reviewed-by: Harald Fernengel --- src/corelib/global/qglobal.h | 31 ++++++--------------- src/corelib/tools/qalgorithms.h | 17 ------------ src/corelib/tools/qshareddata.h | 14 ++++++++++ src/corelib/tools/qsharedpointer_impl.h | 19 +++++++++++-- .../tst_qexplicitlyshareddatapointer.cpp | 20 ++++++++++++++ tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 32 ++++++++++++++++++++++ 6 files changed, 92 insertions(+), 41 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5a2c329..92fe649 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1906,6 +1906,14 @@ public: \ static inline const char *name() { return #TYPE; } \ } +template +inline void qSwap(T &value1, T &value2) +{ + const T t = value1; + value1 = value2; + value2 = t; +} + /* Specialize a shared type with: @@ -1915,33 +1923,12 @@ public: \ types must declare a 'bool isDetached(void) const;' member for this to work. */ -#if defined Q_CC_MSVC && _MSC_VER < 1300 -template -inline void qSwap_helper(T &value1, T &value2, T*) -{ - T t = value1; - value1 = value2; - value2 = t; -} #define Q_DECLARE_SHARED(TYPE) \ template <> inline bool qIsDetached(TYPE &t) { return t.isDetached(); } \ -template <> inline void qSwap_helper(TYPE &value1, TYPE &value2, TYPE*) \ -{ \ - const TYPE::DataPtr t = value1.data_ptr(); \ - value1.data_ptr() = value2.data_ptr(); \ - value2.data_ptr() = t; \ -} -#else -#define Q_DECLARE_SHARED(TYPE) \ -template <> inline bool qIsDetached(TYPE &t) { return t.isDetached(); } \ -template inline void qSwap(T &, T &); \ template <> inline void qSwap(TYPE &value1, TYPE &value2) \ { \ - const TYPE::DataPtr t = value1.data_ptr(); \ - value1.data_ptr() = value2.data_ptr(); \ - value2.data_ptr() = t; \ + qSwap(value1.data_ptr(), value2.data_ptr()); \ } -#endif /* QTypeInfo primitive specializations diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 6f623d9..3e5c3cc 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -141,23 +141,6 @@ inline void qCount(const Container &container, const T &value, Size &n) qCount(container.constBegin(), container.constEnd(), value, n); } - -#if defined Q_CC_MSVC && _MSC_VER < 1300 -template -inline void qSwap(T &value1, T &value2) -{ - qSwap_helper(value1, value2, (T *)0); -} -#else -template -inline void qSwap(T &value1, T &value2) -{ - T t = value1; - value1 = value2; - value2 = t; -} -#endif - #ifdef qdoc template LessThan qLess() diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index e13e37c..dde6e88 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -111,6 +111,9 @@ public: inline bool operator!() const { return !d; } + inline void swap(QSharedDataPointer &other) + { qSwap(d, other.d); } + protected: T *clone(); @@ -186,6 +189,9 @@ public: inline bool operator!() const { return !d; } + inline void swap(QExplicitlySharedDataPointer &other) + { qSwap(d, other.d); } + protected: T *clone(); @@ -235,6 +241,14 @@ template Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *adata) : d(adata) { if (d) d->ref.ref(); } +template +Q_INLINE_TEMPLATE void qSwap(QSharedDataPointer &p1, QSharedDataPointer &p2) +{ p1.swap(p2); } + +template +Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer &p1, QExplicitlySharedDataPointer &p2) +{ p1.swap(p2); } + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index cbeb79f..1136aa9 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -171,8 +171,8 @@ namespace QtSharedPointer { inline ExternalRefCountData() { - QBasicAtomicInt proto = Q_BASIC_ATOMIC_INITIALIZER(1); - weakref = strongref = proto; + strongref = 1; + weakref = 1; } inline ExternalRefCountData(Qt::Initialization) { } virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); } @@ -385,6 +385,12 @@ namespace QtSharedPointer { delete this->value; } + inline void internalSwap(ExternalRefCount &other) + { + qSwap(d, other.d); + qSwap(this->value, other.value); + } + #if defined(Q_NO_TEMPLATE_FRIENDS) public: #else @@ -465,6 +471,9 @@ public: inline QSharedPointer &operator=(const QWeakPointer &other) { internalSet(other.d, other.value); return *this; } + inline void swap(QSharedPointer &other) + { internalSwap(other); } + template QSharedPointer staticCast() const { @@ -682,6 +691,12 @@ Q_INLINE_TEMPLATE QWeakPointer QSharedPointer::toWeakRef() const return QWeakPointer(*this); } +template +inline void qSwap(QSharedPointer &p1, QSharedPointer &p2) +{ + p1.swap(p2); +} + namespace QtSharedPointer { // helper functions: template diff --git a/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp b/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp index 4cdeb5c..97e57f1 100644 --- a/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp +++ b/tests/auto/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp @@ -61,6 +61,7 @@ private Q_SLOTS: void clone() const; void data() const; void reset() const; + void swap() const; }; class MyClass : public QSharedData @@ -233,6 +234,25 @@ void tst_QExplicitlySharedDataPointer::reset() const } } +void tst_QExplicitlySharedDataPointer::swap() const +{ + QExplicitlySharedDataPointer p1(0), p2(new MyClass()); + QVERIFY(!p1.data()); + QVERIFY(p2.data()); + + p1.swap(p2); + QVERIFY(p1.data()); + QVERIFY(!p2.data()); + + p1.swap(p2); + QVERIFY(!p1.data()); + QVERIFY(p2.data()); + + qSwap(p1, p2); + QVERIFY(p1.data()); + QVERIFY(!p2.data()); +} + QTEST_MAIN(tst_QExplicitlySharedDataPointer) #include "tst_qexplicitlyshareddatapointer.moc" diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 58e5401..ab75c91 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -62,6 +62,7 @@ class tst_QSharedPointer: public QObject private slots: void basics_data(); void basics(); + void swap(); void forwardDeclaration1(); void forwardDeclaration2(); void memoryManagement(); @@ -263,6 +264,37 @@ void tst_QSharedPointer::basics() // aData is deleted here } +void tst_QSharedPointer::swap() +{ + QSharedPointer p1, p2(new int(42)), control = p2; + QVERIFY(p1 != control); + QVERIFY(p1.isNull()); + QVERIFY(p2 == control); + QVERIFY(!p2.isNull()); + QVERIFY(*p2 == 42); + + p1.swap(p2); + QVERIFY(p1 == control); + QVERIFY(!p1.isNull()); + QVERIFY(p2 != control); + QVERIFY(p2.isNull()); + QVERIFY(*p1 == 42); + + p1.swap(p2); + QVERIFY(p1 != control); + QVERIFY(p1.isNull()); + QVERIFY(p2 == control); + QVERIFY(!p2.isNull()); + QVERIFY(*p2 == 42); + + qSwap(p1, p2); + QVERIFY(p1 == control); + QVERIFY(!p1.isNull()); + QVERIFY(p2 != control); + QVERIFY(p2.isNull()); + QVERIFY(*p1 == 42); +} + class ForwardDeclared; ForwardDeclared *forwardPointer(); void externalForwardDeclaration(); -- cgit v0.12 From 812f41d1ec0b9f6dd6492e4e9c2d0f19142c91d9 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 14 Aug 2009 17:54:29 +0200 Subject: Doc: Removed claims that QDialog supports border style sheet settings. Task-number: 255853 Reviewed-by: Trust Me I'm-trusting: The information in the task :-) --- doc/src/stylesheet.qdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/stylesheet.qdoc b/doc/src/stylesheet.qdoc index 45621cc..2afe924 100644 --- a/doc/src/stylesheet.qdoc +++ b/doc/src/stylesheet.qdoc @@ -1523,7 +1523,7 @@ This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, - QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit, + QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain \l{QWidget}s. @@ -1569,7 +1569,7 @@ This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, - QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit, + QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain \l{QWidget}s. @@ -1614,7 +1614,7 @@ This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, - QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit, + QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit and QToolTip. -- cgit v0.12 From a7b24170890aad476345a5d7a56ded8d62c53df0 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 14 Aug 2009 17:38:31 +0200 Subject: Avoid wrapping outside word boundaries in QTextDocument unless necessary If you have a floating object which affects the width available to the text, we need to recalculate the width of the text line. In the code, the setLineWidth() call to do this would by default have WrapAnywhere as its wrap mode, even when this was not necessary. The code has now been moved so that WrapAnywhere is only used if we try to set the line width to match the available width and detect that the text is too wide (the natural text width exceeds the available space.) Task-number: 240325 Reviewed-by: Simon Hausmann --- src/gui/text/qtextdocumentlayout.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index e26961f..a795c1f 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2601,13 +2601,13 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi // float has been added in the meantime, redo layoutStruct->pendingFloats.clear(); - if (haveWordOrAnyWrapMode) { - option.setWrapMode(QTextOption::WrapAnywhere); - tl->setTextOption(option); - } - line.setLineWidth((right-left).toReal()); if (QFixed::fromReal(line.naturalTextWidth()) > right-left) { + if (haveWordOrAnyWrapMode) { + option.setWrapMode(QTextOption::WrapAnywhere); + tl->setTextOption(option); + } + layoutStruct->pendingFloats.clear(); // lines min width more than what we have layoutStruct->y = findY(layoutStruct->y, layoutStruct, QFixed::fromReal(line.naturalTextWidth())); @@ -2619,12 +2619,13 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi else right -= text_indent; line.setLineWidth(qMax(line.naturalTextWidth(), (right-left).toReal())); - } - if (haveWordOrAnyWrapMode) { - option.setWrapMode(QTextOption::WordWrap); - tl->setTextOption(option); + if (haveWordOrAnyWrapMode) { + option.setWrapMode(QTextOption::WordWrap); + tl->setTextOption(option); + } } + } QFixed lineHeight = QFixed::fromReal(line.height()); -- cgit v0.12 From ca89fd9ee95511a7fe1e8cdb2317e7c8388ec220 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 14 Aug 2009 17:49:31 +0200 Subject: Autotest for correct word wrapping on text next to floating object We set the document's page size to be large enough to contain an image which is 100 pixels wide and one, but not two, instances of the word 'Foobar'. We then render HTML which contains a string with repeated occurrences of the word 'Foobar' next to a floating, right-aligned image which is 100 pixels wide. The layout should break on word boundaries, since this is the default in QTextDocument, and thus each text line should contain one instance of the word 'Foobar'. Task-number: 240325 --- tests/auto/qtextdocument/tst_qtextdocument.cpp | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 72f3ea8..4643df0 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -55,8 +55,13 @@ #include #include #include +#include +#include +#include +#include #include "common.h" + QT_FORWARD_DECLARE_CLASS(QTextDocument) //TESTED_CLASS= @@ -93,6 +98,8 @@ private slots: void noundo_isModified3(); void mightBeRichText(); + void task240325(); + void toHtml_data(); void toHtml(); void toHtml2(); @@ -532,6 +539,38 @@ void tst_QTextDocument::noundo_basicIsModifiedChecks() QCOMPARE(spy.count(), 0); } +void tst_QTextDocument::task240325() +{ + doc->setHtml("Foobar Foobar Foobar Foobar"); + + QImage img(1000, 7000, QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + QFontMetrics fm(p.font()); + + // Set page size to contain image and one "Foobar" + doc->setPageSize(QSize(100 + fm.width("Foobar")*2, 1000)); + + // Force layout + doc->drawContents(&p); + + QCOMPARE(doc->blockCount(), 1); + for (QTextBlock block = doc->begin() ; block!=doc->end() ; block = block.next()) { + QTextLayout *layout = block.layout(); + QCOMPARE(layout->lineCount(), 4); + for (int lineIdx=0;lineIdxlineCount();++lineIdx) { + QTextLine line = layout->lineAt(lineIdx); + + QString text = block.text().mid(line.textStart(), line.textLength()).trimmed(); + + // Remove start token + if (lineIdx == 0) + text = text.mid(1); + + QCOMPARE(text, QString::fromLatin1("Foobar")); + } + } +} + void tst_QTextDocument::noundo_moreIsModified() { doc->setUndoRedoEnabled(false); -- cgit v0.12 From ef682d7d0043d5054818908ffe1ba573ef6cb01b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sat, 15 Aug 2009 08:33:18 +1000 Subject: Fixed compile. Put QString::toReal back to QString::toDouble, there is no QString::toReal. --- src/svg/qsvghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 5e07181..a79e4a0 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1743,7 +1743,7 @@ static void parseOpacity(QSvgNode *node, const QString value = attributes.value(QLatin1String("opacity")).toString().trimmed(); bool ok = false; - qreal op = value.toReal(&ok); + qreal op = value.toDouble(&ok); if (ok) { QSvgOpacityStyle *opacity = new QSvgOpacityStyle(qBound(qreal(0.0), op, qreal(1.0))); -- cgit v0.12 From aa09d4f9c2d47348e6eac76e66500f4807b132a3 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sat, 15 Aug 2009 09:18:23 +1000 Subject: Fixed compile. Put EffectParameter::userType back to EffectParameter::type. --- src/3rdparty/phonon/phonon/effectwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 8f105f2..fb9cf6e 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -111,7 +111,7 @@ void EffectWidgetPrivate::autogenerateUi() #endif QWidget *control = 0; - switch (para.userType()) { + switch (para.type()) { case QVariant::String: { QComboBox *cb = new QComboBox(q); @@ -161,9 +161,9 @@ void EffectWidgetPrivate::autogenerateUi() case QVariant::Double: { const qreal minValue = para.minimumValue().canConvert(QVariant::Double) ? - para.minimumValue().toReal(&ok) : DEFAULT_MIN; + para.minimumValue().toReal() : DEFAULT_MIN; const qreal maxValue = para.maximumValue().canConvert(QVariant::Double) ? - para.maximumValue().toReal(&ok) : DEFAULT_MAX; + para.maximumValue().toReal() : DEFAULT_MAX; if (minValue == -1. && maxValue == 1.) { //Special case values between -1 and 1.0 to use a slider for improved usability -- cgit v0.12 From 72c1cb2ffdfb2742985e12025d4578aa2fe80ce7 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 16 Aug 2009 13:00:53 +0200 Subject: Doc: Fix links and silence qdoc warnings. --- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 6 ++--- src/gui/image/qicon.cpp | 28 ++++++++++++----------- src/gui/text/qfontmetrics.cpp | 15 ++++++------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index dd90f39..3ef969e 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -393,7 +393,7 @@ QString QWebElement::attribute(const QString &name, const QString &defaultValue) Returns the attribute with the given \a name in \a namespaceUri. If the attribute does not exist, \a defaultValue is returned. - \sa setAtributeNS(), setAttribute(), attribute() + \sa setAttributeNS(), setAttribute(), attribute() */ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &name, const QString &defaultValue) const { @@ -976,7 +976,7 @@ QStringList QWebElement::scriptableProperties() const /*! Returns the value of the style with the given \a name. If a style with - \name does not exist, an empty string is returned. + \a name does not exist, an empty string is returned. If \a rule is IgnoreCascadingStyles, the value defined inside the element (inline in CSS terminology) is returned. @@ -1099,7 +1099,7 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St /*! Returns the computed value for style with the given \a name. If a style - with \name does not exist, an empty string is returned. + with \a name does not exist, an empty string is returned. */ QString QWebElement::computedStyleProperty(const QString &name) const { diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0d854d0..677cc44 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -871,7 +871,7 @@ QList QIcon::availableSizes(Mode mode, State state) const \since 4.6 Sets the search paths for icon themes to \a paths. - \sa themeSearchPaths(), fromTheme() + \sa themeSearchPaths(), fromTheme(), setThemeName() */ void QIcon::setThemeSearchPaths(const QStringList &paths) { @@ -893,7 +893,7 @@ void QIcon::setThemeSearchPaths(const QStringList &paths) On Mac the default search path will search in the [Contents/Resources/icons] part of the application bundle. - \sa setThemeSearchPaths(), fromTheme() + \sa setThemeSearchPaths(), fromTheme(), setThemeName() */ QStringList QIcon::themeSearchPaths() { @@ -903,16 +903,17 @@ QStringList QIcon::themeSearchPaths() /*! \since 4.6 - Sets the current icon theme. + Sets the current icon theme to \a name. - The name should correspond to a directory name in the - current \ themeSearchPath() containing an index.theme - file describing it's contents.. + The \a name should correspond to a directory name in the + current themeSearchPath() containing an index.theme + file describing it's contents. + \sa themeSearchPaths(), themeName() */ -void QIcon::setThemeName(const QString &path) +void QIcon::setThemeName(const QString &name) { - QIconLoader::instance()->setThemeName(path); + QIconLoader::instance()->setThemeName(name); } /*! @@ -923,7 +924,8 @@ void QIcon::setThemeName(const QString &path) On X11, the current icon theme depends on your desktop settings. On other platforms it is not set by default. - \sa themeSearchPaths(), fromTheme(), hasThemeIcon() + \sa setThemeName(), themeSearchPaths(), fromTheme(), + hasThemeIcon() */ QString QIcon::themeName() { @@ -960,7 +962,7 @@ QString QIcon::themeName() compliant theme in one of your themeSearchPaths() and set the appropriate themeName(). - \sa themeName(), themeSearchPaths() + \sa themeName(), setThemeName(), themeSearchPaths() */ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) { @@ -994,10 +996,10 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) /*! \since 4.6 - Returns true if there is an icon available for a \a name in the current - icon theme, otherwise returns false. + Returns true if there is an icon available for \a name in the + current icon theme, otherwise returns false. - \sa themeSearchPaths(), fromTheme() + \sa themeSearchPaths(), fromTheme(), setThemeName() */ bool QIcon::hasThemeIcon(const QString &name) { diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 3e074a7..b3d1a5f 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -859,24 +859,23 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const right-to-left layouts, and on the left side for right-to-left layouts. Note that this behavior is independent of the text language. - */ -QString QFontMetrics::elidedText(const QString &_text, Qt::TextElideMode mode, int width, int flags) const +QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const { - QString text = _text; + QString _text = text; if (!(flags & Qt::TextLongestVariant)) { int posA = 0; - int posB = text.indexOf(QLatin1Char('\x9c')); + int posB = _text.indexOf(QLatin1Char('\x9c')); while (posB >= 0) { - QString portion = text.mid(posA, posB - posA); + QString portion = _text.mid(posA, posB - posA); if (size(flags, portion).width() <= width) return portion; posA = posB + 1; - posB = text.indexOf(QLatin1Char('\x9c'), posA); + posB = _text.indexOf(QLatin1Char('\x9c'), posA); } - text = text.mid(posA); + _text = _text.mid(posA); } - QStackTextEngine engine(text, QFont(d)); + QStackTextEngine engine(_text, QFont(d)); return engine.elidedText(mode, width, flags); } -- cgit v0.12 From caef9533a860941701745e221e719438ea6870d8 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Mon, 17 Aug 2009 15:34:39 +1000 Subject: Snippet files for gesture overview documentation --- .../snippets/gestures/imageviewer/imagewidget.cpp | 364 +++++++++++++++++++++ .../snippets/gestures/imageviewer/imagewidget.h | 137 ++++++++ .../gestures/imageviewer/tapandholdgesture.cpp | 159 +++++++++ .../gestures/imageviewer/tapandholdgesture.h | 74 +++++ 4 files changed, 734 insertions(+) create mode 100644 doc/src/snippets/gestures/imageviewer/imagewidget.cpp create mode 100644 doc/src/snippets/gestures/imageviewer/imagewidget.h create mode 100644 doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp create mode 100644 doc/src/snippets/gestures/imageviewer/tapandholdgesture.h diff --git a/doc/src/snippets/gestures/imageviewer/imagewidget.cpp b/doc/src/snippets/gestures/imageviewer/imagewidget.cpp new file mode 100644 index 0000000..f9d6a77 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/imagewidget.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "imagewidget.h" + +#include + +ImageWidget::ImageWidget(QWidget *parent) + : QWidget(parent) +{ + setAttribute(Qt::WA_AcceptTouchEvents); + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_NoSystemBackground); + + setObjectName("ImageWidget"); + + setMinimumSize(QSize(100,100)); + + position = 0; + zoomed = rotated = false; + + zoomedIn = false; + horizontalOffset = 0; + verticalOffset = 0; + +//! [imagewidget-connect] + panGesture = new QPanGesture(this); + connect(panGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); + + tapAndHoldGesture = new TapAndHoldGesture(this); + connect(tapAndHoldGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered())); + connect(tapAndHoldGesture, SIGNAL(finished()), this, SLOT(gestureFinished())); +//! [imagewidget-connect] +} + +void ImageWidget::paintEvent(QPaintEvent*) +{ + QPainter p(this); + if (currentImage.isNull()) { + p.fillRect(geometry(), Qt::white); + return; + } + int hoffset = 0; + int voffset = 0; + const int w = pixmap.width(); + const int h = pixmap.height(); + p.save(); + if (zoomedIn) { + hoffset = horizontalOffset; + voffset = verticalOffset; + if (horizontalOffset > 0) + p.fillRect(0, 0, horizontalOffset, height(), Qt::white); + if (verticalOffset > 0) + p.fillRect(0, 0, width(), verticalOffset, Qt::white); + } + p.drawPixmap(hoffset, voffset, pixmap); + if (hoffset + w < width()) + p.fillRect(hoffset + w, 0, width() - w - hoffset, height(), Qt::white); + if (voffset + h < height()) + p.fillRect(0, voffset + h, width(), height() - h - voffset, Qt::white); + + // paint touch feedback + if (touchFeedback.tapped || touchFeedback.doubleTapped) { + p.setPen(QPen(Qt::gray, 2)); + p.drawEllipse(touchFeedback.position, 5, 5); + if (touchFeedback.doubleTapped) { + p.setPen(QPen(Qt::darkGray, 2, Qt::DotLine)); + p.drawEllipse(touchFeedback.position, 15, 15); + } else if (touchFeedback.tapAndHoldState != 0) { + QPoint pts[8] = { + touchFeedback.position + QPoint( 0, -15), + touchFeedback.position + QPoint( 10, -10), + touchFeedback.position + QPoint( 15, 0), + touchFeedback.position + QPoint( 10, 10), + touchFeedback.position + QPoint( 0, 15), + touchFeedback.position + QPoint(-10, 10), + touchFeedback.position + QPoint(-15, 0) + }; + for (int i = 0; i < touchFeedback.tapAndHoldState/5; ++i) + p.drawEllipse(pts[i], 3, 3); + } + } else if (touchFeedback.sliding) { + p.setPen(QPen(Qt::red, 3)); + QPoint endPos = QPoint(touchFeedback.position.x(), touchFeedback.slidingStartPosition.y()); + p.drawLine(touchFeedback.slidingStartPosition, endPos); + int dx = 10; + if (touchFeedback.slidingStartPosition.x() < endPos.x()) + dx = -1*dx; + p.drawLine(endPos, endPos + QPoint(dx, 5)); + p.drawLine(endPos, endPos + QPoint(dx, -5)); + } + + for (int i = 0; i < TouchFeedback::MaximumNumberOfTouches; ++i) { + if (touchFeedback.touches[i].isNull()) + break; + p.drawEllipse(touchFeedback.touches[i], 10, 10); + } + p.restore(); +} + +void ImageWidget::mousePressEvent(QMouseEvent *event) +{ + touchFeedback.tapped = true; + touchFeedback.position = event->pos(); +} + +void ImageWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + touchFeedback.doubleTapped = true; + const QPoint p = event->pos(); + touchFeedback.position = p; + horizontalOffset = p.x() - currentImage.width()*1.0*p.x()/width(); + verticalOffset = p.y() - currentImage.height()*1.0*p.y()/height(); + setZoomedIn(!zoomedIn); + zoomed = rotated = false; + updateImage(); + + feedbackFadeOutTimer.start(500, this); +} + +//! [imagewidget-triggered-1] +void ImageWidget::gestureTriggered() +{ + if (sender() == panGesture) { +//! [imagewidget-triggered-1] + touchFeedback.tapped = false; + touchFeedback.doubleTapped = false; + QPanGesture *pg = qobject_cast(sender()); + if (zoomedIn) { +#ifndef QT_NO_CURSOR + switch (pg->state()) { + case Qt::GestureStarted: + case Qt::GestureUpdated: + setCursor(Qt::SizeAllCursor); + break; + default: + setCursor(Qt::ArrowCursor); + } +#endif + horizontalOffset += pg->lastOffset().width(); + verticalOffset += pg->lastOffset().height(); + } else { + // only slide gesture should be accepted + if (pg->state() == Qt::GestureFinished) { + touchFeedback.sliding = false; + zoomed = rotated = false; + if (pg->totalOffset().width() > 0) + goNextImage(); + else + goPrevImage(); + updateImage(); + } + } + update(); + feedbackFadeOutTimer.start(500, this); + } else if (sender() == tapAndHoldGesture) { + if (tapAndHoldGesture->state() == Qt::GestureFinished) { + qDebug() << "tap and hold detected"; + touchFeedback.reset(); + update(); + + QMenu menu; + menu.addAction("Action 1"); + menu.addAction("Action 2"); + menu.addAction("Action 3"); + menu.exec(mapToGlobal(tapAndHoldGesture->pos())); + } else { + ++touchFeedback.tapAndHoldState; + update(); + } + feedbackFadeOutTimer.start(500, this); + } +} + +void ImageWidget::gestureFinished() +{ + qDebug() << "gesture finished" << sender(); +} + +void ImageWidget::gestureCancelled() +{ + qDebug() << "gesture cancelled" << sender(); +} + +void ImageWidget::resizeEvent(QResizeEvent*) +{ + updateImage(); +} + +void ImageWidget::updateImage() +{ + // should use qtconcurrent here? + transformation = QTransform(); + if (zoomedIn) { + } else { + if (currentImage.isNull()) + return; + if (zoomed) { + transformation = transformation.scale(zoom, zoom); + } else { + double xscale = (double)width()/currentImage.width(); + double yscale = (double)height()/currentImage.height(); + if (xscale < yscale) + yscale = xscale; + else + xscale = yscale; + transformation = transformation.scale(xscale, yscale); + } + if (rotated) + transformation = transformation.rotate(angle); + } + pixmap = QPixmap::fromImage(currentImage).transformed(transformation); + update(); +} + +void ImageWidget::openDirectory(const QString &path) +{ + this->path = path; + QDir dir(path); + QStringList nameFilters; + nameFilters << "*.jpg" << "*.png"; + files = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); + + position = 0; + goToImage(0); + updateImage(); +} + +QImage ImageWidget::loadImage(const QString &fileName) +{ + QImageReader reader(fileName); + if (!reader.canRead()) { + qDebug() << fileName << ": can't load image"; + return QImage(); + } + QImage image; + if (!reader.read(&image)) { + qDebug() << fileName << ": corrupted image"; + return QImage(); + } + return image; +} + +void ImageWidget::setZoomedIn(bool zoomed) +{ + zoomedIn = zoomed; +} + +void ImageWidget::goNextImage() +{ + if (files.isEmpty()) + return; + if (position < files.size()-1) { + ++position; + prevImage = currentImage; + currentImage = nextImage; + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + } + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::goPrevImage() +{ + if (files.isEmpty()) + return; + if (position > 0) { + --position; + nextImage = currentImage; + currentImage = prevImage; + if (position > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + } + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::goToImage(int index) +{ + if (files.isEmpty()) + return; + if (index < 0 || index >= files.size()) { + qDebug() << "goToImage: invalid index: " << index; + return; + } + if (index == position+1) { + goNextImage(); + return; + } + if (position > 0 && index == position-1) { + goPrevImage(); + return; + } + position = index; + pixmap = QPixmap(); + if (index > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + currentImage = loadImage(path+QLatin1String("/")+files.at(position)); + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + setZoomedIn(false); + updateImage(); +} + +void ImageWidget::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == touchFeedback.tapTimer.timerId()) { + touchFeedback.tapTimer.stop(); + } else if (event->timerId() == feedbackFadeOutTimer.timerId()) { + feedbackFadeOutTimer.stop(); + touchFeedback.reset(); + } + update(); +} + +#include "moc_imagewidget.cpp" diff --git a/doc/src/snippets/gestures/imageviewer/imagewidget.h b/doc/src/snippets/gestures/imageviewer/imagewidget.h new file mode 100644 index 0000000..fcad5b9 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/imagewidget.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IMAGEWIDGET_H +#define IMAGEWIDGET_H + +#include +#include +#include + +#include + +#include "tapandholdgesture.h" + +class ImageWidget : public QWidget +{ + Q_OBJECT + +public: + ImageWidget(QWidget *parent = 0); + + void openDirectory(const QString &path); + +protected: + void paintEvent(QPaintEvent*); + void resizeEvent(QResizeEvent*); + void timerEvent(QTimerEvent*); + void mousePressEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + +//! [imagewidget-slots] +private slots: + void gestureTriggered(); + void gestureFinished(); + void gestureCancelled(); +//! [imagewidget-slots] + +private: + void updateImage(); + QImage loadImage(const QString &fileName); + void loadImage(); + void setZoomedIn(bool zoomed); + void goNextImage(); + void goPrevImage(); + void goToImage(int index); + + QPanGesture *panGesture; + TapAndHoldGesture *tapAndHoldGesture; + + QString path; + QStringList files; + int position; + + QImage prevImage, nextImage; + QImage currentImage; + QPixmap pixmap; + QTransform transformation; + + bool zoomedIn; + int horizontalOffset; + int verticalOffset; + + bool zoomed; + qreal zoom; + bool rotated; + qreal angle; + + struct TouchFeedback + { + bool tapped; + QPoint position; + bool sliding; + QPoint slidingStartPosition; + QBasicTimer tapTimer; + int tapState; + bool doubleTapped; + int tapAndHoldState; + + enum { MaximumNumberOfTouches = 5 }; + QPoint touches[MaximumNumberOfTouches]; + + inline TouchFeedback() { reset(); } + inline void reset() + { + tapped = false; + sliding = false; + tapTimer.stop(); + tapState = 0; + doubleTapped = false; + tapAndHoldState = 0; + for (int i = 0; i < MaximumNumberOfTouches; ++i) { + touches[i] = QPoint(); + } + } + } touchFeedback; + QBasicTimer feedbackFadeOutTimer; +}; + +#endif diff --git a/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp new file mode 100644 index 0000000..03898dc --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tapandholdgesture.h" + +#include + +// #define TAPANDHOLD_USING_MOUSE + +/*! + \class TapAndHoldGesture + \since 4.6 + + \brief The TapAndHoldGesture class represents a Tap-and-Hold gesture, + providing additional information. +*/ + +const int TapAndHoldGesture::iterationCount = 40; +const int TapAndHoldGesture::iterationTimeout = 50; + +/*! + Creates a new Tap and Hold gesture handler object and marks it as a child + of \a parent. + + On some platforms like Windows there is a system-wide tap and hold gesture + that cannot be overriden, hence the gesture might never trigger and default + context menu will be shown instead. +*/ +TapAndHoldGesture::TapAndHoldGesture(QWidget *parent) + : QGesture(parent), iteration(0) +{ +} + +/*! \internal */ +bool TapAndHoldGesture::filterEvent(QEvent *event) +{ + if (!event->spontaneous()) + return false; + const QTouchEvent *ev = static_cast(event); + switch (event->type()) { + case QEvent::TouchBegin: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = ev->touchPoints().at(0).pos().toPoint(); + position = p; + break; + } + case QEvent::TouchUpdate: + if (ev->touchPoints().size() == 1) { + const QPoint startPos = ev->touchPoints().at(0).startPos().toPoint(); + const QPoint pos = ev->touchPoints().at(0).pos().toPoint(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + } else { + reset(); + } + break; + case QEvent::TouchEnd: + reset(); + break; +#ifdef TAPANDHOLD_USING_MOUSE + case QEvent::MouseButtonPress: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = static_cast(event)->pos(); + position = startPosition = p; + break; + } + case QEvent::MouseMove: { + const QPoint startPos = startPosition; + const QPoint pos = static_cast(event)->pos(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + break; + } + case QEvent::MouseButtonRelease: + reset(); + break; +#endif // TAPANDHOLD_USING_MOUSE + default: + break; + } + return false; +} + +/*! \internal */ +void TapAndHoldGesture::timerEvent(QTimerEvent *event) +{ + if (event->timerId() != timer.timerId()) + return; + if (iteration == TapAndHoldGesture::iterationCount) { + timer.stop(); + updateState(Qt::GestureFinished); + } else { + updateState(Qt::GestureUpdated); + } + ++iteration; +} + +/*! \internal */ +//! [tapandhold-reset] +void TapAndHoldGesture::reset() +{ + timer.stop(); + iteration = 0; + position = startPosition = QPoint(); + updateState(Qt::NoGesture); +} +//! [tapandhold-reset] + +/*! + \property TapAndHoldGesture::pos + + \brief The position of the gesture. +*/ +QPoint TapAndHoldGesture::pos() const +{ + return position; +} diff --git a/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h new file mode 100644 index 0000000..bf0f867 --- /dev/null +++ b/doc/src/snippets/gestures/imageviewer/tapandholdgesture.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TAPANDHOLDGESTURE_H +#define TAPANDHOLDGESTURE_H + +#include +#include +#include + +class TapAndHoldGesture : public QGesture +{ + Q_OBJECT + Q_PROPERTY(QPoint pos READ pos) + +public: + TapAndHoldGesture(QWidget *parent); + + bool filterEvent(QEvent *event); + void reset(); + + QPoint pos() const; + +protected: + void timerEvent(QTimerEvent *event); + +private: + QBasicTimer timer; + int iteration; + QPoint position; + QPoint startPosition; + static const int iterationCount; + static const int iterationTimeout; +}; + +#endif // TAPANDHOLDGESTURE_H -- cgit v0.12 From c09c9704a934000425a1f4a0db0c59f09eaee041 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 17 Aug 2009 09:45:01 +0200 Subject: Doc: Mention that destroying an item that belongs to a QGraphicsScene is inneficient As the virtual functions (such as the boundingRect()) are not available anymore in the destructor, the view has to refresh everything. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 74b8fe2..f454d7c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1183,6 +1183,9 @@ QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent, Destroys the QGraphicsItem and all its children. If this item is currently associated with a scene, the item will be removed from the scene before it is deleted. + + \note It is more efficient to remove the item from the QGraphicsScene before + destroying the item. */ QGraphicsItem::~QGraphicsItem() { -- cgit v0.12 From 58e5dbb977bf7f52c2a374e589de2faaa336dbb9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:49:22 +0200 Subject: qpdf: fix memory leak detected by coverity --- src/gui/painting/qpdf.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 9b3b289..6a7889a 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1773,6 +1773,9 @@ bool QPdfBaseEnginePrivate::openPrintDevice() (void)execv("/bin/lpr", lprargs); (void)execv("/usr/bin/lp", lpargs); (void)execv("/usr/bin/lpr", lprargs); + + delete []lpargs; + delete []lprargs; } // if we couldn't exec anything, close the fd, // wait for a second so the parent process (the -- cgit v0.12 From 8096d2bbbb1f4becaaefe2219560f8dd558235de Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 17 Aug 2009 12:26:00 +0200 Subject: doc: Eliminated two qdoc error reports. --- src/corelib/tools/qshareddata.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index dd98499..9f49898 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -285,6 +285,11 @@ QT_BEGIN_NAMESPACE \sa data() */ +/*! \fn void QSharedDataPointer::swap(QSharedDataPointer &other) + Swap this instance's shared data pointer with the shared + data pointer in \a other. + */ + /*! \fn bool QSharedDataPointer::operator==(const QSharedDataPointer& other) const Returns true if \a other and \e this have the same \e{d pointer}. This function does \e not call detach(). @@ -436,6 +441,11 @@ QT_BEGIN_NAMESPACE \sa data() */ +/*! \fn void QExplicitlySharedDataPointer::swap(QExplicitlySharedDataPointer &other) + Swap this instance's explicitly shared data pointer with + the explicitly shared data pointer in \a other. + */ + /*! \fn bool QExplicitlySharedDataPointer::operator==(const QExplicitlySharedDataPointer& other) const Returns true if \a other and \e this have the same \e{d pointer}. */ -- cgit v0.12 From 5bc8c27e9406fd55693e3a3963030c6d9a89b08a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 20 Oct 2008 09:59:51 +0200 Subject: Add LIBS_PRIVATE to qmake. The difference between LIBS and LIBS_PRIVATE is that private libraries are those that are not part of the public interface of a library. For example, if you're writing a Qt application and link to QtGui, you definitely need the development files for QtCore, but not necessarily for Glib and GThread, or maybe even X11. The private libraries are necessary only in static builds, so the information should still be published in .prl and pkg-config files. Reviewed-By: Marius Storm-Olsen --- qmake/generators/makefile.cpp | 2 ++ qmake/generators/unix/unixmake.cpp | 3 ++- qmake/generators/unix/unixmake2.cpp | 18 ++++++++++-------- qmake/generators/win32/mingw_make.cpp | 11 +++++++++-- qmake/generators/win32/mingw_make.h | 1 + qmake/generators/win32/msvc_nmake.cpp | 1 + qmake/generators/win32/winmakefile.cpp | 2 +- qmake/generators/win32/winmakefile.h | 2 +- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 9580101..bf0e6df 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -967,6 +967,8 @@ MakefileGenerator::writePrlFile(QTextStream &t) libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); else libs << "QMAKE_LIBS"; //obvious one + if(project->isActiveConfig("staticlib")) + libs << "QMAKE_LIBS_PRIVATE"; t << "QMAKE_PRL_LIBS = "; for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << project->values((*it)).join(" ") << " "; diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 36470f2..626b955a5 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -127,6 +127,7 @@ UnixMakefileGenerator::init() project->values("QMAKE_ORIG_TARGET") = project->values("TARGET"); project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR"); project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) || (project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) { if(configs.indexOf("dll") == -1) configs.append("dll"); @@ -441,7 +442,7 @@ UnixMakefileGenerator::findLibraries() QList libdirs, frameworkdirs; frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks")); frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks")); - const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", QString() }; + const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LFLAGS", "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", QString() }; for(int i = 0; !lflags[i].isNull(); i++) { QStringList &l = project->values(lflags[i]); for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index b8252b8..07c7d38 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -149,7 +149,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "LINK = " << var("QMAKE_LINK") << endl; t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_FRAMEWORKDIR_FLAGS") << " " - << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; + << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl; } t << "AR = " << var("QMAKE_AR") << endl; @@ -1424,13 +1424,6 @@ UnixMakefileGenerator::writePkgConfigFile() t << "Version: " << project->first("VERSION") << endl; // libs - QStringList libs; - if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) { - libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); - } else { - libs << "QMAKE_LIBS"; //obvious one - } - libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? t << "Libs: "; QString pkgConfiglibDir; QString pkgConfiglibName; @@ -1450,6 +1443,15 @@ UnixMakefileGenerator::writePkgConfigFile() pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length()); } t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl; + + QStringList libs; + if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) { + libs = project->values("QMAKE_INTERNAL_PRL_LIBS"); + } else { + libs << "QMAKE_LIBS"; //obvious one + } + libs << "QMAKE_LIBS_PRIVATE"; + libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? t << "Libs.private: "; for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) { t << project->values((*it)).join(" ") << " "; diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 84104fd..fb0f48d 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -82,7 +82,12 @@ QString MingwMakefileGenerator::getLibTarget() bool MingwMakefileGenerator::findLibraries() { - QStringList &l = project->values("QMAKE_LIBS"); + return findLibraries("QMAKE_LIBS") && findLibraries("QMAKE_LIBS_PRIVATE"); +} + +bool MingwMakefileGenerator::findLibraries(const QString &where) +{ + QStringList &l = project->values(where); QList dirs; { @@ -258,6 +263,7 @@ void MingwMakefileGenerator::init() // LIBS defined in Profile comes first for gcc project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); QString targetfilename = project->values("TARGET").first(); QStringList &configs = project->values("CONFIG"); @@ -344,7 +350,8 @@ void MingwMakefileGenerator::writeLibsPart(QTextStream &t) t << "LIBS = "; if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); - t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl; + t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' ' + << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl; } } diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h index c95beff..8640bbc 100644 --- a/qmake/generators/win32/mingw_make.h +++ b/qmake/generators/win32/mingw_make.h @@ -72,6 +72,7 @@ private: QString preCompHeaderOut; virtual bool findLibraries(); + bool findLibraries(const QString &where); void fixTargetExt(); bool init_flag; diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 7613ef2..3a0ca6f 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -172,6 +172,7 @@ void NmakeMakefileGenerator::init() } project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); processVars(); if (!project->values("RES_FILE").isEmpty()) { diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index e3923c6..3a4329c 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -708,7 +708,7 @@ void Win32MakefileGenerator::writeLibsPart(QTextStream &t) if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); t << var("QMAKE_LFLAGS") << endl; - t << "LIBS = " << var("QMAKE_LIBS") << endl; + t << "LIBS = " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl; } } diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h index e2b6608..7032251 100644 --- a/qmake/generators/win32/winmakefile.h +++ b/qmake/generators/win32/winmakefile.h @@ -89,7 +89,7 @@ inline Win32MakefileGenerator::~Win32MakefileGenerator() { } inline bool Win32MakefileGenerator::findLibraries() -{ return findLibraries("QMAKE_LIBS"); } +{ return findLibraries("QMAKE_LIBS") && findLibraries("QMAKE_LIBS_PRIVATE"); } QT_END_NAMESPACE -- cgit v0.12 From 83940f25dba51a9942ab55ed8475fc7fc8a8da84 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Aug 2009 10:43:48 +0200 Subject: Use LIBS_PRIVATE on Mac and X11. On the Mac, it means "-framework ApplicationServices -framework Carbon -framework AppKit" are no longer part of the default LIBS in Qt applications. This required a lot of fixes where we used Mac-specific code in Qt. On X11, it was very straightforward, because we apparently use very little of X11 outside QtGui. I haven't changed the Windows-specific LIBS paths, because I don't know how Windows behaves. Windows has DLLs, but it links to static "import" libraries. So is it static linking or dynamic linking? Reviewed-By: Marius Storm-Olsen --- config.tests/unix/clock-gettime/clock-gettime.pri | 2 +- demos/macmainwindow/macmainwindow.pro | 2 +- mkspecs/features/unix/dylib.prf | 2 +- mkspecs/features/unix/opengl.prf | 2 +- mkspecs/features/unix/x11lib.prf | 2 +- mkspecs/features/unix/x11sm.prf | 2 +- src/3rdparty/webkit/WebCore/WebCore.pro | 1 + src/corelib/codecs/codecs.pri | 2 +- src/corelib/corelib.pro | 2 +- src/corelib/kernel/kernel.pri | 2 +- src/corelib/plugin/plugin.pri | 2 ++ src/corelib/tools/tools.pri | 5 +++-- src/dbus/dbus.pro | 10 +++++----- src/gui/egl/egl.pri | 2 +- src/gui/embedded/embedded.pri | 2 +- src/gui/image/image.pri | 2 +- src/gui/kernel/kernel.pri | 4 ++-- src/gui/kernel/mac.pri | 2 +- src/gui/kernel/x11.pri | 2 +- src/gui/painting/painting.pri | 7 ++++++- src/gui/styles/styles.pri | 2 +- src/gui/text/text.pri | 2 +- src/multimedia/audio/audio.pri | 4 ++-- src/network/access/access.pri | 2 +- src/network/kernel/kernel.pri | 2 +- src/network/ssl/ssl.pri | 2 +- src/opengl/opengl.pro | 14 ++++++++++++-- src/openvg/openvg.pro | 12 ++++++------ src/plugins/phonon/qt7/qt7.pro | 2 +- src/qt3support/network/network.pri | 2 +- src/qt3support/qt3support.pro | 2 +- src/svg/svg.pro | 2 +- src/testlib/testlib.pro | 7 +++---- tools/assistant/lib/lib.pro | 8 +++----- 34 files changed, 68 insertions(+), 52 deletions(-) diff --git a/config.tests/unix/clock-gettime/clock-gettime.pri b/config.tests/unix/clock-gettime/clock-gettime.pri index 2a6160b..65b49fb 100644 --- a/config.tests/unix/clock-gettime/clock-gettime.pri +++ b/config.tests/unix/clock-gettime/clock-gettime.pri @@ -1,2 +1,2 @@ # clock_gettime() is implemented in librt on these systems -linux-*|hpux-*|solaris-*:LIBS *= -lrt +linux-*|hpux-*|solaris-*:LIBS_PRIVATE *= -lrt diff --git a/demos/macmainwindow/macmainwindow.pro b/demos/macmainwindow/macmainwindow.pro index f5165a7..ba6ffbb 100644 --- a/demos/macmainwindow/macmainwindow.pro +++ b/demos/macmainwindow/macmainwindow.pro @@ -12,7 +12,7 @@ build_all:!build_pass { CONFIG += release } -LIBS += -framework Cocoa +LIBS += -framework Cocoa -framework Carbon # install mac { diff --git a/mkspecs/features/unix/dylib.prf b/mkspecs/features/unix/dylib.prf index 1268fae..8b13789 100644 --- a/mkspecs/features/unix/dylib.prf +++ b/mkspecs/features/unix/dylib.prf @@ -1 +1 @@ -LIBS += $$QMAKE_LIBS_DYNLOAD + diff --git a/mkspecs/features/unix/opengl.prf b/mkspecs/features/unix/opengl.prf index 231d0aa..2fdf324 100644 --- a/mkspecs/features/unix/opengl.prf +++ b/mkspecs/features/unix/opengl.prf @@ -1,4 +1,4 @@ INCLUDEPATH += $$QMAKE_INCDIR_OPENGL !isEmpty(QMAKE_LIBDIR_OPENGL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL -target_qt:LIBS += $$QMAKE_LIBS_OPENGL_QT +target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_QT else:LIBS += $$QMAKE_LIBS_OPENGL diff --git a/mkspecs/features/unix/x11lib.prf b/mkspecs/features/unix/x11lib.prf index 521518a..b661d53 100644 --- a/mkspecs/features/unix/x11lib.prf +++ b/mkspecs/features/unix/x11lib.prf @@ -1,2 +1,2 @@ !isEmpty(QMAKE_LIBDIR_X11):QMAKE_LIBDIR += $$QMAKE_LIBDIR_X11 -LIBS += $$QMAKE_LIBS_X11 +LIBS_PRIVATE += $$QMAKE_LIBS_X11 diff --git a/mkspecs/features/unix/x11sm.prf b/mkspecs/features/unix/x11sm.prf index b455b01..5176147 100644 --- a/mkspecs/features/unix/x11sm.prf +++ b/mkspecs/features/unix/x11sm.prf @@ -1,2 +1,2 @@ !isEmpty(QMAKE_LIBDIR_X11):QMAKE_LIBDIR += $$QMAKE_LIBDIR_X11 -LIBS += $$QMAKE_LIBS_X11SM +LIBS_PRIVATE += $$QMAKE_LIBS_X11SM diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 68da1d6..2fb5c32 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2165,6 +2165,7 @@ SOURCES += \ SOURCES += \ platform/text/cf/StringCF.cpp \ platform/text/cf/StringImplCF.cpp + LIBS_PRIVATE += -framework Carbon -framework AppKit } win32-* { diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri index 2e247e5..724b18d 100644 --- a/src/corelib/codecs/codecs.pri +++ b/src/corelib/codecs/codecs.pri @@ -29,7 +29,7 @@ unix { SOURCES += codecs/qiconvcodec.cpp DEFINES += GNU_LIBICONV - !mac:LIBS *= -liconv + !mac:LIBS_PRIVATE *= -liconv } else { # no iconv, so we put all plugins in the library HEADERS += \ diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index db51d43..d028772 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -18,7 +18,7 @@ include(codecs/codecs.pri) include(statemachine/statemachine.pri) include(xml/xml.pri) -mac|darwin:LIBS += -framework ApplicationServices +mac|darwin:LIBS_PRIVATE += -framework ApplicationServices mac:lib_bundle:DEFINES += QT_NO_DEBUG_PLUGIN_CHECK win32:DEFINES-=QT_NO_CAST_TO_ASCII diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 3493784..5c2f384 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -103,7 +103,7 @@ unix { HEADERS += \ kernel/qeventdispatcher_glib_p.h QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB - LIBS +=$$QT_LIBS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB } SOURCES += \ kernel/qeventdispatcher_unix.cpp diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index aaecec9..c05ff48 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -22,3 +22,5 @@ win32 { unix { SOURCES += plugin/qlibrary_unix.cpp } + +LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 44fbb62..1a6c1c0 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -91,7 +91,7 @@ contains(QT_CONFIG, zlib) { ../3rdparty/zlib/uncompr.c \ ../3rdparty/zlib/zutil.c } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz # win32:LIBS += libz.lib } @@ -109,4 +109,5 @@ SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \ tools/qharfbuzz.cpp HEADERS += tools/qharfbuzz_p.h -!macx-icc:!vxworks:unix:LIBS += -lm +# Note: libm should be present by default becaue this is C++ +!macx-icc:!vxworks:unix:LIBS_PRIVATE += -lm diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 39adfe1..dcd8418 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -6,8 +6,8 @@ DEFINES += QDBUS_MAKEDLL DBUS_API_SUBJECT_TO_CHANGE QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS contains(QT_CONFIG, dbus-linked) { - LIBS += $$QT_LIBS_DBUS - DEFINES += QT_LINKED_LIBDBUS + LIBS_PRIVATE += $$QT_LIBS_DBUS + DEFINES += QT_LINKED_LIBDBUS } #INCLUDEPATH += . @@ -18,9 +18,9 @@ unix { } win32 { - LIBS += -lws2_32 -ladvapi32 -lnetapi32 -luser32 - CONFIG(debug, debug|release):LIBS += -ldbus-1d - else:LIBS += -ldbus-1 + LIBS_PRIVATE += -lws2_32 -ladvapi32 -lnetapi32 -luser32 + CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d + else:LIBS_PRIVATE += -ldbus-1 } include(../qbase.pri) diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 651507f..75a3d91 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -25,4 +25,4 @@ for(p, QMAKE_LIBDIR_EGL) { } !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL -!isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL +!isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri index e8eb959..255a504 100644 --- a/src/gui/embedded/embedded.pri +++ b/src/gui/embedded/embedded.pri @@ -189,7 +189,7 @@ embedded { } contains( mouse-drivers, tslib ) { - LIBS += -lts + LIBS_PRIVATE += -lts HEADERS +=embedded/qmousetslib_qws.h SOURCES +=embedded/qmousetslib_qws.cpp } diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index baf2125..5507d25 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -89,7 +89,7 @@ SOURCES += \ SOURCES += image/qpnghandler.cpp contains(QT_CONFIG, system-png) { - unix:LIBS += -lpng + unix:LIBS_PRIVATE += -lpng win32:LIBS += libpng.lib } else { !isEqual(QT_ARCH, i386):!isEqual(QT_ARCH, x86_64):DEFINES += PNG_NO_ASSEMBLER_CODE diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index d9deefe..a94c5a3 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -124,7 +124,7 @@ unix:x11 { HEADERS += \ kernel/qguieventdispatcher_glib_p.h QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB - LIBS +=$$QT_LIBS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB } SOURCES += \ kernel/qeventdispatcher_x11.cpp @@ -205,7 +205,7 @@ embedded { QMAKE_BUNDLE_DATA += MENU_NIB RESOURCES += mac/macresources.qrc - LIBS += -framework AppKit + LIBS_PRIVATE += -framework AppKit } wince*: { diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri index 415fe0a..1538510 100644 --- a/src/gui/kernel/mac.pri +++ b/src/gui/kernel/mac.pri @@ -1,4 +1,4 @@ !x11:!embedded:mac { - LIBS += -framework Carbon -lz + LIBS_PRIVATE += -framework Carbon -lz *-mwerks:INCLUDEPATH += compat } diff --git a/src/gui/kernel/x11.pri b/src/gui/kernel/x11.pri index ac40f69..82de1b6 100644 --- a/src/gui/kernel/x11.pri +++ b/src/gui/kernel/x11.pri @@ -1,4 +1,4 @@ x11 { - contains(QT_CONFIG, nas): LIBS += -laudio -lXt + contains(QT_CONFIG, nas): LIBS_PRIVATE += -laudio -lXt } diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index d226be2..adb73aa 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -352,4 +352,9 @@ embedded { SOURCES += painting/qwindowsurface_qws.cpp } - +contains(QT_CONFIG, zlib) { + INCLUDEPATH += ../3rdparty/zlib +} else:!contains(QT_CONFIG, no-zlib) { + unix:LIBS_PRIVATE += -lz +# win32:LIBS += libz.lib +} diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index d255f80..ce1f91f 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -37,7 +37,7 @@ x11|embedded|!macx-*:styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE - LIBS += $$QT_LIBS_QGTKSTYLE + LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE styles += gtk } diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index fc33d43..94ed756 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -164,7 +164,7 @@ contains(QT_CONFIG, freetype) { embedded:CONFIG += opentype # pull in the proper freetype2 include directory include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) - LIBS += -lfreetype + LIBS_PRIVATE += -lfreetype } else { DEFINES *= QT_NO_FREETYPE } diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index 3ddb23b..c7fbbb0 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -31,7 +31,7 @@ mac { $$PWD/qaudioinput_mac_p.cpp \ $$PWD/qaudio_mac.cpp - LIBS += -framework CoreAudio -framework AudioUnit -framework AudioToolbox + LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox } else:win32 { @@ -50,7 +50,7 @@ mac { SOURCES += $$PWD/qaudiodeviceinfo_alsa_p.cpp \ $$PWD/qaudiooutput_alsa_p.cpp \ $$PWD/qaudioinput_alsa_p.cpp - LIBS += -lasound + LIBS_PRIVATE += -lasound } } } diff --git a/src/network/access/access.pri b/src/network/access/access.pri index ab7b3a7..edc1b63 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -59,6 +59,6 @@ SOURCES += access/qftp.cpp \ contains(QT_CONFIG, zlib) { INCLUDEPATH += ../3rdparty/zlib } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz # win32:LIBS += libz.lib } diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 8aa6ff4..09d2acf 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -23,7 +23,7 @@ SOURCES += kernel/qauthenticator.cpp \ unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp -mac:LIBS+= -framework SystemConfiguration +mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation mac:SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:SOURCES += kernel/qnetworkproxy_win.cpp else:SOURCES += kernel/qnetworkproxy_generic.cpp diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 196e19d..44f4812 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -29,5 +29,5 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { RESOURCES += network.qrc # Add optional SSL libs - LIBS += $$OPENSSL_LIBS + LIBS_PRIVATE += $$OPENSSL_LIBS } diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 868484e..4231721 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -73,16 +73,26 @@ x11 { } contains(QT_CONFIG, fontconfig) { + contains(QT_CONFIG, system-freetype) { + embedded:CONFIG += opentype + # pull in the proper freetype2 include directory include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) + LIBS_PRIVATE += -lfreetype + } else { + ### Note: how does this compile with a non-system freetype? + # This probably doesn't compile + } } else { DEFINES *= QT_NO_FREETYPE } + + LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD } mac { OBJECTIVE_SOURCES += qgl_mac.mm \ qglpixelbuffer_mac.mm - LIBS += -framework AppKit + LIBS_PRIVATE += -framework AppKit -framework Carbon } win32:!wince*: { SOURCES += qgl_win.cpp \ @@ -131,5 +141,5 @@ wince*: { } } else { - QMAKE_LIBS += $$QMAKE_LIBS_OPENGL + LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL } diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro index 240bf13..bf224b4 100644 --- a/src/openvg/openvg.pro +++ b/src/openvg/openvg.pro @@ -36,19 +36,19 @@ include(../qbase.pri) unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui !isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG -!isEmpty(QMAKE_LIBDIR_OPENVG): LIBS += -L$$QMAKE_LIBDIR_OPENVG -!isEmpty(QMAKE_LIBS_OPENVG): LIBS += $$QMAKE_LIBS_OPENVG +!isEmpty(QMAKE_LIBDIR_OPENVG): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENVG +!isEmpty(QMAKE_LIBS_OPENVG): LIBS_PRIVATE += $$QMAKE_LIBS_OPENVG contains(QT_CONFIG, egl) { !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL - !isEmpty(QMAKE_LIBDIR_EGL): LIBS += -L$$QMAKE_LIBDIR_EGL - !isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL + !isEmpty(QMAKE_LIBDIR_EGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_EGL + !isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL } contains(QT_CONFIG, openvg_on_opengl) { !isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL - !isEmpty(QMAKE_LIBDIR_OPENGL): LIBS += -L$$QMAKE_LIBDIR_OPENGL - !isEmpty(QMAKE_LIBS_OPENGL): LIBS += $$QMAKE_LIBS_OPENGL + !isEmpty(QMAKE_LIBDIR_OPENGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENGL + !isEmpty(QMAKE_LIBS_OPENGL): LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL } INCLUDEPATH += ../3rdparty/harfbuzz/src diff --git a/src/plugins/phonon/qt7/qt7.pro b/src/plugins/phonon/qt7/qt7.pro index 665baee..53407db 100644 --- a/src/plugins/phonon/qt7/qt7.pro +++ b/src/plugins/phonon/qt7/qt7.pro @@ -12,7 +12,7 @@ contains(QMAKE_MAC_XARCH, no) { LIBS += -Xarch_i386 -framework QuickTime -Xarch_ppc -framework QuickTime } -LIBS += -framework AudioUnit \ +LIBS += -framework AppKit -framework AudioUnit \ -framework AudioToolbox -framework CoreAudio \ -framework QuartzCore -framework QTKit diff --git a/src/qt3support/network/network.pri b/src/qt3support/network/network.pri index 31ea682..086f56a 100644 --- a/src/qt3support/network/network.pri +++ b/src/qt3support/network/network.pri @@ -26,5 +26,5 @@ SOURCES += network/q3dns.cpp \ win32:SOURCES += network/q3socketdevice_win.cpp unix:SOURCES += network/q3socketdevice_unix.cpp -mac:LIBS += -lresolv +mac:LIBS_PRIVATE += -lresolv diff --git a/src/qt3support/qt3support.pro b/src/qt3support/qt3support.pro index 23a4696..a30117c 100644 --- a/src/qt3support/qt3support.pro +++ b/src/qt3support/qt3support.pro @@ -25,7 +25,7 @@ unix { QMAKE_PKGCONFIG_CFLAGS += -DQT3_SUPPORT QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork QtSql } -mac:LIBS += -framework Carbon +mac:LIBS_PRIVATE += -framework Carbon QMAKE_LIBS += $$QMAKE_LIBS_COMPAT $$QMAKE_LIBS_NETWORK DEFINES -= QT3_SUPPORT_WARNINGS diff --git a/src/svg/svg.pro b/src/svg/svg.pro index aef0786..9a01983 100644 --- a/src/svg/svg.pro +++ b/src/svg/svg.pro @@ -44,5 +44,5 @@ INCLUDEPATH += ../3rdparty/harfbuzz/src contains(QT_CONFIG, zlib) { INCLUDEPATH += ../3rdparty/zlib } else:!contains(QT_CONFIG, no-zlib) { - unix:LIBS += -lz + unix:LIBS_PRIVATE += -lz } diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 9740c21..5238dfe 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -57,10 +57,9 @@ wince*::LIBS += libcmt.lib \ commctrl.lib \ coredll.lib \ winsock.lib -mac:LIBS += -framework \ - IOKit \ - -framework \ - Security +mac:LIBS += -framework IOKit \ + -framework ApplicationServices \ + -framework Security include(../qbase.pri) QMAKE_TARGET_PRODUCT = QTestLib QMAKE_TARGET_DESCRIPTION = Qt \ diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index 5d6d436..011dec2 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -18,14 +18,12 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { mac:qclucene = $${qclucene}_debug win32:qclucene = $${qclucene}d } -linux-lsb-g++:LIBS += --lsb-shared-libs=$$qclucene -unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ - QtSql \ - QtXml -LIBS += -l$$qclucene +linux-lsb-g++:LIBS_PRIVATE += --lsb-shared-libs=$$qclucene unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ QtSql \ QtXml +LIBS_PRIVATE += -l$$qclucene + RESOURCES += helpsystem.qrc SOURCES += qhelpenginecore.cpp \ qhelpengine.cpp \ -- cgit v0.12 From 213e2c937b667dba7e4996b0857ae5791c6d5fc8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 12:01:21 +0200 Subject: Fixed coverity warnings --- src/corelib/io/qiodevice.cpp | 2 +- src/gui/itemviews/qlistview.cpp | 1 - src/gui/itemviews/qlistview_p.h | 7 ++++--- src/gui/itemviews/qtreewidget.cpp | 1 + src/gui/painting/qpdf.cpp | 2 +- src/gui/styles/qstyleoption.cpp | 6 +++--- src/gui/text/qcssparser_p.h | 2 +- src/xml/dom/qdom.cpp | 5 ++--- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 4108136..35b85c3 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -811,7 +811,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize) #endif if (readFromDevice < bytesToBuffer) - d->buffer.truncate(readFromDevice < 0 ? 0 : int(readFromDevice)); + d->buffer.truncate(int(readFromDevice)); if (!d->buffer.isEmpty()) { lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); readSoFar += lastReadChunkSize; diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 1870a3b..3ab3204 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1957,7 +1957,6 @@ bool QListView::event(QEvent *e) QListViewPrivate::QListViewPrivate() : QAbstractItemViewPrivate(), dynamicListView(0), - staticListView(0), wrap(false), space(0), flow(QListView::TopToBottom), diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index 1131059..6c8d324 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -351,9 +351,10 @@ public: QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; - // ### FIXME: we only need one at a time - QDynamicListViewBase *dynamicListView; - QStaticListViewBase *staticListView; + union { + QDynamicListViewBase *dynamicListView; + QStaticListViewBase *staticListView; + }; // ### FIXME: see if we can move the members into the dynamic/static classes diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 025f83c..1ab69df 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1768,6 +1768,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const // special case for check state in tristate if (children.count() && (itemFlags & Qt::ItemIsTristate)) return childrenCheckState(column); + // fallthrough intended default: if (column >= 0 && column < values.size()) { const QVector &column_values = values.at(column); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 6a7889a..478a2a8 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -313,7 +313,7 @@ QByteArray QPdf::generatePath(const QPainterPath &path, const QTransform &matrix Qt::FillRule fillRule = path.fillRule(); - const char *op = 0; + const char *op = ""; switch (flags) { case ClipPath: op = (fillRule == Qt::WindingFill) ? "W n\n" : "W* n\n"; diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 98996e2..eabbb8d 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -712,7 +712,7 @@ QStyleOptionFrameV2 &QStyleOptionFrameV2::operator=(const QStyleOptionFrame &oth Constructs a QStyleOptionFrameV3 object. */ QStyleOptionFrameV3::QStyleOptionFrameV3() - : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame) + : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame), unused(0) { } @@ -726,7 +726,7 @@ QStyleOptionFrameV3::QStyleOptionFrameV3() \internal */ QStyleOptionFrameV3::QStyleOptionFrameV3(int version) - : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame) + : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame), unused(0) { } @@ -4845,7 +4845,7 @@ QStyleOptionTabBarBaseV2 &QStyleOptionTabBarBaseV2::operator = (const QStyleOpti /*! \internal */ QStyleOptionTabBarBaseV2::QStyleOptionTabBarBaseV2(int version) - : QStyleOptionTabBarBase(version) + : QStyleOptionTabBarBase(version), documentMode(false) { } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index c685b08..6f73445 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -504,7 +504,7 @@ const int NumPseudos = 46; struct Pseudo { - Pseudo() : negated(false) { } + Pseudo() : type(0), negated(false) { } quint64 type; QString name; QString function; diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index a7dfaa9..85a31c7 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -1845,8 +1845,7 @@ QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild) oldChild->prev = 0; // We are no longer interested in the old node - if (oldChild) - oldChild->ref.deref(); + oldChild->ref.deref(); return oldChild; } @@ -4355,7 +4354,7 @@ bool QDomAttr::specified() const QDomElement QDomAttr::ownerElement() const { Q_ASSERT(impl->parent()); - if (!impl || !impl->parent()->isElement()) + if (!impl->parent()->isElement()) return QDomElement(); return QDomElement((QDomElementPrivate*)(impl->parent())); } -- cgit v0.12 From dc2771eb57702a0daf5164b0f9ad569c9fe0e5ba Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 12:51:37 +0200 Subject: Better handling of qreal with QVariant --- src/corelib/kernel/qabstractitemmodel.cpp | 39 ++++++++++++++++++++----------- src/corelib/kernel/qabstractitemmodel_p.h | 2 +- src/corelib/kernel/qvariant.cpp | 2 +- src/gui/itemviews/qlistwidget.cpp | 4 +--- src/gui/itemviews/qstyleditemdelegate.cpp | 2 +- src/gui/itemviews/qtablewidget.cpp | 4 +--- src/gui/itemviews/qtreewidget.cpp | 4 +--- src/gui/text/qcssparser.cpp | 2 +- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cfc961c..61b19a2 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -488,35 +488,48 @@ const QHash &QAbstractItemModelPrivate::defaultRoleNames() return *qDefaultRoleNames(); } -/*! - \internal - return true if \a value contains a numerical type - This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. - We cannot rely on QVariant::canConvert because this would take strings as double - and then not sort strings correctly -*/ -bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) +static uint typeOfVariant(const QVariant &value) { + //return 0 for integer, 1 for floating point and 2 for other switch (value.userType()) { case QVariant::Bool: case QVariant::Int: case QVariant::UInt: case QVariant::LongLong: case QVariant::ULongLong: - case QVariant::Double: case QVariant::Char: - case QMetaType::Float: case QMetaType::Short: case QMetaType::UShort: case QMetaType::UChar: case QMetaType::ULong: case QMetaType::Long: - return true; + return 0; + case QVariant::Double: + case QMetaType::Float: + return 1; default: - return false; + return 2; + } +} + +/*! + \internal + return true if \a value contains a numerical type + + This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. +*/ +bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVariant &v2) +{ + switch(qMax(typeOfVariant(v1), typeOfVariant(v2))) + { + case 0: //integer type + return v1.toLongLong() < v2.toLongLong(); + case 1: //floating point + return v1.toReal() < v2.toReal(); + default: + return v1.toString() < v2.toString(); } - return false; } void QAbstractItemModelPrivate::removePersistentIndexData(QPersistentModelIndexData *data) diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/kernel/qabstractitemmodel_p.h index 76c2d70..e81e627 100644 --- a/src/corelib/kernel/qabstractitemmodel_p.h +++ b/src/corelib/kernel/qabstractitemmodel_p.h @@ -89,7 +89,7 @@ public: void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last); void columnsRemoved(const QModelIndex &parent, int first, int last); static QAbstractItemModel *staticEmptyModel(); - static bool canConvertToDouble(const QVariant &value); + static bool variantLessThan(const QVariant &v1, const QVariant &v2); inline QModelIndex createIndex(int row, int column, void *data = 0) const { return q_func()->createIndex(row, column, data); diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 3c430eb..66c4176 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2776,7 +2776,7 @@ bool QVariant::cmp(const QVariant &v) const if (d.type != v2.d.type) { if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) { if (qIsFloatingPoint(d.type) || qIsFloatingPoint(v.d.type)) - return qFuzzyCompare(toDouble(), v.toDouble()); + return qFuzzyCompare(toReal(), v.toReal()); else return toLongLong() == v.toLongLong(); } diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 2792bbd..a1f8288 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -708,9 +708,7 @@ QVariant QListWidgetItem::data(int role) const bool QListWidgetItem::operator<(const QListWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index f7c7d12..a8ea218 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -270,7 +270,7 @@ QString QStyledItemDelegate::displayText(const QVariant &value, const QLocale& l switch (value.userType()) { case QMetaType::Float: case QVariant::Double: - text = locale.toString(value.toDouble()); + text = locale.toString(value.toReal()); break; case QVariant::Int: case QVariant::LongLong: diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index fea81e5..de8ebde 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -1392,9 +1392,7 @@ QVariant QTableWidgetItem::data(int role) const bool QTableWidgetItem::operator<(const QTableWidgetItem &other) const { const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 1ab69df..f48e393 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1790,9 +1790,7 @@ bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const int column = view ? view->sortColumn() : 0; const QVariant v1 = data(column, Qt::DisplayRole); const QVariant v2 = other.data(column, Qt::DisplayRole); - if (QAbstractItemModelPrivate::canConvertToDouble(v1) && QAbstractItemModelPrivate::canConvertToDouble(v2)) - return v1.toDouble() < v2.toDouble(); - return v1.toString() < v2.toString(); + return QAbstractItemModelPrivate::variantLessThan(v1, v2); } #ifndef QT_NO_DATASTREAM diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 181ec7e..f11104f 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -793,7 +793,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) { spread = spreads.indexOf(value.variant.toString()); } else { - vars[attr] = value.variant.toString().toDouble(); + vars[attr] = value.variant.toReal(); } } parser.skipSpace(); -- cgit v0.12 From efd84105355552bcb203b5e402be0352641e7480 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 17 Aug 2009 13:14:27 +0200 Subject: Fix compiler flags setting for .mm files on Mac. Commit 7f1cba82 causes {x86, x86_64, ppc, ppc64}.prf to be loaded before objective_c.prf. This will add content to QMAKE_OBJECTIVE_CFLAGS, causing the isEmpty test to skip populating QMAKE_OBJECTIVE_CFLAGS. Remove the isEmpty test to fix the issue. --- mkspecs/features/mac/objective_c.prf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkspecs/features/mac/objective_c.prf b/mkspecs/features/mac/objective_c.prf index 0a73af9..0df7013 100644 --- a/mkspecs/features/mac/objective_c.prf +++ b/mkspecs/features/mac/objective_c.prf @@ -1,6 +1,5 @@ isEmpty(QMAKE_OBJECTIVE_CC):QMAKE_OBJECTIVE_CC = $$QMAKE_CC -isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF @@ -9,7 +8,7 @@ isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS_X86 = $$QMAKE_CFLAGS_X86 QMAKE_OBJECTIVE_CFLAGS_PPC = $$QMAKE_CFLAGS_PPC QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS -} + OBJECTIVE_C_OBJECTS_DIR = $$OBJECTS_DIR isEmpty(OBJECTIVE_C_OBJECTS_DIR):OBJECTIVE_C_OBJECTS_DIR = . isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .mm .m -- cgit v0.12 From abdf1befb8de4b88da43561dae2e1beb09c2a532 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 17 Aug 2009 13:29:09 +0200 Subject: Transforms do not obey AnchorUnderMouse with viewport margins set setTransformationAnchor(QGraphicsView::AnchorUnderMouse) would not work properly if viewport margins were set. When centering the view in QGraphicsViewPrivate::centerView, the viewport margins were not being taken into account. Mapping from global cursor coordinates in the viewport instead of the view fixes the issue. Task-number: 255529 Reviewed-by: Olivier --- src/gui/graphicsview/qgraphicsview.cpp | 4 +-- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 37 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 7213542..91e654c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -493,8 +493,8 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) // Last scene pos: lastMouseMoveScenePoint // Current mouse pos: QPointF transformationDiff = q->mapToScene(viewport->rect().center()) - - q->mapToScene(q->mapFromGlobal(QCursor::pos())); - q->centerOn(lastMouseMoveScenePoint + transformationDiff);; + - q->mapToScene(viewport->mapFromGlobal(QCursor::pos())); + q->centerOn(lastMouseMoveScenePoint + transformationDiff); } else { q->centerOn(lastCenterPoint); } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 0c65b87..c12fb11 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -216,6 +216,7 @@ private slots: void task239047_fitInViewSmallViewport(); void task245469_itemsAtPointWithClip(); void task253415_reconnectUpdateSceneOnSceneChanged(); + void task255529_transformationAnchorMouseAndViewportMargins(); }; void tst_QGraphicsView::initTestCase() @@ -3617,5 +3618,41 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() QVERIFY(wasConnected2); } +void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() +{ + QGraphicsScene scene(-100, -100, 200, 200); + scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue)); + + class VpGraphicsView: public QGraphicsView + { + public: + VpGraphicsView(QGraphicsScene *scene) + : QGraphicsView(scene) + { + setViewportMargins(8, 16, 12, 20); + setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + setMouseTracking(true); + } + }; + + VpGraphicsView view(&scene); + view.show(); + QPoint mouseViewPos(20, 20); + sendMouseMove(view.viewport(), mouseViewPos); + QTest::qWait(125); + + QPointF mouseScenePos = view.mapToScene(mouseViewPos); + view.setTransform(QTransform().scale(5, 5)); + QTest::qWait(125); + view.setTransform(QTransform().rotate(5, Qt::ZAxis), true); + QTest::qWait(125); + + QPointF newMouseScenePos = view.mapToScene(mouseViewPos); + qreal slack = 3; + QVERIFY(qAbs(newMouseScenePos.x() - mouseScenePos.x()) < slack); + QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack); +} + + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" -- cgit v0.12 From 025a7395153c3708e2964cfd93957532b19ae04f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 17 Aug 2009 13:15:08 +0200 Subject: QPaintDevice implemented in qpaintdevice.cpp. Saves duplicated code Reviewed-by: Eskil --- src/gui/painting/painting.pri | 5 +-- src/gui/painting/qpaintdevice.cpp | 66 +++++++++++++++++++++++++++++++++++ src/gui/painting/qpaintdevice_mac.cpp | 28 --------------- src/gui/painting/qpaintdevice_win.cpp | 21 ----------- src/gui/painting/qpaintdevice_x11.cpp | 21 ----------- 5 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 src/gui/painting/qpaintdevice.cpp diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index adb73aa..b9d293c 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -46,7 +46,7 @@ HEADERS += \ SOURCES += \ painting/qbezier.cpp \ - painting/qblendfunctions.cpp \ + painting/qblendfunctions.cpp \ painting/qbrush.cpp \ painting/qcolor.cpp \ painting/qcolor_p.cpp \ @@ -57,6 +57,7 @@ SOURCES += \ painting/qmatrix.cpp \ painting/qmemrotate.cpp \ painting/qoutlinemapper.cpp \ + painting/qpaintdevice.cpp \ painting/qpaintengine.cpp \ painting/qpaintengine_alpha.cpp \ painting/qpaintengine_preview.cpp \ @@ -75,9 +76,9 @@ SOURCES += \ painting/qstroker.cpp \ painting/qstylepainter.cpp \ painting/qtessellator.cpp \ - painting/qwindowsurface.cpp \ painting/qtextureglyphcache.cpp \ painting/qtransform.cpp \ + painting/qwindowsurface.cpp \ DEFINES += QT_RASTER_IMAGEENGINE win32:DEFINES += QT_RASTER_PAINTENGINE diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp new file mode 100644 index 0000000..6477952 --- /dev/null +++ b/src/gui/painting/qpaintdevice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qpaintdevice.h" + +QT_BEGIN_NAMESPACE + +extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp + +QPaintDevice::QPaintDevice() +{ + painters = 0; +} + +QPaintDevice::~QPaintDevice() +{ + if (paintingActive()) + qWarning("QPaintDevice: Cannot destroy paint device that is being " + "painted"); + qt_painter_removePaintDevice(this); +} + + +int QPaintDevice::metric(PaintDeviceMetric) const +{ + qWarning("QPaintDevice::metrics: Device has no metric information"); + return 0; +} diff --git a/src/gui/painting/qpaintdevice_mac.cpp b/src/gui/painting/qpaintdevice_mac.cpp index bf5e261..aa7c2ac 100644 --- a/src/gui/painting/qpaintdevice_mac.cpp +++ b/src/gui/painting/qpaintdevice_mac.cpp @@ -57,34 +57,6 @@ QT_BEGIN_NAMESPACE Internal variables and functions *****************************************************************************/ - -/***************************************************************************** - External functions - *****************************************************************************/ - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -/***************************************************************************** - QPaintDevice member functions - *****************************************************************************/ -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -QPaintDevice::~QPaintDevice() -{ - if(paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted, be sure to QPainter::end() painters"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - return 0; -} - /*! \internal */ float qt_mac_defaultDpi_x() { diff --git a/src/gui/painting/qpaintdevice_win.cpp b/src/gui/painting/qpaintdevice_win.cpp index 86de028..f964feb 100644 --- a/src/gui/painting/qpaintdevice_win.cpp +++ b/src/gui/painting/qpaintdevice_win.cpp @@ -50,27 +50,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted. Be sure to QPainter::end() painters!"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - HDC QPaintDevice::getDC() const { return 0; diff --git a/src/gui/painting/qpaintdevice_x11.cpp b/src/gui/painting/qpaintdevice_x11.cpp index b0ed732..474f3f1 100644 --- a/src/gui/painting/qpaintdevice_x11.cpp +++ b/src/gui/painting/qpaintdevice_x11.cpp @@ -49,21 +49,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted"); - qt_painter_removePaintDevice(this); -} - /*! \internal Returns the X11 Drawable of the paint device. 0 is returned if it @@ -96,12 +81,6 @@ const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd) return 0; } -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - #ifdef QT3_SUPPORT -- cgit v0.12 From 3d50220423b96a84f1ca4c0f5ef9246345aad359 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:48:51 +0200 Subject: Fix coverity warnings --- src/gui/image/qmovie.cpp | 2 +- src/gui/image/qppmhandler.cpp | 2 +- src/gui/itemviews/qheaderview.cpp | 2 +- src/gui/painting/qpaintengine_raster.cpp | 3 --- src/gui/text/qcssparser.cpp | 6 +++--- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 2265e7b..c341e5e 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -356,7 +356,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) reader = new QImageReader(device, format); else reader = new QImageReader(absoluteFilePath, format); - reader->canRead(); // Provoke a device->open() call + (void)reader->canRead(); // Provoke a device->open() call reader->device()->seek(initialDevicePos); reader->setBackgroundColor(bgColor); reader->setScaledSize(scaledSize); diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 77ccb48..ed8f4c1 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -80,7 +80,7 @@ static int read_pbm_int(QIODevice *d) else if (isspace((uchar) c)) continue; else if (c == '#') - d->readLine(buf, buflen); + (void)d->readLine(buf, buflen); else break; } diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 633dd53..96df758 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2615,7 +2615,7 @@ void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot int first = orientation() == Qt::Horizontal ? topLeft.column() : topLeft.row(); int last = orientation() == Qt::Horizontal ? bottomRight.column() : bottomRight.row(); for (int i = first; i <= last && !resizeRequired; ++i) - resizeRequired = (resizeRequired && resizeMode(i)); + resizeRequired = (resizeMode(i) == ResizeToContents); if (resizeRequired) d->doDelayedResizeSections(); } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 654870f..d00329b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1022,9 +1022,6 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, if (alpha == 0 || !clip.isValid()) return; - if (alpha ==0) - return; - Q_ASSERT(img.depth() >= 8); int srcBPL = img.bytesPerLine(); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index f11104f..d3dcf50 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -789,7 +789,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) } else { parser.next(); Value value; - parser.parseTerm(&value); + (void)parser.parseTerm(&value); if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0) { spread = spreads.indexOf(value.variant.toString()); } else { @@ -797,7 +797,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal) } } parser.skipSpace(); - parser.test(COMMA); + (void)parser.test(COMMA); } if (gradType == 0) { @@ -2458,7 +2458,7 @@ bool Parser::parseAttrib(AttributeSelector *attr) bool Parser::parsePseudo(Pseudo *pseudo) { - test(COLON); + (void)test(COLON); pseudo->negated = test(EXCLAMATION_SYM); if (test(IDENT)) { pseudo->name = lexem(); -- cgit v0.12 From b80312254e61986e6848d1608dcac54e0b3f191a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 12 Aug 2009 10:34:40 +0200 Subject: remove QT_RASTER_PAINTENGINE and QT_RASTER_IMAGEENGINE defines as they are legacy and completely pointless... Reviewed-By: Eskil --- src/gui/image/qimage.cpp | 7 +---- src/gui/image/qpixmap_mac.cpp | 11 ------- src/gui/kernel/qcocoaview_mac.mm | 67 +++++++++++++++++++--------------------- src/gui/kernel/qwidget_mac.mm | 27 +--------------- src/gui/painting/painting.pri | 3 -- 5 files changed, 33 insertions(+), 82 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 0001e2b..09bc8c8 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -61,11 +61,7 @@ #include -#ifdef QT_RASTER_IMAGEENGINE #include -#else -#include -#endif #include @@ -5255,11 +5251,10 @@ QPaintEngine *QImage::paintEngine() const if (!d) return 0; -#ifdef QT_RASTER_IMAGEENGINE if (!d->paintEngine) { d->paintEngine = new QRasterPaintEngine(const_cast(this)); } -#endif + return d->paintEngine; } diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 8c911bb..5959da1 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -38,7 +38,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//#define QT_RASTER_PAINTENGINE #include "qpixmap.h" #include "qimage.h" @@ -52,9 +51,6 @@ #include #include #include -#ifdef QT_RASTER_PAINTENGINE -# include -#endif #include #include #include @@ -1098,14 +1094,7 @@ QPaintEngine* QMacPixmapData::paintEngine() const { if (!pengine) { QMacPixmapData *that = const_cast(this); -#ifdef QT_RASTER_PAINTENGINE - if (qgetenv("QT_MAC_USE_COREGRAPHICS").isNull()) - that->pengine = new QRasterPaintEngine(); - else - that->pengine = new QCoreGraphicsPaintEngine(); -#else that->pengine = new QCoreGraphicsPaintEngine(); -#endif } return pengine; } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index c20445a..45b0ada 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -102,7 +102,7 @@ static dndenum_mapper dnd_enums[] = { { NSDragOperationCopy, Qt::CopyAction, true }, { NSDragOperationGeneric, Qt::CopyAction, false }, { NSDragOperationEvery, Qt::ActionMask, false }, - { NSDragOperationNone, Qt::IgnoreAction, false } + { NSDragOperationNone, Qt::IgnoreAction, false } }; static NSDragOperation qt_mac_mapDropAction(Qt::DropAction action) @@ -228,14 +228,14 @@ extern "C" { currentCustomTypes = new QStringList(); *currentCustomTypes = customTypes; const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; - NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, - NSFilenamesPboardType, NSStringPboardType, - NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, - NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, - NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, - NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, + NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, + NSFilenamesPboardType, NSStringPboardType, + NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, + NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, + NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, + NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, NSURLPboardType, NSPDFPboardType, NSVCardPboardType, - NSFilesPromisePboardType, NSInkTextPboardType, + NSFilesPromisePboardType, NSInkTextPboardType, NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; // Add custom types supported by the application. for (int i = 0; i < customTypes.size(); i++) { @@ -280,16 +280,16 @@ extern "C" { dropData = 0; } } - -- (void)addDropData:(id )sender + +- (void)addDropData:(id )sender { [self removeDropData]; - CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name]; + CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name]; dropData = new QCocoaDropData(dropPasteboard); -} +} -- (NSDragOperation)draggingEntered:(id )sender -{ +- (NSDragOperation)draggingEntered:(id )sender +{ if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false) return NSDragOperationNone; NSPoint windowPoint = [sender draggingLocation]; @@ -307,7 +307,7 @@ extern "C" { NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; QPoint posDrag(localPoint.x, localPoint.y); - NSDragOperation nsActions = [sender draggingSourceOperationMask]; + NSDragOperation nsActions = [sender draggingSourceOperationMask]; Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions); QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; Qt::KeyboardModifiers modifiers = Qt::NoModifier; @@ -336,8 +336,8 @@ extern "C" { qDMEvent.accept(); // accept by default, since enter event was accepted. QApplication::sendEvent(qwidget, &qDMEvent); if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) { - // since we accepted the drag enter event, the widget expects - // future drage move events. + // since we accepted the drag enter event, the widget expects + // future drage move events. // ### check if we need to treat this like the drag enter event. nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction()); } else { @@ -345,7 +345,7 @@ extern "C" { } QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent); return nsActions; - } + } } - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender @@ -373,7 +373,7 @@ extern "C" { 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)); - // send drag move event to the widget + // 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); Qt::KeyboardModifiers modifiers = Qt::NoModifier; @@ -436,7 +436,7 @@ extern "C" { NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; QPoint posDrop(localPoint.x, localPoint.y); - NSDragOperation nsActions = [sender draggingSourceOperationMask]; + NSDragOperation nsActions = [sender draggingSourceOperationMask]; Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions); QMimeData *mimeData = dropData; if (QDragManager::self()->source()) @@ -563,11 +563,6 @@ extern "C" { qt_sendSpontaneousEvent(qwidget, &e); if (!redirectionOffset.isNull()) QPainter::restoreRedirected(qwidget); -#ifdef QT_RASTER_PAINTENGINE - if(engine && engine->type() == QPaintEngine::Raster) - static_cast(engine)->flush(qwidget, - qrgn.boundingRect().topLeft()); -#endif if (engine) engine->setSystemClip(QRegion()); qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); @@ -638,7 +633,7 @@ extern "C" { QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1)); QApplicationPrivate::instance()->notify_helper(qwidget, &he); } - } + } } - (void)mouseExited:(NSEvent *)event @@ -647,7 +642,7 @@ extern "C" { NSPoint globalPoint = [[event window] convertBaseToScreen:[event locationInWindow]]; if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) { QApplication::sendEvent(qwidget, &leaveEvent); - + // ### Think about if it is necessary to update the cursor, should only be for a few cases. qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint()); if (qwidget->testAttribute(Qt::WA_Hover) @@ -679,7 +674,7 @@ extern "C" { { qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::LeftButton); // Don't call super here. This prevents us from getting the mouseUp event, - // which we need to send even if the mouseDown event was not accepted. + // which we need to send even if the mouseDown event was not accepted. // (this is standard Qt behavior.) } @@ -843,7 +838,7 @@ extern "C" { } #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 -- (void)touchesBeganWithEvent:(NSEvent *)event; +- (void)touchesBeganWithEvent:(NSEvent *)event; { bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents); qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all)); @@ -1128,7 +1123,7 @@ extern "C" { while (index < composingLength) { NSRange effectiveRange; NSRange range = NSMakeRange(index, composingLength-index); - NSDictionary *attributes = [aString attributesAtIndex:index + NSDictionary *attributes = [aString attributesAtIndex:index longestEffectiveRange:&effectiveRange inRange:range]; NSNumber *underlineStyle = [attributes objectForKey:NSUnderlineStyleAttributeName]; @@ -1137,7 +1132,7 @@ extern "C" { NSColor *color = [attributes objectForKey:NSUnderlineColorAttributeName]; if (color) { clr = colorFrom(color); - } + } QTextCharFormat format; format.setFontUnderline(true); format.setUnderlineColor(clr); @@ -1213,7 +1208,7 @@ extern "C" { - (NSRange) markedRange { - NSRange range; + NSRange range; if (composing) { range.location = 0; range.length = composingLength; @@ -1238,13 +1233,13 @@ extern "C" { selRange.length = 0; } return selRange; - + } - (NSRect) firstRectForCharacterRange:(NSRange)theRange { Q_UNUSED(theRange); - // The returned rect is always based on the internal cursor. + // The returned rect is always based on the internal cursor. QRect mr(qwidget->inputMethodQuery(Qt::ImMicroFocus).toRect()); QPoint mp(qwidget->mapToGlobal(QPoint(mr.bottomLeft()))); NSRect rect ; @@ -1392,7 +1387,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) NSImage *image = (NSImage *)qt_mac_create_nsimage(pix); [image retain]; DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; - // save supported actions + // save supported actions [dndParams->view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; NSPoint imageLoc = {dndParams->localPoint.x - hotspot.x(), dndParams->localPoint.y + pix.height() - hotspot.y()}; @@ -1416,7 +1411,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { - // check if the receiver points us to a file location. + // check if the receiver points us to a file location. // if so, we need to do the file copy/move ourselves. QCFType pasteLocation = 0; PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5948cd4..5bf140c 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -72,7 +72,6 @@ ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ****************************************************************************/ -//#define QT_RASTER_PAINTENGINE #include #include @@ -88,9 +87,6 @@ #include "qlayout.h" #include "qmenubar.h" #include -#ifdef QT_RASTER_PAINTENGINE -# include -#endif #include #include #include "qpainter.h" @@ -1220,11 +1216,6 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event, QApplication::sendSpontaneousEvent(widget, &e); if (!redirectionOffset.isNull()) widget->d_func()->restoreRedirected(); -#ifdef QT_RASTER_PAINTENGINE - if(engine && engine->type() == QPaintEngine::Raster) - static_cast(engine)->flush(widget, - qrgn.boundingRect().topLeft()); -#endif //cleanup if (engine) @@ -3101,7 +3092,7 @@ void QWidgetPrivate::update_sys(const QRegion &rgn) dirtyOnWidget += rgn; #ifndef QT_MAC_USE_COCOA RgnHandle rgnHandle = rgn.toQDRgnForUpdate_sys(); - if (rgnHandle) + if (rgnHandle) HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true); else { HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. @@ -4555,21 +4546,6 @@ Q_GLOBAL_STATIC(QPaintEngineCleanupHandler, engineHandler) QPaintEngine *QWidget::paintEngine() const { QPaintEngine *&pe = engineHandler()->engine; -#ifdef QT_RASTER_PAINTENGINE - if (!pe) { - if(qgetenv("QT_MAC_USE_COREGRAPHICS").isNull()) - pe = new QRasterPaintEngine(); - else - pe = new QCoreGraphicsPaintEngine(); - } - if (pe->isActive()) { - QPaintEngine *engine = - qgetenv("QT_MAC_USE_COREGRAPHICS").isNull() - ? (QPaintEngine*)new QRasterPaintEngine() : (QPaintEngine*)new QCoreGraphicsPaintEngine(); - engine->setAutoDestruct(true); - return engine; - } -#else if (!pe) pe = new QCoreGraphicsPaintEngine(); if (pe->isActive()) { @@ -4577,7 +4553,6 @@ QPaintEngine *QWidget::paintEngine() const engine->setAutoDestruct(true); return engine; } -#endif return pe; } diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index b9d293c..d11e818 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -80,9 +80,6 @@ SOURCES += \ painting/qtransform.cpp \ painting/qwindowsurface.cpp \ - DEFINES += QT_RASTER_IMAGEENGINE - win32:DEFINES += QT_RASTER_PAINTENGINE - embedded:DEFINES += QT_RASTER_PAINTENGINE SOURCES += \ painting/qpaintengine_raster.cpp \ painting/qdrawhelper.cpp \ -- cgit v0.12 From 38f41726cf3a76a57ca15f7cc82e56a5aa2c5a1c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 13:59:43 +0200 Subject: QTextControl::print: fix coverity warning the test was wrong on the QPrinter pointer In addition, priv is never null --- src/gui/text/qtextcontrol.cpp | 2 +- src/gui/text/qtextcursor.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 58f8a06..1c14d20 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -2262,7 +2262,7 @@ void QTextControl::print(QPrinter *printer) const { #ifndef QT_NO_PRINTER Q_D(const QTextControl); - if (printer && !printer->isValid()) + if (!printer || !printer->isValid()) return; QTextDocument *tempDoc = 0; const QTextDocument *doc = d->doc; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 6ab89dc..f97146d 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -84,8 +84,7 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) QTextCursorPrivate::~QTextCursorPrivate() { - if (priv) - priv->removeCursor(this); + priv->removeCursor(this); } QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) @@ -125,7 +124,7 @@ QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int position void QTextCursorPrivate::setX() { - if (priv && priv->isInEditBlock()) { + if (priv->isInEditBlock()) { x = -1; // mark dirty return; } -- cgit v0.12 From 1ca6a2f3174fdfbbe080af920ab75558a1a9247e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 17 Aug 2009 14:28:45 +0200 Subject: qdoc: Fixed the bug that made reporting NOTIFY signals not work. The signal was being associated with a particular property, but in many classes, the NOTIFY signal applies to multiple properties. Added a new function to the PropertyNode class that adds the signal function without associating it with any property. Task-number: 259071 --- src/gui/graphicsview/qgraphicsitem.cpp | 5 +++-- tools/qdoc3/cppcodeparser.cpp | 4 ++-- tools/qdoc3/node.h | 6 ++++++ tools/qdoc3/tree.cpp | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f454d7c..6d75db3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6831,11 +6831,12 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent By default, this property is true. - \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled(), enabledChanged() + \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled() + \sa QGraphicsObject::enabledChanged() */ /*! - \fn QGraphicsObject::enabledChanged() + \fn void QGraphicsObject::enabledChanged() This signal gets emitted whenever the item get's enabled or disabled. diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ebe5ec9..7519ff1 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1734,11 +1734,11 @@ bool CppCodeParser::matchProperty(InnerNode *parent) property->setDesignable(value.toLower() == "true"); else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); -#if 0 + else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } -#endif + } match(Tok_RightParen); return true; diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 2a1ca05..0cddf51 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -598,6 +598,7 @@ class PropertyNode : public LeafNode void setDataType(const QString& dataType) { dt = dataType; } void addFunction(FunctionNode *function, FunctionRole role); + void addSignal(FunctionNode *function, FunctionRole role); void setStored(bool stored) { sto = toTrool(stored); } void setDesignable(bool designable) { des = toTrool(designable); } void setOverriddenFrom(const PropertyNode *baseProperty); @@ -641,6 +642,11 @@ inline void PropertyNode::addFunction(FunctionNode *function, FunctionRole role) function->setAssociatedProperty(this); } +inline void PropertyNode::addSignal(FunctionNode *function, FunctionRole role) +{ + funcs[(int)role].append(function); +} + inline NodeList PropertyNode::functions() const { NodeList list; diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index b42701f..7d488df 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -501,7 +501,7 @@ void Tree::resolveProperties() } else if (function->name() == resetterName) { property->addFunction(function, PropertyNode::Resetter); } else if (function->name() == notifierName) { - property->addFunction(function, PropertyNode::Notifier); + property->addSignal(function, PropertyNode::Notifier); } } } -- cgit v0.12 From 6687a82476a96922f23d4fd3535d4e7354d9cdab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 14:42:48 +0200 Subject: More coverity warnings removed --- src/corelib/io/qfileinfo_p.h | 4 ++-- src/gui/text/qtextobject.cpp | 10 ---------- src/gui/text/qtextobject_p.h | 2 +- src/gui/text/qtexttable_p.h | 2 +- src/svg/qsvgstyle.cpp | 4 +++- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index d64a5c4..d92090c 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -81,11 +81,11 @@ public: CachedSize =0x08 }; struct Data { inline Data() - : ref(1), fileEngine(0), cache_enabled(1) + : ref(1), fileEngine(0), cache_enabled(1), fileSize(0) { clear(); } inline Data(const Data ©) : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), cache_enabled(copy.cache_enabled) + fileName(copy.fileName), cache_enabled(copy.cache_enabled), fileSize(copy.fileSize) { clear(); } inline ~Data() { delete fileEngine; } inline void clearFlags() { diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 98c92eb..5dc0c48 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -412,11 +412,6 @@ QTextFrameLayoutData::~QTextFrameLayoutData() QTextFrame::QTextFrame(QTextDocument *doc) : QTextObject(*new QTextFramePrivate(doc), doc) { - Q_D(QTextFrame); - d->fragment_start = 0; - d->fragment_end = 0; - d->parentFrame = 0; - d->layoutData = 0; } // ### DOC: What does this do to child frames? @@ -435,11 +430,6 @@ QTextFrame::~QTextFrame() QTextFrame::QTextFrame(QTextFramePrivate &p, QTextDocument *doc) : QTextObject(p, doc) { - Q_D(QTextFrame); - d->fragment_start = 0; - d->fragment_end = 0; - d->parentFrame = 0; - d->layoutData = 0; } /*! diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index e862b30..22034c8 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -94,7 +94,7 @@ class QTextFramePrivate : public QTextObjectPrivate Q_DECLARE_PUBLIC(QTextFrame) public: QTextFramePrivate(QTextDocument *doc) - : QTextObjectPrivate(doc) + : QTextObjectPrivate(doc), fragment_start(0), fragment_end(0), parentFrame(0), layoutData(0) { } virtual void fragmentAdded(const QChar &type, uint fragment); diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index 4dd52c7..7783b5d 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -62,7 +62,7 @@ class QTextTablePrivate : public QTextFramePrivate { Q_DECLARE_PUBLIC(QTextTable) public: - QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {} + QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {} ~QTextTablePrivate(); static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat); diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 820f716..1ecf870 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -90,6 +90,7 @@ QSvgFillStyle::QSvgFillStyle(const QBrush &brush) , m_fillRule(Qt::WindingFill) , m_fillOpacitySet(false) , m_fillOpacity(1.0) + , m_oldOpacity(0) , m_gradientResolved(true) , m_fillSet(true) { @@ -101,6 +102,7 @@ QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style) , m_fillRule(Qt::WindingFill) , m_fillOpacitySet(false) , m_fillOpacity(1.0) + , m_oldOpacity(0) , m_gradientResolved(true) , m_fillSet(style != 0) { @@ -858,7 +860,7 @@ QSvgStyleProperty::Type QSvgAnimateColor::type() const } QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity) - : m_opacity(opacity) + : m_opacity(opacity), m_oldOpacity(0) { } -- cgit v0.12 From 9e144490bfa059050f8b90645db80b1fd45fd2b1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 17 Aug 2009 15:08:14 +0200 Subject: Fix a crash in the destruction of QListView --- src/gui/itemviews/qlistview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 3ab3204..b055d32 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1974,8 +1974,10 @@ QListViewPrivate::QListViewPrivate() QListViewPrivate::~QListViewPrivate() { - delete staticListView; - delete dynamicListView; + if (viewMode == QListView::ListMode) + delete staticListView; + else + delete dynamicListView; } void QListViewPrivate::clear() -- cgit v0.12 From 4929da8ad0a43220c3cbd2d9f11db4c535028243 Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 17 Aug 2009 15:11:32 +0200 Subject: Add some more exception around to clucene index writer. Reviewed-by: ck --- .../lib/qhelpsearchindexwriter_clucene.cpp | 78 ++++++++++++++++------ .../lib/qhelpsearchindexwriter_clucene_p.h | 2 + 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index 6f7c035..4651d2e 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -590,15 +590,24 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, void QHelpSearchIndexWriter::optimizeIndex() { - if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) { - if (QCLuceneIndexReader::isLocked(m_indexFilesFolder)) - return; - - QCLuceneStandardAnalyzer analyzer; - QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false); - writer.optimize(); - writer.close(); +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + if (QCLuceneIndexReader::indexExists(m_indexFilesFolder)) { + if (QCLuceneIndexReader::isLocked(m_indexFilesFolder)) + return; + + QCLuceneStandardAnalyzer analyzer; + QCLuceneIndexWriter writer(m_indexFilesFolder, analyzer, false); + writer.optimize(); + writer.close(); + } +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not optimize index."); + return; } +#endif } void QHelpSearchIndexWriter::run() @@ -720,21 +729,30 @@ void QHelpSearchIndexWriter::run() } #if !defined(QT_NO_EXCEPTIONS) } catch (...) { - qWarning("Full Text Search, could not create index writer in '%s'.", qPrintable(indexPath)); + qWarning("Full Text Search, could not create index writer in '%s'.", + qPrintable(indexPath)); return; } #endif - writer->setMergeFactor(100); - writer->setMinMergeDocs(1000); - writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->setMergeFactor(100); + writer->setMinMergeDocs(1000); + writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not set writer properties."); + return; + } +#endif QStringList namespaces; foreach(const QString &namespaceName, registeredDocs) { mutexLocker.relock(); if (m_cancel) { - writer->close(); - delete writer; + closeIndexWriter(writer); emit indexingFinished(); return; } @@ -777,8 +795,7 @@ void QHelpSearchIndexWriter::run() mutexLocker.unlock(); } - writer->close(); - delete writer; + closeIndexWriter(writer); mutexLocker.relock(); if (!m_cancel) { @@ -813,15 +830,23 @@ bool QHelpSearchIndexWriter::addDocuments(const QList docFiles, foreach(const QUrl &url, docFiles) { QCLuceneDocument document; DocumentHelper helper(url.toString(), engine.fileData(url)); - if (helper.addFieldsToDocument(&document, namespaceName, attrList)) - writer->addDocument(document, analyzer); - + if (helper.addFieldsToDocument(&document, namespaceName, attrList)) { +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->addDocument(document, analyzer); +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not properly add documents."); + return false; + } +#endif + } locker.relock(); if (m_cancel) return false; locker.unlock(); } - return true; } @@ -861,6 +886,19 @@ QList QHelpSearchIndexWriter::indexableFiles(QHelpEngineCore *helpEngine, return docFiles; } +void QHelpSearchIndexWriter::closeIndexWriter(QCLuceneIndexWriter *writer) +{ +#if !defined(QT_NO_EXCEPTIONS) + try { +#endif + writer->close(); + delete writer; +#if !defined(QT_NO_EXCEPTIONS) + } catch (...) { + qWarning("Full Text Search, could not properly close index writer."); + } +#endif +} } // namespace clucene } // namespace fulltextsearch diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h index e9a917b..d4bb755 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene_p.h @@ -104,6 +104,8 @@ private: QList indexableFiles(QHelpEngineCore *helpEngine, const QString &namespaceName, const QStringList &attributes) const; + void closeIndexWriter(QCLuceneIndexWriter *writer); + private: QMutex mutex; QWaitCondition waitCondition; -- cgit v0.12 From 3a095929a13b9503946d97eded36e02ed07d81d3 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 17 Aug 2009 15:34:34 +0200 Subject: Doc: Fixed number of commercial editions. Reviewed-by: Trust Me --- doc/src/legal/commercialeditions.qdoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/legal/commercialeditions.qdoc b/doc/src/legal/commercialeditions.qdoc index 93c1bc0..761a53b 100644 --- a/doc/src/legal/commercialeditions.qdoc +++ b/doc/src/legal/commercialeditions.qdoc @@ -54,8 +54,7 @@ If you want to develop Free or Open Source software for release using a recognized Open Source license, you can use the \l{Open Source Versions of Qt}. - The table below summarizes the differences between the three - commercial editions: + The table below summarizes the differences between the two commercial editions: \table 75% \header \o{1,2} Features \o{2,1} Editions -- cgit v0.12 From 53807e58770f27d46ca8ecaa33a3d5f7b6925517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 17 Aug 2009 15:45:43 +0200 Subject: Fixed text rendering on GL ES 2 implementations. Some GL ES 2 implementations seem to have problems with glCopyTexSubImage2D(), so we fall back and read the old font texture into system memory and re-upload the new font texture. Also, the precision used for texture coordinates in the fragment programs wasn't high enough, which could lead to rendering artifacts. Reviewed-by: Samuel --- .../gl2paintengineex/qglengineshadersource_p.h | 6 ++-- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 37 ++++++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index b0b91ae..c80d6e1 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -73,8 +73,8 @@ static const char* const qglslMainVertexShader = "\ }"; static const char* const qglslMainWithTexCoordsVertexShader = "\ - attribute lowp vec2 textureCoordArray; \ - varying lowp vec2 textureCoords; \ + attribute mediump vec2 textureCoordArray; \ + varying mediump vec2 textureCoords; \ uniform highp float depth;\ void setPosition();\ void main(void) \ @@ -284,7 +284,7 @@ static const char* const qglslSolidBrushSrcFragmentShader = "\ }"; static const char* const qglslImageSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ + varying mediump vec2 textureCoords; \ uniform sampler2D imageTexture; \ lowp vec4 srcPixel() { \ return texture2D(imageTexture, textureCoords); \ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 5e1e892..34f7e7a 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -75,6 +75,7 @@ #include #include #include +#include #include "qglgradientcache_p.h" #include "qglengineshadermanager_p.h" @@ -175,7 +176,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) m_height = height; QVarLengthArray data(width * height); - for (int i = 0; i < width * height; ++i) + for (int i = 0; i < data.size(); ++i) data[i] = 0; if (m_type == QFontEngineGlyphCache::Raster_RGBMask) @@ -200,13 +201,18 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); - GLuint colorBuffer; - glGenRenderbuffers(1, &colorBuffer); - glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorBuffer); - glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, oldWidth, oldHeight); - glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_RENDERBUFFER_EXT, colorBuffer); - glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); + GLuint tmp_texture; + glGenTextures(1, &tmp_texture); + glBindTexture(GL_TEXTURE_2D, tmp_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, tmp_texture, 0); glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, oldTexture); @@ -237,11 +243,24 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); glBindTexture(GL_TEXTURE_2D, m_texture); + +#ifdef QT_OPENGL_ES_2 + QDataBuffer buffer(4*oldWidth*oldHeight); + glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); + + // do an in-place conversion from GL_RGBA to GL_ALPHA + for (int i=0; id_ptr->current_fbo); -- cgit v0.12 From 85edfcbde9f1d2f77a05edb8d01361c76234f47c Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 17 Aug 2009 15:41:51 +0200 Subject: Merge QGV delta from kinetic-declarativeui into master. New flag: QGraphicsItem::ItemNegativeZStacksBehindParent, which makes it easy to toggle stack-behind based on the value of Z alone. Add interface initializations to QGV classes. Add a simple internal focus policy to QGraphicsItem to allow derived items to be focusable without allowing clickfocus. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 15 +++++++++++++++ src/gui/graphicsview/qgraphicsitem.h | 8 +++++--- src/gui/graphicsview/qgraphicsitem_p.h | 10 ++++++---- src/gui/graphicsview/qgraphicslayout.h | 2 ++ src/gui/graphicsview/qgraphicslayoutitem.h | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 7 ++++--- src/gui/graphicsview/qgraphicsscene_p.h | 1 + src/gui/graphicsview/qgraphicswidget.cpp | 4 +++- src/gui/graphicsview/qgraphicswidget.h | 1 + tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 26 ++++++++++++++++++++++++++ 10 files changed, 65 insertions(+), 11 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 6d75db3..37d969b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -328,6 +328,10 @@ used for Asian languages. This flag was introduced in Qt 4.6. + \value ItemNegativeZStacksBehindParent The item automatically stacks behind + it's parent if it's z-value is negative. This flag enables setZValue() to + toggle ItemStacksBehindParent. + \value ItemAutoDetectsFocusProxy The item will assign any child that gains input focus as its focus proxy. See also focusProxy(). This flag was introduced in Qt 4.6. @@ -1566,6 +1570,11 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->scene->d_func()->updateInputMethodSensitivityInViews(); } + if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { + // Update stack-behind. + setFlag(ItemStacksBehindParent, d_ptr->z < qreal(0.0)); + } + if (d_ptr->scene) { d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, @@ -3719,6 +3728,9 @@ void QGraphicsItem::setZValue(qreal z) itemChange(ItemZValueHasChanged, newZVariant); + if (d_ptr->flags & ItemNegativeZStacksBehindParent) + setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0)); + if (d_ptr->isObject) emit static_cast(this)->zChanged(); } @@ -10103,6 +10115,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) case QGraphicsItem::ItemAcceptsInputMethod: str = "ItemAcceptsInputMethod"; break; + case QGraphicsItem::ItemNegativeZStacksBehindParent: + str = "ItemNegativeZStacksBehindParent"; + break; case QGraphicsItem::ItemAutoDetectsFocusProxy: str = "ItemAutoDetectsFocusProxy"; break; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 3acf265..b5e6ed5 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -101,7 +101,8 @@ public: ItemHasNoContents = 0x400, ItemSendsGeometryChanges = 0x800, ItemAcceptsInputMethod = 0x1000, - ItemAutoDetectsFocusProxy = 0x2000 + ItemAutoDetectsFocusProxy = 0x2000, + ItemNegativeZStacksBehindParent = 0x4000 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) @@ -452,6 +453,7 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags) +Q_DECLARE_INTERFACE(QGraphicsItem, "com.trolltech.Qt.QGraphicsItem") inline void QGraphicsItem::setPos(qreal ax, qreal ay) { setPos(QPointF(ax, ay)); } @@ -504,9 +506,9 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_OBJECT Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) Q_PROPERTY(QString id READ objectName WRITE setObjectName) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index c654d4f..43d690f 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -95,7 +95,7 @@ public: void purge(); }; -class Q_AUTOTEST_EXPORT QGraphicsItemPrivate +class Q_GUI_EXPORT QGraphicsItemPrivate { Q_DECLARE_PUBLIC(QGraphicsItem) public: @@ -165,6 +165,7 @@ public: acceptedTouchBeginEvent(0), filtersDescendantEvents(0), sceneTransformTranslateOnly(0), + mouseSetsFocus(1), globalStackingOrder(-1), q_ptr(0) { @@ -201,7 +202,7 @@ public: virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const; static bool movableAncestorIsSelected(const QGraphicsItem *item); - void setPosHelper(const QPointF &pos); + virtual void setPosHelper(const QPointF &pos); void setTransformHelper(const QTransform &transform); void appendGraphicsTransform(QGraphicsTransform *t); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); @@ -452,7 +453,7 @@ public: // New 32 bits quint32 fullUpdatePending : 1; - quint32 flags : 14; + quint32 flags : 15; quint32 dirtyChildrenBoundingRect : 1; quint32 paintedViewBoundingRectsNeedRepaint : 1; quint32 dirtySceneTransform : 1; @@ -465,7 +466,8 @@ public: quint32 acceptedTouchBeginEvent : 1; quint32 filtersDescendantEvents : 1; quint32 sceneTransformTranslateOnly : 1; - quint32 unused : 5; // feel free to use + quint32 mouseSetsFocus : 1; + quint32 unused : 3; // feel free to use // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicslayout.h b/src/gui/graphicsview/qgraphicslayout.h index d7e087b..1a21e53 100644 --- a/src/gui/graphicsview/qgraphicslayout.h +++ b/src/gui/graphicsview/qgraphicslayout.h @@ -85,6 +85,8 @@ private: friend class QGraphicsWidget; }; +Q_DECLARE_INTERFACE(QGraphicsLayout, "com.trolltech.Qt.QGraphicsLayout") + #endif QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h index 44c1c0f..f315404 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.h +++ b/src/gui/graphicsview/qgraphicslayoutitem.h @@ -121,6 +121,8 @@ private: friend class QGraphicsLayout; }; +Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem") + inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah) { setMinimumSize(QSizeF(aw, ah)); } inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 2178850..21ea72f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1079,7 +1079,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Set focus on the topmost enabled item that can take focus. bool setFocus = false; foreach (QGraphicsItem *item, cachedItemsUnderMouse) { - if (item->isEnabled() && (item->flags() & QGraphicsItem::ItemIsFocusable)) { + if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { setFocus = true; if (item != q->focusItem()) @@ -3802,7 +3802,8 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) bool hasSetFocus = false; foreach (QGraphicsItem *item, wheelCandidates) { - if (!hasSetFocus && item->isEnabled() && (item->flags() & QGraphicsItem::ItemIsFocusable)) { + if (!hasSetFocus && item->isEnabled() + && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { if (item->isWidget() && static_cast(item)->focusPolicy() == Qt::WheelFocus) { hasSetFocus = true; if (item != focusItem()) @@ -5298,7 +5299,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve // Set focus on the topmost enabled item that can take focus. bool setFocus = false; foreach (QGraphicsItem *item, cachedItemsUnderMouse) { - if (item->isEnabled() && (item->flags() & QGraphicsItem::ItemIsFocusable)) { + if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { setFocus = true; if (item != q->focusItem()) diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 836522d..685f534 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -59,6 +59,7 @@ #include "qgraphicssceneevent.h" #include "qgraphicsview.h" +#include "qgraphicsview_p.h" #include "qgraphicsitem_p.h" #include diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 64881b5..4b41f1f 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -258,7 +258,7 @@ QGraphicsWidget::~QGraphicsWidget() //we check if we have a layout previously if (d->layout) { - delete d->layout; + QGraphicsLayout *temp = d->layout; foreach (QGraphicsItem * item, childItems()) { // In case of a custom layout which doesn't remove and delete items, we ensure that // the parent layout item does not point to the deleted layout. This code is here to @@ -269,6 +269,8 @@ QGraphicsWidget::~QGraphicsWidget() widget->setParentLayoutItem(0); } } + d->layout = 0; + delete temp; } // Remove this graphics widget from widgetStyles diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h index 62b353a..57015f9 100644 --- a/src/gui/graphicsview/qgraphicswidget.h +++ b/src/gui/graphicsview/qgraphicswidget.h @@ -69,6 +69,7 @@ class QGraphicsWidgetPrivate; class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem { Q_OBJECT + Q_INTERFACES(QGraphicsItem QGraphicsLayoutItem) Q_PROPERTY(QPalette palette READ palette WRITE setPalette) Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index a623b50..10f0e42 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -281,6 +281,7 @@ private slots: void subFocus(); void reverseCreateAutoFocusProxy(); void focusProxyDeletion(); + void negativeZStacksBehindParent(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7558,5 +7559,30 @@ void tst_QGraphicsItem::focusProxyDeletion() delete scene; // don't crash } +void tst_QGraphicsItem::negativeZStacksBehindParent() +{ + QGraphicsRectItem rect; + QCOMPARE(rect.zValue(), qreal(0.0)); + QVERIFY(!(rect.flags() & QGraphicsItem::ItemNegativeZStacksBehindParent)); + QVERIFY(!(rect.flags() & QGraphicsItem::ItemStacksBehindParent)); + rect.setZValue(-1); + QCOMPARE(rect.zValue(), qreal(-1.0)); + QVERIFY(!(rect.flags() & QGraphicsItem::ItemStacksBehindParent)); + rect.setZValue(0); + rect.setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent); + QVERIFY(rect.flags() & QGraphicsItem::ItemNegativeZStacksBehindParent); + QVERIFY(!(rect.flags() & QGraphicsItem::ItemStacksBehindParent)); + rect.setZValue(-1); + QVERIFY(rect.flags() & QGraphicsItem::ItemStacksBehindParent); + rect.setZValue(0); + QVERIFY(!(rect.flags() & QGraphicsItem::ItemStacksBehindParent)); + rect.setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, false); + rect.setZValue(-1); + rect.setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, true); + QVERIFY(rect.flags() & QGraphicsItem::ItemStacksBehindParent); + rect.setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, false); + QVERIFY(rect.flags() & QGraphicsItem::ItemStacksBehindParent); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 55e3c88a002de2a99e144df82ad7ac375a7c51aa Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 17 Aug 2009 16:07:21 +0200 Subject: Doc - some clean ups to QSortFilterProxyModel's documentation Reviewed-By: TrustMe --- src/gui/itemviews/qsortfilterproxymodel.cpp | 171 +++++++++++++--------------- 1 file changed, 82 insertions(+), 89 deletions(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 8444a5b..aef59b5 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1278,82 +1278,76 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( /*! \since 4.1 \class QSortFilterProxyModel - \brief The QSortFilterProxyModel class provides support for sorting and filtering data passed - between another model and a view. + \brief The QSortFilterProxyModel class provides support for sorting and + filtering data passed between another model and a view. \ingroup model-view - QSortFilterProxyModel can be used for sorting items, filtering - out items, or both. The model transforms the structure of a - source model by mapping the model indexes it supplies to new - indexes, corresponding to different locations, for views to use. - This approach allows a given source model to be restructured as - far as views are concerned without requiring any transformations - on the underlying data, and without duplicating the data in + QSortFilterProxyModel can be used for sorting items, filtering out items, + or both. The model transforms the structure of a source model by mapping + the model indexes it supplies to new indexes, corresponding to different + locations, for views to use. This approach allows a given source model to + be restructured as far as views are concerned without requiring any + transformations on the underlying data, and without duplicating the data in memory. - Let's assume that we want to sort and filter the items provided - by a custom model. The code to set up the model and the view, \e - without sorting and filtering, would look like this: + Let's assume that we want to sort and filter the items provided by a custom + model. The code to set up the model and the view, \e without sorting and + filtering, would look like this: \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 1 - To add sorting and filtering support to \c MyItemModel, we need - to create a QSortFilterProxyModel, call setSourceModel() with the - \c MyItemModel as argument, and install the QSortFilterProxyModel - on the view: + To add sorting and filtering support to \c MyItemModel, we need to create + a QSortFilterProxyModel, call setSourceModel() with the \c MyItemModel as + argument, and install the QSortFilterProxyModel on the view: \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 0 \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 2 - At this point, neither sorting nor filtering is enabled; the - original data is displayed in the view. Any changes made through - the QSortFilterProxyModel are applied to the original model. + At this point, neither sorting nor filtering is enabled; the original data + is displayed in the view. Any changes made through the + QSortFilterProxyModel are applied to the original model. - The QSortFilterProxyModel acts as a wrapper for the original - model. If you need to convert source \l{QModelIndex}es to - sorted/filtered model indexes or vice versa, use mapToSource(), - mapFromSource(), mapSelectionToSource(), and - mapSelectionFromSource(). + The QSortFilterProxyModel acts as a wrapper for the original model. If you + need to convert source \l{QModelIndex}es to sorted/filtered model indexes + or vice versa, use mapToSource(), mapFromSource(), mapSelectionToSource(), + and mapSelectionFromSource(). - \note By default, the model does not dynamically re-sort and re-filter - data whenever the original model changes. This behavior can be - changed by setting the \l{QSortFilterProxyModel::dynamicSortFilter} - {dynamicSortFilter} property. + \note By default, the model does not dynamically re-sort and re-filter data + whenever the original model changes. This behavior can be changed by + setting the \l{QSortFilterProxyModel::dynamicSortFilter}{dynamicSortFilter} + property. - The \l{itemviews/basicsortfiltermodel}{Basic Sort/Filter Model} - and \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} - examples illustrate how to use QSortFilterProxyModel to perform - basic sorting and filtering and how to subclass it to implement - custom behavior. + The \l{itemviews/basicsortfiltermodel}{Basic Sort/Filter Model} and + \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} examples + illustrate how to use QSortFilterProxyModel to perform basic sorting and + filtering and how to subclass it to implement custom behavior. \section1 Sorting QTableView and QTreeView have a - \l{QTreeView::sortingEnabled}{sortingEnabled} property that - controls whether the user can sort the view by clicking the - view's horizontal header. For example: + \l{QTreeView::sortingEnabled}{sortingEnabled} property that controls + whether the user can sort the view by clicking the view's horizontal + header. For example: \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 3 - When this feature is on (the default is off), clicking on a - header section sorts the items according to that column. By - clicking repeatedly, the user can alternate between ascending and - descending order. + When this feature is on (the default is off), clicking on a header section + sorts the items according to that column. By clicking repeatedly, the user + can alternate between ascending and descending order. \image qsortfilterproxymodel-sorting.png A sorted QTreeView - Behind the scene, the view calls the sort() virtual function on - the model to reorder the data in the model. To make your data - sortable, you can either implement sort() in your model, or you - use a QSortFilterProxyModel to wrap your model -- - QSortFilterProxyModel provides a generic sort() reimplementation - that operates on the sortRole() (Qt::DisplayRole by default) of - the items and that understands several data types, including \c - int, QString, and QDateTime. For hierarchical models, sorting is - applied recursively to all child items. String comparisons are - case sensitive by default; this can be changed by setting the - \l{QSortFilterProxyModel::}{sortCaseSensitivity} property. + Behind the scene, the view calls the sort() virtual function on the model + to reorder the data in the model. To make your data sortable, you can + either implement sort() in your model, or use a QSortFilterProxyModel to + wrap your model -- QSortFilterProxyModel provides a generic sort() + reimplementation that operates on the sortRole() (Qt::DisplayRole by + default) of the items and that understands several data types, including + \c int, QString, and QDateTime. For hierarchical models, sorting is applied + recursively to all child items. String comparisons are case sensitive by + default; this can be changed by setting the \l{QSortFilterProxyModel::} + {sortCaseSensitivity} property. Custom sorting behavior is achieved by subclassing QSortFilterProxyModel and reimplementing lessThan(), which is @@ -1365,43 +1359,42 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} example.) - An alternative approach to sorting is to disable sorting on the - view and to impose a certain order to the user. This is done by - explicitly calling sort() with the desired column and order as - arguments on the QSortFilterProxyModel (or on the original model - if it implements sort()). For example: + An alternative approach to sorting is to disable sorting on the view and to + impose a certain order to the user. This is done by explicitly calling + sort() with the desired column and order as arguments on the + QSortFilterProxyModel (or on the original model if it implements sort()). + For example: \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 4 - QSortFilterProxyModel can be sorted by column -1, in which case it - returns to the sort order of the underlying source model. + QSortFilterProxyModel can be sorted by column -1, in which case it returns + to the sort order of the underlying source model. \section1 Filtering - In addition to sorting, QSortFilterProxyModel can be used to hide - items that don't match a certain filter. The filter is specified - using a QRegExp object and is applied to the filterRole() - (Qt::DisplayRole by default) of each item, for a given column. - The QRegExp object can be used to match a regular expression, a - wildcard pattern, or a fixed string. For example: + In addition to sorting, QSortFilterProxyModel can be used to hide items + that do not match a certain filter. The filter is specified using a QRegExp + object and is applied to the filterRole() (Qt::DisplayRole by default) of + each item, for a given column. The QRegExp object can be used to match a + regular expression, a wildcard pattern, or a fixed string. For example: \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 5 - For hierarchical models, the filter is applied recursively to all - children. If a parent item doesn't match the filter, none of its - children will be shown. + For hierarchical models, the filter is applied recursively to all children. + If a parent item doesn't match the filter, none of its children will be + shown. - A common use case is to let the user specify the filter regexp, - wildcard pattern, or fixed string in a QLineEdit and to connect - the \l{QLineEdit::textChanged()}{textChanged()} signal to - setFilterRegExp(), setFilterWildcard(), or setFilterFixedString() - to reapply the filter. + A common use case is to let the user specify the filter regexp, wildcard + pattern, or fixed string in a QLineEdit and to connect the + \l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegExp(), + setFilterWildcard(), or setFilterFixedString() to reapply the filter. Custom filtering behavior can be achieved by reimplementing the filterAcceptsRow() and filterAcceptsColumn() functions. For - example, the following implementation ignores the - \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} - property and performs filtering on columns 0, 1, and 2: + example (from the \l{itemviews/customsortfiltermodel} + {Custom Sort/Filter Model} example), the following implementation ignores + the \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} property + and performs filtering on columns 0, 1, and 2: \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3 @@ -1411,24 +1404,24 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( If you are working with large amounts of filtering and have to invoke invalidateFilter() repeatedly, using reset() may be more efficient, - depending on the implementation of your model. However, note that reset() - returns the proxy model to its original state, losing selection - information, and will cause the proxy model to be repopulated. + depending on the implementation of your model. However, reset() returns the + proxy model to its original state, losing selection information, and will + cause the proxy model to be repopulated. \section1 Subclassing - \bold{Note:} Some general guidelines for subclassing models are - available in the \l{Model Subclassing Reference}. - Since QAbstractProxyModel and its subclasses are derived from - QAbstractItemModel, much of the same advice about subclassing normal - models also applies to proxy models. In addition, it is worth noting - that many of the default implementations of functions in this class - are written so that they call the equivalent functions in the relevant - source model. This simple proxying mechanism may need to be overridden - for source models with more complex behavior; for example, if the - source model provides a custom hasChildren() implementation, you - should also provide one in the proxy model. + QAbstractItemModel, much of the same advice about subclassing normal models + also applies to proxy models. In addition, it is worth noting that many of + the default implementations of functions in this class are written so that + they call the equivalent functions in the relevant source model. This + simple proxying mechanism may need to be overridden for source models with + more complex behavior; for example, if the source model provides a custom + hasChildren() implementation, you should also provide one in the proxy + model. + + \note Some general guidelines for subclassing models are available in the + \l{Model Subclassing Reference}. \sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming}, {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example} -- cgit v0.12 From b31244b59396abea08254cb649eb1f59b2f8ed55 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 17 Aug 2009 16:12:55 +0200 Subject: Doc - mentioned that if no QRegExp is set, or an empty string is set, everything in the source model will be accepted. Task: 251308 Reviewed-By: Olivier Goffart --- src/gui/itemviews/qsortfilterproxymodel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index aef59b5..d173efe 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1984,9 +1984,11 @@ Qt::SortOrder QSortFilterProxyModel::sortOrder() const \brief the QRegExp used to filter the contents of the source model Setting this property overwrites the current - \l{QSortFilterProxyModel::filterCaseSensitivity} - {filterCaseSensitivity}. By default, the QRegExp is an empty - string matching all contents. + \l{QSortFilterProxyModel::filterCaseSensitivity}{filterCaseSensitivity}. + By default, the QRegExp is an empty string matching all contents. + + If no QRegExp or an empty string is set, everything in the source model + will be accepted. \sa filterCaseSensitivity, setFilterWildcard(), setFilterFixedString() */ -- cgit v0.12 From ac9f56b31dacc35dd2007caee69a9cf521ed8410 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 17 Aug 2009 16:12:12 +0200 Subject: Add support for the orientation of tiff images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The orientation tag was ignored for tiff images. The tag is now used to rotate the image before providing it to the user. The orientation of indexed an mono images is done completely manually. The orientation of other type is done in conjunction to the mirroring already performed by libtiff. Task-number: 258526 Reviewed-by: Samuel Rødal --- src/plugins/imageformats/tiff/qtiffhandler.cpp | 107 ++++++++++++++++++++- .../tiff_oriented/indexed_orientation_1.tiff | Bin 0 -> 7740 bytes .../tiff_oriented/indexed_orientation_2.tiff | Bin 0 -> 9570 bytes .../tiff_oriented/indexed_orientation_3.tiff | Bin 0 -> 11392 bytes .../tiff_oriented/indexed_orientation_4.tiff | Bin 0 -> 11392 bytes .../tiff_oriented/indexed_orientation_5.tiff | Bin 0 -> 11392 bytes .../tiff_oriented/indexed_orientation_6.tiff | Bin 0 -> 11392 bytes .../tiff_oriented/indexed_orientation_7.tiff | Bin 0 -> 11392 bytes .../tiff_oriented/indexed_orientation_8.tiff | Bin 0 -> 11392 bytes .../images/tiff_oriented/mono_orientation_1.tiff | Bin 0 -> 2382 bytes .../images/tiff_oriented/mono_orientation_2.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_3.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_4.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_5.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_6.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_7.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/mono_orientation_8.tiff | Bin 0 -> 1608 bytes .../images/tiff_oriented/original_indexed.tiff | Bin 0 -> 5922 bytes .../images/tiff_oriented/original_mono.tiff | Bin 0 -> 786 bytes .../images/tiff_oriented/original_rgb.tiff | Bin 0 -> 12608 bytes .../images/tiff_oriented/rgb_orientation_1.tiff | Bin 0 -> 15560 bytes .../images/tiff_oriented/rgb_orientation_2.tiff | Bin 0 -> 17972 bytes .../images/tiff_oriented/rgb_orientation_3.tiff | Bin 0 -> 17324 bytes .../images/tiff_oriented/rgb_orientation_4.tiff | Bin 0 -> 17324 bytes .../images/tiff_oriented/rgb_orientation_5.tiff | Bin 0 -> 17648 bytes .../images/tiff_oriented/rgb_orientation_6.tiff | Bin 0 -> 17324 bytes .../images/tiff_oriented/rgb_orientation_7.tiff | Bin 0 -> 17324 bytes .../images/tiff_oriented/rgb_orientation_8.tiff | Bin 0 -> 17324 bytes tests/auto/qimagereader/tst_qimagereader.cpp | 45 +++++++++ 29 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_1.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_2.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_3.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_4.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_5.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_6.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_7.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_8.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_1.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_2.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_3.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_4.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_5.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_6.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_7.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/mono_orientation_8.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/original_indexed.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/original_mono.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/original_rgb.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_1.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_2.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_3.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_4.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_5.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_6.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_7.tiff create mode 100644 tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_8.tiff diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index ec8a483..59edaf4 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -98,6 +98,43 @@ void qtiffUnmapProc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) { } +// for 32 bits images +inline void rotate_right_mirror_horizontal(QImage *const image)// rotate right->mirrored horizontal +{ + const int height = image->height(); + const int width = image->width(); + QImage generated(/* width = */ height, /* height = */ width, image->format()); + const uint32 *originalPixel = reinterpret_cast(image->bits()); + uint32 *const generatedPixels = reinterpret_cast(generated.bits()); + for (int row=0; row < height; ++row) { + for (int col=0; col < width; ++col) { + int idx = col * height + row; + generatedPixels[idx] = *originalPixel; + ++originalPixel; + } + } + *image = generated; +} + +inline void rotate_right_mirror_vertical(QImage *const image) // rotate right->mirrored vertical +{ + const int height = image->height(); + const int width = image->width(); + QImage generated(/* width = */ height, /* height = */ width, image->format()); + const int lastCol = width - 1; + const int lastRow = height - 1; + const uint32 *pixel = reinterpret_cast(image->bits()); + uint32 *const generatedBits = reinterpret_cast(generated.bits()); + for (int row=0; row < height; ++row) { + for (int col=0; col < width; ++col) { + int idx = (lastCol - col) * height + (lastRow - row); + generatedBits[idx] = *pixel; + ++pixel; + } + } + *image = generated; +} + QTiffHandler::QTiffHandler() : QImageIOHandler() { compression = NoCompression; @@ -223,7 +260,8 @@ bool QTiffHandler::read(QImage *image) if (image->size() != QSize(width, height) || image->format() != QImage::Format_ARGB32) *image = QImage(width, height, QImage::Format_ARGB32); if (!image->isNull()) { - if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast(image->bits()), ORIENTATION_TOPLEFT, 0)) { + const int stopOnError = 1; + if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast(image->bits()), ORIENTATION_TOPLEFT, stopOnError)) { for (uint32 y=0; yscanLine(y), width); } else { @@ -262,6 +300,73 @@ bool QTiffHandler::read(QImage *image) } } + // rotate the image if the orientation is defined in the file + uint16 orientationTag; + if (TIFFGetField(tiff, TIFFTAG_ORIENTATION, &orientationTag)) { + if (image->format() == QImage::Format_ARGB32) { + // TIFFReadRGBAImageOriented() flip the image but does not rotate them + switch (orientationTag) { + case 5: + rotate_right_mirror_horizontal(image); + break; + case 6: + rotate_right_mirror_vertical(image); + break; + case 7: + rotate_right_mirror_horizontal(image); + break; + case 8: + rotate_right_mirror_vertical(image); + break; + } + } else { + switch (orientationTag) { + case 1: // default orientation + break; + case 2: // mirror horizontal + *image = image->mirrored(true, false); + break; + case 3: // mirror both + *image = image->mirrored(true, true); + break; + case 4: // mirror vertical + *image = image->mirrored(false, true); + break; + case 5: // rotate right mirror horizontal + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + *image = image->mirrored(true, false); + break; + } + case 6: // rotate right + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + break; + } + case 7: // rotate right, mirror vertical + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + *image = image->mirrored(false, true); + break; + } + case 8: // rotate left + { + QMatrix transformation; + transformation.rotate(270); + *image = image->transformed(transformation); + break; + } + } + } + } + + TIFFClose(tiff); return true; } diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_1.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_1.tiff new file mode 100644 index 0000000..3fcb8a9 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_1.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_2.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_2.tiff new file mode 100644 index 0000000..6f3e9d5 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_2.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_3.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_3.tiff new file mode 100644 index 0000000..aab9cf2 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_3.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_4.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_4.tiff new file mode 100644 index 0000000..aad96ff Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_4.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_5.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_5.tiff new file mode 100644 index 0000000..05d23dc Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_5.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_6.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_6.tiff new file mode 100644 index 0000000..9ffe7fc Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_6.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_7.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_7.tiff new file mode 100644 index 0000000..eeeb019 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_7.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_8.tiff b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_8.tiff new file mode 100644 index 0000000..87cf2fd Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/indexed_orientation_8.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_1.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_1.tiff new file mode 100644 index 0000000..3b589b2 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_1.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_2.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_2.tiff new file mode 100644 index 0000000..9a66223 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_2.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_3.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_3.tiff new file mode 100644 index 0000000..eed2423 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_3.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_4.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_4.tiff new file mode 100644 index 0000000..055480e Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_4.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_5.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_5.tiff new file mode 100644 index 0000000..b4d0974 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_5.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_6.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_6.tiff new file mode 100644 index 0000000..3b1e02a Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_6.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_7.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_7.tiff new file mode 100644 index 0000000..b752c74 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_7.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_8.tiff b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_8.tiff new file mode 100644 index 0000000..e228d05 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/mono_orientation_8.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/original_indexed.tiff b/tests/auto/qimagereader/images/tiff_oriented/original_indexed.tiff new file mode 100644 index 0000000..7507e52 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/original_indexed.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/original_mono.tiff b/tests/auto/qimagereader/images/tiff_oriented/original_mono.tiff new file mode 100644 index 0000000..8ff9db8 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/original_mono.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/original_rgb.tiff b/tests/auto/qimagereader/images/tiff_oriented/original_rgb.tiff new file mode 100644 index 0000000..321ea3e Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/original_rgb.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_1.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_1.tiff new file mode 100644 index 0000000..2756a82 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_1.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_2.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_2.tiff new file mode 100644 index 0000000..ae9af09 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_2.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_3.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_3.tiff new file mode 100644 index 0000000..a2f4325 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_3.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_4.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_4.tiff new file mode 100644 index 0000000..f35bfc4 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_4.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_5.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_5.tiff new file mode 100644 index 0000000..70e5478 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_5.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_6.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_6.tiff new file mode 100644 index 0000000..b2635fe Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_6.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_7.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_7.tiff new file mode 100644 index 0000000..1fb0cd9 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_7.tiff differ diff --git a/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_8.tiff b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_8.tiff new file mode 100644 index 0000000..666b1b4 Binary files /dev/null and b/tests/auto/qimagereader/images/tiff_oriented/rgb_orientation_8.tiff differ diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index dad771b..ba3d83e 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -149,6 +149,9 @@ private slots: void tiffCompression_data(); void tiffCompression(); void tiffEndianness(); + + void tiffOrientation_data(); + void tiffOrientation(); #endif void autoDetectImageFormat(); @@ -1308,6 +1311,48 @@ void tst_QImageReader::tiffEndianness() QCOMPARE(littleEndian, bigEndian); } +void tst_QImageReader::tiffOrientation_data() +{ + QTest::addColumn("expected"); + QTest::addColumn("oriented"); + QTest::newRow("Indexed TIFF, orientation1") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_1.tiff"; + QTest::newRow("Indexed TIFF, orientation2") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_2.tiff"; + QTest::newRow("Indexed TIFF, orientation3") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_3.tiff"; + QTest::newRow("Indexed TIFF, orientation4") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_4.tiff"; + QTest::newRow("Indexed TIFF, orientation5") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_5.tiff"; + QTest::newRow("Indexed TIFF, orientation6") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_6.tiff"; + QTest::newRow("Indexed TIFF, orientation7") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_7.tiff"; + QTest::newRow("Indexed TIFF, orientation8") << "tiff_oriented/original_indexed.tiff" << "tiff_oriented/indexed_orientation_8.tiff"; + + QTest::newRow("Mono TIFF, orientation1") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_1.tiff"; + QTest::newRow("Mono TIFF, orientation2") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_2.tiff"; + QTest::newRow("Mono TIFF, orientation3") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_3.tiff"; + QTest::newRow("Mono TIFF, orientation4") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_4.tiff"; + QTest::newRow("Mono TIFF, orientation5") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_5.tiff"; + QTest::newRow("Mono TIFF, orientation6") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_6.tiff"; + QTest::newRow("Mono TIFF, orientation7") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_7.tiff"; + QTest::newRow("Mono TIFF, orientation8") << "tiff_oriented/original_mono.tiff" << "tiff_oriented/mono_orientation_8.tiff"; + + QTest::newRow("RGB TIFF, orientation1") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_1.tiff"; + QTest::newRow("RGB TIFF, orientation2") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_2.tiff"; + QTest::newRow("RGB TIFF, orientation3") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_3.tiff"; + QTest::newRow("RGB TIFF, orientation4") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_4.tiff"; + QTest::newRow("RGB TIFF, orientation5") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_5.tiff"; + QTest::newRow("RGB TIFF, orientation6") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_6.tiff"; + QTest::newRow("RGB TIFF, orientation7") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_7.tiff"; + QTest::newRow("RGB TIFF, orientation8") << "tiff_oriented/original_rgb.tiff" << "tiff_oriented/rgb_orientation_8.tiff"; +} + +void tst_QImageReader::tiffOrientation() +{ + QFETCH(QString, expected); + QFETCH(QString, oriented); + + QImage expectedImage(prefix + expected); + QImage orientedImage(prefix + oriented); + QCOMPARE(expectedImage, orientedImage); +} + #endif void tst_QImageReader::dotsPerMeter_data() -- cgit v0.12