diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-07 19:25:16 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-07 19:25:16 +0000 |
commit | 77ead0ba5f91ad6fd04fca1ab1e2b6847bf88136 (patch) | |
tree | 82bf3c5b668e0d2f2f3649421e2934a1b9896d53 /qtinterface/tqt4/Qt/qlist.h | |
parent | 0630a9067e5db373c6fd33bbe8145e29f18e9a54 (diff) | |
download | tqtinterface-77ead0ba5f91ad6fd04fca1ab1e2b6847bf88136.tar.gz tqtinterface-77ead0ba5f91ad6fd04fca1ab1e2b6847bf88136.zip |
Yet more Qt4 API extensions...
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1160323 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtinterface/tqt4/Qt/qlist.h')
-rw-r--r-- | qtinterface/tqt4/Qt/qlist.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/qtinterface/tqt4/Qt/qlist.h b/qtinterface/tqt4/Qt/qlist.h index 39c3b83..fb4d3e3 100644 --- a/qtinterface/tqt4/Qt/qlist.h +++ b/qtinterface/tqt4/Qt/qlist.h @@ -110,8 +110,8 @@ class QList union { QListData p; QListData::Data *d; }; public: - inline QList() : d(&QListData::shared_null) { d->ref.ref(); } - inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } + inline QList() : d(&QListData::shared_null) { d->ref.ref(); current_index=0; } + inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); current_index=0; } ~QList(); QList<T> &operator=(const QList<T> &l); bool operator==(const QList<T> &l) const; @@ -120,6 +120,7 @@ public: operator bool() const; inline operator const QList<T> *() const { return const_cast<QList<T> *>(this); } + inline operator QList<T> *() const { return const_cast<QList<T> *>(this); } inline int size() const { return p.size(); } @@ -159,8 +160,12 @@ public: int indexOf(const T &t, int from = 0) const; int lastIndexOf(const T &t, int from = -1) const; QBool contains(const T &t) const; + inline uint containsRef( const T &t ) { return count(t); }; int count(const T &t) const; + inline T next() { current_index++; return *this[current_index]; } + inline T prev() { current_index--; return *this[current_index]; } + class const_iterator; class iterator { @@ -264,10 +269,10 @@ public: typedef const_iterator ConstIterator; inline int count() const { return p.size(); } inline int length() const { return p.size(); } // Same as count() - inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } - inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } + inline T& first() { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); } + inline const T& first() const { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); } T& last() { Q_ASSERT(!isEmpty()); return *(--end()); } - const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); } + const T& last() const { Q_ASSERT(!isEmpty()); current_index=count()-1; return *(--end()); } inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); } inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); } inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; } @@ -341,6 +346,8 @@ private: void node_destruct(Node *n); void node_copy(Node *from, Node *to, Node *src); void node_destruct(Node *from, Node *to); + + int current_index; }; #if defined(Q_CC_BOR) |