From f330818d5e9dda6af7407f08935e1d66c9b04d12 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 11:27:45 -0700 Subject: Make QWS compile again 025a7395153c3708e2964cfd93957532b19ae04f broke the build on QWS because of duplicate symbols. Reviewed-by: Donald --- src/gui/painting/qpaintdevice_qws.cpp | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/gui/painting/qpaintdevice_qws.cpp b/src/gui/painting/qpaintdevice_qws.cpp index 9a6a3d3..b161cb8 100644 --- a/src/gui/painting/qpaintdevice_qws.cpp +++ b/src/gui/painting/qpaintdevice_qws.cpp @@ -48,39 +48,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); -} - - -int QPaintDevice::metric(PaintDeviceMetric m) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - if (m == PdmDpiX) { - return 72; - } else if (m == PdmDpiY) { - return 72; - } else if (m == PdmNumColors) { - // FIXME: does this need to be a real value? - return 256; - } else { - qDebug("Unrecognised metric %d!",m); - return 0; - } -} - QWSDisplay *QPaintDevice::qwsDisplay() { return qt_fbdpy; -- cgit v0.12 From 843d2eed0ac10589a01d40bfdf88cb44c6a00b17 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 17 Aug 2009 20:41:38 +0200 Subject: Rename qlistdata.cpp (back) to qlist.cpp. In the old days, some compilers would implicitly include the *.cpp file if the *.h file contained templates. That's why we had qlistdata.cpp not qlist.cpp. Those compilers are no longer supported. Rev-by: Harald Fernengel --- qmake/qmake.pri | 2 +- src/corelib/tools/qlist.cpp | 1752 ++++++++++++++++++++++++++ src/corelib/tools/qlistdata.cpp | 1752 -------------------------- src/corelib/tools/tools.pri | 2 +- src/tools/bootstrap/bootstrap.pro | 2 +- tools/configure/configure.pro | 2 +- tools/qtestlib/wince/cetest/bootstrapped.pri | 2 +- 7 files changed, 1757 insertions(+), 1757 deletions(-) create mode 100644 src/corelib/tools/qlist.cpp delete mode 100644 src/corelib/tools/qlistdata.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 1f9243b..67fc8f2 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -46,7 +46,7 @@ bootstrap { #Qt code qnumeric.cpp \ qhash.cpp \ qiodevice.cpp \ - qlistdata.cpp \ + qlist.cpp \ qlinkedlist.cpp \ qlocale.cpp \ qmalloc.cpp \ diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp new file mode 100644 index 0000000..0993681 --- /dev/null +++ b/src/corelib/tools/qlist.cpp @@ -0,0 +1,1752 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 "qlist.h" +#include "qtools_p.h" +#include + +QT_BEGIN_NAMESPACE + +/* + QList as an array-list combines the easy-of-use of a random + access interface with fast list operations and the low memory + management overhead of an array. Accessing elements by index, + appending, prepending, and removing elements from both the front + and the back all happen in constant time O(1). Inserting or + removing elements at random index positions \ai happens in linear + time, or more precisly in O(min{i,n-i}) <= O(n/2), with n being + the number of elements in the list. +*/ + +QListData::Data QListData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, true, { 0 } }; + +static int grow(int size) +{ + // dear compiler: don't optimize me out. + volatile int x = qAllocMore(size * sizeof(void *), QListData::DataHeaderSize) / sizeof(void *); + return x; +} + +#if QT_VERSION >= 0x050000 +# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x" +#endif +QListData::Data *QListData::detach() +{ + Data *x = static_cast(qMalloc(DataHeaderSize + d->alloc * sizeof(void *))); + if (!x) + qFatal("QList: Out of memory"); + + ::memcpy(x, d, DataHeaderSize + d->alloc * sizeof(void *)); + x->alloc = d->alloc; + x->ref = 1; + x->sharable = true; + if (!x->alloc) + x->begin = x->end = 0; + + qSwap(d, x); + if (!x->ref.deref()) + return x; + return 0; +} + +// Returns the old (shared) data, it is up to the caller to deref() and free() +QListData::Data *QListData::detach2() +{ + Data *x = d; + d = static_cast(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); + if (!d) + qFatal("QList: Out of memory"); + + ::memcpy(d, x, DataHeaderSize + x->alloc * sizeof(void *)); + d->alloc = x->alloc; + d->ref = 1; + d->sharable = true; + if (!d->alloc) + d->begin = d->end = 0; + + return x; +} + +void QListData::realloc(int alloc) +{ + Q_ASSERT(d->ref == 1); + Data *x = static_cast(qRealloc(d, DataHeaderSize + alloc * sizeof(void *))); + if (!x) + qFatal("QList: Out of memory"); + + d = x; + d->alloc = alloc; + if (!alloc) + d->begin = d->end = 0; +} + +void **QListData::append() +{ + Q_ASSERT(d->ref == 1); + if (d->end == d->alloc) { + int n = d->end - d->begin; + if (d->begin > 2 * d->alloc / 3) { + ::memcpy(d->array + n, d->array + d->begin, n * sizeof(void *)); + d->begin = n; + d->end = n * 2; + } else { + realloc(grow(d->alloc + 1)); + } + } + return d->array + d->end++; +} + +void **QListData::append(const QListData& l) +{ + Q_ASSERT(d->ref == 1); + int e = d->end; + int n = l.d->end - l.d->begin; + if (n) { + if (e + n > d->alloc) + realloc(grow(e + l.d->end - l.d->begin)); + ::memcpy(d->array + d->end, l.d->array + l.d->begin, n * sizeof(void*)); + d->end += n; + } + return d->array + e; +} + +void **QListData::prepend() +{ + Q_ASSERT(d->ref == 1); + if (d->begin == 0) { + if (d->end >= d->alloc / 3) + realloc(grow(d->alloc + 1)); + + if (d->end < d->alloc / 3) + d->begin = d->alloc - 2 * d->end; + else + d->begin = d->alloc - d->end; + + ::memmove(d->array + d->begin, d->array, d->end * sizeof(void *)); + d->end += d->begin; + } + return d->array + --d->begin; +} + +void **QListData::insert(int i) +{ + Q_ASSERT(d->ref == 1); + if (i <= 0) + return prepend(); + if (i >= d->end - d->begin) + return append(); + + bool leftward = false; + int size = d->end - d->begin; + + if (d->begin == 0) { + if (d->end == d->alloc) { + // If the array is full, we expand it and move some items rightward + realloc(grow(d->alloc + 1)); + } else { + // If there is free space at the end of the array, we move some items rightward + } + } else { + if (d->end == d->alloc) { + // If there is free space at the beginning of the array, we move some items leftward + leftward = true; + } else { + // If there is free space at both ends, we move as few items as possible + leftward = (i < size - i); + } + } + + if (leftward) { + --d->begin; + ::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *)); + } else { + ::memmove(d->array + d->begin + i + 1, d->array + d->begin + i, + (size - i) * sizeof(void *)); + ++d->end; + } + return d->array + d->begin + i; +} + +void QListData::remove(int i) +{ + Q_ASSERT(d->ref == 1); + i += d->begin; + if (i - d->begin < d->end - i) { + if (int offset = i - d->begin) + ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); + d->begin++; + } else { + if (int offset = d->end - i - 1) + ::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *)); + d->end--; + } +} + +void QListData::remove(int i, int n) +{ + Q_ASSERT(d->ref == 1); + i += d->begin; + int middle = i + n/2; + if (middle - d->begin < d->end - middle) { + ::memmove(d->array + d->begin + n, d->array + d->begin, + (i - d->begin) * sizeof(void*)); + d->begin += n; + } else { + ::memmove(d->array + i, d->array + i + n, + (d->end - i - n) * sizeof(void*)); + d->end -= n; + } +} + +void QListData::move(int from, int to) +{ + Q_ASSERT(d->ref == 1); + if (from == to) + return; + + from += d->begin; + to += d->begin; + void *t = d->array[from]; + + if (from < to) { + if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) { + ::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *)); + } else { + // optimization + if (int offset = from - d->begin) + ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); + if (int offset = d->end - (to + 1)) + ::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *)); + ++d->begin; + ++d->end; + ++to; + } + } else { + if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) { + ::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *)); + } else { + // optimization + if (int offset = to - d->begin) + ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *)); + if (int offset = d->end - (from + 1)) + ::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *)); + --d->begin; + --d->end; + --to; + } + } + d->array[to] = t; +} + +void **QListData::erase(void **xi) +{ + Q_ASSERT(d->ref == 1); + int i = xi - (d->array + d->begin); + remove(i); + return d->array + d->begin + i; +} + +/*! \class QList + \brief The QList class is a template class that provides lists. + + \ingroup tools + \ingroup shared + + \reentrant + + QList\ is one of Qt's generic \l{container classes}. It + stores a list of values and provides fast index-based access as + well as fast insertions and removals. + + QList\, QLinkedList\, and QVector\ provide similar + functionality. Here's an overview: + + \list + \i For most purposes, QList is the right class to use. Its + index-based API is more convenient than QLinkedList's + iterator-based API, and it is usually faster than + QVector because of the way it stores its items in + memory. It also expands to less code in your executable. + \i If you need a real linked list, with guarantees of \l{constant + time} insertions in the middle of the list and iterators to + items rather than indexes, use QLinkedList. + \i If you want the items to occupy adjacent memory positions, + use QVector. + \endlist + + + Internally, QList\ is represented as an array of pointers to + items of type T. If T is itself a pointer type or a basic type + that is no larger than a pointer, or if T is one of Qt's \l{shared + classes}, then QList\ stores the items directly in the pointer + array. For lists under a thousand items, this array representation + allows for very fast insertions in the middle, and it allows + index-based access. Furthermore, operations like prepend() and + append() are very fast, because QList preallocates memory at both + ends of its internal array. (See \l{Algorithmic Complexity} for + details.) Note, however, that for unshared list items that are + larger than a pointer, each append or insert of a new item + requires allocating the new item on the heap, and this per item + allocation might make QVector a better choice in cases that do + lots of appending or inserting, since QVector allocates memory for + its items in a single heap allocation. + + Note that the internal array only ever gets bigger over the life + of the list. It never shrinks. The internal array is deallocated + by the destructor and by the assignment operator, when one list + is assigned to another. + + Here's an example of a QList that stores integers and + a QList that stores QDate values: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0 + + Qt includes a QStringList class that inherits QList\ + and adds a few convenience functions, such as QStringList::join() + and QStringList::find(). (QString::split() creates QStringLists + from strings.) + + QList stores a list of items. The default constructor creates an + empty list. To insert items into the list, you can use + operator<<(): + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 1 + + QList provides these basic functions to add, move, and remove + items: insert(), replace(), removeAt(), move(), and swap(). In + addition, it provides the following convenience functions: + append(), prepend(), removeFirst(), and removeLast(). + + QList uses 0-based indexes, just like C++ arrays. To access the + item at a particular index position, you can use operator[](). On + non-const lists, operator[]() returns a reference to the item and + can be used on the left side of an assignment: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 2 + + Because QList is implemented as an array of pointers, this + operation is very fast (\l{constant time}). For read-only access, + an alternative syntax is to use at(): + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 3 + + at() can be faster than operator[](), because it never causes a + \l{deep copy} to occur. + + A common requirement is to remove an item from a list and do + something with it. For this, QList provides takeAt(), takeFirst(), + and takeLast(). Here's a loop that removes the items from a list + one at a time and calls \c delete on them: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 4 + + Inserting and removing items at either ends of the list is very + fast (\l{constant time} in most cases), because QList + preallocates extra space on both sides of its internal buffer to + allow for fast growth at both ends of the list. + + If you want to find all occurrences of a particular value in a + list, use indexOf() or lastIndexOf(). The former searches forward + starting from a given index position, the latter searches + backward. Both return the index of a matching item if they find + it; otherwise, they return -1. For example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 5 + + If you simply want to check whether a list contains a particular + value, use contains(). If you want to find out how many times a + particular value occurs in the list, use count(). If you want to + replace all occurrences of a particular value with another, use + replace(). + + QList's value type must be an \l{assignable data type}. This + covers most data types that are commonly used, but the compiler + won't let you, for example, store a QWidget as a value; instead, + store a QWidget *. A few functions have additional requirements; + for example, indexOf() and lastIndexOf() expect the value type to + support \c operator==(). These requirements are documented on a + per-function basis. + + Like the other container classes, QList provides \l{Java-style + iterators} (QListIterator and QMutableListIterator) and + \l{STL-style iterators} (QList::const_iterator and + QList::iterator). In practice, these are rarely used, because you + can use indexes into the QList. QList is implemented in such a way + that direct index-based access is just as fast as using iterators. + + QList does \e not support inserting, prepending, appending or + replacing with references to its own values. Doing so will cause + your application to abort with an error message. + + To make QList as efficient as possible, its member functions don't + validate their input before using it. Except for isEmpty(), member + functions always assume the list is \e not empty. Member functions + that take index values as parameters always assume their index + value parameters are in the valid range. This means QList member + functions can fail. If you define QT_NO_DEBUG when you compile, + failures will not be detected. If you \e don't define QT_NO_DEBUG, + failures will be detected using Q_ASSERT() or Q_ASSERT_X() with an + appropriate message. + + To avoid failures when your list can be empty, call isEmpty() + before calling other member functions. If you must pass an index + value that might not be in the valid range, check that it is less + than the value returned by size() but \e not less than 0. + + \sa QListIterator, QMutableListIterator, QLinkedList, QVector +*/ + +/*! + \fn QList QList::mid(int pos, int length) const + + Returns a list whose elements are copied from this list, + starting at position \a pos. If \a length is -1 (the default), all + elements from \a pos are copied; otherwise \a length elements (or + all remaining elements if there are less than \a length elements) + are copied. +*/ + +/*! \fn QList::QList() + + Constructs an empty list. +*/ + +/*! \fn QList::QList(const QList &other) + + Constructs a copy of \a other. + + This operation takes \l{constant time}, because QList is + \l{implicitly shared}. This makes returning a QList from a + function very fast. If a shared instance is modified, it will be + copied (copy-on-write), and that takes \l{linear time}. + + \sa operator=() +*/ + +/*! \fn QList::~QList() + + Destroys the list. References to the values in the list and all + iterators of this list become invalid. +*/ + +/*! \fn QList &QList::operator=(const QList &other) + + Assigns \a other to this list and returns a reference to this + list. +*/ + +/*! \fn bool QList::operator==(const QList &other) const + + Returns true if \a other is equal to this list; otherwise returns + false. + + Two lists are considered equal if they contain the same values in + the same order. + + This function requires the value type to have an implementation of + \c operator==(). + + \sa operator!=() +*/ + +/*! \fn bool QList::operator!=(const QList &other) const + + Returns true if \a other is not equal to this list; otherwise + returns false. + + Two lists are considered equal if they contain the same values in + the same order. + + This function requires the value type to have an implementation of + \c operator==(). + + \sa operator==() +*/ + +/*! + \fn int QList::size() const + + Returns the number of items in the list. + + \sa isEmpty(), count() +*/ + +/*! \fn void QList::detach() + + \internal +*/ + +/*! \fn bool QList::isDetached() const + + \internal +*/ + +/*! \fn void QList::setSharable(bool sharable) + + \internal +*/ + +/*! \fn bool QList::isEmpty() const + + Returns true if the list contains no items; otherwise returns + false. + + \sa size() +*/ + +/*! \fn void QList::clear() + + Removes all items from the list. + + \sa removeAll() +*/ + +/*! \fn const T &QList::at(int i) const + + Returns the item at index position \a i in the list. \a i must be + a valid index position in the list (i.e., 0 <= \a i < size()). + + This function is very fast (\l{constant time}). + + \sa value(), operator[]() +*/ + +/*! \fn T &QList::operator[](int i) + + Returns the item at index position \a i as a modifiable reference. + \a i must be a valid index position in the list (i.e., 0 <= \a i < + size()). + + This function is very fast (\l{constant time}). + + \sa at(), value() +*/ + +/*! \fn const T &QList::operator[](int i) const + + \overload + + Same as at(). +*/ + +/*! \fn void QList::append(const T &value) + + Inserts \a value at the end of the list. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 6 + + This is the same as list.insert(size(), \a value). + + This operation is typically very fast (\l{constant time}), + because QList preallocates extra space on both sides of its + internal buffer to allow for fast growth at both ends of the + list. + + \sa operator<<(), prepend(), insert() +*/ + +/*! \fn void QList::append(const QList &value) + + \overload + + \since 4.5 + + Appends the items of the \a value list to this list. + + \sa operator<<(), operator+=() +*/ + +/*! \fn void QList::prepend(const T &value) + + Inserts \a value at the beginning of the list. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 7 + + This is the same as list.insert(0, \a value). + + This operation is usually very fast (\l{constant time}), because + QList preallocates extra space on both sides of its internal + buffer to allow for fast growth at both ends of the list. + + \sa append(), insert() +*/ + +/*! \fn void QList::insert(int i, const T &value) + + Inserts \a value at index position \a i in the list. If \a i + is 0, the value is prepended to the list. If \a i is size(), the + value is appended to the list. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 8 + + \sa append(), prepend(), replace(), removeAt() +*/ + +/*! \fn QList::iterator QList::insert(iterator before, const T &value) + + \overload + + Inserts \a value in front of the item pointed to by the + iterator \a before. Returns an iterator pointing at the inserted + item. Note that the iterator passed to the function will be + invalid after the call; the returned iterator should be used + instead. +*/ + +/*! \fn void QList::replace(int i, const T &value) + + Replaces the item at index position \a i with \a value. \a i must + be a valid index position in the list (i.e., 0 <= \a i < size()). + + \sa operator[](), removeAt() +*/ + +/*! + \fn int QList::removeAll(const T &value) + + Removes all occurrences of \a value in the list and returns the + number of entries removed. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 9 + + This function requires the value type to have an implementation of + \c operator==(). + + \sa removeOne(), removeAt(), takeAt(), replace() +*/ + +/*! + \fn bool QList::removeOne(const T &value) + \since 4.4 + + Removes the first occurrence of \a value in the list and returns + true on success; otherwise returns false. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 10 + + This function requires the value type to have an implementation of + \c operator==(). + + \sa removeAll(), removeAt(), takeAt(), replace() +*/ + +/*! \fn void QList::removeAt(int i) + + Removes the item at index position \a i. \a i must be a valid + index position in the list (i.e., 0 <= \a i < size()). + + \sa takeAt(), removeFirst(), removeLast(), removeOne() +*/ + +/*! \fn T QList::takeAt(int i) + + Removes the item at index position \a i and returns it. \a i must + be a valid index position in the list (i.e., 0 <= \a i < size()). + + If you don't use the return value, removeAt() is more efficient. + + \sa removeAt(), takeFirst(), takeLast() +*/ + +/*! \fn T QList::takeFirst() + + Removes the first item in the list and returns it. This is the + same as takeAt(0). This function assumes the list is not empty. To + avoid failure, call isEmpty() before calling this function. + + This operation is very fast (\l{constant time}), because QList + preallocates extra space on both sides of its internal buffer to + allow for fast growth at both ends of the list. + + If you don't use the return value, removeFirst() is more + efficient. + + \sa takeLast(), takeAt(), removeFirst() +*/ + +/*! \fn T QList::takeLast() + + Removes the last item in the list and returns it. This is the + same as takeAt(size() - 1). This function assumes the list is + not empty. To avoid failure, call isEmpty() before calling this + function. + + This operation is very fast (\l{constant time}), because QList + preallocates extra space on both sides of its internal buffer to + allow for fast growth at both ends of the list. + + If you don't use the return value, removeLast() is more + efficient. + + \sa takeFirst(), takeAt(), removeLast() +*/ + +/*! \fn void QList::move(int from, int to) + + Moves the item at index position \a from to index position \a to. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 11 + + This is the same as insert(\a{to}, takeAt(\a{from})).This function + assumes that both \a from and \a to are at least 0 but less than + size(). To avoid failure, test that both \a from and \a to are at + least 0 and less than size(). + + \sa swap(), insert(), takeAt() +*/ + +/*! \fn void QList::swap(int i, int j) + + Exchange the item at index position \a i with the item at index + position \a j. This function assumes that both \a i and \a j are + at least 0 but less than size(). To avoid failure, test that both + \a i and \a j are at least 0 and less than size(). + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 12 + + \sa move() +*/ + +/*! \fn int QList::indexOf(const T &value, int from = 0) const + + Returns the index position of the first occurrence of \a value in + the list, searching forward from index position \a from. Returns + -1 if no item matched. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 13 + + This function requires the value type to have an implementation of + \c operator==(). + + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + + \sa lastIndexOf(), contains() +*/ + +/*! \fn int QList::lastIndexOf(const T &value, int from = -1) const + + Returns the index position of the last occurrence of \a value in + the list, searching backward from index position \a from. If \a + from is -1 (the default), the search starts at the last item. + Returns -1 if no item matched. + + Example: + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 14 + + This function requires the value type to have an implementation of + \c operator==(). + + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + + \sa indexOf() +*/ + +/*! \fn QBool QList::contains(const T &value) const + + Returns true if the list contains an occurrence of \a value; + otherwise returns false. + + This function requires the value type to have an implementation of + \c operator==(). + + \sa indexOf(), count() +*/ + +/*! \fn int QList::count(const T &value) const + + Returns the number of occurrences of \a value in the list. + + This function requires the value type to have an implementation of + \c operator==(). + + \sa contains(), indexOf() +*/ + +/*! \fn bool QList::startsWith(const T &value) const + \since 4.5 + + Returns true if this list is not empty and its first + item is equal to \a value; otherwise returns false. + + \sa isEmpty(), contains() +*/ + +/*! \fn bool QList::endsWith(const T &value) const + \since 4.5 + + Returns true if this list is not empty and its last + item is equal to \a value; otherwise returns false. + + \sa isEmpty(), contains() +*/ + +/*! \fn QList::iterator QList::begin() + + Returns an \l{STL-style iterator} pointing to the first item in + the list. + + \sa constBegin(), end() +*/ + +/*! \fn QList::const_iterator QList::begin() const + + \overload +*/ + +/*! \fn QList::const_iterator QList::constBegin() const + + Returns a const \l{STL-style iterator} pointing to the first item + in the list. + + \sa begin(), constEnd() +*/ + +/*! \fn QList::iterator QList::end() + + Returns an \l{STL-style iterator} pointing to the imaginary item + after the last item in the list. + + \sa begin(), constEnd() +*/ + +/*! \fn const_iterator QList::end() const + + \overload +*/ + +/*! \fn QList::const_iterator QList::constEnd() const + + Returns a const \l{STL-style iterator} pointing to the imaginary + item after the last item in the list. + + \sa constBegin(), end() +*/ + +/*! \fn QList::iterator QList::erase(iterator pos) + + Removes the item associated with the iterator \a pos from the + list, and returns an iterator to the next item in the list (which + may be end()). + + \sa insert(), removeAt() +*/ + +/*! \fn QList::iterator QList::erase(iterator begin, iterator end) + + \overload + + Removes all the items from \a begin up to (but not including) \a + end. Returns an iterator to the same item that \a end referred to + before the call. +*/ + +/*! \typedef QList::Iterator + + Qt-style synonym for QList::iterator. +*/ + +/*! \typedef QList::ConstIterator + + Qt-style synonym for QList::const_iterator. +*/ + +/*! + \typedef QList::size_type + + Typedef for int. Provided for STL compatibility. +*/ + +/*! + \typedef QList::value_type + + Typedef for T. Provided for STL compatibility. +*/ + +/*! + \typedef QList::difference_type + + Typedef for ptrdiff_t. Provided for STL compatibility. +*/ + +/*! + \typedef QList::pointer + + Typedef for T *. Provided for STL compatibility. +*/ + +/*! + \typedef QList::const_pointer + + Typedef for const T *. Provided for STL compatibility. +*/ + +/*! + \typedef QList::reference + + Typedef for T &. Provided for STL compatibility. +*/ + +/*! + \typedef QList::const_reference + + Typedef for const T &. Provided for STL compatibility. +*/ + +/*! \fn int QList::count() const + + Returns the number of items in the list. This is effectively the + same as size(). +*/ + +/*! \fn int QList::length() const + \since 4.5 + + This function is identical to count(). + + \sa count() +*/ + +/*! \fn T& QList::first() + + Returns a reference to the first item in the list. The list must + not be empty. If the list can be empty, call isEmpty() before + calling this function. + + \sa last(), isEmpty() +*/ + +/*! \fn const T& QList::first() const + + \overload +*/ + +/*! \fn T& QList::last() + + Returns a reference to the last item in the list. The list must + not be empty. If the list can be empty, call isEmpty() before + calling this function. + + \sa first(), isEmpty() +*/ + +/*! \fn const T& QList::last() const + + \overload +*/ + +/*! \fn void QList::removeFirst() + + Removes the first item in the list. Calling this function is + equivalent to calling removeAt(0). The list must not be empty. If + the list can be empty, call isEmpty() before calling this + function. + + \sa removeAt(), takeFirst() +*/ + +/*! \fn void QList::removeLast() + + Removes the last item in the list. Calling this function is + equivalent to calling removeAt(size() - 1). The list must not be + empty. If the list can be empty, call isEmpty() before calling + this function. + + \sa removeAt(), takeLast() +*/ + +/*! \fn T QList::value(int i) const + + Returns the value at index position \a i in the list. + + If the index \a i is out of bounds, the function returns a + \l{default-constructed value}. If you are certain that the index + is going to be within bounds, you can use at() instead, which is + slightly faster. + + \sa at(), operator[]() +*/ + +/*! \fn T QList::value(int i, const T &defaultValue) const + + \overload + + If the index \a i is out of bounds, the function returns + \a defaultValue. +*/ + +/*! \fn void QList::push_back(const T &value) + + This function is provided for STL compatibility. It is equivalent + to \l{QList::append()}{append(\a value)}. +*/ + +/*! \fn void QList::push_front(const T &value) + + This function is provided for STL compatibility. It is equivalent + to \l{QList::prepend()}{prepend(\a value)}. +*/ + +/*! \fn T& QList::front() + + This function is provided for STL compatibility. It is equivalent + to first(). The list must not be empty. If the list can be empty, + call isEmpty() before calling this function. +*/ + +/*! \fn const T& QList::front() const + + \overload +*/ + +/*! \fn T& QList::back() + + This function is provided for STL compatibility. It is equivalent + to last(). The list must not be empty. If the list can be empty, + call isEmpty() before calling this function. +*/ + +/*! \fn const T& QList::back() const + + \overload +*/ + +/*! \fn void QList::pop_front() + + This function is provided for STL compatibility. It is equivalent + to removeFirst(). The list must not be empty. If the list can be + empty, call isEmpty() before calling this function. +*/ + +/*! \fn void QList::pop_back() + + This function is provided for STL compatibility. It is equivalent + to removeLast(). The list must not be empty. If the list can be + empty, call isEmpty() before calling this function. +*/ + +/*! \fn bool QList::empty() const + + This function is provided for STL compatibility. It is equivalent + to isEmpty() and returns true if the list is empty. +*/ + +/*! \fn QList &QList::operator+=(const QList &other) + + Appends the items of the \a other list to this list and returns a + reference to this list. + + \sa operator+(), append() +*/ + +/*! \fn void QList::operator+=(const T &value) + + \overload + + Appends \a value to the list. + + \sa append(), operator<<() +*/ + +/*! \fn QList QList::operator+(const QList &other) const + + Returns a list that contains all the items in this list followed + by all the items in the \a other list. + + \sa operator+=() +*/ + +/*! \fn QList &QList::operator<<(const QList &other) + + Appends the items of the \a other list to this list and returns a + reference to this list. + + \sa operator+=(), append() +*/ + +/*! \fn void QList::operator<<(const T &value) + + \overload + + Appends \a value to the list. +*/ + +/*! \class QList::iterator + \brief The QList::iterator class provides an STL-style non-const iterator for QList and QQueue. + + QList features both \l{STL-style iterators} and \l{Java-style + iterators}. The STL-style iterators are more low-level and more + cumbersome to use; on the other hand, they are slightly faster + and, for developers who already know STL, have the advantage of + familiarity. + + QList\::iterator allows you to iterate over a QList\ (or + QQueue\) and to modify the list item associated with the + iterator. If you want to iterate over a const QList, use + QList::const_iterator instead. It is generally good practice to + use QList::const_iterator on a non-const QList as well, unless + you need to change the QList through the iterator. Const + iterators are slightly faster, and can improve code readability. + + The default QList::iterator constructor creates an uninitialized + iterator. You must initialize it using a QList function like + QList::begin(), QList::end(), or QList::insert() before you can + start iterating. Here's a typical loop that prints all the items + stored in a list: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 15 + + Let's see a few examples of things we can do with a + QList::iterator that we cannot do with a QList::const_iterator. + Here's an example that increments every value stored in a + QList\ by 2: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 16 + + Most QList functions accept an integer index rather than an + iterator. For that reason, iterators are rarely useful in + connection with QList. One place where STL-style iterators do + make sense is as arguments to \l{generic algorithms}. + + For example, here's how to delete all the widgets stored in a + QList\: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 17 + + Multiple iterators can be used on the same list. However, be + aware that any non-const function call performed on the QList + will render all existing iterators undefined. If you need to keep + iterators over a long period of time, we recommend that you use + QLinkedList rather than QList. + + \sa QList::const_iterator, QMutableListIterator +*/ + +/*! \typedef QList::iterator::iterator_category + + A synonym for \e {std::random_access_iterator_tag} indicating + this iterator is a random access iterator. +*/ + +/*! \typedef QList::iterator::difference_type + + \internal +*/ + +/*! \typedef QList::iterator::value_type + + \internal +*/ + +/*! \typedef QList::iterator::pointer + + \internal +*/ + +/*! \typedef QList::iterator::reference + + \internal +*/ + +/*! \fn QList::iterator::iterator() + + Constructs an uninitialized iterator. + + Functions like operator*() and operator++() should not be called + on an uninitialized iterator. Use operator=() to assign a value + to it before using it. + + \sa QList::begin() QList::end() +*/ + +/*! \fn QList::iterator::iterator(Node *node) + + \internal +*/ + +/*! \fn QList::iterator::iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn T &QList::iterator::operator*() const + + Returns a modifiable reference to the current item. + + You can change the value of an item by using operator*() on the + left side of an assignment, for example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 18 + + \sa operator->() +*/ + +/*! \fn T *QList::iterator::operator->() const + + Returns a pointer to the current item. + + \sa operator*() +*/ + +/*! \fn T &QList::iterator::operator[](int j) const + + Returns a modifiable reference to the item at position *this + + \a{j}. + + This function is provided to make QList iterators behave like C++ + pointers. + + \sa operator+() +*/ + +/*! + \fn bool QList::iterator::operator==(const iterator &other) const + \fn bool QList::iterator::operator==(const const_iterator &other) const + + Returns true if \a other points to the same item as this + iterator; otherwise returns false. + + \sa operator!=() +*/ + +/*! + \fn bool QList::iterator::operator!=(const iterator &other) const + \fn bool QList::iterator::operator!=(const const_iterator &other) const + + Returns true if \a other points to a different item than this + iterator; otherwise returns false. + + \sa operator==() +*/ + +/*! + \fn bool QList::iterator::operator<(const iterator& other) const + \fn bool QList::iterator::operator<(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is less than + the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::iterator::operator<=(const iterator& other) const + \fn bool QList::iterator::operator<=(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is less than + or equal to the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::iterator::operator>(const iterator& other) const + \fn bool QList::iterator::operator>(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is greater + than the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::iterator::operator>=(const iterator& other) const + \fn bool QList::iterator::operator>=(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is greater + than or equal to the item pointed to by the \a other iterator. +*/ + +/*! \fn QList::iterator &QList::iterator::operator++() + + The prefix ++ operator (\c{++it}) advances the iterator to the + next item in the list and returns an iterator to the new current + item. + + Calling this function on QList::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn QList::iterator QList::iterator::operator++(int) + + \overload + + The postfix ++ operator (\c{it++}) advances the iterator to the + next item in the list and returns an iterator to the previously + current item. +*/ + +/*! \fn QList::iterator &QList::iterator::operator--() + + The prefix -- operator (\c{--it}) makes the preceding item + current and returns an iterator to the new current item. + + Calling this function on QList::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! \fn QList::iterator QList::iterator::operator--(int) + + \overload + + The postfix -- operator (\c{it--}) makes the preceding item + current and returns an iterator to the previously current item. +*/ + +/*! \fn QList::iterator &QList::iterator::operator+=(int j) + + Advances the iterator by \a j items. (If \a j is negative, the + iterator goes backward.) + + \sa operator-=(), operator+() +*/ + +/*! \fn QList::iterator &QList::iterator::operator-=(int j) + + Makes the iterator go back by \a j items. (If \a j is negative, + the iterator goes forward.) + + \sa operator+=(), operator-() +*/ + +/*! \fn QList::iterator QList::iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. (If \a j is negative, the iterator goes backward.) + + \sa operator-(), operator+=() +*/ + +/*! \fn QList::iterator QList::iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. (If \a j is negative, the iterator goes forward.) + + \sa operator+(), operator-=() +*/ + +/*! \fn int QList::iterator::operator-(iterator other) const + + Returns the number of items between the item pointed to by \a + other and the item pointed to by this iterator. +*/ + +/*! \class QList::const_iterator + \brief The QList::const_iterator class provides an STL-style const iterator for QList and QQueue. + + QList provides both \l{STL-style iterators} and \l{Java-style + iterators}. The STL-style iterators are more low-level and more + cumbersome to use; on the other hand, they are slightly faster + and, for developers who already know STL, have the advantage of + familiarity. + + QList\::const_iterator allows you to iterate over a + QList\ (or a QQueue\). If you want to modify the QList as + you iterate over it, use QList::iterator instead. It is generally + good practice to use QList::const_iterator on a non-const QList + as well, unless you need to change the QList through the + iterator. Const iterators are slightly faster, and can improve + code readability. + + The default QList::const_iterator constructor creates an + uninitialized iterator. You must initialize it using a QList + function like QList::constBegin(), QList::constEnd(), or + QList::insert() before you can start iterating. Here's a typical + loop that prints all the items stored in a list: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 19 + + Most QList functions accept an integer index rather than an + iterator. For that reason, iterators are rarely useful in + connection with QList. One place where STL-style iterators do + make sense is as arguments to \l{generic algorithms}. + + For example, here's how to delete all the widgets stored in a + QList\: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 20 + + Multiple iterators can be used on the same list. However, be + aware that any non-const function call performed on the QList + will render all existing iterators undefined. If you need to keep + iterators over a long period of time, we recommend that you use + QLinkedList rather than QList. + + \sa QList::iterator, QListIterator +*/ + +/*! \fn QList::const_iterator::const_iterator() + + Constructs an uninitialized iterator. + + Functions like operator*() and operator++() should not be called + on an uninitialized iterator. Use operator=() to assign a value + to it before using it. + + \sa QList::constBegin() QList::constEnd() +*/ + +/*! \typedef QList::const_iterator::iterator_category + + A synonym for \e {std::random_access_iterator_tag} indicating + this iterator is a random access iterator. +*/ + +/*! \typedef QList::const_iterator::difference_type + + \internal +*/ + +/*! \typedef QList::const_iterator::value_type + + \internal +*/ + +/*! \typedef QList::const_iterator::pointer + + \internal +*/ + +/*! \typedef QList::const_iterator::reference + + \internal +*/ + +/*! \fn QList::const_iterator::const_iterator(Node *node) + + \internal +*/ + +/*! \fn QList::const_iterator::const_iterator(const const_iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn QList::const_iterator::const_iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn const T &QList::const_iterator::operator*() const + + Returns the current item. + + \sa operator->() +*/ + +/*! \fn const T *QList::const_iterator::operator->() const + + Returns a pointer to the current item. + + \sa operator*() +*/ + +/*! \fn const T &QList::const_iterator::operator[](int j) const + + Returns the item at position *this + \a{j}. + + This function is provided to make QList iterators behave like C++ + pointers. + + \sa operator+() +*/ + +/*! \fn bool QList::const_iterator::operator==(const const_iterator &other) const + + Returns true if \a other points to the same item as this + iterator; otherwise returns false. + + \sa operator!=() +*/ + +/*! \fn bool QList::const_iterator::operator!=(const const_iterator &other) const + + Returns true if \a other points to a different item than this + iterator; otherwise returns false. + + \sa operator==() +*/ + +/*! + \fn bool QList::const_iterator::operator<(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is less than + the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::const_iterator::operator<=(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is less than + or equal to the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::const_iterator::operator>(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is greater + than the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool QList::const_iterator::operator>=(const const_iterator& other) const + + Returns true if the item pointed to by this iterator is greater + than or equal to the item pointed to by the \a other iterator. +*/ + +/*! \fn QList::const_iterator &QList::const_iterator::operator++() + + The prefix ++ operator (\c{++it}) advances the iterator to the + next item in the list and returns an iterator to the new current + item. + + Calling this function on QList::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn QList::const_iterator QList::const_iterator::operator++(int) + + \overload + + The postfix ++ operator (\c{it++}) advances the iterator to the + next item in the list and returns an iterator to the previously + current item. +*/ + +/*! \fn QList::const_iterator &QList::const_iterator::operator--() + + The prefix -- operator (\c{--it}) makes the preceding item + current and returns an iterator to the new current item. + + Calling this function on QList::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! \fn QList::const_iterator QList::const_iterator::operator--(int) + + \overload + + The postfix -- operator (\c{it--}) makes the preceding item + current and returns an iterator to the previously current item. +*/ + +/*! \fn QList::const_iterator &QList::const_iterator::operator+=(int j) + + Advances the iterator by \a j items. (If \a j is negative, the + iterator goes backward.) + + \sa operator-=(), operator+() +*/ + +/*! \fn QList::const_iterator &QList::const_iterator::operator-=(int j) + + Makes the iterator go back by \a j items. (If \a j is negative, + the iterator goes forward.) + + \sa operator+=(), operator-() +*/ + +/*! \fn QList::const_iterator QList::const_iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. (If \a j is negative, the iterator goes backward.) + + \sa operator-(), operator+=() +*/ + +/*! \fn QList::const_iterator QList::const_iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. (If \a j is negative, the iterator goes forward.) + + \sa operator+(), operator-=() +*/ + +/*! \fn int QList::const_iterator::operator-(const_iterator other) const + + Returns the number of items between the item pointed to by \a + other and the item pointed to by this iterator. +*/ + +/*! \fn QDataStream &operator<<(QDataStream &out, const QList &list) + \relates QList + + Writes the list \a list to stream \a out. + + This function requires the value type to implement \c + operator<<(). + + \sa \link datastreamformat.html Format of the QDataStream operators \endlink +*/ + +/*! \fn QDataStream &operator>>(QDataStream &in, QList &list) + \relates QList + + Reads a list from stream \a in into \a list. + + This function requires the value type to implement \c + operator>>(). + + \sa \link datastreamformat.html Format of the QDataStream operators \endlink +*/ + +/*! + \fn iterator QList::remove(iterator pos) + + Use erase() instead. +*/ + +/*! + \fn int QList::remove(const T &t) + + Use removeAll() instead. +*/ + +/*! + \fn int QList::findIndex(const T& t) const + + Use indexOf() instead. +*/ + +/*! + \fn iterator QList::find(const T& t) + + Use indexOf() instead. +*/ + +/*! + \fn const_iterator QList::find (const T& t) const + + Use indexOf() instead. +*/ + +/*! + \fn iterator QList::find(iterator from, const T& t) + + Use indexOf() instead. +*/ + +/*! + \fn const_iterator QList::find(const_iterator from, const T& t) const + + Use indexOf() instead. +*/ + +/*! \fn QList QList::fromVector(const QVector &vector) + + Returns a QList object with the data contained in \a vector. + + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 21 + + \sa fromSet(), toVector(), QVector::toList() +*/ + +/*! \fn QVector QList::toVector() const + + Returns a QVector object with the data contained in this QList. + + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 22 + + \sa toSet(), fromVector(), QVector::fromList() +*/ + +/*! \fn QList QList::fromSet(const QSet &set) + + Returns a QList object with the data contained in \a set. The + order of the elements in the QList is undefined. + + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 23 + + \sa fromVector(), toSet(), QSet::toList(), qSort() +*/ + +/*! \fn QSet QList::toSet() const + + Returns a QSet object with the data contained in this QList. + Since QSet doesn't allow duplicates, the resulting QSet might be + smaller than the original list was. + + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 24 + + \sa toVector(), fromSet(), QSet::fromList() +*/ + +/*! \fn QList QList::fromStdList(const std::list &list) + + Returns a QList object with the data contained in \a list. The + order of the elements in the QList is the same as in \a list. + + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 25 + + \sa toStdList(), QVector::fromStdVector() +*/ + +/*! \fn std::list QList::toStdList() const + + Returns a std::list object with the data contained in this QList. + Example: + + \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 26 + + \sa fromStdList(), QVector::toStdVector() +*/ + +QT_END_NAMESPACE diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp deleted file mode 100644 index 0993681..0000000 --- a/src/corelib/tools/qlistdata.cpp +++ /dev/null @@ -1,1752 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore 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 "qlist.h" -#include "qtools_p.h" -#include - -QT_BEGIN_NAMESPACE - -/* - QList as an array-list combines the easy-of-use of a random - access interface with fast list operations and the low memory - management overhead of an array. Accessing elements by index, - appending, prepending, and removing elements from both the front - and the back all happen in constant time O(1). Inserting or - removing elements at random index positions \ai happens in linear - time, or more precisly in O(min{i,n-i}) <= O(n/2), with n being - the number of elements in the list. -*/ - -QListData::Data QListData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, true, { 0 } }; - -static int grow(int size) -{ - // dear compiler: don't optimize me out. - volatile int x = qAllocMore(size * sizeof(void *), QListData::DataHeaderSize) / sizeof(void *); - return x; -} - -#if QT_VERSION >= 0x050000 -# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x" -#endif -QListData::Data *QListData::detach() -{ - Data *x = static_cast(qMalloc(DataHeaderSize + d->alloc * sizeof(void *))); - if (!x) - qFatal("QList: Out of memory"); - - ::memcpy(x, d, DataHeaderSize + d->alloc * sizeof(void *)); - x->alloc = d->alloc; - x->ref = 1; - x->sharable = true; - if (!x->alloc) - x->begin = x->end = 0; - - qSwap(d, x); - if (!x->ref.deref()) - return x; - return 0; -} - -// Returns the old (shared) data, it is up to the caller to deref() and free() -QListData::Data *QListData::detach2() -{ - Data *x = d; - d = static_cast(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); - if (!d) - qFatal("QList: Out of memory"); - - ::memcpy(d, x, DataHeaderSize + x->alloc * sizeof(void *)); - d->alloc = x->alloc; - d->ref = 1; - d->sharable = true; - if (!d->alloc) - d->begin = d->end = 0; - - return x; -} - -void QListData::realloc(int alloc) -{ - Q_ASSERT(d->ref == 1); - Data *x = static_cast(qRealloc(d, DataHeaderSize + alloc * sizeof(void *))); - if (!x) - qFatal("QList: Out of memory"); - - d = x; - d->alloc = alloc; - if (!alloc) - d->begin = d->end = 0; -} - -void **QListData::append() -{ - Q_ASSERT(d->ref == 1); - if (d->end == d->alloc) { - int n = d->end - d->begin; - if (d->begin > 2 * d->alloc / 3) { - ::memcpy(d->array + n, d->array + d->begin, n * sizeof(void *)); - d->begin = n; - d->end = n * 2; - } else { - realloc(grow(d->alloc + 1)); - } - } - return d->array + d->end++; -} - -void **QListData::append(const QListData& l) -{ - Q_ASSERT(d->ref == 1); - int e = d->end; - int n = l.d->end - l.d->begin; - if (n) { - if (e + n > d->alloc) - realloc(grow(e + l.d->end - l.d->begin)); - ::memcpy(d->array + d->end, l.d->array + l.d->begin, n * sizeof(void*)); - d->end += n; - } - return d->array + e; -} - -void **QListData::prepend() -{ - Q_ASSERT(d->ref == 1); - if (d->begin == 0) { - if (d->end >= d->alloc / 3) - realloc(grow(d->alloc + 1)); - - if (d->end < d->alloc / 3) - d->begin = d->alloc - 2 * d->end; - else - d->begin = d->alloc - d->end; - - ::memmove(d->array + d->begin, d->array, d->end * sizeof(void *)); - d->end += d->begin; - } - return d->array + --d->begin; -} - -void **QListData::insert(int i) -{ - Q_ASSERT(d->ref == 1); - if (i <= 0) - return prepend(); - if (i >= d->end - d->begin) - return append(); - - bool leftward = false; - int size = d->end - d->begin; - - if (d->begin == 0) { - if (d->end == d->alloc) { - // If the array is full, we expand it and move some items rightward - realloc(grow(d->alloc + 1)); - } else { - // If there is free space at the end of the array, we move some items rightward - } - } else { - if (d->end == d->alloc) { - // If there is free space at the beginning of the array, we move some items leftward - leftward = true; - } else { - // If there is free space at both ends, we move as few items as possible - leftward = (i < size - i); - } - } - - if (leftward) { - --d->begin; - ::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *)); - } else { - ::memmove(d->array + d->begin + i + 1, d->array + d->begin + i, - (size - i) * sizeof(void *)); - ++d->end; - } - return d->array + d->begin + i; -} - -void QListData::remove(int i) -{ - Q_ASSERT(d->ref == 1); - i += d->begin; - if (i - d->begin < d->end - i) { - if (int offset = i - d->begin) - ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); - d->begin++; - } else { - if (int offset = d->end - i - 1) - ::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *)); - d->end--; - } -} - -void QListData::remove(int i, int n) -{ - Q_ASSERT(d->ref == 1); - i += d->begin; - int middle = i + n/2; - if (middle - d->begin < d->end - middle) { - ::memmove(d->array + d->begin + n, d->array + d->begin, - (i - d->begin) * sizeof(void*)); - d->begin += n; - } else { - ::memmove(d->array + i, d->array + i + n, - (d->end - i - n) * sizeof(void*)); - d->end -= n; - } -} - -void QListData::move(int from, int to) -{ - Q_ASSERT(d->ref == 1); - if (from == to) - return; - - from += d->begin; - to += d->begin; - void *t = d->array[from]; - - if (from < to) { - if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) { - ::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *)); - } else { - // optimization - if (int offset = from - d->begin) - ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *)); - if (int offset = d->end - (to + 1)) - ::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *)); - ++d->begin; - ++d->end; - ++to; - } - } else { - if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) { - ::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *)); - } else { - // optimization - if (int offset = to - d->begin) - ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *)); - if (int offset = d->end - (from + 1)) - ::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *)); - --d->begin; - --d->end; - --to; - } - } - d->array[to] = t; -} - -void **QListData::erase(void **xi) -{ - Q_ASSERT(d->ref == 1); - int i = xi - (d->array + d->begin); - remove(i); - return d->array + d->begin + i; -} - -/*! \class QList - \brief The QList class is a template class that provides lists. - - \ingroup tools - \ingroup shared - - \reentrant - - QList\ is one of Qt's generic \l{container classes}. It - stores a list of values and provides fast index-based access as - well as fast insertions and removals. - - QList\, QLinkedList\, and QVector\ provide similar - functionality. Here's an overview: - - \list - \i For most purposes, QList is the right class to use. Its - index-based API is more convenient than QLinkedList's - iterator-based API, and it is usually faster than - QVector because of the way it stores its items in - memory. It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant - time} insertions in the middle of the list and iterators to - items rather than indexes, use QLinkedList. - \i If you want the items to occupy adjacent memory positions, - use QVector. - \endlist - - - Internally, QList\ is represented as an array of pointers to - items of type T. If T is itself a pointer type or a basic type - that is no larger than a pointer, or if T is one of Qt's \l{shared - classes}, then QList\ stores the items directly in the pointer - array. For lists under a thousand items, this array representation - allows for very fast insertions in the middle, and it allows - index-based access. Furthermore, operations like prepend() and - append() are very fast, because QList preallocates memory at both - ends of its internal array. (See \l{Algorithmic Complexity} for - details.) Note, however, that for unshared list items that are - larger than a pointer, each append or insert of a new item - requires allocating the new item on the heap, and this per item - allocation might make QVector a better choice in cases that do - lots of appending or inserting, since QVector allocates memory for - its items in a single heap allocation. - - Note that the internal array only ever gets bigger over the life - of the list. It never shrinks. The internal array is deallocated - by the destructor and by the assignment operator, when one list - is assigned to another. - - Here's an example of a QList that stores integers and - a QList that stores QDate values: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 0 - - Qt includes a QStringList class that inherits QList\ - and adds a few convenience functions, such as QStringList::join() - and QStringList::find(). (QString::split() creates QStringLists - from strings.) - - QList stores a list of items. The default constructor creates an - empty list. To insert items into the list, you can use - operator<<(): - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 1 - - QList provides these basic functions to add, move, and remove - items: insert(), replace(), removeAt(), move(), and swap(). In - addition, it provides the following convenience functions: - append(), prepend(), removeFirst(), and removeLast(). - - QList uses 0-based indexes, just like C++ arrays. To access the - item at a particular index position, you can use operator[](). On - non-const lists, operator[]() returns a reference to the item and - can be used on the left side of an assignment: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 2 - - Because QList is implemented as an array of pointers, this - operation is very fast (\l{constant time}). For read-only access, - an alternative syntax is to use at(): - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 3 - - at() can be faster than operator[](), because it never causes a - \l{deep copy} to occur. - - A common requirement is to remove an item from a list and do - something with it. For this, QList provides takeAt(), takeFirst(), - and takeLast(). Here's a loop that removes the items from a list - one at a time and calls \c delete on them: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 4 - - Inserting and removing items at either ends of the list is very - fast (\l{constant time} in most cases), because QList - preallocates extra space on both sides of its internal buffer to - allow for fast growth at both ends of the list. - - If you want to find all occurrences of a particular value in a - list, use indexOf() or lastIndexOf(). The former searches forward - starting from a given index position, the latter searches - backward. Both return the index of a matching item if they find - it; otherwise, they return -1. For example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 5 - - If you simply want to check whether a list contains a particular - value, use contains(). If you want to find out how many times a - particular value occurs in the list, use count(). If you want to - replace all occurrences of a particular value with another, use - replace(). - - QList's value type must be an \l{assignable data type}. This - covers most data types that are commonly used, but the compiler - won't let you, for example, store a QWidget as a value; instead, - store a QWidget *. A few functions have additional requirements; - for example, indexOf() and lastIndexOf() expect the value type to - support \c operator==(). These requirements are documented on a - per-function basis. - - Like the other container classes, QList provides \l{Java-style - iterators} (QListIterator and QMutableListIterator) and - \l{STL-style iterators} (QList::const_iterator and - QList::iterator). In practice, these are rarely used, because you - can use indexes into the QList. QList is implemented in such a way - that direct index-based access is just as fast as using iterators. - - QList does \e not support inserting, prepending, appending or - replacing with references to its own values. Doing so will cause - your application to abort with an error message. - - To make QList as efficient as possible, its member functions don't - validate their input before using it. Except for isEmpty(), member - functions always assume the list is \e not empty. Member functions - that take index values as parameters always assume their index - value parameters are in the valid range. This means QList member - functions can fail. If you define QT_NO_DEBUG when you compile, - failures will not be detected. If you \e don't define QT_NO_DEBUG, - failures will be detected using Q_ASSERT() or Q_ASSERT_X() with an - appropriate message. - - To avoid failures when your list can be empty, call isEmpty() - before calling other member functions. If you must pass an index - value that might not be in the valid range, check that it is less - than the value returned by size() but \e not less than 0. - - \sa QListIterator, QMutableListIterator, QLinkedList, QVector -*/ - -/*! - \fn QList QList::mid(int pos, int length) const - - Returns a list whose elements are copied from this list, - starting at position \a pos. If \a length is -1 (the default), all - elements from \a pos are copied; otherwise \a length elements (or - all remaining elements if there are less than \a length elements) - are copied. -*/ - -/*! \fn QList::QList() - - Constructs an empty list. -*/ - -/*! \fn QList::QList(const QList &other) - - Constructs a copy of \a other. - - This operation takes \l{constant time}, because QList is - \l{implicitly shared}. This makes returning a QList from a - function very fast. If a shared instance is modified, it will be - copied (copy-on-write), and that takes \l{linear time}. - - \sa operator=() -*/ - -/*! \fn QList::~QList() - - Destroys the list. References to the values in the list and all - iterators of this list become invalid. -*/ - -/*! \fn QList &QList::operator=(const QList &other) - - Assigns \a other to this list and returns a reference to this - list. -*/ - -/*! \fn bool QList::operator==(const QList &other) const - - Returns true if \a other is equal to this list; otherwise returns - false. - - Two lists are considered equal if they contain the same values in - the same order. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa operator!=() -*/ - -/*! \fn bool QList::operator!=(const QList &other) const - - Returns true if \a other is not equal to this list; otherwise - returns false. - - Two lists are considered equal if they contain the same values in - the same order. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa operator==() -*/ - -/*! - \fn int QList::size() const - - Returns the number of items in the list. - - \sa isEmpty(), count() -*/ - -/*! \fn void QList::detach() - - \internal -*/ - -/*! \fn bool QList::isDetached() const - - \internal -*/ - -/*! \fn void QList::setSharable(bool sharable) - - \internal -*/ - -/*! \fn bool QList::isEmpty() const - - Returns true if the list contains no items; otherwise returns - false. - - \sa size() -*/ - -/*! \fn void QList::clear() - - Removes all items from the list. - - \sa removeAll() -*/ - -/*! \fn const T &QList::at(int i) const - - Returns the item at index position \a i in the list. \a i must be - a valid index position in the list (i.e., 0 <= \a i < size()). - - This function is very fast (\l{constant time}). - - \sa value(), operator[]() -*/ - -/*! \fn T &QList::operator[](int i) - - Returns the item at index position \a i as a modifiable reference. - \a i must be a valid index position in the list (i.e., 0 <= \a i < - size()). - - This function is very fast (\l{constant time}). - - \sa at(), value() -*/ - -/*! \fn const T &QList::operator[](int i) const - - \overload - - Same as at(). -*/ - -/*! \fn void QList::append(const T &value) - - Inserts \a value at the end of the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 6 - - This is the same as list.insert(size(), \a value). - - This operation is typically very fast (\l{constant time}), - because QList preallocates extra space on both sides of its - internal buffer to allow for fast growth at both ends of the - list. - - \sa operator<<(), prepend(), insert() -*/ - -/*! \fn void QList::append(const QList &value) - - \overload - - \since 4.5 - - Appends the items of the \a value list to this list. - - \sa operator<<(), operator+=() -*/ - -/*! \fn void QList::prepend(const T &value) - - Inserts \a value at the beginning of the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 7 - - This is the same as list.insert(0, \a value). - - This operation is usually very fast (\l{constant time}), because - QList preallocates extra space on both sides of its internal - buffer to allow for fast growth at both ends of the list. - - \sa append(), insert() -*/ - -/*! \fn void QList::insert(int i, const T &value) - - Inserts \a value at index position \a i in the list. If \a i - is 0, the value is prepended to the list. If \a i is size(), the - value is appended to the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 8 - - \sa append(), prepend(), replace(), removeAt() -*/ - -/*! \fn QList::iterator QList::insert(iterator before, const T &value) - - \overload - - Inserts \a value in front of the item pointed to by the - iterator \a before. Returns an iterator pointing at the inserted - item. Note that the iterator passed to the function will be - invalid after the call; the returned iterator should be used - instead. -*/ - -/*! \fn void QList::replace(int i, const T &value) - - Replaces the item at index position \a i with \a value. \a i must - be a valid index position in the list (i.e., 0 <= \a i < size()). - - \sa operator[](), removeAt() -*/ - -/*! - \fn int QList::removeAll(const T &value) - - Removes all occurrences of \a value in the list and returns the - number of entries removed. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 9 - - This function requires the value type to have an implementation of - \c operator==(). - - \sa removeOne(), removeAt(), takeAt(), replace() -*/ - -/*! - \fn bool QList::removeOne(const T &value) - \since 4.4 - - Removes the first occurrence of \a value in the list and returns - true on success; otherwise returns false. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 10 - - This function requires the value type to have an implementation of - \c operator==(). - - \sa removeAll(), removeAt(), takeAt(), replace() -*/ - -/*! \fn void QList::removeAt(int i) - - Removes the item at index position \a i. \a i must be a valid - index position in the list (i.e., 0 <= \a i < size()). - - \sa takeAt(), removeFirst(), removeLast(), removeOne() -*/ - -/*! \fn T QList::takeAt(int i) - - Removes the item at index position \a i and returns it. \a i must - be a valid index position in the list (i.e., 0 <= \a i < size()). - - If you don't use the return value, removeAt() is more efficient. - - \sa removeAt(), takeFirst(), takeLast() -*/ - -/*! \fn T QList::takeFirst() - - Removes the first item in the list and returns it. This is the - same as takeAt(0). This function assumes the list is not empty. To - avoid failure, call isEmpty() before calling this function. - - This operation is very fast (\l{constant time}), because QList - preallocates extra space on both sides of its internal buffer to - allow for fast growth at both ends of the list. - - If you don't use the return value, removeFirst() is more - efficient. - - \sa takeLast(), takeAt(), removeFirst() -*/ - -/*! \fn T QList::takeLast() - - Removes the last item in the list and returns it. This is the - same as takeAt(size() - 1). This function assumes the list is - not empty. To avoid failure, call isEmpty() before calling this - function. - - This operation is very fast (\l{constant time}), because QList - preallocates extra space on both sides of its internal buffer to - allow for fast growth at both ends of the list. - - If you don't use the return value, removeLast() is more - efficient. - - \sa takeFirst(), takeAt(), removeLast() -*/ - -/*! \fn void QList::move(int from, int to) - - Moves the item at index position \a from to index position \a to. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 11 - - This is the same as insert(\a{to}, takeAt(\a{from})).This function - assumes that both \a from and \a to are at least 0 but less than - size(). To avoid failure, test that both \a from and \a to are at - least 0 and less than size(). - - \sa swap(), insert(), takeAt() -*/ - -/*! \fn void QList::swap(int i, int j) - - Exchange the item at index position \a i with the item at index - position \a j. This function assumes that both \a i and \a j are - at least 0 but less than size(). To avoid failure, test that both - \a i and \a j are at least 0 and less than size(). - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 12 - - \sa move() -*/ - -/*! \fn int QList::indexOf(const T &value, int from = 0) const - - Returns the index position of the first occurrence of \a value in - the list, searching forward from index position \a from. Returns - -1 if no item matched. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 13 - - This function requires the value type to have an implementation of - \c operator==(). - - Note that QList uses 0-based indexes, just like C++ arrays. Negative - indexes are not supported with the exception of the value mentioned - above. - - \sa lastIndexOf(), contains() -*/ - -/*! \fn int QList::lastIndexOf(const T &value, int from = -1) const - - Returns the index position of the last occurrence of \a value in - the list, searching backward from index position \a from. If \a - from is -1 (the default), the search starts at the last item. - Returns -1 if no item matched. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 14 - - This function requires the value type to have an implementation of - \c operator==(). - - Note that QList uses 0-based indexes, just like C++ arrays. Negative - indexes are not supported with the exception of the value mentioned - above. - - \sa indexOf() -*/ - -/*! \fn QBool QList::contains(const T &value) const - - Returns true if the list contains an occurrence of \a value; - otherwise returns false. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa indexOf(), count() -*/ - -/*! \fn int QList::count(const T &value) const - - Returns the number of occurrences of \a value in the list. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa contains(), indexOf() -*/ - -/*! \fn bool QList::startsWith(const T &value) const - \since 4.5 - - Returns true if this list is not empty and its first - item is equal to \a value; otherwise returns false. - - \sa isEmpty(), contains() -*/ - -/*! \fn bool QList::endsWith(const T &value) const - \since 4.5 - - Returns true if this list is not empty and its last - item is equal to \a value; otherwise returns false. - - \sa isEmpty(), contains() -*/ - -/*! \fn QList::iterator QList::begin() - - Returns an \l{STL-style iterator} pointing to the first item in - the list. - - \sa constBegin(), end() -*/ - -/*! \fn QList::const_iterator QList::begin() const - - \overload -*/ - -/*! \fn QList::const_iterator QList::constBegin() const - - Returns a const \l{STL-style iterator} pointing to the first item - in the list. - - \sa begin(), constEnd() -*/ - -/*! \fn QList::iterator QList::end() - - Returns an \l{STL-style iterator} pointing to the imaginary item - after the last item in the list. - - \sa begin(), constEnd() -*/ - -/*! \fn const_iterator QList::end() const - - \overload -*/ - -/*! \fn QList::const_iterator QList::constEnd() const - - Returns a const \l{STL-style iterator} pointing to the imaginary - item after the last item in the list. - - \sa constBegin(), end() -*/ - -/*! \fn QList::iterator QList::erase(iterator pos) - - Removes the item associated with the iterator \a pos from the - list, and returns an iterator to the next item in the list (which - may be end()). - - \sa insert(), removeAt() -*/ - -/*! \fn QList::iterator QList::erase(iterator begin, iterator end) - - \overload - - Removes all the items from \a begin up to (but not including) \a - end. Returns an iterator to the same item that \a end referred to - before the call. -*/ - -/*! \typedef QList::Iterator - - Qt-style synonym for QList::iterator. -*/ - -/*! \typedef QList::ConstIterator - - Qt-style synonym for QList::const_iterator. -*/ - -/*! - \typedef QList::size_type - - Typedef for int. Provided for STL compatibility. -*/ - -/*! - \typedef QList::value_type - - Typedef for T. Provided for STL compatibility. -*/ - -/*! - \typedef QList::difference_type - - Typedef for ptrdiff_t. Provided for STL compatibility. -*/ - -/*! - \typedef QList::pointer - - Typedef for T *. Provided for STL compatibility. -*/ - -/*! - \typedef QList::const_pointer - - Typedef for const T *. Provided for STL compatibility. -*/ - -/*! - \typedef QList::reference - - Typedef for T &. Provided for STL compatibility. -*/ - -/*! - \typedef QList::const_reference - - Typedef for const T &. Provided for STL compatibility. -*/ - -/*! \fn int QList::count() const - - Returns the number of items in the list. This is effectively the - same as size(). -*/ - -/*! \fn int QList::length() const - \since 4.5 - - This function is identical to count(). - - \sa count() -*/ - -/*! \fn T& QList::first() - - Returns a reference to the first item in the list. The list must - not be empty. If the list can be empty, call isEmpty() before - calling this function. - - \sa last(), isEmpty() -*/ - -/*! \fn const T& QList::first() const - - \overload -*/ - -/*! \fn T& QList::last() - - Returns a reference to the last item in the list. The list must - not be empty. If the list can be empty, call isEmpty() before - calling this function. - - \sa first(), isEmpty() -*/ - -/*! \fn const T& QList::last() const - - \overload -*/ - -/*! \fn void QList::removeFirst() - - Removes the first item in the list. Calling this function is - equivalent to calling removeAt(0). The list must not be empty. If - the list can be empty, call isEmpty() before calling this - function. - - \sa removeAt(), takeFirst() -*/ - -/*! \fn void QList::removeLast() - - Removes the last item in the list. Calling this function is - equivalent to calling removeAt(size() - 1). The list must not be - empty. If the list can be empty, call isEmpty() before calling - this function. - - \sa removeAt(), takeLast() -*/ - -/*! \fn T QList::value(int i) const - - Returns the value at index position \a i in the list. - - If the index \a i is out of bounds, the function returns a - \l{default-constructed value}. If you are certain that the index - is going to be within bounds, you can use at() instead, which is - slightly faster. - - \sa at(), operator[]() -*/ - -/*! \fn T QList::value(int i, const T &defaultValue) const - - \overload - - If the index \a i is out of bounds, the function returns - \a defaultValue. -*/ - -/*! \fn void QList::push_back(const T &value) - - This function is provided for STL compatibility. It is equivalent - to \l{QList::append()}{append(\a value)}. -*/ - -/*! \fn void QList::push_front(const T &value) - - This function is provided for STL compatibility. It is equivalent - to \l{QList::prepend()}{prepend(\a value)}. -*/ - -/*! \fn T& QList::front() - - This function is provided for STL compatibility. It is equivalent - to first(). The list must not be empty. If the list can be empty, - call isEmpty() before calling this function. -*/ - -/*! \fn const T& QList::front() const - - \overload -*/ - -/*! \fn T& QList::back() - - This function is provided for STL compatibility. It is equivalent - to last(). The list must not be empty. If the list can be empty, - call isEmpty() before calling this function. -*/ - -/*! \fn const T& QList::back() const - - \overload -*/ - -/*! \fn void QList::pop_front() - - This function is provided for STL compatibility. It is equivalent - to removeFirst(). The list must not be empty. If the list can be - empty, call isEmpty() before calling this function. -*/ - -/*! \fn void QList::pop_back() - - This function is provided for STL compatibility. It is equivalent - to removeLast(). The list must not be empty. If the list can be - empty, call isEmpty() before calling this function. -*/ - -/*! \fn bool QList::empty() const - - This function is provided for STL compatibility. It is equivalent - to isEmpty() and returns true if the list is empty. -*/ - -/*! \fn QList &QList::operator+=(const QList &other) - - Appends the items of the \a other list to this list and returns a - reference to this list. - - \sa operator+(), append() -*/ - -/*! \fn void QList::operator+=(const T &value) - - \overload - - Appends \a value to the list. - - \sa append(), operator<<() -*/ - -/*! \fn QList QList::operator+(const QList &other) const - - Returns a list that contains all the items in this list followed - by all the items in the \a other list. - - \sa operator+=() -*/ - -/*! \fn QList &QList::operator<<(const QList &other) - - Appends the items of the \a other list to this list and returns a - reference to this list. - - \sa operator+=(), append() -*/ - -/*! \fn void QList::operator<<(const T &value) - - \overload - - Appends \a value to the list. -*/ - -/*! \class QList::iterator - \brief The QList::iterator class provides an STL-style non-const iterator for QList and QQueue. - - QList features both \l{STL-style iterators} and \l{Java-style - iterators}. The STL-style iterators are more low-level and more - cumbersome to use; on the other hand, they are slightly faster - and, for developers who already know STL, have the advantage of - familiarity. - - QList\::iterator allows you to iterate over a QList\ (or - QQueue\) and to modify the list item associated with the - iterator. If you want to iterate over a const QList, use - QList::const_iterator instead. It is generally good practice to - use QList::const_iterator on a non-const QList as well, unless - you need to change the QList through the iterator. Const - iterators are slightly faster, and can improve code readability. - - The default QList::iterator constructor creates an uninitialized - iterator. You must initialize it using a QList function like - QList::begin(), QList::end(), or QList::insert() before you can - start iterating. Here's a typical loop that prints all the items - stored in a list: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 15 - - Let's see a few examples of things we can do with a - QList::iterator that we cannot do with a QList::const_iterator. - Here's an example that increments every value stored in a - QList\ by 2: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 16 - - Most QList functions accept an integer index rather than an - iterator. For that reason, iterators are rarely useful in - connection with QList. One place where STL-style iterators do - make sense is as arguments to \l{generic algorithms}. - - For example, here's how to delete all the widgets stored in a - QList\: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 17 - - Multiple iterators can be used on the same list. However, be - aware that any non-const function call performed on the QList - will render all existing iterators undefined. If you need to keep - iterators over a long period of time, we recommend that you use - QLinkedList rather than QList. - - \sa QList::const_iterator, QMutableListIterator -*/ - -/*! \typedef QList::iterator::iterator_category - - A synonym for \e {std::random_access_iterator_tag} indicating - this iterator is a random access iterator. -*/ - -/*! \typedef QList::iterator::difference_type - - \internal -*/ - -/*! \typedef QList::iterator::value_type - - \internal -*/ - -/*! \typedef QList::iterator::pointer - - \internal -*/ - -/*! \typedef QList::iterator::reference - - \internal -*/ - -/*! \fn QList::iterator::iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called - on an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QList::begin() QList::end() -*/ - -/*! \fn QList::iterator::iterator(Node *node) - - \internal -*/ - -/*! \fn QList::iterator::iterator(const iterator &other) - - Constructs a copy of \a other. -*/ - -/*! \fn T &QList::iterator::operator*() const - - Returns a modifiable reference to the current item. - - You can change the value of an item by using operator*() on the - left side of an assignment, for example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 18 - - \sa operator->() -*/ - -/*! \fn T *QList::iterator::operator->() const - - Returns a pointer to the current item. - - \sa operator*() -*/ - -/*! \fn T &QList::iterator::operator[](int j) const - - Returns a modifiable reference to the item at position *this + - \a{j}. - - This function is provided to make QList iterators behave like C++ - pointers. - - \sa operator+() -*/ - -/*! - \fn bool QList::iterator::operator==(const iterator &other) const - \fn bool QList::iterator::operator==(const const_iterator &other) const - - Returns true if \a other points to the same item as this - iterator; otherwise returns false. - - \sa operator!=() -*/ - -/*! - \fn bool QList::iterator::operator!=(const iterator &other) const - \fn bool QList::iterator::operator!=(const const_iterator &other) const - - Returns true if \a other points to a different item than this - iterator; otherwise returns false. - - \sa operator==() -*/ - -/*! - \fn bool QList::iterator::operator<(const iterator& other) const - \fn bool QList::iterator::operator<(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is less than - the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::iterator::operator<=(const iterator& other) const - \fn bool QList::iterator::operator<=(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is less than - or equal to the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::iterator::operator>(const iterator& other) const - \fn bool QList::iterator::operator>(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is greater - than the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::iterator::operator>=(const iterator& other) const - \fn bool QList::iterator::operator>=(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is greater - than or equal to the item pointed to by the \a other iterator. -*/ - -/*! \fn QList::iterator &QList::iterator::operator++() - - The prefix ++ operator (\c{++it}) advances the iterator to the - next item in the list and returns an iterator to the new current - item. - - Calling this function on QList::end() leads to undefined results. - - \sa operator--() -*/ - -/*! \fn QList::iterator QList::iterator::operator++(int) - - \overload - - The postfix ++ operator (\c{it++}) advances the iterator to the - next item in the list and returns an iterator to the previously - current item. -*/ - -/*! \fn QList::iterator &QList::iterator::operator--() - - The prefix -- operator (\c{--it}) makes the preceding item - current and returns an iterator to the new current item. - - Calling this function on QList::begin() leads to undefined results. - - \sa operator++() -*/ - -/*! \fn QList::iterator QList::iterator::operator--(int) - - \overload - - The postfix -- operator (\c{it--}) makes the preceding item - current and returns an iterator to the previously current item. -*/ - -/*! \fn QList::iterator &QList::iterator::operator+=(int j) - - Advances the iterator by \a j items. (If \a j is negative, the - iterator goes backward.) - - \sa operator-=(), operator+() -*/ - -/*! \fn QList::iterator &QList::iterator::operator-=(int j) - - Makes the iterator go back by \a j items. (If \a j is negative, - the iterator goes forward.) - - \sa operator+=(), operator-() -*/ - -/*! \fn QList::iterator QList::iterator::operator+(int j) const - - Returns an iterator to the item at \a j positions forward from - this iterator. (If \a j is negative, the iterator goes backward.) - - \sa operator-(), operator+=() -*/ - -/*! \fn QList::iterator QList::iterator::operator-(int j) const - - Returns an iterator to the item at \a j positions backward from - this iterator. (If \a j is negative, the iterator goes forward.) - - \sa operator+(), operator-=() -*/ - -/*! \fn int QList::iterator::operator-(iterator other) const - - Returns the number of items between the item pointed to by \a - other and the item pointed to by this iterator. -*/ - -/*! \class QList::const_iterator - \brief The QList::const_iterator class provides an STL-style const iterator for QList and QQueue. - - QList provides both \l{STL-style iterators} and \l{Java-style - iterators}. The STL-style iterators are more low-level and more - cumbersome to use; on the other hand, they are slightly faster - and, for developers who already know STL, have the advantage of - familiarity. - - QList\::const_iterator allows you to iterate over a - QList\ (or a QQueue\). If you want to modify the QList as - you iterate over it, use QList::iterator instead. It is generally - good practice to use QList::const_iterator on a non-const QList - as well, unless you need to change the QList through the - iterator. Const iterators are slightly faster, and can improve - code readability. - - The default QList::const_iterator constructor creates an - uninitialized iterator. You must initialize it using a QList - function like QList::constBegin(), QList::constEnd(), or - QList::insert() before you can start iterating. Here's a typical - loop that prints all the items stored in a list: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 19 - - Most QList functions accept an integer index rather than an - iterator. For that reason, iterators are rarely useful in - connection with QList. One place where STL-style iterators do - make sense is as arguments to \l{generic algorithms}. - - For example, here's how to delete all the widgets stored in a - QList\: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 20 - - Multiple iterators can be used on the same list. However, be - aware that any non-const function call performed on the QList - will render all existing iterators undefined. If you need to keep - iterators over a long period of time, we recommend that you use - QLinkedList rather than QList. - - \sa QList::iterator, QListIterator -*/ - -/*! \fn QList::const_iterator::const_iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called - on an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QList::constBegin() QList::constEnd() -*/ - -/*! \typedef QList::const_iterator::iterator_category - - A synonym for \e {std::random_access_iterator_tag} indicating - this iterator is a random access iterator. -*/ - -/*! \typedef QList::const_iterator::difference_type - - \internal -*/ - -/*! \typedef QList::const_iterator::value_type - - \internal -*/ - -/*! \typedef QList::const_iterator::pointer - - \internal -*/ - -/*! \typedef QList::const_iterator::reference - - \internal -*/ - -/*! \fn QList::const_iterator::const_iterator(Node *node) - - \internal -*/ - -/*! \fn QList::const_iterator::const_iterator(const const_iterator &other) - - Constructs a copy of \a other. -*/ - -/*! \fn QList::const_iterator::const_iterator(const iterator &other) - - Constructs a copy of \a other. -*/ - -/*! \fn const T &QList::const_iterator::operator*() const - - Returns the current item. - - \sa operator->() -*/ - -/*! \fn const T *QList::const_iterator::operator->() const - - Returns a pointer to the current item. - - \sa operator*() -*/ - -/*! \fn const T &QList::const_iterator::operator[](int j) const - - Returns the item at position *this + \a{j}. - - This function is provided to make QList iterators behave like C++ - pointers. - - \sa operator+() -*/ - -/*! \fn bool QList::const_iterator::operator==(const const_iterator &other) const - - Returns true if \a other points to the same item as this - iterator; otherwise returns false. - - \sa operator!=() -*/ - -/*! \fn bool QList::const_iterator::operator!=(const const_iterator &other) const - - Returns true if \a other points to a different item than this - iterator; otherwise returns false. - - \sa operator==() -*/ - -/*! - \fn bool QList::const_iterator::operator<(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is less than - the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::const_iterator::operator<=(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is less than - or equal to the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::const_iterator::operator>(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is greater - than the item pointed to by the \a other iterator. -*/ - -/*! - \fn bool QList::const_iterator::operator>=(const const_iterator& other) const - - Returns true if the item pointed to by this iterator is greater - than or equal to the item pointed to by the \a other iterator. -*/ - -/*! \fn QList::const_iterator &QList::const_iterator::operator++() - - The prefix ++ operator (\c{++it}) advances the iterator to the - next item in the list and returns an iterator to the new current - item. - - Calling this function on QList::end() leads to undefined results. - - \sa operator--() -*/ - -/*! \fn QList::const_iterator QList::const_iterator::operator++(int) - - \overload - - The postfix ++ operator (\c{it++}) advances the iterator to the - next item in the list and returns an iterator to the previously - current item. -*/ - -/*! \fn QList::const_iterator &QList::const_iterator::operator--() - - The prefix -- operator (\c{--it}) makes the preceding item - current and returns an iterator to the new current item. - - Calling this function on QList::begin() leads to undefined results. - - \sa operator++() -*/ - -/*! \fn QList::const_iterator QList::const_iterator::operator--(int) - - \overload - - The postfix -- operator (\c{it--}) makes the preceding item - current and returns an iterator to the previously current item. -*/ - -/*! \fn QList::const_iterator &QList::const_iterator::operator+=(int j) - - Advances the iterator by \a j items. (If \a j is negative, the - iterator goes backward.) - - \sa operator-=(), operator+() -*/ - -/*! \fn QList::const_iterator &QList::const_iterator::operator-=(int j) - - Makes the iterator go back by \a j items. (If \a j is negative, - the iterator goes forward.) - - \sa operator+=(), operator-() -*/ - -/*! \fn QList::const_iterator QList::const_iterator::operator+(int j) const - - Returns an iterator to the item at \a j positions forward from - this iterator. (If \a j is negative, the iterator goes backward.) - - \sa operator-(), operator+=() -*/ - -/*! \fn QList::const_iterator QList::const_iterator::operator-(int j) const - - Returns an iterator to the item at \a j positions backward from - this iterator. (If \a j is negative, the iterator goes forward.) - - \sa operator+(), operator-=() -*/ - -/*! \fn int QList::const_iterator::operator-(const_iterator other) const - - Returns the number of items between the item pointed to by \a - other and the item pointed to by this iterator. -*/ - -/*! \fn QDataStream &operator<<(QDataStream &out, const QList &list) - \relates QList - - Writes the list \a list to stream \a out. - - This function requires the value type to implement \c - operator<<(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -/*! \fn QDataStream &operator>>(QDataStream &in, QList &list) - \relates QList - - Reads a list from stream \a in into \a list. - - This function requires the value type to implement \c - operator>>(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -/*! - \fn iterator QList::remove(iterator pos) - - Use erase() instead. -*/ - -/*! - \fn int QList::remove(const T &t) - - Use removeAll() instead. -*/ - -/*! - \fn int QList::findIndex(const T& t) const - - Use indexOf() instead. -*/ - -/*! - \fn iterator QList::find(const T& t) - - Use indexOf() instead. -*/ - -/*! - \fn const_iterator QList::find (const T& t) const - - Use indexOf() instead. -*/ - -/*! - \fn iterator QList::find(iterator from, const T& t) - - Use indexOf() instead. -*/ - -/*! - \fn const_iterator QList::find(const_iterator from, const T& t) const - - Use indexOf() instead. -*/ - -/*! \fn QList QList::fromVector(const QVector &vector) - - Returns a QList object with the data contained in \a vector. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 21 - - \sa fromSet(), toVector(), QVector::toList() -*/ - -/*! \fn QVector QList::toVector() const - - Returns a QVector object with the data contained in this QList. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 22 - - \sa toSet(), fromVector(), QVector::fromList() -*/ - -/*! \fn QList QList::fromSet(const QSet &set) - - Returns a QList object with the data contained in \a set. The - order of the elements in the QList is undefined. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 23 - - \sa fromVector(), toSet(), QSet::toList(), qSort() -*/ - -/*! \fn QSet QList::toSet() const - - Returns a QSet object with the data contained in this QList. - Since QSet doesn't allow duplicates, the resulting QSet might be - smaller than the original list was. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 24 - - \sa toVector(), fromSet(), QSet::fromList() -*/ - -/*! \fn QList QList::fromStdList(const std::list &list) - - Returns a QList object with the data contained in \a list. The - order of the elements in the QList is the same as in \a list. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 25 - - \sa toStdList(), QVector::fromStdVector() -*/ - -/*! \fn std::list QList::toStdList() const - - Returns a std::list object with the data contained in this QList. - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlistdata.cpp 26 - - \sa fromStdList(), QVector::toStdVector() -*/ - -QT_END_NAMESPACE diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 1a6c1c0..05d866c 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -55,7 +55,7 @@ SOURCES += \ tools/qhash.cpp \ tools/qline.cpp \ tools/qlinkedlist.cpp \ - tools/qlistdata.cpp \ + tools/qlist.cpp \ tools/qlocale.cpp \ tools/qpoint.cpp \ tools/qmap.cpp \ diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 396e9ae..1f81a6c 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -69,7 +69,7 @@ SOURCES += \ ../../corelib/tools/qbytearraymatcher.cpp \ ../../corelib/tools/qdatetime.cpp \ ../../corelib/tools/qhash.cpp \ - ../../corelib/tools/qlistdata.cpp \ + ../../corelib/tools/qlist.cpp \ ../../corelib/tools/qlocale.cpp \ ../../corelib/tools/qmap.cpp \ ../../corelib/tools/qregexp.cpp \ diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index eeec62a..06e9fe0 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -62,7 +62,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qchar.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlistdata.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qlist.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qlocale.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qvector.cpp \ $$QT_SOURCE_TREE/src/corelib/codecs/qutfcodec.cpp \ diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index a31374e..3a0ce24 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -24,7 +24,7 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qvector.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlistdata.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qlist.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \ $$QT_SOURCE_TREE/src/corelib/global/qglobal.cpp \ $$QT_BUILD_TREE/src/corelib/global/qconfig.cpp \ -- cgit v0.12 From 725d3a60c62468553c63a0269282ebdb821c650c Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 17 Aug 2009 20:46:45 +0200 Subject: fix includes to use lower-case Makes sure that we can bootstrap QtCore easier on weird platforms without having to run syncqt first --- src/corelib/animation/qparallelanimationgroup_p.h | 2 +- src/corelib/concurrent/qfuturewatcher.cpp | 6 +++--- src/corelib/concurrent/qfuturewatcher_p.h | 2 +- src/corelib/io/qdir.cpp | 2 +- src/corelib/io/qfilesystemwatcher_fsevents_p.h | 4 ++-- src/corelib/io/qnoncontiguousbytedevice.cpp | 7 +++---- src/corelib/io/qnoncontiguousbytedevice_p.h | 2 +- src/corelib/kernel/qcoreglobaldata.cpp | 2 -- src/corelib/tools/qeasingcurve.cpp | 2 +- src/corelib/tools/qsharedpointer.cpp | 2 +- src/corelib/xml/qxmlstream.cpp | 4 ++-- src/corelib/xml/qxmlstream.h | 6 +++--- src/corelib/xml/qxmlutils.cpp | 4 ++-- src/corelib/xml/qxmlutils_p.h | 2 +- 14 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index 65bf693..db804d5 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -55,7 +55,7 @@ #include "qparallelanimationgroup.h" #include "private/qanimationgroup_p.h" -#include +#include #ifndef QT_NO_ANIMATION diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp index 4e9e723..84715b4 100644 --- a/src/corelib/concurrent/qfuturewatcher.cpp +++ b/src/corelib/concurrent/qfuturewatcher.cpp @@ -43,9 +43,9 @@ #ifndef QT_NO_QFUTURE -#include -#include -#include +#include +#include +#include #include "qfuturewatcher_p.h" diff --git a/src/corelib/concurrent/qfuturewatcher_p.h b/src/corelib/concurrent/qfuturewatcher_p.h index 69a28eb..8fb0e4f 100644 --- a/src/corelib/concurrent/qfuturewatcher_p.h +++ b/src/corelib/concurrent/qfuturewatcher_p.h @@ -54,7 +54,7 @@ // #include "qfutureinterface_p.h" -#include +#include #ifndef QT_NO_QFUTURE diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index d08cb2f..ca178ce 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -58,7 +58,7 @@ #include "qvarlengtharray.h" -#include "../kernel/qcoreglobaldata_p.h" +#include "private/qcoreglobaldata_p.h" #include QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h index b93d711..317c149 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h +++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h @@ -59,8 +59,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index 89ed041..185d961 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -40,10 +40,9 @@ ****************************************************************************/ #include "qnoncontiguousbytedevice_p.h" -#include -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h index dd34c67..ecf9b9c 100644 --- a/src/corelib/io/qnoncontiguousbytedevice_p.h +++ b/src/corelib/io/qnoncontiguousbytedevice_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include +#include #include #include #include diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp index c2a226d..6b90ed7 100644 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ b/src/corelib/kernel/qcoreglobaldata.cpp @@ -41,8 +41,6 @@ #include "qcoreglobaldata_p.h" -#include - QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 5cc8080..e84e3f0 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -301,7 +301,7 @@ #ifndef QT_NO_DEBUG_STREAM #include -#include +#include #endif QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 834531e..4e2c206 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1210,7 +1210,7 @@ #include #if !defined(QT_NO_QOBJECT) -#include "../kernel/qobject_p.h" +#include "private/qobject_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 7924bd0..a08b167 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -52,13 +52,13 @@ #include "qxmlutils_p.h" #include -#include +#include #include #include #include #include #ifndef QT_BOOTSTRAPPED -#include +#include #else // This specialization of Q_DECLARE_TR_FUNCTIONS is not in qcoreapplication.h, // because that header depends on QObject being available, which is not the diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 3353cd4..420a66a 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -42,12 +42,12 @@ #ifndef QXMLSTREAM_H #define QXMLSTREAM_H -#include +#include #ifndef QT_NO_XMLSTREAM -#include -#include +#include +#include QT_BEGIN_HEADER diff --git a/src/corelib/xml/qxmlutils.cpp b/src/corelib/xml/qxmlutils.cpp index 036869b..d9219be 100644 --- a/src/corelib/xml/qxmlutils.cpp +++ b/src/corelib/xml/qxmlutils.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include -#include +#include +#include #include "qxmlutils_p.h" diff --git a/src/corelib/xml/qxmlutils_p.h b/src/corelib/xml/qxmlutils_p.h index 431c0ad..6e7ba7b 100644 --- a/src/corelib/xml/qxmlutils_p.h +++ b/src/corelib/xml/qxmlutils_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 33e1639ba798a5726d322139770dc771d03cae72 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Aug 2009 19:13:58 +0200 Subject: cut down on real code remove all c++ code which is not part of the critical test data. as a result, remove the license headers where the remaining text cannot be reasonably considered copyright-worthy any more. this is a somewhat persistent solution to the ever-changing license headers screwing up the tests. --- .../good/mergecpp_noobsolete/finddialog.cpp | 108 ---------------- .../good/mergecpp_noobsolete/project.ts.result | 8 +- .../testdata/good/mergecpp_obsolete/finddialog.cpp | 137 -------------------- .../good/mergecpp_obsolete/project.ts.result | 8 +- .../testdata/good/mergeui/project.ts.before | 6 +- .../testdata/good/mergeui/project.ts.result | 6 +- .../lupdate/testdata/good/mergeui/project.ui | 40 ------ .../testdata/good/parsecpp/project.ts.result | 22 ++-- .../testdata/good/parseui/project.ts.result | 4 +- .../lupdate/testdata/good/parseui/project.ui | 40 ------ .../lupdate/testdata/recursivescan/bar.ts.result | 8 +- .../lupdate/testdata/recursivescan/foo.ts.result | 12 +- .../lupdate/testdata/recursivescan/project.ui | 40 ------ .../testdata/recursivescan/sub/finddialog.cpp | 139 --------------------- 14 files changed, 37 insertions(+), 541 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp index 7958055..7215ebe 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp @@ -1,44 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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 "finddialog.h" #include "mainwindow.h" #include "tabbedbrowser.h" @@ -51,83 +10,18 @@ #include #include -CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) - : QStandardItemModel(rows, columns, parent) -{} -QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, - int hits, Qt::MatchFlags flags) const -{ - if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) - flags |= Qt::MatchCaseSensitive; - - return QStandardItemModel::match(start, role, value, hits, flags); -} - FindDialog::FindDialog(MainWindow *parent) : QDialog(parent) { - contentsWidget = new QWidget(this); - ui.setupUi(contentsWidget); - ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); - - QVBoxLayout *l = new QVBoxLayout(this); - l->setMargin(0); - l->setSpacing(0); - l->addWidget(contentsWidget); - - lastBrowser = 0; - onceFound = false; - findExpr.clear(); - sb = new QStatusBar(this); l->addWidget(sb); sb->showMessage(tr("Enter the text you want to find.")); - connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); - connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); -} - -FindDialog::~FindDialog() -{ -} - -void FindDialog::findButtonClicked() -{ - doFind(ui.radioForward->isChecked()); } void FindDialog::doFind(bool forward) { - QTextBrowser *browser = static_cast(mainWindow()->browsers()->currentBrowser()); - sb->clearMessage(); - - if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) - onceFound = false; - findExpr = ui.comboFind->currentText(); - - QTextDocument::FindFlags flags = 0; - - if (ui.checkCase->isChecked()) - flags |= QTextDocument::FindCaseSensitively; - - if (ui.checkWords->isChecked()) - flags |= QTextDocument::FindWholeWords; - - QTextCursor c = browser->textCursor(); - if (!c.hasSelection()) { - if (forward) - c.movePosition(QTextCursor::Start); - else - c.movePosition(QTextCursor::End); - - browser->setTextCursor(c); - } - - QTextDocument::FindFlags options; - if (forward == false) - flags |= QTextDocument::FindBackward; - QTextCursor found = browser->document()->find(findExpr, c, flags); if (found.isNull()) { if (onceFound) { @@ -141,8 +35,6 @@ void FindDialog::doFind(bool forward) } else { browser->setTextCursor(found); } - onceFound |= !found.isNull(); - lastBrowser = browser; } bool FindDialog::hasFindExpression() const diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result index 21d1ca0..de2c45a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result @@ -4,22 +4,22 @@ FindDialog - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp index 045fab1..756c9a3 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp @@ -1,44 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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 "finddialog.h" #include "mainwindow.h" #include "tabbedbrowser.h" @@ -51,86 +10,17 @@ #include #include -CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) - : QStandardItemModel(rows, columns, parent) -{} -QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, - int hits, Qt::MatchFlags flags) const -{ - if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) - flags |= Qt::MatchCaseSensitive; - - return QStandardItemModel::match(start, role, value, hits, flags); -} - FindDialog::FindDialog(MainWindow *parent) : QDialog(parent) { - contentsWidget = new QWidget(this); - ui.setupUi(contentsWidget); - ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); - - QVBoxLayout *l = new QVBoxLayout(this); - l->setMargin(0); - l->setSpacing(0); - l->addWidget(contentsWidget); - - lastBrowser = 0; - onceFound = false; - findExpr.clear(); - - sb = new QStatusBar(this); - l->addWidget(sb); - - // Move it to another line and change the text, // then lupdate should add this one as a new one, and mark the old one as obsolete. sb->showMessage(tr("Enter the text you want to find.")); - connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); - connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); -} - -FindDialog::~FindDialog() -{ -} - -void FindDialog::findButtonClicked() -{ - doFind(ui.radioForward->isChecked()); } void FindDialog::doFind(bool forward) { - QTextBrowser *browser = static_cast(mainWindow()->browsers()->currentBrowser()); - sb->clearMessage(); - - if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) - onceFound = false; - findExpr = ui.comboFind->currentText(); - - QTextDocument::FindFlags flags = 0; - - if (ui.checkCase->isChecked()) - flags |= QTextDocument::FindCaseSensitively; - - if (ui.checkWords->isChecked()) - flags |= QTextDocument::FindWholeWords; - - QTextCursor c = browser->textCursor(); - if (!c.hasSelection()) { - if (forward) - c.movePosition(QTextCursor::Start); - else - c.movePosition(QTextCursor::End); - - browser->setTextCursor(c); - } - - QTextDocument::FindFlags options; - if (forward == false) - flags |= QTextDocument::FindBackward; - QTextCursor found = browser->document()->find(findExpr, c, flags); if (found.isNull()) { if (onceFound) { @@ -144,31 +34,4 @@ void FindDialog::doFind(bool forward) } else { browser->setTextCursor(found); } - onceFound |= !found.isNull(); - lastBrowser = browser; -} - -bool FindDialog::hasFindExpression() const -{ - return !findExpr.isEmpty(); -} - -void FindDialog::statusMessage(const QString &message) -{ - if (isVisible()) - sb->showMessage(message); - else - static_cast(parent())->statusBar()->showMessage(message, 2000); -} - -MainWindow *FindDialog::mainWindow() const -{ - return static_cast(parentWidget()); -} - -void FindDialog::reset() -{ - ui.comboFind->setFocus(); - ui.comboFind->lineEdit()->setSelection( - 0, ui.comboFind->lineEdit()->text().length()); } diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result index b7074fe..4012182 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result @@ -8,22 +8,22 @@ Skriv inn teksten du soker etter - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before index 076520a..1ad6ec8 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before @@ -3,18 +3,18 @@ FindDialog - + Qt Assistant - Find text Qt Assistant - Finn tekst - + 300px 300px - + 400px diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result index b21f583..4c5f74d 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result @@ -4,18 +4,18 @@ FindDialog - + Qt Assistant - Find Text Qt Assistant - Find text Qt Assistant - Finn tekst - + 300px 300px - + 401 pixels diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui index 2a0bb70..d332eeb 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui @@ -1,45 +1,5 @@ - ********************************************************************* -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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$ -** -********************************************************************* FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 97d3bce..8c48245 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -79,27 +79,27 @@ backslashed \ stuff. FindDialog - + Enter the text you are looking for. - + Search reached end of the document - + Search reached start of the document - + Text not found - + null comment @@ -107,7 +107,7 @@ backslashed \ stuff. KÃ¥ntekst - + encoding, using QApplication @@ -151,28 +151,28 @@ backslashed \ stuff. QCoreApplication - + with comment comment - + empty comment - + null comment - + encoding, using QCoreApplication - + encoding, using QApplication diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result index ddf58c3..7f665f4 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result @@ -4,12 +4,12 @@ FindDialog - + Qt Assistant - Finn text - + Finn tekst - Der Bjørn möchte auch mal. diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui index 9beb8d5..65a00c7 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui @@ -1,45 +1,5 @@ - ********************************************************************* -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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$ -** -********************************************************************* FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result index e132342..f6415bf 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result @@ -4,22 +4,22 @@ FindDialog - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result index 6646014..581e4b6 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result @@ -4,32 +4,32 @@ FindDialog - + Qt Assistant - Finn text - + Finn tekst - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui index 97553db..8dea10b 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui @@ -1,45 +1,5 @@ - ********************************************************************* -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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$ -** -********************************************************************* FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp index 3800ee7..3875473 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp @@ -1,44 +1,3 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the autotests 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 "finddialog.h" #include "mainwindow.h" #include "tabbedbrowser.h" @@ -51,83 +10,14 @@ #include #include -CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) - : QStandardItemModel(rows, columns, parent) -{} -QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, - int hits, Qt::MatchFlags flags) const -{ - if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) - flags |= Qt::MatchCaseSensitive; - - return QStandardItemModel::match(start, role, value, hits, flags); -} - FindDialog::FindDialog(MainWindow *parent) : QDialog(parent) { - contentsWidget = new QWidget(this); - ui.setupUi(contentsWidget); - ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); - - QVBoxLayout *l = new QVBoxLayout(this); - l->setMargin(0); - l->setSpacing(0); - l->addWidget(contentsWidget); - - lastBrowser = 0; - onceFound = false; - findExpr.clear(); - - sb = new QStatusBar(this); - l->addWidget(sb); - sb->showMessage(tr("Enter the text you want to find.")); - - connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); - connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); -} - -FindDialog::~FindDialog() -{ -} - -void FindDialog::findButtonClicked() -{ - doFind(ui.radioForward->isChecked()); } void FindDialog::doFind(bool forward) { - QTextBrowser *browser = static_cast(mainWindow()->browsers()->currentBrowser()); - sb->clearMessage(); - - if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) - onceFound = false; - findExpr = ui.comboFind->currentText(); - - QTextDocument::FindFlags flags = 0; - - if (ui.checkCase->isChecked()) - flags |= QTextDocument::FindCaseSensitively; - - if (ui.checkWords->isChecked()) - flags |= QTextDocument::FindWholeWords; - - QTextCursor c = browser->textCursor(); - if (!c.hasSelection()) { - if (forward) - c.movePosition(QTextCursor::Start); - else - c.movePosition(QTextCursor::End); - - browser->setTextCursor(c); - } - - QTextDocument::FindFlags options; - if (forward == false) - flags |= QTextDocument::FindBackward; - QTextCursor found = browser->document()->find(findExpr, c, flags); if (found.isNull()) { if (onceFound) { @@ -138,34 +28,5 @@ void FindDialog::doFind(bool forward) } else { statusMessage(tr( "Text not found" )); } - } else { - browser->setTextCursor(found); } - onceFound |= !found.isNull(); - lastBrowser = browser; -} - -bool FindDialog::hasFindExpression() const -{ - return !findExpr.isEmpty(); -} - -void FindDialog::statusMessage(const QString &message) -{ - if (isVisible()) - sb->showMessage(message); - else - static_cast(parent())->statusBar()->showMessage(message, 2000); -} - -MainWindow *FindDialog::mainWindow() const -{ - return static_cast(parentWidget()); -} - -void FindDialog::reset() -{ - ui.comboFind->setFocus(); - ui.comboFind->lineEdit()->setSelection( - 0, ui.comboFind->lineEdit()->text().length()); } -- cgit v0.12 From 0e6fd509068e1aeeec41d0d1aae7ec2c79b479b6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Aug 2009 17:10:55 +0200 Subject: optimize getChar() work more with raw data instead of qstring functions --- tools/linguist/lupdate/cpp.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 581662a..70a2470 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -312,26 +312,28 @@ void CppParser::setInput(QTextStream &ts, const QString &fileName) uint CppParser::getChar() { + int len = yyInStr.size(); + const ushort *uc = (const ushort *)yyInStr.unicode(); forever { - if (yyInPos >= yyInStr.size()) + if (yyInPos >= len) return EOF; - uint c = yyInStr[yyInPos++].unicode(); - if (c == '\\' && yyInPos < yyInStr.size()) { - if (yyInStr[yyInPos].unicode() == '\n') { + uint c = uc[yyInPos++]; + if (c == '\\' && yyInPos < len) { + if (uc[yyInPos] == '\n') { ++yyCurLineNo; ++yyInPos; continue; } - if (yyInStr[yyInPos].unicode() == '\r') { + if (uc[yyInPos] == '\r') { ++yyCurLineNo; ++yyInPos; - if (yyInPos < yyInStr.size() && yyInStr[yyInPos].unicode() == '\n') + if (yyInPos < len && uc[yyInPos] == '\n') ++yyInPos; continue; } } if (c == '\r') { - if (yyInPos < yyInStr.size() && yyInStr[yyInPos].unicode() == '\n') + if (yyInPos < len && uc[yyInPos] == '\n') ++yyInPos; c = '\n'; ++yyCurLineNo; -- cgit v0.12 From 913e9652f3c1f964545877424a06658ef724c83f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Aug 2009 17:13:43 +0200 Subject: optimize getToken(), part 1 compare with pre-initialized qstrings instead of qlatin1strings. that way the length is known in advance. --- tools/linguist/lupdate/cpp.cpp | 76 ++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 70a2470..5bd1b44 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -58,9 +58,7 @@ QT_BEGIN_NAMESPACE static const char MagicComment[] = "TRANSLATOR "; -#define STRINGIFY_INTERNAL(x) #x -#define STRINGIFY(x) STRINGIFY_INTERNAL(x) -#define STRING(s) static QString str##s(QLatin1String(STRINGIFY(s))) +#define STRING(s) static QString str##s(QLatin1String(#s)) //#define DIAGNOSE_RETRANSLATABILITY // FIXME: should make a runtime option of this @@ -348,6 +346,30 @@ uint CppParser::getChar() } } +STRING(Q_OBJECT); +STRING(Q_DECLARE_TR_FUNCTIONS); +STRING(QT_TR_NOOP); +STRING(QT_TRID_NOOP); +STRING(QT_TRANSLATE_NOOP); +STRING(QT_TRANSLATE_NOOP3); +STRING(QT_TR_NOOP_UTF8); +STRING(QT_TRANSLATE_NOOP_UTF8); +STRING(QT_TRANSLATE_NOOP3_UTF8); +STRING(class); +// QTranslator::findMessage() has the same parameters as QApplication::translate() +STRING(findMessage); +STRING(friend); +STRING(namespace); +STRING(qtTrId); +STRING(return); +STRING(struct); +STRING(TR); +STRING(Tr); +STRING(tr); +STRING(trUtf8); +STRING(translate); +STRING(using); + uint CppParser::getToken() { restart: @@ -547,35 +569,34 @@ uint CppParser::getToken() //qDebug() << "IDENT: " << yyIdent; - switch (yyIdent.at(0).unicode()) { + switch (yyIdent.unicode()[0].unicode()) { case 'Q': - if (yyIdent == QLatin1String("Q_OBJECT")) + if (yyIdent == strQ_OBJECT) return Tok_Q_OBJECT; - if (yyIdent == QLatin1String("Q_DECLARE_TR_FUNCTIONS")) + if (yyIdent == strQ_DECLARE_TR_FUNCTIONS) return Tok_Q_DECLARE_TR_FUNCTIONS; - if (yyIdent == QLatin1String("QT_TR_NOOP")) + if (yyIdent == strQT_TR_NOOP) return Tok_tr; - if (yyIdent == QLatin1String("QT_TRID_NOOP")) + if (yyIdent == strQT_TRID_NOOP) return Tok_trid; - if (yyIdent == QLatin1String("QT_TRANSLATE_NOOP")) + if (yyIdent == strQT_TRANSLATE_NOOP) return Tok_translate; - if (yyIdent == QLatin1String("QT_TRANSLATE_NOOP3")) + if (yyIdent == strQT_TRANSLATE_NOOP3) return Tok_translate; - if (yyIdent == QLatin1String("QT_TR_NOOP_UTF8")) + if (yyIdent == strQT_TR_NOOP_UTF8) return Tok_trUtf8; - if (yyIdent == QLatin1String("QT_TRANSLATE_NOOP_UTF8")) + if (yyIdent == strQT_TRANSLATE_NOOP_UTF8) return Tok_translateUtf8; - if (yyIdent == QLatin1String("QT_TRANSLATE_NOOP3_UTF8")) + if (yyIdent == strQT_TRANSLATE_NOOP3_UTF8) return Tok_translateUtf8; break; case 'T': // TR() for when all else fails - if (yyIdent.compare(QLatin1String("TR"), Qt::CaseInsensitive) == 0) { + if (yyIdent == strTR || yyIdent == strTr) return Tok_tr; - } break; case 'c': - if (yyIdent == QLatin1String("class")) + if (yyIdent == strclass) return Tok_class; break; case 'f': @@ -583,40 +604,37 @@ uint CppParser::getToken() QTranslator::findMessage() has the same parameters as QApplication::translate(). */ - if (yyIdent == QLatin1String("findMessage")) + if (yyIdent == strfindMessage) return Tok_translate; - if (yyIdent == QLatin1String("friend")) + if (yyIdent == strfriend) return Tok_friend; break; case 'n': - if (yyIdent == QLatin1String("namespace")) + if (yyIdent == strnamespace) return Tok_namespace; break; case 'q': - if (yyIdent == QLatin1String("qtTrId")) + if (yyIdent == strqtTrId) return Tok_trid; break; case 'r': - if (yyIdent == QLatin1String("return")) + if (yyIdent == strreturn) return Tok_return; break; case 's': - if (yyIdent == QLatin1String("struct")) + if (yyIdent == strstruct) return Tok_class; break; case 't': - if (yyIdent == QLatin1String("tr")) { + if (yyIdent == strtr) return Tok_tr; - } - if (yyIdent == QLatin1String("trUtf8")) { + if (yyIdent == strtrUtf8) return Tok_trUtf8; - } - if (yyIdent == QLatin1String("translate")) { + if (yyIdent == strtranslate) return Tok_translate; - } break; case 'u': - if (yyIdent == QLatin1String("using")) + if (yyIdent == strusing) return Tok_using; break; } -- cgit v0.12 From a6c18d32e117d9ffd358fa3a23cc0f38a43dfe47 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Aug 2009 18:16:03 +0200 Subject: consolidate some variables only one of yyIdent, yyComment and yyString is used at a time, so use a common yyWord instead --- tools/linguist/lupdate/cpp.cpp | 136 ++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 70 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 5bd1b44..0191393 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -213,9 +213,7 @@ private: bool yyAtNewline; bool yyCodecIsUtf8; bool yyForceUtf8; - QString yyIdent; - QString yyComment; - QString yyString; + QString yyWord; qlonglong yyInteger; QStack yyIfdefStack; int yyBraceDepth; @@ -373,9 +371,7 @@ STRING(using); uint CppParser::getToken() { restart: - yyIdent.clear(); - yyComment.clear(); - yyString.clear(); + yyWord.clear(); while (yyCh != EOF) { yyLineNo = yyCurLineNo; @@ -482,7 +478,7 @@ uint CppParser::getToken() yyCh = getChar(); break; } - yyString += yyCh; + yyWord += yyCh; } return (tChar == '"') ? Tok_QuotedInclude : Tok_AngledInclude; } @@ -563,40 +559,40 @@ uint CppParser::getToken() yyCh = getChar(); } else if (isalpha(yyCh) || yyCh == '_') { do { - yyIdent += yyCh; + yyWord += yyCh; yyCh = getChar(); } while (isalnum(yyCh) || yyCh == '_'); - //qDebug() << "IDENT: " << yyIdent; + //qDebug() << "IDENT: " << yyWord; - switch (yyIdent.unicode()[0].unicode()) { + switch (yyWord.unicode()[0].unicode()) { case 'Q': - if (yyIdent == strQ_OBJECT) + if (yyWord == strQ_OBJECT) return Tok_Q_OBJECT; - if (yyIdent == strQ_DECLARE_TR_FUNCTIONS) + if (yyWord == strQ_DECLARE_TR_FUNCTIONS) return Tok_Q_DECLARE_TR_FUNCTIONS; - if (yyIdent == strQT_TR_NOOP) + if (yyWord == strQT_TR_NOOP) return Tok_tr; - if (yyIdent == strQT_TRID_NOOP) + if (yyWord == strQT_TRID_NOOP) return Tok_trid; - if (yyIdent == strQT_TRANSLATE_NOOP) + if (yyWord == strQT_TRANSLATE_NOOP) return Tok_translate; - if (yyIdent == strQT_TRANSLATE_NOOP3) + if (yyWord == strQT_TRANSLATE_NOOP3) return Tok_translate; - if (yyIdent == strQT_TR_NOOP_UTF8) + if (yyWord == strQT_TR_NOOP_UTF8) return Tok_trUtf8; - if (yyIdent == strQT_TRANSLATE_NOOP_UTF8) + if (yyWord == strQT_TRANSLATE_NOOP_UTF8) return Tok_translateUtf8; - if (yyIdent == strQT_TRANSLATE_NOOP3_UTF8) + if (yyWord == strQT_TRANSLATE_NOOP3_UTF8) return Tok_translateUtf8; break; case 'T': // TR() for when all else fails - if (yyIdent == strTR || yyIdent == strTr) + if (yyWord == strTR || yyWord == strTr) return Tok_tr; break; case 'c': - if (yyIdent == strclass) + if (yyWord == strclass) return Tok_class; break; case 'f': @@ -604,37 +600,37 @@ uint CppParser::getToken() QTranslator::findMessage() has the same parameters as QApplication::translate(). */ - if (yyIdent == strfindMessage) + if (yyWord == strfindMessage) return Tok_translate; - if (yyIdent == strfriend) + if (yyWord == strfriend) return Tok_friend; break; case 'n': - if (yyIdent == strnamespace) + if (yyWord == strnamespace) return Tok_namespace; break; case 'q': - if (yyIdent == strqtTrId) + if (yyWord == strqtTrId) return Tok_trid; break; case 'r': - if (yyIdent == strreturn) + if (yyWord == strreturn) return Tok_return; break; case 's': - if (yyIdent == strstruct) + if (yyWord == strstruct) return Tok_class; break; case 't': - if (yyIdent == strtr) + if (yyWord == strtr) return Tok_tr; - if (yyIdent == strtrUtf8) + if (yyWord == strtrUtf8) return Tok_trUtf8; - if (yyIdent == strtranslate) + if (yyWord == strtranslate) return Tok_translate; break; case 'u': - if (yyIdent == strusing) + if (yyWord == strusing) return Tok_using; break; } @@ -658,7 +654,7 @@ uint CppParser::getToken() yyCh = getChar(); if (yyCh == EOF) break; - yyComment.append(yyCh); + yyWord.append(yyCh); } while (yyCh != '\n'); } else if (yyCh == '*') { bool metAster = false; @@ -670,7 +666,7 @@ uint CppParser::getToken() qPrintable(yyFileName), yyLineNo); return Tok_Comment; } - yyComment.append(yyCh); + yyWord.append(yyCh); if (yyCh == '*') metAster = true; @@ -680,7 +676,7 @@ uint CppParser::getToken() metAster = false; } yyCh = getChar(); - yyComment.chop(2); + yyWord.chop(2); } return Tok_Comment; case '"': @@ -690,9 +686,9 @@ uint CppParser::getToken() yyCh = getChar(); if (yyCh == EOF || yyCh == '\n') break; - yyString.append(QLatin1Char('\\')); + yyWord.append(QLatin1Char('\\')); } - yyString.append(yyCh); + yyWord.append(yyCh); yyCh = getChar(); } @@ -1170,7 +1166,7 @@ bool CppParser::matchString(QString *s) bool matches = (yyTok == Tok_String); s->clear(); while (yyTok == Tok_String) { - *s += yyString; + *s += yyWord; do { yyTok = getToken(); } while (yyTok == Tok_Comment); @@ -1188,17 +1184,17 @@ bool CppParser::matchEncoding(bool *utf8) if (yyTok != Tok_Ident) return false; - if (yyIdent == strQApplication || yyIdent == strQCoreApplication) { + if (yyWord == strQApplication || yyWord == strQCoreApplication) { yyTok = getToken(); if (yyTok == Tok_ColonColon) yyTok = getToken(); } - if (yyIdent == strUnicodeUTF8) { + if (yyWord == strUnicodeUTF8) { *utf8 = true; yyTok = getToken(); return true; } - if (yyIdent == strDefaultCodec || yyIdent == strCodecForTr) { + if (yyWord == strDefaultCodec || yyWord == strCodecForTr) { *utf8 = false; yyTok = getToken(); return true; @@ -1370,7 +1366,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) //qDebug() << "TOKEN: " << yyTok; switch (yyTok) { case Tok_QuotedInclude: { - text = QDir(QFileInfo(yyFileName).absolutePath()).absoluteFilePath(yyString); + text = QDir(QFileInfo(yyFileName).absolutePath()).absoluteFilePath(yyWord); if (QFileInfo(text).isFile()) { processInclude(text, cd, inclusions); yyTok = getToken(); @@ -1379,14 +1375,14 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) } /* fall through */ case Tok_AngledInclude: { - QStringList cSources = cd.m_allCSources.values(yyString); + QStringList cSources = cd.m_allCSources.values(yyWord); if (!cSources.isEmpty()) { foreach (const QString &cSource, cSources) processInclude(cSource, cd, inclusions); goto incOk; } foreach (const QString &incPath, cd.m_includePath) { - text = QDir(incPath).absoluteFilePath(yyString); + text = QDir(incPath).absoluteFilePath(yyWord); if (QFileInfo(text).isFile()) { processInclude(text, cd, inclusions); goto incOk; @@ -1418,14 +1414,14 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) 'class Q_EXPORT QMessageBox', in which case 'QMessageBox' is the class name, not 'Q_EXPORT'. */ - fct = QStringList(yyIdent); + fct = QStringList(yyWord); yyTok = getToken(); } while (yyTok == Tok_Ident); while (yyTok == Tok_ColonColon) { yyTok = getToken(); if (yyTok != Tok_Ident) break; // Oops ... - fct += yyIdent; + fct += yyWord; yyTok = getToken(); } if (fct.count() > 1) { @@ -1470,7 +1466,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) yyTokColonSeen = false; yyTok = getToken(); if (yyTok == Tok_Ident) { - QString ns = yyIdent; + QString ns = yyWord; yyTok = getToken(); if (yyTok == Tok_LeftBrace) { namespaceDepths.push(namespaces.count()); @@ -1484,7 +1480,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { if (yyTok == Tok_Ident) - fullName.append(yyIdent); + fullName.append(yyWord); yyTok = getToken(); } if (fullName.isEmpty()) @@ -1510,7 +1506,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { if (yyTok == Tok_Ident) - fullName.append(yyIdent); + fullName.append(yyWord); yyTok = getToken(); } NamespaceList nsl; @@ -1525,7 +1521,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { if (yyTok == Tok_Ident) - fullName.append(yyIdent); + fullName.append(yyWord); yyTok = getToken(); } if (fullName.isEmpty()) @@ -1722,7 +1718,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) yyTok = getToken(); break; case Tok_Ident: - prefix += yyIdent; + prefix += yyWord; yyTok = getToken(); if (yyTok != Tok_ColonColon) { prefix.clear(); @@ -1733,24 +1729,24 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) case Tok_Comment: if (!results->tor) goto case_default; - if (yyComment.startsWith(QLatin1Char(':'))) { - yyComment.remove(0, 1); - extracomment.append(yyComment); - } else if (yyComment.startsWith(QLatin1Char('='))) { - yyComment.remove(0, 1); - msgid = yyComment.simplified(); - } else if (yyComment.startsWith(QLatin1Char('~'))) { - yyComment.remove(0, 1); - yyComment = yyComment.trimmed(); - int k = yyComment.indexOf(QLatin1Char(' ')); + if (yyWord.startsWith(QLatin1Char(':'))) { + yyWord.remove(0, 1); + extracomment.append(yyWord); + } else if (yyWord.startsWith(QLatin1Char('='))) { + yyWord.remove(0, 1); + msgid = yyWord.simplified(); + } else if (yyWord.startsWith(QLatin1Char('~'))) { + yyWord.remove(0, 1); + yyWord = yyWord.trimmed(); + int k = yyWord.indexOf(QLatin1Char(' ')); if (k > -1) - extra.insert(yyComment.left(k), yyComment.mid(k + 1).trimmed()); - } else if (yyComment.startsWith(QLatin1Char('%'))) { + extra.insert(yyWord.left(k), yyWord.mid(k + 1).trimmed()); + } else if (yyWord.startsWith(QLatin1Char('%'))) { int p = 1, c; forever { - if (p >= yyComment.length()) + if (p >= yyWord.length()) break; - c = yyComment.unicode()[p++].unicode(); + c = yyWord.unicode()[p++].unicode(); if (isspace(c)) continue; if (c != '"') { @@ -1759,19 +1755,19 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) break; } forever { - if (p >= yyComment.length()) { + if (p >= yyWord.length()) { whoops: qWarning("%s:%d: Unterminated meta string\n", qPrintable(yyFileName), yyLineNo); break; } - c = yyComment.unicode()[p++].unicode(); + c = yyWord.unicode()[p++].unicode(); if (c == '"') break; if (c == '\\') { - if (p >= yyComment.length()) + if (p >= yyWord.length()) goto whoops; - c = yyComment.unicode()[p++].unicode(); + c = yyWord.unicode()[p++].unicode(); if (c == '\n') goto whoops; sourcetext.append(QLatin1Char('\\')); @@ -1780,7 +1776,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) } } } else { - comment = yyComment.simplified(); + comment = yyWord.simplified(); if (comment.startsWith(QLatin1String(MagicComment))) { comment.remove(0, sizeof(MagicComment) - 1); int k = comment.indexOf(QLatin1Char(' ')); @@ -1812,7 +1808,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) yyTok = getToken(); #ifdef DIAGNOSE_RETRANSLATABILITY if (yyTok == Tok_Ident && yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) - functionName = yyIdent; + functionName = yyWord; #endif break; case Tok_RightBrace: -- cgit v0.12 From 5f2c869e787160f94bd08faf8b625458e2ceb3a7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Aug 2009 21:05:54 +0200 Subject: optimize getToken(), part 2: avoid QString::append() --- tools/linguist/lupdate/cpp.cpp | 90 +++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 0191393..e929c0d 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -371,7 +371,9 @@ STRING(using); uint CppParser::getToken() { restart: - yyWord.clear(); + // Failing this assertion would mean losing the preallocated buffer. + Q_ASSERT(yyWord.isDetached()); + yyWord.resize(0); while (yyCh != EOF) { yyLineNo = yyCurLineNo; @@ -470,6 +472,7 @@ uint CppParser::getToken() tChar = '>'; else break; + ushort *ptr = (ushort *)yyWord.unicode(); forever { yyCh = getChar(); if (yyCh == EOF || yyCh == '\n') @@ -478,8 +481,9 @@ uint CppParser::getToken() yyCh = getChar(); break; } - yyWord += yyCh; + *ptr++ = yyCh; } + yyWord.resize(ptr - (ushort *)yyWord.unicode()); return (tChar == '"') ? Tok_QuotedInclude : Tok_AngledInclude; } break; @@ -558,10 +562,12 @@ uint CppParser::getToken() } while (yyCh != '\n' && yyCh != EOF); yyCh = getChar(); } else if (isalpha(yyCh) || yyCh == '_') { + ushort *ptr = (ushort *)yyWord.unicode(); do { - yyWord += yyCh; + *ptr++ = yyCh; yyCh = getChar(); } while (isalnum(yyCh) || yyCh == '_'); + yyWord.resize(ptr - (ushort *)yyWord.unicode()); //qDebug() << "IDENT: " << yyWord; @@ -650,14 +656,17 @@ uint CppParser::getToken() case '/': yyCh = getChar(); if (yyCh == '/') { + ushort *ptr = (ushort *)yyWord.unicode() + yyWord.length(); do { yyCh = getChar(); if (yyCh == EOF) break; - yyWord.append(yyCh); + *ptr++ = yyCh; } while (yyCh != '\n'); + yyWord.resize(ptr - (ushort *)yyWord.unicode()); } else if (yyCh == '*') { bool metAster = false; + ushort *ptr = (ushort *)yyWord.unicode() + yyWord.length(); forever { yyCh = getChar(); @@ -666,7 +675,7 @@ uint CppParser::getToken() qPrintable(yyFileName), yyLineNo); return Tok_Comment; } - yyWord.append(yyCh); + *ptr++ = yyCh; if (yyCh == '*') metAster = true; @@ -675,22 +684,25 @@ uint CppParser::getToken() else metAster = false; } + yyWord.resize(ptr - (ushort *)yyWord.unicode() - 2); + yyCh = getChar(); - yyWord.chop(2); } return Tok_Comment; - case '"': + case '"': { + ushort *ptr = (ushort *)yyWord.unicode() + yyWord.length(); yyCh = getChar(); while (yyCh != EOF && yyCh != '\n' && yyCh != '"') { if (yyCh == '\\') { yyCh = getChar(); if (yyCh == EOF || yyCh == '\n') break; - yyWord.append(QLatin1Char('\\')); + *ptr++ = '\\'; } - yyWord.append(yyCh); + *ptr++ = yyCh; yyCh = getChar(); } + yyWord.resize(ptr - (ushort *)yyWord.unicode()); if (yyCh != '"') qWarning("%s:%d: Unterminated C++ string\n", @@ -698,6 +710,7 @@ uint CppParser::getToken() else yyCh = getChar(); return Tok_String; + } case '-': yyCh = getChar(); if (yyCh == '>') { @@ -1167,6 +1180,7 @@ bool CppParser::matchString(QString *s) s->clear(); while (yyTok == Tok_String) { *s += yyWord; + s->detach(); do { yyTok = getToken(); } while (yyTok == Tok_Comment); @@ -1360,6 +1374,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) bool utf8; bool yyTokColonSeen = false; // Start of c'tor's initializer list + yyWord.reserve(yyInStr.size()); // Rather insane. That's because we do no length checking. yyCh = getChar(); yyTok = getToken(); while (yyTok != Tok_Eof) { @@ -1367,6 +1382,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) switch (yyTok) { case Tok_QuotedInclude: { text = QDir(QFileInfo(yyFileName).absolutePath()).absoluteFilePath(yyWord); + text.detach(); if (QFileInfo(text).isFile()) { processInclude(text, cd, inclusions); yyTok = getToken(); @@ -1383,6 +1399,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) } foreach (const QString &incPath, cd.m_includePath) { text = QDir(incPath).absoluteFilePath(yyWord); + text.detach(); if (QFileInfo(text).isFile()) { processInclude(text, cd, inclusions); goto incOk; @@ -1414,14 +1431,18 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) 'class Q_EXPORT QMessageBox', in which case 'QMessageBox' is the class name, not 'Q_EXPORT'. */ - fct = QStringList(yyWord); + text = yyWord; + text.detach(); + fct = QStringList(text); yyTok = getToken(); } while (yyTok == Tok_Ident); while (yyTok == Tok_ColonColon) { yyTok = getToken(); if (yyTok != Tok_Ident) break; // Oops ... - fct += yyWord; + text = yyWord; + text.detach(); + fct += text; yyTok = getToken(); } if (fct.count() > 1) { @@ -1467,6 +1488,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) yyTok = getToken(); if (yyTok == Tok_Ident) { QString ns = yyWord; + ns.detach(); yyTok = getToken(); if (yyTok == Tok_LeftBrace) { namespaceDepths.push(namespaces.count()); @@ -1479,8 +1501,11 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) if (yyTok == Tok_ColonColon) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { - if (yyTok == Tok_Ident) - fullName.append(yyWord); + if (yyTok == Tok_Ident) { + text = yyWord; + text.detach(); + fullName.append(text); + } yyTok = getToken(); } if (fullName.isEmpty()) @@ -1505,8 +1530,11 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) if (yyTok == Tok_ColonColon) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { - if (yyTok == Tok_Ident) - fullName.append(yyWord); + if (yyTok == Tok_Ident) { + text = yyWord; + text.detach(); + fullName.append(text); + } yyTok = getToken(); } NamespaceList nsl; @@ -1520,8 +1548,11 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) if (yyTok == Tok_ColonColon) fullName.append(QString()); while (yyTok == Tok_ColonColon || yyTok == Tok_Ident) { - if (yyTok == Tok_Ident) - fullName.append(yyWord); + if (yyTok == Tok_Ident) { + text = yyWord; + text.detach(); + fullName.append(text); + } yyTok = getToken(); } if (fullName.isEmpty()) @@ -1719,6 +1750,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) break; case Tok_Ident: prefix += yyWord; + prefix.detach(); yyTok = getToken(); if (yyTok != Tok_ColonColon) { prefix.clear(); @@ -1731,17 +1763,22 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) goto case_default; if (yyWord.startsWith(QLatin1Char(':'))) { yyWord.remove(0, 1); - extracomment.append(yyWord); + extracomment += yyWord; + extracomment.detach(); } else if (yyWord.startsWith(QLatin1Char('='))) { yyWord.remove(0, 1); msgid = yyWord.simplified(); + msgid.detach(); } else if (yyWord.startsWith(QLatin1Char('~'))) { yyWord.remove(0, 1); - yyWord = yyWord.trimmed(); - int k = yyWord.indexOf(QLatin1Char(' ')); + text = yyWord.trimmed(); + int k = text.indexOf(QLatin1Char(' ')); if (k > -1) - extra.insert(yyWord.left(k), yyWord.mid(k + 1).trimmed()); + extra.insert(text.left(k), text.mid(k + 1).trimmed()); + text.clear(); } else if (yyWord.startsWith(QLatin1Char('%'))) { + sourcetext.reserve(sourcetext.length() + yyWord.length()); + ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); int p = 1, c; forever { if (p >= yyWord.length()) @@ -1770,11 +1807,12 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) c = yyWord.unicode()[p++].unicode(); if (c == '\n') goto whoops; - sourcetext.append(QLatin1Char('\\')); + *ptr++ = '\\'; } - sourcetext.append(c); + *ptr++ = c; } } + sourcetext.resize(ptr - (ushort *)sourcetext.data()); } else { comment = yyWord.simplified(); if (comment.startsWith(QLatin1String(MagicComment))) { @@ -1791,6 +1829,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) results->tor->setExtras(extra); extra.clear(); } + } else { + comment.detach(); } } yyTok = getToken(); @@ -1807,8 +1847,10 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) prefix += strColons; yyTok = getToken(); #ifdef DIAGNOSE_RETRANSLATABILITY - if (yyTok == Tok_Ident && yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) + if (yyTok == Tok_Ident && yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) { functionName = yyWord; + functionName.detach(); + } #endif break; case Tok_RightBrace: -- cgit v0.12 From bc6c569b0d5862a159394de831cd129b610715ad Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 13:21:38 -0700 Subject: Fix a bug in wrt DFBWindowSurface's paintEngine Make sure we recreate the paint engine if it's 0 in beginPaint. Also don't delete the paint engine in moves, only resizes. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 17 ++++++----------- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 1 - 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index d837509..57894d5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -55,7 +55,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { @@ -76,7 +75,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { @@ -223,13 +221,14 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) break; } } + if (size() != geometry().size()) { + delete engine; + engine = 0; + } + if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); } - if (engine) { - delete engine; - engine = 0; - } QWSWindowSurface::setGeometry(rect); } @@ -419,12 +418,8 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, void QDirectFBWindowSurface::beginPaint(const QRegion &) { - const int h = height(); - if (h > engineHeight) { - engineHeight = h; - delete engine; + if (!engine) engine = new QDirectFBPaintEngine(this); - } } void QDirectFBWindowSurface::endPaint(const QRegion &) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 0d6ebc0..396cc32 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -91,7 +91,6 @@ private: void createWindow(); IDirectFBWindow *dfbWindow; #endif - int engineHeight; enum Mode { Primary, -- cgit v0.12 From ab4c3e1c2948c2edf078db4c1992848307b0c78e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 12:24:56 -0700 Subject: Clean up primary surface handling in DFB To avoid confusion rename QDirectFBScreen::dfbSurface() primarySurface() since this is what it is. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 48 +++++++++++----------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 +- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 4 +- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index a1edbd6..c54c1c6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -64,7 +64,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; IDirectFB *dfb; - IDirectFBSurface *dfbSurface; + IDirectFBSurface *primarySurface; DFBSurfaceFlipFlags flipFlags; #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbLayer; @@ -86,7 +86,7 @@ public: }; QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) - : QWSGraphicsSystem(qptr), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) + : QWSGraphicsSystem(qptr), dfb(0), primarySurface(0), flipFlags(DSFLIP_NONE) #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) #endif @@ -119,8 +119,8 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() (*it)->Release(*it); } - if (dfbSurface) - dfbSurface->Release(dfbSurface); + if (primarySurface) + primarySurface->Release(primarySurface); #ifndef QT_NO_DIRECTFB_LAYER if (dfbLayer) @@ -366,9 +366,9 @@ IDirectFB *QDirectFBScreen::dfb() return d_ptr->dfb; } -IDirectFBSurface *QDirectFBScreen::dfbSurface() +IDirectFBSurface *QDirectFBScreen::primarySurface() { - return d_ptr->dfbSurface; + return d_ptr->primarySurface; } #ifndef QT_NO_DIRECTFB_LAYER @@ -952,15 +952,15 @@ bool QDirectFBScreen::connect(const QString &displaySpec) } // We don't track the primary surface as it's released in disconnect - d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface); - if (!d_ptr->dfbSurface) { + d_ptr->primarySurface = createDFBSurface(description, DontTrackSurface); + if (!d_ptr->primarySurface) { DirectFBError("QDirectFBScreen: error creating primary surface", result); return false; } // Work out what format we're going to use for surfaces with an alpha channel - d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface); + d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->primarySurface); setPixelFormat(d_ptr->alphaPixmapFormat); switch (d_ptr->alphaPixmapFormat) { case QImage::Format_RGB666: @@ -994,7 +994,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) // works already break; } - d_ptr->dfbSurface->GetSize(d_ptr->dfbSurface, &w, &h); + d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h); data = 0; lstep = 0; @@ -1003,14 +1003,12 @@ bool QDirectFBScreen::connect(const QString &displaySpec) dh = h; DFBSurfacePixelFormat format; - result = d_ptr->dfbSurface->GetPixelFormat(d_ptr->dfbSurface, &format); + result = d_ptr->primarySurface->GetPixelFormat(d_ptr->primarySurface, &format); if (result == DFB_OK) QScreen::d = depth(format); else DirectFBError("QDirectFBScreen: error getting surface format", result); - setPixelFormat(getImageFormat(d_ptr->dfbSurface)); - physWidth = physHeight = -1; ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); @@ -1042,7 +1040,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) #if (Q_DIRECTFB_VERSION >= 0x000923) if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) - printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface); + printDirectFBInfo(d_ptr->dfb, d_ptr->primarySurface); #endif QRegExp backgroundColorRegExp("bgcolor=?(.+)"); @@ -1058,8 +1056,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) void QDirectFBScreen::disconnect() { - d_ptr->dfbSurface->Release(d_ptr->dfbSurface); - d_ptr->dfbSurface = 0; + d_ptr->primarySurface->Release(d_ptr->primarySurface); + d_ptr->primarySurface = 0; foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces) surf->Release(surf); @@ -1207,7 +1205,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) const DFBRectangle rect = { source.x(), source.y(), source.width(), source.height() }; - d_ptr->dfbSurface->Blit(d_ptr->dfbSurface, surface, &rect, + d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, &rect, windowGeometry.x() + source.x(), windowGeometry.y() + source.y()); } else { @@ -1225,7 +1223,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) dfbPoints[i].x = (windowGeometry.x() + source.x()); dfbPoints[i].y = (windowGeometry.y() + source.y()); } - d_ptr->dfbSurface->BatchBlit(d_ptr->dfbSurface, surface, dfbRectangles.constData(), + d_ptr->primarySurface->BatchBlit(d_ptr->primarySurface, surface, dfbRectangles.constData(), dfbPoints.constData(), n); } } @@ -1237,15 +1235,15 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) if (cursor->isVisible() && !cursor->isAccelerated() && cursorRectangle.intersects(brect)) { const QImage image = cursor->image(); IDirectFBSurface *surface = createDFBSurface(image, QDirectFBScreen::DontTrackSurface); - d_ptr->dfbSurface->SetBlittingFlags(d_ptr->dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); - d_ptr->dfbSurface->Blit(d_ptr->dfbSurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); + d_ptr->primarySurface->SetBlittingFlags(d_ptr->primarySurface, DSBLIT_BLEND_ALPHACHANNEL); + d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); surface->Release(surface); #if (Q_DIRECTFB_VERSION >= 0x010000) - d_ptr->dfbSurface->ReleaseSource(d_ptr->dfbSurface); + d_ptr->primarySurface->ReleaseSource(d_ptr->primarySurface); #endif } } - flipSurface(d_ptr->dfbSurface, d_ptr->flipFlags, r, QPoint()); + flipSurface(d_ptr->primarySurface, d_ptr->flipFlags, r, QPoint()); } void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) @@ -1253,13 +1251,13 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) if (region.isEmpty()) return; - d_ptr->dfbSurface->SetColor(d_ptr->dfbSurface, + d_ptr->primarySurface->SetColor(d_ptr->primarySurface, color.red(), color.green(), color.blue(), color.alpha()); const int n = region.numRects(); if (n > 1) { const QRect r = region.boundingRect(); - d_ptr->dfbSurface->FillRectangle(d_ptr->dfbSurface, r.x(), r.y(), r.width(), r.height()); + d_ptr->primarySurface->FillRectangle(d_ptr->primarySurface, r.x(), r.y(), r.width(), r.height()); } else { const QVector rects = region.rects(); QVarLengthArray rectArray(n); @@ -1270,7 +1268,7 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) rectArray[i].w = r.width(); rectArray[i].h = r.height(); } - d_ptr->dfbSurface->FillRectangles(d_ptr->dfbSurface, rectArray.constData(), n); + d_ptr->primarySurface->FillRectangles(d_ptr->primarySurface, rectArray.constData(), n); } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 78765ac..c7e6cca 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -108,7 +108,7 @@ public: } IDirectFB *dfb(); - IDirectFBSurface *dfbSurface(); + IDirectFBSurface *primarySurface(); #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbDisplayLayer(); #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 57894d5..55d6466 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -170,7 +170,7 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const void QDirectFBWindowSurface::setGeometry(const QRect &rect) { - IDirectFBSurface *primarySurface = screen->dfbSurface(); + IDirectFBSurface *primarySurface = screen->primarySurface(); Q_ASSERT(primarySurface); if (rect.isNull()) { #ifndef QT_NO_DIRECTFB_WM @@ -348,7 +348,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, } const QRect windowGeometry = QDirectFBWindowSurface::geometry(); - IDirectFBSurface *primarySurface = screen->dfbSurface(); + IDirectFBSurface *primarySurface = screen->primarySurface(); if (mode == Offscreen) { primarySurface->SetBlittingFlags(primarySurface, DSBLIT_NOFX); const QRect windowRect(0, 0, windowGeometry.width(), windowGeometry.height()); -- cgit v0.12 From 469c79c72dcac4e2306682c8c2a650c5e6a74d3d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 13:30:12 -0700 Subject: Clean up DirectFB defines Make QT_DIRECTFB_WM be defined if QT_NO_DIRECTFB_WM is not. This makes it possible to write more readable code. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index c7e6cca..a95708b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -50,6 +50,31 @@ QT_BEGIN_HEADER QT_MODULE(Gui) +#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER +#define QT_DIRECTFB_LAYER +#endif +#if !defined QT_NO_DIRECTFB_WM && !defined QT_DIRECTFB_WM +#define QT_DIRECTFB_WM +#endif +#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE +#define QT_NO_DIRECTFB_IMAGECACHE +#endif +#if !defined QT_NO_DIRECTFB_PALETTE && !defined QT_DIRECTFB_PALETTE +#define QT_DIRECTFB_PALETTE +#endif +#if !defined QT_NO_DIRECTFB_PREALLOCATED && !defined QT_DIRECTFB_PREALLOCATED +#define QT_DIRECTFB_PREALLOCATED +#endif +#if !defined QT_NO_DIRECTFB_MOUSE && !defined QT_DIRECTFB_MOUSE +#define QT_DIRECTFB_MOUSE +#endif +#if !defined QT_NO_DIRECTFB_KEYBOARD && !defined QT_DIRECTFB_KEYBOARD +#define QT_DIRECTFB_KEYBOARD +#endif +#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION +#define QT_DIRECTFB_OPAQUE_DETECTION +#endif + #define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERION << 8) | DIRECTFB_MICRO_VERSION) #define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \ -- cgit v0.12 From f844d3905e80194be7d56cbb631ae31ef36f29f8 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 13:34:36 -0700 Subject: Clean up DirectFB with WM enabled When we have proper window manager support from DirectFB we shouldn't create our own primary surface. This patch vastly cleans up a number of issues in QDirectFBScreen regarding this. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 146 ++++++++++++++------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 + .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 46 ++++--- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 5 +- 4 files changed, 123 insertions(+), 76 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index c54c1c6..774162c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -64,13 +64,16 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; IDirectFB *dfb; - IDirectFBSurface *primarySurface; DFBSurfaceFlipFlags flipFlags; + QDirectFBScreen::DirectFBFlags directFBFlags; + QImage::Format alphaPixmapFormat; + IDirectFBScreen *dfbScreen; +#ifdef QT_NO_DIRECTFB_WM + IDirectFBSurface *primarySurface; +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbLayer; #endif - IDirectFBScreen *dfbScreen; - QSet allocatedSurfaces; #ifndef QT_NO_DIRECTFB_MOUSE @@ -79,26 +82,26 @@ public: #ifndef QT_NO_DIRECTFB_KEYBOARD QDirectFBKeyboardHandler *keyboard; #endif - QDirectFBScreen::DirectFBFlags directFBFlags; - QImage::Format alphaPixmapFormat; QColor backgroundColor; QDirectFBScreen *q; }; QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) - : QWSGraphicsSystem(qptr), dfb(0), primarySurface(0), flipFlags(DSFLIP_NONE) + : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE), + directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid), + dfbScreen(0) +#ifdef QT_NO_DIRECTFB_WM + , primarySurface(0) +#endif #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) #endif - , dfbScreen(0) #ifndef QT_NO_DIRECTFB_MOUSE , mouse(0) #endif #ifndef QT_NO_DIRECTFB_KEYBOARD , keyboard(0) #endif - , directFBFlags(QDirectFBScreen::NoFlags) - , alphaPixmapFormat(QImage::Format_Invalid) , q(qptr) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -119,8 +122,10 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() (*it)->Release(*it); } +#ifdef QT_NO_DIRECTFB_WM if (primarySurface) primarySurface->Release(primarySurface); +#endif #ifndef QT_NO_DIRECTFB_LAYER if (dfbLayer) @@ -366,10 +371,12 @@ IDirectFB *QDirectFBScreen::dfb() return d_ptr->dfb; } +#ifdef QT_NO_DIRECTFB_WM IDirectFBSurface *QDirectFBScreen::primarySurface() { return d_ptr->primarySurface; } +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer() @@ -863,6 +870,36 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var return false; } +static inline int depth(QImage::Format format) +{ + switch (format) { + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + return 1; + case QImage::Format_Indexed8: + return 8; + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + case QImage::Format_ARGB32_Premultiplied: + return 32; + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_RGB666: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_RGB888: + return 24; + case QImage::Format_RGB555: + case QImage::Format_RGB444: + case QImage::Format_RGB16: + case QImage::Format_ARGB4444_Premultiplied: + return 16; + case QImage::Format_Invalid: + case QImage::NImageFormats: + break; + } + return -1; +} + bool QDirectFBScreen::connect(const QString &displaySpec) { DFBResult result = DFB_OK; @@ -923,7 +960,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) DFBSurfaceDescription description; memset(&description, 0, sizeof(DFBSurfaceDescription)); + IDirectFBSurface *surface; +#ifdef QT_NO_DIRECTFB_WM description.flags = DSDESC_CAPS; if (::setIntOption(displayArgs, QLatin1String("width"), &description.width)) description.flags |= DSDESC_WIDTH; @@ -959,8 +998,15 @@ bool QDirectFBScreen::connect(const QString &displaySpec) return false; } + surface = d_ptr->primarySurface; +#else + description.flags = DSDESC_WIDTH|DSDESC_HEIGHT; + description.width = description.height = 1; + surface = createDFBSurface(description, DontTrackSurface); +#endif // Work out what format we're going to use for surfaces with an alpha channel - d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->primarySurface); + d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(surface); + setPixelFormat(d_ptr->alphaPixmapFormat); switch (d_ptr->alphaPixmapFormat) { case QImage::Format_RGB666: @@ -994,29 +1040,11 @@ bool QDirectFBScreen::connect(const QString &displaySpec) // works already break; } - d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h); + QScreen::d = ::depth(pixelFormat()); data = 0; lstep = 0; size = 0; - dw = w; - dh = h; - - DFBSurfacePixelFormat format; - result = d_ptr->primarySurface->GetPixelFormat(d_ptr->primarySurface, &format); - if (result == DFB_OK) - QScreen::d = depth(format); - else - DirectFBError("QDirectFBScreen: error getting surface format", result); - - physWidth = physHeight = -1; - ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); - ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); - const int dpi = 72; - if (physWidth < 0) - physWidth = qRound(dw * 25.4 / dpi); - if (physHeight < 0) - physHeight = qRound(dh * 25.4 / dpi); #ifndef QT_NO_DIRECTFB_LAYER result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, DLID_PRIMARY, @@ -1035,12 +1063,35 @@ bool QDirectFBScreen::connect(const QString &displaySpec) "Unable to get screen!", result); return false; } + result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::connect: " + "Unable to get screen size!", result); + return false; + } + + dw = w; + dh = h; + + Q_ASSERT(dw != 0 && dh != 0); + + physWidth = physHeight = -1; + ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); + ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); + const int dpi = 72; + if (physWidth < 0) + physWidth = qRound(dw * 25.4 / dpi); + if (physHeight < 0) + physHeight = qRound(dh * 25.4 / dpi); setGraphicsSystem(d_ptr); #if (Q_DIRECTFB_VERSION >= 0x000923) if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) - printDirectFBInfo(d_ptr->dfb, d_ptr->primarySurface); + printDirectFBInfo(d_ptr->dfb, surface); +#endif +#ifndef QT_NO_DIRECTFB_WM + surface->Release(surface); #endif QRegExp backgroundColorRegExp("bgcolor=?(.+)"); @@ -1056,8 +1107,10 @@ bool QDirectFBScreen::connect(const QString &displaySpec) void QDirectFBScreen::disconnect() { +#ifdef QT_NO_DIRECTFB_WM d_ptr->primarySurface->Release(d_ptr->primarySurface); d_ptr->primarySurface = 0; +#endif foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces) surf->Release(surf); @@ -1153,25 +1206,9 @@ QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const // QT_NO_DIRECTFB_WM isn't set), exposeRegion will simply return. If // QT_NO_DIRECTFB_WM is set, exposeRegion will compose only non-directFB // window surfaces. Normal, directFB surfaces are handled by DirectFB. -static inline bool needExposeRegion() -{ -#ifdef QT_NO_DIRECTFB_WM - return true; -#endif -#ifdef QT_NO_DIRECTFB_LAYER -#ifndef QT_NO_QWS_CURSOR - return true; -#endif -#endif - return false; -} - void QDirectFBScreen::exposeRegion(QRegion r, int changing) { - if (!needExposeRegion()) { - return; - } - +#ifdef QT_NO_DIRECTFB_WM const QList windows = QWSServer::instance()->clientWindows(); if (changing < 0 || changing >= windows.size()) return; @@ -1206,8 +1243,8 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) source.x(), source.y(), source.width(), source.height() }; d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, &rect, - windowGeometry.x() + source.x(), - windowGeometry.y() + source.y()); + windowGeometry.x() + source.x(), + windowGeometry.y() + source.y()); } else { const QVector rects = insideWindow.rects(); QVarLengthArray dfbRectangles(n); @@ -1224,7 +1261,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) dfbPoints[i].y = (windowGeometry.y() + source.y()); } d_ptr->primarySurface->BatchBlit(d_ptr->primarySurface, surface, dfbRectangles.constData(), - dfbPoints.constData(), n); + dfbPoints.constData(), n); } } } @@ -1244,10 +1281,18 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) } } flipSurface(d_ptr->primarySurface, d_ptr->flipFlags, r, QPoint()); +#else + Q_UNUSED(r); + Q_UNUSED(changing); +#endif } void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) { +#ifdef QT_DIRECTFB_WM + Q_UNUSED(color); + Q_UNUSED(region); +#else if (region.isEmpty()) return; @@ -1270,6 +1315,7 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) } d_ptr->primarySurface->FillRectangles(d_ptr->primarySurface, rectArray.constData(), n); } +#endif } void QDirectFBScreen::erase(const QRegion ®ion) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index a95708b..3f9248e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -133,7 +133,9 @@ public: } IDirectFB *dfb(); +#ifdef QT_NO_DIRECTFB_WM IDirectFBSurface *primarySurface(); +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbDisplayLayer(); #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 55d6466..584f334 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -60,8 +60,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect { #ifdef QT_NO_DIRECTFB_WM mode = Offscreen; -#else - mode = Window; #endif setSurfaceFlags(Opaque | Buffered); #ifdef QT_DIRECTFB_TIMING @@ -78,17 +76,18 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { +#ifdef QT_NO_DIRECTFB_WM if (widget && widget->testAttribute(Qt::WA_PaintOnScreen)) { setSurfaceFlags(Opaque | RegionReserved); mode = Primary; } else { -#ifdef QT_NO_DIRECTFB_WM mode = Offscreen; -#else - mode = Window; -#endif setSurfaceFlags(Opaque | Buffered); } +#else + setSurfaceFlags(Opaque | Buffered); +#endif + #ifdef QT_DIRECTFB_TIMING frames = 0; timer.start(); @@ -170,8 +169,10 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const void QDirectFBWindowSurface::setGeometry(const QRect &rect) { +#ifdef QT_NO_DIRECTFB_WM IDirectFBSurface *primarySurface = screen->primarySurface(); Q_ASSERT(primarySurface); +#endif if (rect.isNull()) { #ifndef QT_NO_DIRECTFB_WM if (dfbWindow) { @@ -180,9 +181,10 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) } #endif if (dfbSurface) { - if (dfbSurface != primarySurface) { +#ifdef QT_NO_DIRECTFB_WM + if (dfbSurface != primarySurface) +#endif dfbSurface->Release(dfbSurface); - } dfbSurface = 0; } } else if (rect != geometry()) { @@ -190,8 +192,12 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) DFBResult result = DFB_OK; // If we're in a resize, the surface shouldn't be locked Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); - switch (mode) { - case Primary: +#ifdef QT_DIRECTFB_WM + if (!dfbWindow) + createWindow(); + ::setGeometry(dfbWindow, oldRect, rect); +#else + if (mode == Primary) { if (dfbSurface && dfbSurface != primarySurface) dfbSurface->Release(dfbSurface); if (rect == screen->region().boundingRect()) { @@ -201,15 +207,7 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) rect.width(), rect.height() }; result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } - break; - case Window: -#ifndef QT_NO_DIRECTFB_WM - if (!dfbWindow) - createWindow(); - ::setGeometry(dfbWindow, oldRect, rect); -#endif - break; - case Offscreen: { + } else { if (!dfbSurface || oldRect.size() != rect.size()) { if (dfbSurface) dfbSurface->Release(dfbSurface); @@ -218,9 +216,8 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) const QRegion region = QRegion(oldRect.isEmpty() ? screen->region() : QRegion(oldRect)).subtracted(rect); screen->erase(region); screen->flipSurface(primarySurface, flipFlags, region, QPoint()); - break; } } - +#endif if (size() != geometry().size()) { delete engine; engine = 0; @@ -348,6 +345,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, } const QRect windowGeometry = QDirectFBWindowSurface::geometry(); +#ifdef QT_NO_DIRECTFB_WM IDirectFBSurface *primarySurface = screen->primarySurface(); if (mode == Offscreen) { primarySurface->SetBlittingFlags(primarySurface, DSBLIT_NOFX); @@ -400,9 +398,9 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, } if (mode == Offscreen) { screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft()); - } else { - screen->flipSurface(dfbSurface, flipFlags, region, offset); - } + } else +#endif + screen->flipSurface(dfbSurface, flipFlags, region, offset); #ifdef QT_DIRECTFB_TIMING enum { Secs = 3 }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 396cc32..64b1920 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -92,11 +92,12 @@ private: IDirectFBWindow *dfbWindow; #endif +#ifdef QT_NO_DIRECTFB_WM enum Mode { Primary, - Offscreen, - Window + Offscreen } mode; +#endif QList bufferImages; DFBSurfaceFlipFlags flipFlags; -- cgit v0.12 From 5bc376247a07a79be4a04bf33b44d4fd85a6ae97 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 17 Aug 2009 15:18:17 -0700 Subject: Compile After 843d2eed0ac10589a01d40bfdf88cb44c6a00b17 qmake didn't compile anymore. Reviewed-by: TrustMe --- qmake/Makefile.unix | 8 ++++---- qmake/Makefile.win32 | 8 ++++---- qmake/Makefile.win32-g++ | 6 +++--- qmake/Makefile.win32-g++-sh | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index dcdc805..57d9fb2 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -13,7 +13,7 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ - qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlistdata.o qfile.o \ + qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfile.o \ qfsfileengine_unix.o qfsfileengine_iterator_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ @@ -53,7 +53,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ - $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ $(SOURCE_PATH)/src/corelib/tools/qvector.cpp $(SOURCE_PATH)/src/corelib/tools/qbitarray.cpp \ $(SOURCE_PATH)/src/corelib/io/qdiriterator.cpp \ $(SOURCE_PATH)/src/corelib/io/qdir.cpp $(SOURCE_PATH)/src/corelib/plugin/quuid.cpp \ @@ -179,8 +179,8 @@ qdatastream.o: $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp qbuffer.o: $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp -qlistdata.o: $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp +qlist.o: $(SOURCE_PATH)/src/corelib/tools/qlist.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlist.cpp qfile.o: $(SOURCE_PATH)/src/corelib/io/qfile.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfile.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 6340814..5ade431 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -102,7 +102,7 @@ QTOBJS= \ qglobal.obj \ qhash.obj \ qiodevice.obj \ - qlistdata.obj \ + qlist.obj \ qlinkedlist.obj \ qlocale.obj \ qmalloc.obj \ @@ -191,7 +191,7 @@ clean:: -del qglobal.obj -del qhash.obj -del qiodevice.obj - -del qlistdata.obj + -del qlist.obj -del qlocale.obj -del qmalloc.obj -del qmap.obj @@ -359,8 +359,8 @@ quuid.obj: $(SOURCE_PATH)\src\corelib\plugin\quuid.cpp qbuffer.obj: $(SOURCE_PATH)\src\corelib\io\qbuffer.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qbuffer.cpp -qlistdata.obj: $(SOURCE_PATH)\src\corelib\tools\qlistdata.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\tools\qlistdata.cpp +qlist.obj: $(SOURCE_PATH)\src\corelib\tools\qlist.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\tools\qlist.cpp qlinkedlist.obj: $(SOURCE_PATH)\src\corelib\tools\qlinkedlist.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\tools\qlinkedlist.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index 9439f40..d7ee81d 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -65,7 +65,7 @@ QTOBJS= \ qhash.o \ qiodevice.o \ qlibraryinfo.o \ - qlistdata.o \ + qlist.o \ qlinkedlist.o \ qlocale.o \ qmalloc.o \ @@ -209,8 +209,8 @@ quuid.o: $(SOURCE_PATH)/src/corelib/plugin/quuid.cpp qbuffer.o: $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp -qlistdata.o: $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp +qlist.o: $(SOURCE_PATH)/src/corelib/tools/qlist.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlist.cpp qlinkedlist.o: $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index a0e981e..07302ea 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -65,7 +65,7 @@ QTOBJS= \ qhash.o \ qiodevice.o \ qlibraryinfo.o \ - qlistdata.o \ + qlist.o \ qlinkedlist.o \ qlocale.o \ qmalloc.o \ @@ -208,8 +208,8 @@ quuid.o: $(SOURCE_PATH)/src/corelib/plugin/quuid.cpp qbuffer.o: $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp -qlistdata.o: $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlistdata.cpp +qlist.o: $(SOURCE_PATH)/src/corelib/tools/qlist.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlist.cpp qlinkedlist.o: $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp -- cgit v0.12 From 4b7e40ac69cbec8fcf9a12d71c3911579247fc4b Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 18 Aug 2009 10:04:58 +1000 Subject: Fixes qmake -tp vc qmake -tp vc (rightfully) borks when it tries to include .pros that it shouldn't be, based upon platform. Reviewed-by: Rohan McGovern --- tests/auto/auto.pro | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 585f461..1ae6913 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -11,8 +11,6 @@ SUBDIRS += \ compilerwarnings \ exceptionsafety \ linguist \ - macgui \ - macplist \ mediaobject \ # mediaobject_wince_ds9 \ This is Windows CE only (we test the second phonon backend ds9 here) moc \ @@ -74,7 +72,6 @@ SUBDIRS += \ qabstractspinbox \ qabstracttextdocumentlayout \ qaccessibility \ - qaccessibility_mac \ qaction \ qactiongroup \ qalgorithms \ @@ -97,7 +94,6 @@ SUBDIRS += \ qcombobox \ qcompleter \ qcomplextext \ - qcopchannel \ qcoreapplication \ qcryptographichash \ qcssparser \ @@ -113,7 +109,6 @@ SUBDIRS += \ qdialog \ qdialogbuttonbox \ qdir \ - qdirectpainter \ qdirmodel \ qdockwidget \ qdom \ @@ -209,7 +204,6 @@ SUBDIRS += \ qmouseevent \ qmouseevent_modal \ qmovie \ - qmultiscreen \ qmutex \ qmutexlocker \ qnativesocketengine \ @@ -349,7 +343,6 @@ SUBDIRS += \ qtextlayout \ qtextlist \ qtextobject \ - qtextpiecetable \ qtextscriptengine \ qtextstream \ qtexttable \ @@ -404,6 +397,19 @@ SUBDIRS += \ utf8 contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter +mac: { + SUBDIRS += macgui \ + macplist \ + qaccessibility_mac +} +embedded: { + SUBDIRS += qcopchannel \ + qdirectpainter \ + qmultiscreen +} +!win32: { + SUBDIRS += qtextpiecetable +} # Enable the tests specific to QtXmlPatterns. If you add a test, remember to # update runQtXmlPatternsTests.sh too. Remember that this file, auto.pro, is -- cgit v0.12 From 9cf688e79f67e531ca9fa548911dfb32ee8c0c71 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 18 Aug 2009 12:23:08 +1000 Subject: Fix typo introduced in previous submit. Reviewed-by: Trust Me --- translations/qt_ar.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/translations/qt_ar.ts b/translations/qt_ar.ts index 3e7a635..9631883 100644 --- a/translations/qt_ar.ts +++ b/translations/qt_ar.ts @@ -3024,7 +3024,8 @@ Do you want to delete it anyway? Hide Details... - .nokiassage> + + <h3>About Qt</h3><p>This program uses Qt version %1.</p><p>Qt is a C++ toolkit for cross-platform application development.</p><p>Qt provides single-source portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. Qt is also available for embedded devices as Qt for Embedded Linux and Qt for Windows CE.</p><p>Qt is available under three different licensing options designed to accommodate the needs of our various users.</p>Qt licensed under our commercial license agreement is appropriate for development of proprietary/commercial software where you do not want to share any source code with third parties or otherwise cannot comply with the terms of the GNU LGPL version 2.1 or GNU GPL version 3.0.</p><p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the development of Qt applications (proprietary or open source) provided you can comply with the terms and conditions of the GNU LGPL version 2.1.</p><p>Qt licensed under the GNU General Public License version 3.0 is appropriate for the development of Qt applications where you wish to use such applications in combination with software subject to the terms of the GNU GPL version 3.0 or where you are otherwise willing to comply with the terms of the GNU GPL version 3.0.</p><p>Please see <a href="http://qt.nokia.com/products/licensing">qt.nokia.com/products/licensing</a> for an overview of Qt licensing.</p><p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p><p>Qt is a Nokia product. See <a href="http://qt.nokia.com/">qt.nokia.com</a> for more information.</p> -- cgit v0.12 From d35265496a02db5f213a18e610ad736fe357c26d Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 18 Aug 2009 12:43:58 +1000 Subject: Remove mentions of qtsoftware added by merge of doc branch. Reviewed-by: Trust Me --- doc/src/frameworks-technologies/gestures.qdoc | 2 +- doc/src/xml-processing/xml-processing.qdoc | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index 49a9ae3..316d74d 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -34,7 +34,7 @@ ** 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://www.qtsoftware.com/contact. +** contact the sales department at http://www.example.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/doc/src/xml-processing/xml-processing.qdoc b/doc/src/xml-processing/xml-processing.qdoc index 44c5450..6e48515 100644 --- a/doc/src/xml-processing/xml-processing.qdoc +++ b/doc/src/xml-processing/xml-processing.qdoc @@ -121,18 +121,18 @@ Before we can apply a namespace to element or attribute names we must declare it. - Namespaces are URIs like \e http://www.qtsoftware.com/fnord/book/. This + Namespaces are URIs like \e http://www.example.com/fnord/book/. This does not mean that data must be available at this address; the URI is simply used to provide a unique name. We declare namespaces in the same way as attributes; strictly speaking they \e are attributes. To make for example \e - http://www.qtsoftware.com/fnord/ the document's default XML namespace \e + http://www.example.com/fnord/ the document's default XML namespace \e xmlns we write \snippet doc/src/snippets/code/doc_src_qtxml.qdoc 8 - To distinguish the \e http://www.qtsoftware.com/fnord/book/ namespace from + To distinguish the \e http://www.example.com/fnord/book/ namespace from the default, we must supply it with a prefix: \snippet doc/src/snippets/code/doc_src_qtxml.qdoc 9 @@ -159,12 +159,12 @@ \snippet doc/src/snippets/code/doc_src_qtxml.qdoc 10 Within the \e document element we have two namespaces declared. The - default namespace \e http://www.qtsoftware.com/fnord/ applies to the \e + default namespace \e http://www.example.com/fnord/ applies to the \e book element, the \e chapter element, the appropriate \e title element and of course to \e document itself. The \e book:author and \e book:title elements belong to the namespace - with the URI \e http://www.qtsoftware.com/fnord/book/. + with the URI \e http://www.example.com/fnord/book/. The two \e book:author attributes \e title and \e name have no XML namespace assigned. They are only members of the "traditional" @@ -172,7 +172,7 @@ \e title attributes in \e book:author are forbidden. In the above example we circumvent the last rule by adding a \e title - attribute from the \e http://www.qtsoftware.com/fnord/ namespace to \e + attribute from the \e http://www.example.com/fnord/ namespace to \e book:author: the \e fnord:title comes from the namespace with the prefix \e fnord that is declared in the \e book:author element. @@ -212,7 +212,7 @@ local part of \e book:title.) \o The \e {namespace URI} ("Uniform Resource Identifier") is a unique identifier for a namespace. It looks like a URL - (e.g. \e http://www.qtsoftware.com/fnord/ ) but does not require + (e.g. \e http://www.example.com/fnord/ ) but does not require data to be accessible by the given protocol at the named address. \endlist -- cgit v0.12 From 8b4539770da00ec98820352fcce89bd6d843f51d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 18 Aug 2009 13:25:53 +1000 Subject: Optimize QMatrix4x4::rotate() for 0, 90, 180, 270 degrees. Reviewed-by: Sarah Smith --- src/gui/math3d/qmatrix4x4.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index dc17eda..8fc439b 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1010,11 +1010,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector) */ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z) { + if (angle == 0.0f) + return *this; QMatrix4x4 m(1); // The "1" says to not load the identity. - qreal a = angle * M_PI / 180.0f; - qreal c = qCos(a); - qreal s = qSin(a); - qreal ic; + qreal c, s, ic; + if (angle == 90.0f || angle == -270.0f) { + s = 1.0f; + c = 0.0f; + } else if (angle == -90.0f || angle == 270.0f) { + s = -1.0f; + c = 0.0f; + } else if (angle == 180.0f || angle == -180.0f) { + s = 0.0f; + c = -1.0f; + } else { + qreal a = angle * M_PI / 180.0f; + c = qCos(a); + s = qSin(a); + } bool quick = false; if (x == 0.0f) { if (y == 0.0f) { -- cgit v0.12 From 1ddf4ae979e3b573f45a99ac92838e098dfc8e45 Mon Sep 17 00:00:00 2001 From: Stian Sandvik Thomassen Date: Tue, 18 Aug 2009 14:59:57 +1000 Subject: Doc: sorted list correctly for qLess() documentation --- doc/src/snippets/code/doc_src_qalgorithms.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/code/doc_src_qalgorithms.qdoc b/doc/src/snippets/code/doc_src_qalgorithms.qdoc index 69d943c..e2126dd 100644 --- a/doc/src/snippets/code/doc_src_qalgorithms.qdoc +++ b/doc/src/snippets/code/doc_src_qalgorithms.qdoc @@ -302,7 +302,7 @@ list.clear(); QList list; list << 33 << 12 << 68 << 6 << 12; qSort(list.begin(), list.end(), qLess()); -// list: [ 68, 33, 12, 12, 6 ] +// list: [ 6, 12, 12, 33, 68 ] //! [24] -- cgit v0.12 From 6d9563070a87bc6c0b014b2a40af2e4b6eb1a6f6 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 18 Aug 2009 15:52:10 +1000 Subject: Fold the FAQ.txt file into the known-issues documentation. Reviewed-by: Gareth Pethig --- FAQ.txt | 18 ------------------ doc/src/getting-started/known-issues.qdoc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 18 deletions(-) delete mode 100644 FAQ.txt diff --git a/FAQ.txt b/FAQ.txt deleted file mode 100644 index 1d2266d..0000000 --- a/FAQ.txt +++ /dev/null @@ -1,18 +0,0 @@ -This is a list of Frequently Asked Questions regarding this Qt release. - -Q: I'm using a Unix system and I downloaded the Zip package. However, when I try -to run the configure script, I get the following error message: -"bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory" -A: The problem here is converting files from Windows style line endings (CRLF) -to Unix style line endings (LF). To avoid this problem, uncompress the file -again and give the option "-a" to unzip, which will then add the correct line -endings. - -Q: I'm running Windows XP and I downloaded the qt-win-eval-%VERSION%-vs2008.exe -version of Qt. However, when I try to run the examples I get an error saying: -"The application failed to start because the application configuration is -incorrect. Reinstalling the application may fix this problem.". I reinstalled -the package but the error persists. What am I doing wrong? -A: The problem is an incorrect version of the CRT. Visual studio requires CRT90 -while Windows XP comes with CRT80. To solve this problem, please install the -2008 CRT redistributable package from Microsoft. diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index 0a94d86..41bdcdf 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -133,6 +133,7 @@ \endlist + \section2 Mac OS X Software Support \list @@ -140,4 +141,34 @@ window will cause it to flash. This behavior has been reported to Apple (bug number 5827676). \endlist + + + \section2 Installing source packages on Unix systems + + \list + \o If you download a Zip source package, you will need to convert + Windows-style line endings (CR/LF) to Unix-style line-endings (LF) when + you uncompress the package. To do this, give the "-a" option when you + run the "unzip' command. + + If you fail to supply the "-a" option when unzipping the package, you + will see the following error message when you attempt to execute the + configure command: + "bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory" + \endlist + + + \section2 Running evaluation packages on Windows XP + + \list + \o If running the qt-win-eval-%VERSION%-vs2008.exe package on a Windows XP + system, you may encounter the following error message: + "The application failed to start because the application configuration + is incorrect. Reinstalling the application may fix this problem.". + + This error occurs because the version of the CRT component on the + system is incorrect. Visual Studio 2008 requires CRT90 while Windows + XP comes with CRT80. To solve this problem, please install the 2008 CRT + redistributable package from Microsoft. + \endlist */ -- cgit v0.12 From fb4a884eb76a67919112f2a389283b1bd6d4848e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 18 Aug 2009 09:11:12 +0200 Subject: Avoid divide by zero on buggy Xlib/Xserver implementations Some X servers seem to report zero physical size, so our DPI calculations would crash with divide-by-zero. Avoid this and just use 72 DPI instead. Task-number: 258319 --- src/gui/kernel/qapplication_x11.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index db349f0..d942519 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1851,10 +1851,20 @@ void qt_init(QApplicationPrivate *priv, int, QX11InfoData *screen = X11->screens + s; screen->ref = 1; // ensures it doesn't get deleted screen->screen = s; - screen->dpiX = (DisplayWidth(X11->display, s) * 254 + DisplayWidthMM(X11->display, s)*5) - / (DisplayWidthMM(X11->display, s)*10); - screen->dpiY = (DisplayHeight(X11->display, s) * 254 + DisplayHeightMM(X11->display, s)*5) - / (DisplayHeightMM(X11->display, s)*10); + + int widthMM = DisplayWidthMM(X11->display, s); + if (widthMM != 0) { + screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5) / (widthMM * 10); + } else { + screen->dpiX = 72; + } + + int heightMM = DisplayHeightMM(X11->display, s); + if (heightMM != 0) { + screen->dpiY = (DisplayHeight(X11->display, s) * 254 + heightMM * 5) / (heightMM * 10); + } else { + screen->dpiY = 72; + } X11->argbVisuals[s] = 0; X11->argbColormaps[s] = 0; -- cgit v0.12 From 0e29b6085233bbd14471c7df466575750841f4d7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 10:01:01 +0200 Subject: Fixed a possible crash in QTextCursor --- src/gui/text/qtextcursor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 88ab9d0..5a938e3 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -84,7 +84,8 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) QTextCursorPrivate::~QTextCursorPrivate() { - priv->removeCursor(this); + if (priv) + priv->removeCursor(this); } QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) -- cgit v0.12 From 9b7a6b231014135d7df0f3675d121c2d76d89e76 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 18 Aug 2009 10:07:11 +0200 Subject: As of Qt 4.6, the minimum OS X version is 10.4. --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 92fe649..40b65fd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -297,7 +297,7 @@ namespace QT_NAMESPACE {} # ifdef MAC_OS_X_VERSION_MIN_REQUIRED # undef MAC_OS_X_VERSION_MIN_REQUIRED # endif -# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3 +# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 # include # if !defined(MAC_OS_X_VERSION_10_3) # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 -- cgit v0.12 From b120ff4f1a479c35b3e5bbcbc3c72cc18ee4879c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 18 Aug 2009 10:31:31 +0200 Subject: tst_QTableView::task259308_scrollVerticalHeaderSwappedSections fails. The QTableView scrolled down after the sections swap. Setting the current index to the topmost visual element fixes the issue. Reviewed-by: Thierry --- tests/auto/qtableview/tst_qtableview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 2f41d77..e650dc8 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3270,6 +3270,7 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections() tv.setModel(&model); tv.show(); tv.verticalHeader()->swapSections(0, model.rowCount() - 1); + tv.setCurrentIndex(model.index(model.rowCount() - 1, 0)); QTest::qWait(60); QTest::keyClick(&tv, Qt::Key_PageUp); // PageUp won't scroll when at top -- cgit v0.12 From 7b58efd28ec66725acf0e42d871859f1a046439a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 18 Aug 2009 08:44:16 +0200 Subject: Speed up midpoint lines starting far outside the device bounds. Reviewed-By: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8b83f02..547818c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -5198,6 +5198,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa dy = -dy; } + int x_lower_limit = - 128; + if (x1 < x_lower_limit) { + int cy = dy * (x_lower_limit - x1) / dx + y1; + drawLine_midpoint_i(x_lower_limit, cy, x2, y2, span_func, data, style, devRect); + return; + } + if (style == LineDrawNormal) --x2; @@ -5335,6 +5342,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa dx = -dx; } + int y_lower_limit = - 128; + if (y1 < y_lower_limit) { + int cx = dx * (y_lower_limit - y1) / dy + x1; + drawLine_midpoint_i(cx, y_lower_limit, x2, y2, span_func, data, style, devRect); + return; + } + if (style == LineDrawNormal) --y2; -- cgit v0.12 From a160bbbed21cea0487410013eea95937be65b3d4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 17 Aug 2009 09:56:21 +0200 Subject: Added support for gestures on Mac OS X Carbon --- src/gui/kernel/qcocoaview_mac.mm | 10 ++--- src/gui/kernel/qeventdispatcher_mac.mm | 2 +- src/gui/kernel/qwidget_mac.mm | 71 +++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 45b0ada..7ac0d89 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -872,7 +872,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.percentage = [event magnification]; - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)rotateWithEvent:(NSEvent *)event; @@ -885,7 +885,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.percentage = [event rotation]; - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)swipeWithEvent:(NSEvent *)event; @@ -898,7 +898,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)beginGestureWithEvent:(NSEvent *)event; @@ -910,7 +910,7 @@ extern "C" { qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)endGestureWithEvent:(NSEvent *)event; @@ -922,7 +922,7 @@ extern "C" { qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index efe6375..113362a 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -500,7 +500,7 @@ static bool IsMouseOrKeyEvent( NSEvent* event ) static inline void qt_mac_waitForMoreEvents() { #ifndef QT_MAC_USE_COCOA - while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut); + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut) ; #else // If no event exist in the cocoa event que, wait // (and free up cpu time) until at least one event occur. diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5bf140c..b13c9eb 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -107,6 +107,7 @@ #include #include "qwidget_p.h" +#include "qevent_p.h" #include "qdnd_p.h" #include @@ -729,7 +730,12 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowGetRegion }, { kEventClassWindow, kEventWindowGetClickModality }, { kEventClassWindow, kEventWindowTransitionCompleted }, - { kEventClassMouse, kEventMouseDown } + { kEventClassMouse, kEventMouseDown }, + { kEventClassGesture, kEventGestureStarted }, + { kEventClassGesture, kEventGestureEnded }, + { kEventClassGesture, kEventGestureMagnify }, + { kEventClassGesture, kEventGestureSwipe }, + { kEventClassGesture, kEventGestureRotate } }; static EventHandlerUPP mac_win_eventUPP = 0; static void cleanup_win_eventUPP() @@ -1013,6 +1019,69 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, return SendEventToApplication(event); handled_event = false; break; } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + case kEventClassGesture: { + // First, find the widget that was under + // the mouse when the gesture happened: + HIPoint screenLocation; + if (GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0, + sizeof(screenLocation), 0, &screenLocation) != noErr) { + handled_event = false; + break; + } + QWidget *widget = QApplication::widgetAt(screenLocation.x, screenLocation.y); + if (!widget) { + handled_event = false; + break; + } + + QNativeGestureEvent qNGEvent; + qNGEvent.position = QPoint(screenLocation.x, screenLocation.y); + + switch (ekind) { + case kEventGestureStarted: + qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; + break; + case kEventGestureEnded: + qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; + break; + case kEventGestureRotate: { + CGFloat amount; + if (GetEventParameter(event, kEventParamRotationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + case kEventGestureSwipe: { + HIPoint swipeDirection; + if (GetEventParameter(event, kEventParamSwipeDirection, typeHIPoint, 0, + sizeof(swipeDirection), 0, &swipeDirection) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Swipe; + qNGEvent.direction = QSize(-swipeDirection.x, -swipeDirection.y); + break; } + case kEventGestureMagnify: { + CGFloat amount; + if (GetEventParameter(event, kEventParamMagnificationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + } + + QApplication::sendSpontaneousEvent(widget, &qNGEvent); + break; } +#endif // gestures + default: handled_event = false; } -- cgit v0.12 From 0f8a326341bd3aab1675acb6b15e011247f7c6f8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 18 Aug 2009 11:19:15 +0200 Subject: Fix build failure on Mac OS 10.5 Gestures only awailable on 10.6 --- src/gui/kernel/qwidget_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b13c9eb..999faeb 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -730,12 +730,14 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowGetRegion }, { kEventClassWindow, kEventWindowGetClickModality }, { kEventClassWindow, kEventWindowTransitionCompleted }, - { kEventClassMouse, kEventMouseDown }, +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 { kEventClassGesture, kEventGestureStarted }, { kEventClassGesture, kEventGestureEnded }, { kEventClassGesture, kEventGestureMagnify }, { kEventClassGesture, kEventGestureSwipe }, - { kEventClassGesture, kEventGestureRotate } + { kEventClassGesture, kEventGestureRotate }, +#endif + { kEventClassMouse, kEventMouseDown } }; static EventHandlerUPP mac_win_eventUPP = 0; static void cleanup_win_eventUPP() -- cgit v0.12 From 610af2bf4d6d57f86ca71c9764b5b03b01aafad8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 11:55:07 +0200 Subject: QHeaderView: assertion when modifying the root iem of a treewidget dataChanged is emitted with invalid model index. We needed to handle that. Reviewed-by: ogoffart --- src/gui/itemviews/qheaderview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index f7b5b6f..4ab81f5 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1195,7 +1195,8 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const { Q_D(const QHeaderView); int visual = visualIndex(logicalIndex); - Q_ASSERT(visual != -1); + if (visual == -1) + return Fixed; //the default value return d->headerSectionResizeMode(visual); } -- cgit v0.12 From 7a64a3f67d53a99e6e2200f6481c98013004b4e4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 11:56:46 +0200 Subject: QItemSelectionModel: hasSelection can return true when no selection we needed to finalize the selection when rows are removed Reviewed-by: ogoffart --- src/gui/itemviews/qitemselectionmodel.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 98810a0..8414460 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -573,6 +573,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare int start, int end) { Q_Q(QItemSelectionModel); + finalize(); // update current index if (currentIndex.isValid() && parent == currentIndex.parent() @@ -591,8 +592,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } QItemSelection deselected; - QItemSelection::iterator it = currentSelection.begin(); - while (it != currentSelection.end()) { + QItemSelection::iterator it = ranges.begin(); + while (it != ranges.end()) { if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range QModelIndex itParent = it->topLeft().parent(); while (itParent.isValid() && itParent.parent() != parent) @@ -600,24 +601,22 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else { ++it; } } else if (start <= it->bottom() && it->bottom() <= end // Full inclusion && start <= it->top() && it->top() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else if (start <= it->top() && it->top() <= end) { // Top intersection deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent()))); - it = currentSelection.insert(it, QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), - it->bottomRight())); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight()); + ++it; } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); - it = currentSelection.insert(it, QItemSelectionRange(it->topLeft(), - model->index(start - 1, it->right(), it->parent()))); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); + ++it; } else { if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing) deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), @@ -626,7 +625,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } } - emit q->selectionChanged(QItemSelection(), deselected); + if (!deselected.isEmpty()) + emit q->selectionChanged(QItemSelection(), deselected); } /*! -- cgit v0.12 From 089689914fd7b223c10f5408a6db255ce540e718 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 12:36:40 +0200 Subject: Fix autotest: removed useless debug traces --- tests/auto/qmenu/tst_qmenu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index b06b247..90b9a2a 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -710,7 +710,6 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() uint i = 2; while (main.columnCount() < 2) { main.addAction(QString("Item %1").arg(i)); - qDebug() << "adding action" << i; ++i; Q_ASSERT(i<1000); } -- cgit v0.12 From 7d2fb4f6dfbfe843ec2d101c06b891230a49d20a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 12:42:23 +0200 Subject: Autotest: Be very pedant about the tests. There's at least one compiler where it breaks, so let's find out where. --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 37 +++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index ab75c91..c9b2325 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -761,17 +761,46 @@ void tst_QSharedPointer::differentPointers() { DiffPtrDerivedData *aData = new DiffPtrDerivedData; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast(&aData) != *reinterpret_cast(&aBase)); + + // ensure that this compiler isn't broken + if (*reinterpret_cast(&aData) == *reinterpret_cast(&aBase)) + qFatal("Something went very wrong -- we couldn't create two different pointers to the same object"); + if (aData != aBase) + QSKIP("Broken compiler", SkipAll); + if (aBase != aData) + QSKIP("Broken compiler", SkipAll); QSharedPointer ptr = QSharedPointer(aData); QSharedPointer baseptr = qSharedPointerCast(ptr); - QVERIFY(ptr == baseptr); + qDebug("naked: orig: %p; base: %p (%s) -- QSharedPointer: orig: %p; base %p (%s) -- result: %s", + aData, aBase, aData == aBase ? "equal" : "not equal", + ptr.data(), baseptr.data(), ptr.data() == baseptr.data() ? "equal" : "not equal", + baseptr.data() == aData ? "equal" : "not equal"); + QVERIFY(ptr.data() == baseptr.data()); + QVERIFY(baseptr.data() == ptr.data()); + QVERIFY(ptr == baseptr); + QVERIFY(baseptr == ptr); + + QVERIFY(ptr.data() == aBase); + QVERIFY(aBase == ptr.data()); + QVERIFY(ptr.data() == aData); + QVERIFY(aData == ptr.data()); + QVERIFY(ptr == aBase); + QVERIFY(aBase == ptr); QVERIFY(ptr == aData); - QVERIFY(baseptr == aData); + QVERIFY(aData == ptr); + + QVERIFY(baseptr.data() == aBase); + QVERIFY(aBase == baseptr.data()); QVERIFY(baseptr == aBase); + QVERIFY(aBase == baseptr); + + QVERIFY(baseptr.data() == aData); + QVERIFY(aData == baseptr.data()); + QVERIFY(baseptr == aData); + QVERIFY(aData == baseptr); } check(); -- cgit v0.12 From e1c9136214532cc41074449e3a894fdea020a41e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 13:20:35 +0200 Subject: Fix autotest: on windows, timers are not accurate enough --- tests/auto/qtoolbutton/tst_qtoolbutton.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp index 6376c5d..aca9a20 100644 --- a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp @@ -222,8 +222,10 @@ void tst_QToolButton::task176137_autoRepeatOfAction() tb.setAutoRepeat (true); QSignalSpy repeatSpy(&action,SIGNAL(triggered())); // new spy QTest::mousePress ( &tb, Qt::LeftButton); - QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 2000); - QCOMPARE (repeatSpy.count(), (2000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1); + QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 3000); + qreal expected = (3000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1; + //we check that the difference is less than 10% (on some systems timers are not super accurate) + QVERIFY ( qAbs( (expected - repeatSpy.count()) / expected) < 0.1); } -- cgit v0.12 From 5f2f444a9d8d80d778053c2af66534d582145055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 18 Aug 2009 13:35:30 +0200 Subject: Fixed bug when rendering long lines of text without XRender. XRectangle coordinates need to be clipped to the short integer range. Task-number: 250137 Reviewed-by: Trond --- src/gui/painting/qpaintengine_x11.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 6816aac..a4d34b5 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2459,15 +2459,23 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti) XRectangle rects[rectcount]; int num_rects = 0; + QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy())); + QRect clip(d->polygonClipper.boundingRect()); for (int i=0; i < path.elementCount(); i+=5) { int x = qRound(path.elementAt(i).x); int y = qRound(path.elementAt(i).y); int w = qRound(path.elementAt(i+1).x) - x; int h = qRound(path.elementAt(i+2).y) - y; - rects[num_rects].x = x + qRound(d->matrix.dx()); - rects[num_rects].y = y + qRound(d->matrix.dy()); - rects[num_rects].width = w; - rects[num_rects].height = h; + + QRect rect = QRect(x + delta.x(), y + delta.y(), w, h); + rect = rect.intersected(clip); + if (rect.isEmpty()) + continue; + + rects[num_rects].x = short(rect.x()); + rects[num_rects].y = short(rect.y()); + rects[num_rects].width = ushort(rect.width()); + rects[num_rects].height = ushort(rect.height()); ++num_rects; if (num_rects == rectcount) { XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects); -- cgit v0.12 From a250ca3a3c0b777f274388b9e57a985d7438f8ff Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 14:54:15 +0200 Subject: Make TestLib compatible with mingw when gui is not used The problem is that headers in QTestLib define functions for mouse and key events. Those are causing link errors on all autotests that do "QT -= gui" with mingw (only debug seems to be affected). Reviewed-by: jasplin --- src/testlib/qtestevent.h | 5 +++++ src/testlib/qtestkeyboard.h | 2 +- src/testlib/qtestmouse.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestevent.h b/src/testlib/qtestevent.h index a8376ee..dfbba33 100644 --- a/src/testlib/qtestevent.h +++ b/src/testlib/qtestevent.h @@ -71,6 +71,7 @@ public: virtual ~QTestEvent() {} }; +#ifdef QT_GUI_LIB class QTestKeyEvent: public QTestEvent { public: @@ -135,6 +136,8 @@ private: QPoint _pos; int _delay; }; +#endif //QT_GUI_LIB + class QTestDelayEvent: public QTestEvent { @@ -159,6 +162,7 @@ public: inline void clear() { qDeleteAll(*this); QList::clear(); } +#ifdef QT_GUI_LIB inline void addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) { addKeyEvent(QTest::Click, qtKey, modifiers, msecs); } inline void addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) @@ -194,6 +198,7 @@ public: { append(new QTestMouseEvent(QTest::MouseDClick, button, stateKey, pos, delay)); } inline void addMouseMove(QPoint pos = QPoint(), int delay=-1) { append(new QTestMouseEvent(QTest::MouseMove, Qt::NoButton, 0, pos, delay)); } +#endif //QT_GUI_LIB inline void addDelay(int msecs) { append(new QTestDelayEvent(msecs)); } diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index 2e475b2..af81075 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#ifndef QTESTKEYBOARD_H +#if !defined(QTESTKEYBOARD_H) && defined(QT_GUI_LIB) #define QTESTKEYBOARD_H #if 0 diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 2825c58..7ea927c 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#ifndef QTESTMOUSE_H +#if !defined(QTESTMOUSE_H) && defined(QT_GUI_LIB) #define QTESTMOUSE_H #if 0 -- cgit v0.12 From aaf10f42467aba28717b587adb85f31b4ada08ab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 14:43:14 +0200 Subject: Animations: update the documentation Removed the reference to the QAnimationState that doesn't exist anymore --- src/corelib/animation/qanimationgroup.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index ab47b5a..78777f1 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -79,13 +79,6 @@ QAnimationGroup takes ownership of the animations it manages, and ensures that they are deleted when the animation group is deleted. - You can also use a \l{The State Machine Framework}{state machine} - to create complex animations. The framework provides a special - state, QAnimationState, that plays an animation upon entry and - transitions to a new state when the animation has finished - playing. This technique can also be combined with using animation - groups. - \sa QAbstractAnimation, QVariantAnimation, {The Animation Framework} */ -- cgit v0.12 From 413efbbc942262a636c521b898e0086258daa61a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Aug 2009 15:39:24 +0200 Subject: Compile fix with namespaces --- src/gui/painting/qpaintdevice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 6477952..6a2a4c4 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -64,3 +64,5 @@ int QPaintDevice::metric(PaintDeviceMetric) const qWarning("QPaintDevice::metrics: Device has no metric information"); return 0; } + +QT_END_NAMESPACE -- cgit v0.12 From d59b92565e3632e2b36ea7de881bd08418760bbc Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 15:41:34 +0200 Subject: add QGraphicsObject Q_INTERFACES macro --- src/gui/graphicsview/qgraphicsitem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index b5e6ed5..52b862e 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -516,6 +516,7 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) + Q_INTERFACES(QGraphicsItem) public: QGraphicsObject(QGraphicsItem *parent = 0); -- cgit v0.12 From 37b375092b6db1c3302f93676b6329742f5c9fef Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 15:53:21 +0200 Subject: mingw: make it possible to build without rtti support --- mkspecs/features/win32/rtti_off.prf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/win32/rtti_off.prf b/mkspecs/features/win32/rtti_off.prf index 8f175de..b520bfa 100644 --- a/mkspecs/features/win32/rtti_off.prf +++ b/mkspecs/features/win32/rtti_off.prf @@ -1,3 +1,4 @@ CONFIG -= rtti QMAKE_CFLAGS += $$QMAKE_CFLAGS_RTTI_OFF QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RTTI_OFF +DEFINES += QT_NO_DYNAMIC_CAST \ No newline at end of file -- cgit v0.12 From 68b7514840fe29f84af8d418538084ed337bd171 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 07:05:08 -0700 Subject: Make sure to update pos QDFBCursor::move We don't need to chain to the base class since the QDirectFBScreenCursor always is rendered by hardware but we should update the pos variable in case people ask where the cursor is. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 774162c..2541677 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -578,6 +578,7 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() void QDirectFBScreenCursor::move(int x, int y) { + pos = QPoint(x, y); layer->WarpCursor(layer, x, y); } -- cgit v0.12