summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-12-23 23:00:13 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-12-23 23:00:13 (GMT)
commit8ff74f9008b8846624a9da299beb23949af7c249 (patch)
tree18be776689556fadb56a81fd4910b40ff76c9496 /src
parent8565d6d123227615312a791ae7acc5b252db264a (diff)
parent08f963176b24c4c20a96717ddb2241ba1410b0a1 (diff)
downloadQt-8ff74f9008b8846624a9da299beb23949af7c249.zip
Qt-8ff74f9008b8846624a9da299beb23949af7c249.tar.gz
Qt-8ff74f9008b8846624a9da299beb23949af7c249.tar.bz2
Merge branch '4.7-upstream' into 4.7-water
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp13
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp6
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp11
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp2
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp1
-rw-r--r--src/gui/dialogs/qdialog.cpp24
-rw-r--r--src/gui/painting/qdrawhelper.cpp35
-rw-r--r--src/gui/styles/qcommonstyle.cpp5
-rw-r--r--src/gui/styles/qwindowsstyle.cpp5
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp33
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp116
-rw-r--r--src/sql/drivers/psql/qsql_psql.h6
16 files changed, 226 insertions, 68 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index f1d92c5..f5da491 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -671,10 +671,12 @@ void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction)
void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
+ Q_Q(QDeclarativeFlickable);
if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10))
stealMouse = true; // If we've been flicked then steal the click.
else
stealMouse = false;
+ q->setKeepMouseGrab(stealMouse);
pressed = true;
timeline.clear();
hData.velocity = 0;
@@ -769,6 +771,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
}
stealMouse = stealX || stealY;
+ if (stealMouse)
+ q->setKeepMouseGrab(true);
if (!lastPos.isNull()) {
qreal elapsed = qreal(QDeclarativeItemPrivate::restart(lastPosTime)) / 1000.;
@@ -848,8 +852,6 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeFlickable);
if (d->interactive) {
d->handleMouseMoveEvent(event);
- if (d->stealMouse)
- setKeepMouseGrab(true);
event->accept();
} else {
QDeclarativeItem::mouseMoveEvent(event);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 4a6a9dc..7ddf6a2 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1131,6 +1131,13 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
+ GridView attaches a number of properties to the root item of the delegate, for example
+ \c {GridView.isCurrentItem}. In the following example, the root delegate item can access
+ this attached property directly as \c GridView.isCurrentItem, while the child
+ \c contactInfo object must refer to this property as \c wrapper.GridView.isCurrentItem.
+
+ \snippet doc/src/snippets/declarative/gridview/gridview.qml isCurrentItem
+
\note Views do not set the \l{Item::}{clip} property automatically.
If the view is not clipped by another item or the screen, it will be necessary
to set this property to true in order to clip the items that are partially or
@@ -1167,6 +1174,8 @@ QDeclarativeGridView::~QDeclarativeGridView()
This attached property holds the view that manages this delegate instance.
It is attached to each instance of the delegate.
+
+ \snippet doc/src/snippets/declarative/gridview/gridview.qml isCurrentItem
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 2a7f508..702442b 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -643,7 +643,8 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
int i = visibleItems.count() - 1;
while (i > 0 && visibleItems.at(i)->index == -1)
--i;
- modelIndex = visibleItems.at(i)->index + 1;
+ if (visibleItems.at(i)->index != -1)
+ modelIndex = visibleItems.at(i)->index + 1;
}
bool changed = false;
@@ -1415,6 +1416,13 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
+ ListView attaches a number of properties to the root item of the delegate, for example
+ \c {ListView.isCurrentItem}. In the following example, the root delegate item can access
+ this attached property directly as \c ListView.isCurrentItem, while the child
+ \c contactInfo object must refer to this property as \c wrapper.ListView.isCurrentItem.
+
+ \snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
+
\note Views do not enable \e clip automatically. If the view
is not clipped by another item or the screen, it will be necessary
to set \e {clip: true} in order to have the out of view items clipped
@@ -2804,7 +2812,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
--i;
- if (d->visibleItems.at(i)->index + 1 == modelIndex
+ if (i == 0 && d->visibleItems.first()->index == -1) {
+ // there are no visible items except items marked for removal
+ index = d->visibleItems.count();
+ } else if (d->visibleItems.at(i)->index + 1 == modelIndex
&& d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) {
// Special case of appending an item to the model.
index = d->visibleItems.count();
@@ -2836,7 +2847,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
// index can be the next item past the end of the visible items list (i.e. appended)
int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
- : d->visibleItems.at(index-1)->endPosition()+d->spacing+1;
+ : d->visibleItems.last()->endPosition()+d->spacing+1;
int initialPos = pos;
int diff = 0;
QList<FxListItem*> added;
@@ -2988,14 +2999,16 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
}
// update visibleIndex
+ bool haveVisibleIndex = false;
for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
if ((*it)->index != -1) {
d->visibleIndex = (*it)->index;
+ haveVisibleIndex = true;
break;
}
}
- if (removedVisible && d->visibleItems.isEmpty()) {
+ if (removedVisible && !haveVisibleIndex) {
d->timeline.clear();
if (d->itemCount == 0) {
d->visibleIndex = 0;
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 87ea214..e3987d0 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -393,6 +393,13 @@ void QDeclarativePathViewPrivate::regenerate()
Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
+ PathView attaches a number of properties to the root item of the delegate, for example
+ \c {PathView.isCurrentItem}. In the following example, the root delegate item can access
+ this attached property directly as \c PathView.isCurrentItem, while the child
+ \c nameText object must refer to this property as \c wrapper.PathView.isCurrentItem.
+
+ \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
+
\bold Note that views do not enable \e clip automatically. If the view
is not clipped by another item or the screen, it will be necessary
to set \e {clip: true} in order to have the out of view items clipped
@@ -452,6 +459,8 @@ QDeclarativePathView::~QDeclarativePathView()
It is attached to each instance of the delegate.
This property may be used to adjust the appearance of the current item.
+
+ \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
*/
/*!
@@ -1133,8 +1142,10 @@ void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
QPointF pathPoint = pointNear(event->pos(), &newPc);
if (!stealMouse) {
QPointF delta = pathPoint - startPoint;
- if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance())
+ if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) {
stealMouse = true;
+ startPc = newPc;
+ }
}
if (stealMouse) {
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 4f5213a..bf9263b 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -773,6 +773,8 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model)
QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
d->m_metaDataCacheable = true;
+ if (d->m_abstractItemModel->canFetchMore(d->m_root))
+ d->m_abstractItemModel->fetchMore(d->m_root);
return;
}
if ((d->m_visualItemModel = qvariant_cast<QDeclarativeVisualDataModel *>(model))) {
@@ -870,6 +872,8 @@ void QDeclarativeVisualDataModel::setRootIndex(const QVariant &root)
if (d->m_root != modelIndex) {
int oldCount = d->modelCount();
d->m_root = modelIndex;
+ if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(modelIndex))
+ d->m_abstractItemModel->fetchMore(modelIndex);
int newCount = d->modelCount();
if (d->m_delegate && oldCount)
emit itemsRemoved(0, oldCount);
@@ -1094,6 +1098,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
d->m_delegateValidated = true;
}
}
+ if (d->modelCount()-1 == index && d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root))
+ d->m_abstractItemModel->fetchMore(d->m_root);
return item;
}
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 77fc925..ecb3bc5 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -699,17 +699,6 @@ QObject *QDeclarativeComponent::create(QDeclarativeContext *context)
return rv;
}
-QObject *QDeclarativeComponentPrivate::create(QDeclarativeContextData *context,
- const QBitField &bindings)
-{
- if (!context)
- context = QDeclarativeContextData::get(engine->rootContext());
-
- QObject *rv = beginCreate(context, bindings);
- completeCreate();
- return rv;
-}
-
/*!
This method provides more advanced control over component instance creation.
In general, programmers should use QDeclarativeComponent::create() to create a
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
index 7b30bad..daf1dcb 100644
--- a/src/declarative/qml/qdeclarativecomponent_p.h
+++ b/src/declarative/qml/qdeclarativecomponent_p.h
@@ -81,7 +81,6 @@ class Q_AUTOTEST_EXPORT QDeclarativeComponentPrivate : public QObjectPrivate, pu
public:
QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), engine(0), creationContext(0) {}
- QObject *create(QDeclarativeContextData *, const QBitField &);
QObject *beginCreate(QDeclarativeContextData *, const QBitField &);
void completeCreate();
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 4b78020..9dc214f 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -458,7 +458,7 @@ QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngin
{
d->m_lock.lock();
connect(d, SIGNAL(stopThread()), this, SLOT(quit()), Qt::DirectConnection);
- start(QThread::LowPriority);
+ start(QThread::IdlePriority);
d->m_wait.wait(&d->m_lock);
d->moveToThread(this);
d->m_lock.unlock();
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 49a12b1..e97cd67 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -924,6 +924,7 @@ void QDeclarativeXmlListModel::reload()
} else {
d->notifyQueryStarted(true);
QNetworkRequest req(d->src);
+ req.setRawHeader("Accept", "application/xml");
d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index 16ea045..bcf952c 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -899,9 +899,21 @@ bool QDialog::symbianAdjustedPosition()
{
#if defined(Q_WS_S60)
QPoint p;
- const bool doS60Positioning = !(isFullScreen()||isMaximized());
- if (doS60Positioning) {
- QPoint oldPos = pos();
+ QPoint oldPos = pos();
+ if (isFullScreen()) {
+ p.setX(0);
+ p.setY(0);
+ } else if (isMaximized()) {
+ TRect statusPaneRect = TRect();
+ if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
+ AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane, statusPaneRect);
+ } else {
+ AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, statusPaneRect);
+ }
+
+ p.setX(0);
+ p.setY(statusPaneRect.Height());
+ } else {
// naive way to deduce screen orientation
if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
int cbaHeight;
@@ -937,10 +949,10 @@ bool QDialog::symbianAdjustedPosition()
p.setX(qMax(0,S60->screenWidthInPixels - width()));
}
}
- if (oldPos != p || p.y() < 0)
- move(p);
}
- return doS60Positioning;
+ if (oldPos != p || p.y() < 0)
+ move(p);
+ return true;
#else
// TODO - check positioning requirement for Symbian, non-s60
return false;
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index fdb686d..4fd90ed 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -851,10 +851,9 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
}
}
-#if defined(QT_ALWAYS_HAVE_SSE2)
if (blendType != BlendTransformedBilinearTiled &&
(format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)) {
-
+#if defined(QT_ALWAYS_HAVE_SSE2)
const __m128i disty_ = _mm_set1_epi16(disty);
const __m128i idisty_ = _mm_set1_epi16(idisty);
const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
@@ -884,8 +883,38 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
rRB = _mm_srli_epi16(rRB, 8);
_mm_storeu_si128((__m128i*)(&intermediate_buffer[0][f]), rRB);
}
- }
+#elif defined(QT_ALWAYS_HAVE_NEON)
+ const int16x8_t disty_ = vdupq_n_s16(disty);
+ const int16x8_t idisty_ = vdupq_n_s16(idisty);
+ const int16x8_t colorMask = vdupq_n_s16(0x00ff);
+
+ lim -= 3;
+ for (; f < lim; x += 4, f += 4) {
+ // Load 4 pixels from s1, and split the alpha-green and red-blue component
+ int16x8_t top = vld1q_s16((int16_t*)((const uint *)(s1)+x));
+ int16x8_t topAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(top), 8));
+ int16x8_t topRB = vandq_s16(top, colorMask);
+ // Multiplies each colour component by idisty
+ topAG = vmulq_s16(topAG, idisty_);
+ topRB = vmulq_s16(topRB, idisty_);
+
+ // Same for the s2 vector
+ int16x8_t bottom = vld1q_s16((int16_t*)((const uint *)(s2)+x));
+ int16x8_t bottomAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(bottom), 8));
+ int16x8_t bottomRB = vandq_s16(bottom, colorMask);
+ bottomAG = vmulq_s16(bottomAG, disty_);
+ bottomRB = vmulq_s16(bottomRB, disty_);
+
+ // Add the values, and shift to only keep 8 significant bits per colors
+ int16x8_t rAG = vaddq_s16(topAG, bottomAG);
+ rAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(rAG), 8));
+ vst1q_s16((int16_t*)(&intermediate_buffer[1][f]), rAG);
+ int16x8_t rRB = vaddq_s16(topRB, bottomRB);
+ rRB = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(rRB), 8));
+ vst1q_s16((int16_t*)(&intermediate_buffer[0][f]), rRB);
+ }
#endif
+ }
for (; f < count; f++) { // Same as above but without sse2
if (blendType == BlendTransformedBilinearTiled) {
if (x >= image_width) x -= image_width;
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 039a6da..1d7c838 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1403,8 +1403,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
break;
case CE_ProgressBarGroove:
- qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
- &opt->palette.brush(QPalette::Window));
+ if (opt->rect.isValid())
+ qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
+ &opt->palette.brush(QPalette::Window));
break;
case CE_ProgressBarLabel:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 720dd6d..32a6d8d 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -130,6 +130,7 @@ QWindowsStylePrivate::QWindowsStylePrivate()
pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
}
#endif
+ startTime.start();
}
// Returns true if the toplevel parent of \a widget has seen the Alt-key
@@ -2396,8 +2397,10 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
#ifndef QT_NO_PROGRESSBAR
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
-
QRect rect = pb->rect;
+ if (!rect.isValid())
+ return;
+
bool vertical = false;
bool inverted = false;
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
index 9c71004..7b05bc5 100644
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
@@ -190,6 +190,12 @@ QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) c
return rv;
}
+/*!
+ \qmlproperty int FolderListModel::count
+
+ Returns the number of items in the current folder that match the
+ filter criteria.
+*/
int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
@@ -225,6 +231,11 @@ void QDeclarativeFolderListModel::setFolder(const QUrl &folder)
}
}
+/*!
+ \qmlproperty url FolderListModel::parentFolder
+
+ Returns the URL of the parent of of the current \l folder.
+*/
QUrl QDeclarativeFolderListModel::parentFolder() const
{
QString localFile = d->folder.toLocalFile();
@@ -286,6 +297,21 @@ void QDeclarativeFolderListModel::componentComplete()
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
}
+/*!
+ \qmlproperty enumeration FolderListModel::sortField
+
+ The \a sortField property contains field to use for sorting. sortField
+ may be one of:
+ \list
+ \o Unsorted - no sorting is applied. The order is system default.
+ \o Name - sort by filename
+ \o Time - sort by time modified
+ \o Size - sort by file size
+ \o Type - sort by file type (extension)
+ \endlist
+
+ \sa sortReversed
+*/
QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const
{
return d->sortField;
@@ -299,6 +325,13 @@ void QDeclarativeFolderListModel::setSortField(SortField field)
}
}
+/*!
+ \qmlproperty bool FolderListModel::sortReversed
+
+ If set to true, reverses the sort order. The default is false.
+
+ \sa sortField
+*/
bool QDeclarativeFolderListModel::sortReversed() const
{
return d->sortReversed;
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 2a4e595..bf9685f 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -54,7 +54,6 @@
#include <qstringlist.h>
#include <qmutex.h>
-
#include <libpq-fe.h>
#include <pg_config.h>
@@ -619,6 +618,50 @@ static void setDatestyle(PGconn* connection)
PQclear(result);
}
+static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
+{
+ switch (vMaj) {
+ case 6:
+ return QPSQLDriver::Version6;
+ case 7:
+ {
+ switch (vMin) {
+ case 1:
+ return QPSQLDriver::Version71;
+ case 3:
+ return QPSQLDriver::Version73;
+ case 4:
+ return QPSQLDriver::Version74;
+ default:
+ return QPSQLDriver::Version7;
+ }
+ break;
+ }
+ case 8:
+ {
+ switch (vMin) {
+ case 1:
+ return QPSQLDriver::Version81;
+ case 2:
+ return QPSQLDriver::Version82;
+ case 3:
+ return QPSQLDriver::Version83;
+ case 4:
+ return QPSQLDriver::Version84;
+ default:
+ return QPSQLDriver::Version8;
+ }
+ break;
+ }
+ case 9:
+ return QPSQLDriver::Version9;
+ break;
+ default:
+ break;
+ }
+ return QPSQLDriver::VersionUnknown;
+}
+
static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
@@ -626,50 +669,44 @@ static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
QString val = QString::fromAscii(PQgetvalue(result, 0, 0));
+
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
rx.setMinimal(true); // enforce non-greedy RegExp
+
if (rx.indexIn(val) != -1) {
int vMaj = rx.cap(1).toInt();
int vMin = rx.cap(2).toInt();
-
- switch (vMaj) {
- case 7:
- switch (vMin) {
- case 0:
- serverVersion = QPSQLDriver::Version7;
- break;
- case 1:
- case 2:
- serverVersion = QPSQLDriver::Version71;
- break;
- default:
- serverVersion = QPSQLDriver::Version73;
- break;
- }
- break;
- case 8:
- switch (vMin) {
- case 0:
- serverVersion = QPSQLDriver::Version8;
- break;
- case 1:
- serverVersion = QPSQLDriver::Version81;
- break;
- case 2:
- default:
- serverVersion = QPSQLDriver::Version82;
- break;
- }
- break;
- default:
- break;
+ serverVersion = qMakePSQLVersion(vMaj, vMin);
+#ifdef PG_MAJORVERSION
+ if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1) {
+ vMaj = rx.cap(1).toInt();
+ vMin = rx.cap(2).toInt();
+ }
+ QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin);
+
+ if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) {
+ //Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
+ //but bytea format is set to hex by default in PSQL 9 and above. So need to force the
+ //server use the old escape mode when connects to the new server with old client library.
+ result = PQexec(connection, "SET bytea_output=escape; ");
+ status = PQresultStatus(result);
+ } else if (serverVersion == QPSQLDriver::VersionUnknown) {
+ serverVersion = clientVersion;
+ if (serverVersion != QPSQLDriver::VersionUnknown)
+ qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
}
+#endif
}
}
PQclear(result);
- if (serverVersion < QPSQLDriver::Version71)
+ //keep the old behavior unchanged
+ if (serverVersion == QPSQLDriver::VersionUnknown)
+ serverVersion = QPSQLDriver::Version6;
+
+ if (serverVersion < QPSQLDriver::Version71) {
qWarning("This version of PostgreSQL is not supported and may not work.");
+ }
return serverVersion;
}
@@ -852,7 +889,10 @@ bool QPSQLDriver::commitTransaction()
// This hack can dissapear once there is an API to query this sort of information.
if (d->pro == QPSQLDriver::Version8 ||
d->pro == QPSQLDriver::Version81 ||
- d->pro == QPSQLDriver::Version82) {
+ d->pro == QPSQLDriver::Version82 ||
+ d->pro == QPSQLDriver::Version83 ||
+ d->pro == QPSQLDriver::Version84 ||
+ d->pro == QPSQLDriver::Version9) {
transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0;
}
@@ -963,6 +1003,9 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
case QPSQLDriver::Version8:
case QPSQLDriver::Version81:
case QPSQLDriver::Version82:
+ case QPSQLDriver::Version83:
+ case QPSQLDriver::Version84:
+ case QPSQLDriver::Version9:
stmt = QLatin1String("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_class.relname "
"FROM pg_attribute, pg_class "
@@ -1046,6 +1089,9 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const
case QPSQLDriver::Version8:
case QPSQLDriver::Version81:
case QPSQLDriver::Version82:
+ case QPSQLDriver::Version83:
+ case QPSQLDriver::Version84:
+ case QPSQLDriver::Version9:
stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
"pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
"pg_attrdef.adsrc "
diff --git a/src/sql/drivers/psql/qsql_psql.h b/src/sql/drivers/psql/qsql_psql.h
index 22871ff..107da87 100644
--- a/src/sql/drivers/psql/qsql_psql.h
+++ b/src/sql/drivers/psql/qsql_psql.h
@@ -97,6 +97,7 @@ class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver
Q_OBJECT
public:
enum Protocol {
+ VersionUnknown = -1,
Version6 = 6,
Version7 = 7,
Version71 = 8,
@@ -104,7 +105,10 @@ public:
Version74 = 10,
Version8 = 11,
Version81 = 12,
- Version82 = 13
+ Version82 = 13,
+ Version83 = 14,
+ Version84 = 15,
+ Version9 = 16,
};
explicit QPSQLDriver(QObject *parent=0);