diff options
Diffstat (limited to 'qtinterface/tqlistiterator.h')
-rw-r--r-- | qtinterface/tqlistiterator.h | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/qtinterface/tqlistiterator.h b/qtinterface/tqlistiterator.h index 417bc24..47bd897 100644 --- a/qtinterface/tqlistiterator.h +++ b/qtinterface/tqlistiterator.h @@ -39,16 +39,46 @@ template <typename T> class TQListIterator { public: - TQListIterator(const QList<T> &t); - ~TQListIterator(); + inline TQListIterator(const QList<T> &t) {index = 0; list = &t;} + inline ~TQListIterator() {} + + inline T current() { + if ((index >= 0) && (index < list->size())) { + return list->at(index); + } + else { + return 0; + } + } - T current(); + int operator++() { index++; return index; } + +private: + int index; + const QList<T> *list; +}; + +template <typename T> +class TQListIteratorRetPtr +{ +public: + inline TQListIteratorRetPtr(const QList<T> &t) {index = 0; list = &t;} + inline ~TQListIteratorRetPtr() {} + + inline T * current() { + if ((index >= 0) && (index < list->size())) { + return const_cast<QFileInfo *>(&(list->at(index))); + } + else { + return 0; + } + } int operator++() { index++; return index; } private: int index; - QList<T> *list; + const QList<T> *list; }; #endif // USE_QT4 |