diff options
27 files changed, 3942 insertions, 67 deletions
diff --git a/qtinterface/Makefile.am b/qtinterface/Makefile.am index d0401a5..14bc973 100644 --- a/qtinterface/Makefile.am +++ b/qtinterface/Makefile.am @@ -16,7 +16,7 @@ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# TRINITY PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/qtinterface/convert_qt_tqt2 b/qtinterface/convert_qt_tqt2 index c6a494e..eee091e 100755 --- a/qtinterface/convert_qt_tqt2 +++ b/qtinterface/convert_qt_tqt2 @@ -588,6 +588,8 @@ find ./ -type f -iname "*.c*" -exec sed -i 's/QPainter\([ :<>"()*&.,^;]\)/TQPain find ./ -type f -iname "*.h*" -exec sed -i 's/QPainter\([ :<>"()*&.,^;]\)/TQPainter\1/g' {} \; find ./ -type f -iname "*.c*" -exec sed -i 's/QColorGroup\([ :<>"()*&.,^;]\)/TQColorGroup\1/g' {} \; find ./ -type f -iname "*.h*" -exec sed -i 's/QColorGroup\([ :<>"()*&.,^;]\)/TQColorGroup\1/g' {} \; +find ./ -type f -iname "*.c*" -exec sed -i 's/QPair\([ :<>"()*&.,^;]\)/TQPair\1/g' {} \; +find ./ -type f -iname "*.h*" -exec sed -i 's/QPair\([ :<>"()*&.,^;]\)/TQPair\1/g' {} \; find ./ -type f -iname "*.c*" -exec sed -i 's/QPalette\([ :<>"()*&.,^;]\)/TQPalette\1/g' {} \; find ./ -type f -iname "*.h*" -exec sed -i 's/QPalette\([ :<>"()*&.,^;]\)/TQPalette\1/g' {} \; find ./ -type f -iname "*.c*" -exec sed -i 's/QPen\([ :<>"()*&.,^;]\)/TQPen\1/g' {} \; diff --git a/qtinterface/tqiconset.cpp b/qtinterface/tqiconset.cpp index 11ced75..cab3a65 100644 --- a/qtinterface/tqiconset.cpp +++ b/qtinterface/tqiconset.cpp @@ -26,8 +26,8 @@ Boston, MA 02110-1301, USA. #include "Qt/q3cleanuphandler.h" -static QIconFactory *defaultFac = 0; -static Q3SingleCleanupHandler<QIconFactory> q_cleanup_icon_factory; +static TQIconFactory *defaultFac = 0; +static Q3SingleCleanupHandler<TQIconFactory> q_cleanup_icon_factory; /*! \class TQIconFactory \ingroup advanced @@ -125,4 +125,12 @@ void TQIconFactory::installDefaultFactory( TQIconFactory *factory ) q_cleanup_icon_factory.set( &defaultFac ); } +/** + A little do-nothing function to allow Qt3 code compatibility. +*/ +void QIconSet::installIconFactory( TQIconFactory *factory ) +{ + #warning "QIconSet::installIconFactory( QIconFactory *factory ) unimplemented!" +} + #endif // USE_QT4
\ No newline at end of file diff --git a/qtinterface/tqiconset.h b/qtinterface/tqiconset.h index 81e9ec0..ac6035d 100644 --- a/qtinterface/tqiconset.h +++ b/qtinterface/tqiconset.h @@ -38,27 +38,27 @@ Boston, MA 02110-1301, USA. // Reimplement the QAccel class // For Qt4, some changes are needed -#include <Qt/qicon.h> +#include <tqt4/Qt/qicon.h> #include <Qt/q3shared.h> class TQIconFactory : private Q3Shared { public: - QIconFactory(); - virtual ~QIconFactory(); + TQIconFactory(); + virtual ~TQIconFactory(); virtual QPixmap *createPixmap( const QIconSet& iconSet, QIconSet::Size size, QIconSet::Mode mode, QIconSet::State state ); void setAutoDelete( bool autoDelete ) { autoDel = autoDelete; } bool autoDelete() const { return autoDel; } - static QIconFactory *defaultFactory(); - static void installDefaultFactory( QIconFactory *factory ); + static TQIconFactory *defaultFactory(); + static void installDefaultFactory( TQIconFactory *factory ); private: #if defined(Q_DISABLE_COPY) - QIconFactory( const QIconFactory & ); - QIconFactory &operator=( const QIconFactory & ); + TQIconFactory( const TQIconFactory & ); + TQIconFactory &operator=( const TQIconFactory & ); #endif uint autoDel : 1; diff --git a/qtinterface/tqmap.cpp b/qtinterface/tqmap.cpp index 14eb618..8ab4436 100644 --- a/qtinterface/tqmap.cpp +++ b/qtinterface/tqmap.cpp @@ -21,3 +21,223 @@ Boston, MA 02110-1301, USA. #include <tqt.h> #include <tqmap.h> + +#ifdef USE_QT4 + +typedef TQMapNodeBase* NodePtr; +typedef TQMapNodeBase Node; + + +void TQMapPrivateBase::rotateLeft( NodePtr x, NodePtr& root) +{ + NodePtr y = x->right; + x->right = y->left; + if (y->left !=0) + y->left->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->left) + x->parent->left = y; + else + x->parent->right = y; + y->left = x; + x->parent = y; +} + + +void TQMapPrivateBase::rotateRight( NodePtr x, NodePtr& root ) +{ + NodePtr y = x->left; + x->left = y->right; + if (y->right != 0) + y->right->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->right) + x->parent->right = y; + else + x->parent->left = y; + y->right = x; + x->parent = y; +} + + +void TQMapPrivateBase::rebalance( NodePtr x, NodePtr& root) +{ + x->color = Node::Red; + while ( x != root && x->parent->color == Node::Red ) { + if ( x->parent == x->parent->parent->left ) { + NodePtr y = x->parent->parent->right; + if (y && y->color == Node::Red) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->right) { + x = x->parent; + rotateLeft( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateRight (x->parent->parent, root ); + } + } else { + NodePtr y = x->parent->parent->left; + if ( y && y->color == Node::Red ) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->left) { + x = x->parent; + rotateRight( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateLeft( x->parent->parent, root ); + } + } + } + root->color = Node::Black; +} + + +NodePtr TQMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, + NodePtr& leftmost, + NodePtr& rightmost ) +{ + NodePtr y = z; + NodePtr x; + NodePtr x_parent; + if (y->left == 0) { + x = y->right; + } else { + if (y->right == 0) + x = y->left; + else + { + y = y->right; + while (y->left != 0) + y = y->left; + x = y->right; + } + } + if (y != z) { + z->left->parent = y; + y->left = z->left; + if (y != z->right) { + x_parent = y->parent; + if (x) + x->parent = y->parent; + y->parent->left = x; + y->right = z->right; + z->right->parent = y; + } else { + x_parent = y; + } + if (root == z) + root = y; + else if (z->parent->left == z) + z->parent->left = y; + else + z->parent->right = y; + y->parent = z->parent; + // Swap the colors + Node::Color c = y->color; + y->color = z->color; + z->color = c; + y = z; + } else { + x_parent = y->parent; + if (x) + x->parent = y->parent; + if (root == z) + root = x; + else if (z->parent->left == z) + z->parent->left = x; + else + z->parent->right = x; + if ( leftmost == z ) { + if (z->right == 0) + leftmost = z->parent; + else + leftmost = x->minimum(); + } + if (rightmost == z) { + if (z->left == 0) + rightmost = z->parent; + else + rightmost = x->maximum(); + } + } + if (y->color != Node::Red) { + while (x != root && (x == 0 || x->color == Node::Black)) { + if (x == x_parent->left) { + NodePtr w = x_parent->right; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateLeft(x_parent, root); + w = x_parent->right; + } + if ((w->left == 0 || w->left->color == Node::Black) && + (w->right == 0 || w->right->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->right == 0 || w->right->color == Node::Black) { + if (w->left) + w->left->color = Node::Black; + w->color = Node::Red; + rotateRight(w, root); + w = x_parent->right; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->right) + w->right->color = Node::Black; + rotateLeft(x_parent, root); + break; + } + } else { + NodePtr w = x_parent->left; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateRight(x_parent, root); + w = x_parent->left; + } + if ((w->right == 0 || w->right->color == Node::Black) && + (w->left == 0 || w->left->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->left == 0 || w->left->color == Node::Black) { + if (w->right) + w->right->color = Node::Black; + w->color = Node::Red; + rotateLeft(w, root); + w = x_parent->left; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->left) + w->left->color = Node::Black; + rotateRight(x_parent, root); + break; + } + } + } + if (x) + x->color = Node::Black; + } + return y; +} + +#endif // USE_QT4
\ No newline at end of file diff --git a/qtinterface/tqmap.h b/qtinterface/tqmap.h index 5a445df..92f170d 100644 --- a/qtinterface/tqmap.h +++ b/qtinterface/tqmap.h @@ -39,6 +39,896 @@ Boston, MA 02110-1301, USA. // For Qt4, some changes are needed #include <Qt/qmap.h> +#include <Qt/q3shared.h> +#include <Qt/q3valuelist.h> + +/**************************************************************************** +** +** Definition of TQMap class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +//#define QT_CHECK_MAP_RANGE + +struct TQMapNodeBase +{ + enum Color { Red, Black }; + + TQMapNodeBase* left; + TQMapNodeBase* right; + TQMapNodeBase* parent; + + Color color; + + TQMapNodeBase* minimum() { + TQMapNodeBase* x = this; + while ( x->left ) + x = x->left; + return x; + } + + TQMapNodeBase* maximum() { + TQMapNodeBase* x = this; + while ( x->right ) + x = x->right; + return x; + } +}; + + +template <class K, class T> +struct TQMapNode : public TQMapNodeBase +{ + TQMapNode( const K& _key, const T& _data ) { data = _data; key = _key; } + TQMapNode( const K& _key ) { key = _key; } + TQMapNode( const TQMapNode<K,T>& _n ) { key = _n.key; data = _n.data; } + TQMapNode() { } + T data; + K key; +}; + + +template<class K, class T> +class TQMapIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + TQMapNode<K,T>* node; + + /** + * Functions + */ + TQMapIterator() : node( 0 ) {} + TQMapIterator( TQMapNode<K,T>* p ) : node( p ) {} + TQMapIterator( const TQMapIterator<K,T>& it ) : node( it.node ) {} + + bool operator==( const TQMapIterator<K,T>& it ) const { return node == it.node; } + bool operator!=( const TQMapIterator<K,T>& it ) const { return node != it.node; } + T& operator*() { return node->data; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + T& data() { return node->data; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapIterator<K,T>& operator++() { + inc(); + return *this; + } + + TQMapIterator<K,T> operator++(int) { + TQMapIterator<K,T> tmp = *this; + inc(); + return tmp; + } + + TQMapIterator<K,T>& operator--() { + dec(); + return *this; + } + + TQMapIterator<K,T> operator--(int) { + TQMapIterator<K,T> tmp = *this; + dec(); + return tmp; + } +}; + +template <class K, class T> +int TQMapIterator<K,T>::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template <class K, class T> +int TQMapIterator<K,T>::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template<class K, class T> +class TQMapConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + + /** + * Variables + */ + TQMapNode<K,T>* node; + + /** + * Functions + */ + TQMapConstIterator() : node( 0 ) {} + TQMapConstIterator( TQMapNode<K,T>* p ) : node( p ) {} + TQMapConstIterator( const TQMapConstIterator<K,T>& it ) : node( it.node ) {} + TQMapConstIterator( const TQMapIterator<K,T>& it ) : node( it.node ) {} + + bool operator==( const TQMapConstIterator<K,T>& it ) const { return node == it.node; } + bool operator!=( const TQMapConstIterator<K,T>& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapConstIterator<K,T>& operator++() { + inc(); + return *this; + } + + TQMapConstIterator<K,T> operator++(int) { + TQMapConstIterator<K,T> tmp = *this; + inc(); + return tmp; + } + + TQMapConstIterator<K,T>& operator--() { + dec(); + return *this; + } + + TQMapConstIterator<K,T> operator--(int) { + TQMapConstIterator<K,T> tmp = *this; + dec(); + return tmp; + } +}; + +template <class K, class T> +int TQMapConstIterator<K,T>::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template <class K, class T> +int TQMapConstIterator<K,T>::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +// ### 4.0: rename to something without Private in it. Not really internal. +class TQMapPrivateBase : public Q3Shared +{ +public: + TQMapPrivateBase() { + node_count = 0; + } + TQMapPrivateBase( const TQMapPrivateBase* _map) { + node_count = _map->node_count; + } + + /** + * Implementations of basic tree algorithms + */ + void rotateLeft( TQMapNodeBase* x, TQMapNodeBase*& root); + void rotateRight( TQMapNodeBase* x, TQMapNodeBase*& root ); + void rebalance( TQMapNodeBase* x, TQMapNodeBase*& root ); + TQMapNodeBase* removeAndRebalance( TQMapNodeBase* z, TQMapNodeBase*& root, + TQMapNodeBase*& leftmost, + TQMapNodeBase*& rightmost ); + + /** + * Variables + */ + int node_count; +}; + + +template <class Key, class T> +class TQMapPrivate : public TQMapPrivateBase +{ +public: + /** + * Typedefs + */ + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef TQMapNode< Key, T > Node; + typedef TQMapNode< Key, T >* NodePtr; + + /** + * Functions + */ + TQMapPrivate(); + TQMapPrivate( const TQMapPrivate< Key, T >* _map ); + ~TQMapPrivate() { clear(); delete header; } + + NodePtr copy( NodePtr p ); + void clear(); + void clear( NodePtr p ); + + Iterator begin() { return Iterator( (NodePtr)(header->left ) ); } + Iterator end() { return Iterator( header ); } + ConstIterator begin() const { return ConstIterator( (NodePtr)(header->left ) ); } + ConstIterator end() const { return ConstIterator( header ); } + + ConstIterator find(const Key& k) const; + + void remove( Iterator it ) { + NodePtr del = (NodePtr) removeAndRebalance( it.node, header->parent, header->left, header->right ); + delete del; + --node_count; + } + +#ifdef QT_QMAP_DEBUG + void inorder( TQMapNodeBase* x = 0, int level = 0 ){ + if ( !x ) + x = header->parent; + if ( x->left ) + inorder( x->left, level + 1 ); + //cout << level << " Key=" << key(x) << " Value=" << ((NodePtr)x)->data << endl; + if ( x->right ) + inorder( x->right, level + 1 ); + } +#endif + +#if 0 + Iterator insertMulti(const Key& v){ + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + while (x != 0){ + y = x; + x = ( v < key(x) ) ? x->left : x->right; + } + return insert(x, y, v); + } +#endif + + Iterator insertSingle( const Key& k ); + Iterator insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ); + +protected: + /** + * Helpers + */ + const Key& key( TQMapNodeBase* b ) const { return ((NodePtr)b)->key; } + + /** + * Variables + */ + NodePtr header; +}; + + +template <class Key, class T> +TQMapPrivate<Key,T>::TQMapPrivate() { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + header->parent = 0; + header->left = header->right = header; +} +template <class Key, class T> +TQMapPrivate<Key,T>::TQMapPrivate( const TQMapPrivate< Key, T >* _map ) : TQMapPrivateBase( _map ) { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + if ( _map->header->parent == 0 ) { + header->parent = 0; + header->left = header->right = header; + } else { + header->parent = copy( (NodePtr)(_map->header->parent) ); + header->parent->parent = header; + header->left = header->parent->minimum(); + header->right = header->parent->maximum(); + } +} + +template <class Key, class T> +Q_TYPENAME TQMapPrivate<Key,T>::NodePtr TQMapPrivate<Key,T>::copy( Q_TYPENAME TQMapPrivate<Key,T>::NodePtr p ) +{ + if ( !p ) + return 0; + NodePtr n = new Node( *p ); + n->color = p->color; + if ( p->left ) { + n->left = copy( (NodePtr)(p->left) ); + n->left->parent = n; + } else { + n->left = 0; + } + if ( p->right ) { + n->right = copy( (NodePtr)(p->right) ); + n->right->parent = n; + } else { + n->right = 0; + } + return n; +} + +template <class Key, class T> +void TQMapPrivate<Key,T>::clear() +{ + clear( (NodePtr)(header->parent) ); + header->color = TQMapNodeBase::Red; + header->parent = 0; + header->left = header->right = header; + node_count = 0; +} + +template <class Key, class T> +void TQMapPrivate<Key,T>::clear( Q_TYPENAME TQMapPrivate<Key,T>::NodePtr p ) +{ + while ( p != 0 ) { + clear( (NodePtr)p->right ); + NodePtr y = (NodePtr)p->left; + delete p; + p = y; + } +} + +template <class Key, class T> +Q_TYPENAME TQMapPrivate<Key,T>::ConstIterator TQMapPrivate<Key,T>::find(const Key& k) const +{ + TQMapNodeBase* y = header; // Last node + TQMapNodeBase* x = header->parent; // Root node. + + while ( x != 0 ) { + // If as k <= key(x) go left + if ( !( key(x) < k ) ) { + y = x; + x = x->left; + } else { + x = x->right; + } + } + + // Was k bigger/smaller then the biggest/smallest + // element of the tree ? Return end() + if ( y == header || k < key(y) ) + return ConstIterator( header ); + return ConstIterator( (NodePtr)y ); +} + +template <class Key, class T> +Q_TYPENAME TQMapPrivate<Key,T>::Iterator TQMapPrivate<Key,T>::insertSingle( const Key& k ) +{ + // Search correct position in the tree + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + bool result = TRUE; + while ( x != 0 ) { + result = ( k < key(x) ); + y = x; + x = result ? x->left : x->right; + } + // Get iterator on the last not empty one + Iterator j( (NodePtr)y ); + if ( result ) { + // Smaller then the leftmost one ? + if ( j == begin() ) { + return insert(x, y, k ); + } else { + // Perhaps daddy is the right one ? + --j; + } + } + // Really bigger ? + if ( (j.node->key) < k ) + return insert(x, y, k ); + // We are going to replace a node + return j; +} + + +template <class Key, class T> +Q_TYPENAME TQMapPrivate<Key,T>::Iterator TQMapPrivate<Key,T>::insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ) +{ + NodePtr z = new Node( k ); + if (y == header || x != 0 || k < key(y) ) { + y->left = z; // also makes leftmost = z when y == header + if ( y == header ) { + header->parent = z; + header->right = z; + } else if ( y == header->left ) + header->left = z; // maintain leftmost pointing to min node + } else { + y->right = z; + if ( y == header->right ) + header->right = z; // maintain rightmost pointing to max node + } + z->parent = y; + z->left = 0; + z->right = 0; + rebalance( z, header->parent ); + ++node_count; + return Iterator(z); +} + + +#ifdef QT_CHECK_RANGE +# if !defined( QT_NO_DEBUG ) && defined( QT_CHECK_MAP_RANGE ) +# define QT_CHECK_INVALID_MAP_ELEMENT if ( empty() ) qWarning( "TQMap: Warning invalid element" ) +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define QT_CHECK_INVALID_MAP_ELEMENT +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL +# endif +#else +# define QT_CHECK_INVALID_MAP_ELEMENT +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL +#endif + +template <class T> class QDeepCopy; + +template<class Key, class T> +class TQMap +{ +public: + /** + * Typedefs + */ + typedef Key key_type; + typedef T mapped_type; + typedef QPair<const key_type, mapped_type> value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef size_t size_type; + typedef TQMapIterator<Key,T> iterator; + typedef TQMapConstIterator<Key,T> const_iterator; + typedef QPair<iterator,bool> insert_pair; + + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef T ValueType; + typedef TQMapPrivate< Key, T > Priv; + + /** + * API + */ + TQMap() + { + sh = new TQMapPrivate< Key, T >; + } + TQMap( const TQMap<Key,T>& m ) + { + sh = m.sh; sh->ref(); + } + +#ifndef QT_NO_STL + TQMap( const std::map<Key,T>& m ) + { + sh = new TQMapPrivate<Key,T>; + Q_TYPENAME std::map<Key,T>::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + } +#endif + ~TQMap() + { + if ( sh->deref() ) + delete sh; + } + TQMap<Key,T>& operator= ( const TQMap<Key,T>& m ); +#ifndef QT_NO_STL + TQMap<Key,T>& operator= ( const std::map<Key,T>& m ) + { + clear(); + Q_TYPENAME std::map<Key,T>::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + return *this; + } +#endif + + // Interoperability + TQMap(const QMap<Key,T>& m) + { + QMapIterator<Key,T> i(m); + while (i.hasNext()) { + i.next(); + insert(i.key(), i.value()); + } + } + TQMap<Key,T>& operator= (const QMap<Key,T>& m) + { + this->clear(); + QMapIterator<Key,T> i(m); + while (i.hasNext()) { + i.next(); + insert(i.key(), i.value()); + } + return *this; + } + + operator QMap<Key,T>() const { + QMap<Key,T> map; + iterator it; + for ( it = this->begin(); it != this->end(); ++it) { + map.insert(it.key(), it.data()); + } + return map; + } + + iterator begin() { detach(); return sh->begin(); } + iterator end() { detach(); return sh->end(); } + const_iterator begin() const { return ((const Priv*)sh)->begin(); } + const_iterator end() const { return ((const Priv*)sh)->end(); } + const_iterator constBegin() const { return begin(); } + const_iterator constEnd() const { return end(); } + + iterator replace( const Key& k, const T& v ) + { + remove( k ); + return insert( k, v ); + } + + size_type size() const + { + return sh->node_count; + } + bool empty() const + { + return sh->node_count == 0; + } + QPair<iterator,bool> insert( const value_type& x ); + + void erase( iterator it ) + { + detach(); + sh->remove( it ); + } + void erase( const key_type& k ); + size_type count( const key_type& k ) const; + T& operator[] ( const Key& k ); + void clear(); + + iterator find ( const Key& k ) + { + detach(); + return iterator( sh->find( k ).node ); + } + const_iterator find ( const Key& k ) const { return sh->find( k ); } + + const T& operator[] ( const Key& k ) const + { QT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } + bool contains ( const Key& k ) const + { return find( k ) != end(); } + //{ return sh->find( k ) != ((const Priv*)sh)->end(); } + + size_type count() const { return sh->node_count; } + + Q3ValueList<Key> keys() const { + Q3ValueList<Key> r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(i.key()); + return r; + } + + Q3ValueList<T> values() const { + Q3ValueList<T> r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(*i); + return r; + } + + bool isEmpty() const { return sh->node_count == 0; } + + iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); + void remove( iterator it ) { detach(); sh->remove( it ); } + void remove( const Key& k ); + +#if defined(Q_FULL_TEMPLATE_INSTANTIATION) + bool operator==( const TQMap<Key,T>& ) const { return FALSE; } +#ifndef QT_NO_STL + bool operator==( const std::map<Key,T>& ) const { return FALSE; } +#endif +#endif + +protected: + /** + * Helpers + */ + void detach() { if ( sh->count > 1 ) detachInternal(); } + + Priv* sh; +private: + void detachInternal(); + + friend class QDeepCopy< TQMap<Key,T> >; +}; + +template<class Key, class T> +TQMap<Key,T>& TQMap<Key,T>::operator= ( const TQMap<Key,T>& m ) +{ + m.sh->ref(); + if ( sh->deref() ) + delete sh; + sh = m.sh; + return *this; +} + +template<class Key, class T> +Q_TYPENAME TQMap<Key,T>::insert_pair TQMap<Key,T>::insert( const Q_TYPENAME TQMap<Key,T>::value_type& x ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( x.first ); + bool inserted = FALSE; + if ( n < size() ) { + inserted = TRUE; + it.data() = x.second; + } + return QPair<iterator,bool>( it, inserted ); +} + +template<class Key, class T> +void TQMap<Key,T>::erase( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template<class Key, class T> +Q_TYPENAME TQMap<Key,T>::size_type TQMap<Key,T>::count( const Key& k ) const +{ + const_iterator it( sh->find( k ).node ); + if ( it != end() ) { + size_type c = 0; + while ( it != end() ) { + ++it; + ++c; + } + return c; + } + return 0; +} + +template<class Key, class T> +T& TQMap<Key,T>::operator[] ( const Key& k ) +{ + detach(); + TQMapNode<Key,T>* p = sh->find( k ).node; + if ( p != sh->end().node ) + return p->data; + return insert( k, T() ).data(); +} + +template<class Key, class T> +void TQMap<Key,T>::clear() +{ + if ( sh->count == 1 ) + sh->clear(); + else { + sh->deref(); + sh = new TQMapPrivate<Key,T>; + } +} + +template<class Key, class T> +Q_TYPENAME TQMap<Key,T>::iterator TQMap<Key,T>::insert( const Key& key, const T& value, bool overwrite ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( key ); + if ( overwrite || n < size() ) + it.data() = value; + return it; +} + +template<class Key, class T> +void TQMap<Key,T>::remove( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template<class Key, class T> +void TQMap<Key,T>::detachInternal() +{ + sh->deref(); sh = new TQMapPrivate<Key,T>( sh ); +} + + +#ifndef QT_NO_DATASTREAM +template<class Key, class T> +QDataStream& operator>>( QDataStream& s, TQMap<Key,T>& m ) { + m.clear(); + Q_UINT32 c; + s >> c; + for( Q_UINT32 i = 0; i < c; ++i ) { + Key k; T t; + s >> k >> t; + m.insert( k, t ); + if ( s.atEnd() ) + break; + } + return s; +} + + +template<class Key, class T> +QDataStream& operator<<( QDataStream& s, const TQMap<Key,T>& m ) { + s << (Q_UINT32)m.size(); + TQMapConstIterator<Key,T> it = m.begin(); + for( ; it != m.end(); ++it ) + s << it.key() << it.data(); + return s; +} +#endif + +/**********************************************************************/ #endif // USE_QT4 diff --git a/qtinterface/tqpair.h b/qtinterface/tqpair.h index 883fa3f..db3ec73 100644 --- a/qtinterface/tqpair.h +++ b/qtinterface/tqpair.h @@ -40,6 +40,104 @@ Boston, MA 02110-1301, USA. #include <Qt/qpair.h> +/**************************************************************************** +** +** Definition of TQPair class +** +** +** Copyright (C) 1992-2005 Trolltech AS. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be distributed under the terms of the Q Public License +** as defined by Trolltech AS of Norway and appearing in the file +** LICENSE.QPL included in the packaging of this file. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition +** licenses may use this file in accordance with the Qt Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/pricing.html or email [email protected] for +** information about Qt Commercial License Agreements. +** See http://www.trolltech.com/qpl/ for QPL licensing information. +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact [email protected] if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +template <class T1, class T2> +struct TQPair +{ + typedef T1 first_type; + typedef T2 second_type; + + TQPair() + : first( T1() ), second( T2() ) + {} + TQPair( const T1& t1, const T2& t2 ) + : first( t1 ), second( t2 ) + {} + + TQPair<T1, T2>& operator=(const TQPair<T1, T2>& other) + { + if (this != &other) { + first = other.first; + second = other.second; + } + return *this; + } + + T1 first; + T2 second; +}; + +template <class T1, class T2> +bool operator==( const TQPair<T1, T2>& x, const TQPair<T1, T2>& y ) +{ + return x.first == y.first && x.second == y.second; +} + +template <class T1, class T2> +bool operator<( const TQPair<T1, T2>& x, const TQPair<T1, T2>& y ) +{ + return x.first < y.first || + ( !( y.first < x.first ) && x.second < y.second ); +} + +template <class T1, class T2> +TQPair<T1, T2> qMakePair( const T1& x, const T2& y ) +{ + return TQPair<T1, T2>( x, y ); +} + +#ifndef QT_NO_DATASTREAM +template <class T1, class T2> +inline QDataStream& operator>>( QDataStream& s, TQPair<T1, T2>& p ) +{ + s >> p.first >> p.second; + return s; +} + +template <class T1, class T2> +inline QDataStream& operator<<( QDataStream& s, const TQPair<T1, T2>& p ) +{ + s << p.first << p.second; + return s; +} +#endif + +/**********************************************************************/ + #endif // USE_QT4 #endif /* TQPAIR_H */
\ No newline at end of file diff --git a/qtinterface/tqptrlist.h b/qtinterface/tqptrlist.h index 37d338c..6dc6771 100644 --- a/qtinterface/tqptrlist.h +++ b/qtinterface/tqptrlist.h @@ -26,7 +26,7 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT3 -// Reimplement the QPtrList class +// Reimplement the TQPtrList class // For Qt3, no changes are needed #include <qptrlist.h> @@ -35,10 +35,222 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 -// Reimplement the QPtrList class +// Reimplement the TQPtrList class // For Qt4, some changes are needed #include <Qt/q3ptrlist.h> +#include <Qt/q3glist.h> +#include <Qt/q3gvector.h> +#include <Qt/q3ptrcollection.h> +#include <Qt/qlist.h> + +/**************************************************************************** +** +** Definition of TQPtrList template/macro class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +template<class type> +class TQPtrListStdIterator : public Q3GListStdIterator +{ +public: + inline TQPtrListStdIterator( Q3LNode* n ): Q3GListStdIterator(n) {} + type *operator*() { return node ? (type *)node->getData() : 0; } + inline TQPtrListStdIterator<type> operator++() + { node = next(); return *this; } + inline TQPtrListStdIterator<type> operator++(int) + { Q3LNode* n = node; node = next(); return TQPtrListStdIterator<type>( n ); } + inline bool operator==( const TQPtrListStdIterator<type>& it ) const { return node == it.node; } + inline bool operator!=( const TQPtrListStdIterator<type>& it ) const { return node != it.node; } +}; + + +template<class type> +class TQPtrList +#ifdef Q_QDOC + : public Q3PtrCollection +#else + : public Q3GList +#endif +{ +public: + + TQPtrList() {} + TQPtrList( const TQPtrList<type> &l ) : Q3GList(l) {} + ~TQPtrList() { clear(); } + TQPtrList<type> &operator=(const TQPtrList<type> &l) + { return (TQPtrList<type>&)Q3GList::operator=(l); } + bool operator==( const TQPtrList<type> &list ) const + { return Q3GList::operator==( list ); } + bool operator!=( const TQPtrList<type> &list ) const + { return !Q3GList::operator==( list ); } + + // Interoperability + TQPtrList(const QList<type*>& l) + { + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + } + + TQPtrList<type>& operator= (const QList<type*>& l) + { + this->clear(); + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + return *this; + } + + operator QList<type*>() const { + QList<type*> list; + for (typename TQPtrList<type>::const_iterator it = TQPtrList<type>::constBegin(); + it != TQPtrList<type>::constEnd(); ++it) + list.append(*it); + return list; + } + + uint count() const { return Q3GList::count(); } + bool isEmpty() const { return Q3GList::count() == 0; } + bool insert( uint i, const type *d){ return Q3GList::insertAt(i,(Q3PtrCollection::Item)d); } + void inSort( const type *d ) { Q3GList::inSort((Q3PtrCollection::Item)d); } + void prepend( const type *d ) { Q3GList::insertAt(0,(Q3PtrCollection::Item)d); } + void append( const type *d ) { Q3GList::append((Q3PtrCollection::Item)d); } + bool remove( uint i ) { return Q3GList::removeAt(i); } + bool remove() { return Q3GList::remove((Q3PtrCollection::Item)0); } + bool remove( const type *d ) { return Q3GList::remove((Q3PtrCollection::Item)d); } + bool removeRef( const type *d ) { return Q3GList::removeRef((Q3PtrCollection::Item)d); } + void removeNode( Q3LNode *n ) { Q3GList::removeNode(n); } + bool removeFirst() { return Q3GList::removeFirst(); } + bool removeLast() { return Q3GList::removeLast(); } + type *take( uint i ) { return (type *)Q3GList::takeAt(i); } + type *take() { return (type *)Q3GList::take(); } + type *takeNode( Q3LNode *n ) { return (type *)Q3GList::takeNode(n); } + void clear() { Q3GList::clear(); } + void sort() { Q3GList::sort(); } + int find( const type *d ) { return Q3GList::find((Q3PtrCollection::Item)d); } + int findNext( const type *d ) { return Q3GList::find((Q3PtrCollection::Item)d,FALSE); } + int findRef( const type *d ) { return Q3GList::findRef((Q3PtrCollection::Item)d); } + int findNextRef( const type *d ){ return Q3GList::findRef((Q3PtrCollection::Item)d,FALSE);} + uint contains( const type *d ) const { return Q3GList::contains((Q3PtrCollection::Item)d); } + uint containsRef( const type *d ) const + { return Q3GList::containsRef((Q3PtrCollection::Item)d); } + bool replace( uint i, const type *d ) { return Q3GList::replaceAt( i, (Q3PtrCollection::Item)d ); } + type *at( uint i ) { return (type *)Q3GList::at(i); } + int at() const { return Q3GList::at(); } + type *current() const { return (type *)Q3GList::get(); } + Q3LNode *currentNode() const { return Q3GList::currentNode(); } + type *getFirst() const { return (type *)Q3GList::cfirst(); } + type *getLast() const { return (type *)Q3GList::clast(); } + type *first() { return (type *)Q3GList::first(); } + type *last() { return (type *)Q3GList::last(); } + type *next() { return (type *)Q3GList::next(); } + type *prev() { return (type *)Q3GList::prev(); } + void toVector( Q3GVector *vec )const{ Q3GList::toVector(vec); } + + + // standard iterators + typedef TQPtrListStdIterator<type> Iterator; + typedef TQPtrListStdIterator<type> ConstIterator; + inline Iterator begin() { return Q3GList::begin(); } + inline ConstIterator begin() const { return Q3GList::begin(); } + inline ConstIterator constBegin() const { return Q3GList::begin(); } + inline Iterator end() { return Q3GList::end(); } + inline ConstIterator end() const { return Q3GList::end(); } + inline ConstIterator constEnd() const { return Q3GList::end(); } + inline Iterator erase( Iterator it ) { return Q3GList::erase( it ); } + // stl syntax compatibility + typedef Iterator iterator; + typedef ConstIterator const_iterator; + + +#ifdef Q_QDOC +protected: + virtual int compareItems( Q3PtrCollection::Item, Q3PtrCollection::Item ); + virtual QDataStream& read( QDataStream&, Q3PtrCollection::Item& ); + virtual QDataStream& write( QDataStream&, Q3PtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrList<void>::deleteItem( Q3PtrCollection::Item ) +{ +} +#endif + +template<class type> inline void TQPtrList<type>::deleteItem( Q3PtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template<class type> +class TQPtrListIterator : public Q3GListIterator +{ +public: + TQPtrListIterator(const TQPtrList<type> &l) :Q3GListIterator((Q3GList &)l) {} + ~TQPtrListIterator() {} + uint count() const { return list->count(); } + bool isEmpty() const { return list->count() == 0; } + bool atFirst() const { return Q3GListIterator::atFirst(); } + bool atLast() const { return Q3GListIterator::atLast(); } + type *toFirst() { return (type *)Q3GListIterator::toFirst(); } + type *toLast() { return (type *)Q3GListIterator::toLast(); } + operator type *() const { return (type *)Q3GListIterator::get(); } + type *operator*() { return (type *)Q3GListIterator::get(); } + + // No good, since TQPtrList<char> (ie. QStrList fails... + // + // MSVC++ gives warning + // Sunpro C++ 4.1 gives error + // type *operator->() { return (type *)Q3GListIterator::get(); } + + type *current() const { return (type *)Q3GListIterator::get(); } + type *operator()() { return (type *)Q3GListIterator::operator()();} + type *operator++() { return (type *)Q3GListIterator::operator++(); } + type *operator+=(uint j) { return (type *)Q3GListIterator::operator+=(j);} + type *operator--() { return (type *)Q3GListIterator::operator--(); } + type *operator-=(uint j) { return (type *)Q3GListIterator::operator-=(j);} + TQPtrListIterator<type>& operator=(const TQPtrListIterator<type>&it) + { Q3GListIterator::operator=(it); return *this; } +}; + +#ifndef QT_NO_COMPAT +#define TQList TQPtrList +#define TQListIterator TQPtrListIterator +#endif + +/**********************************************************************/ #endif // USE_QT4 diff --git a/qtinterface/tqstringlist.cpp b/qtinterface/tqstringlist.cpp index 5b76f61..853dbdd 100644 --- a/qtinterface/tqstringlist.cpp +++ b/qtinterface/tqstringlist.cpp @@ -21,3 +21,158 @@ Boston, MA 02110-1301, USA. #include <tqt.h> #include <tqstringlist.h> + +#ifdef USE_QT4 + +void TQStringList::sort() +{ + qHeapSort( *this ); +} + +TQStringList TQStringList::split( const QChar &sep, const QString &str, + bool allowEmptyEntries ) +{ + return split( QString(sep), str, allowEmptyEntries ); +} + +TQStringList TQStringList::split( const QString &sep, const QString &str, + bool allowEmptyEntries ) +{ + TQStringList lst; + + int j = 0; + int i = str.find( sep, j ); + + while ( i != -1 ) { + if ( i > j && i <= (int)str.length() ) + lst << str.mid( j, i - j ); + else if ( allowEmptyEntries ) + lst << QString::null; + j = i + sep.length(); + i = str.find( sep, sep.length() > 0 ? j : j+1 ); + } + + int l = str.length() - 1; + if ( str.mid( j, l - j + 1 ).length() > 0 ) + lst << str.mid( j, l - j + 1 ); + else if ( allowEmptyEntries ) + lst << QString::null; + + return lst; +} + +#ifndef QT_NO_REGEXP +TQStringList TQStringList::split( const QRegExp &sep, const QString &str, + bool allowEmptyEntries ) +{ + TQStringList lst; + + QRegExp tep = sep; + + int j = 0; + int i = tep.search( str, j ); + + while ( i != -1 ) { + if ( str.mid( j, i - j ).length() > 0 ) + lst << str.mid( j, i - j ); + else if ( allowEmptyEntries ) + lst << QString::null; + if ( tep.matchedLength() == 0 ) + j = i + 1; + else + j = i + tep.matchedLength(); + i = tep.search( str, j ); + } + + int l = str.length() - 1; + if ( str.mid( j, l - j + 1 ).length() > 0 ) + lst << str.mid( j, l - j + 1 ); + else if ( allowEmptyEntries ) + lst << QString::null; + + return lst; +} +#endif + +TQStringList TQStringList::grep( const QString &str, bool cs ) const +{ + TQStringList res; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) + if ( (*it).contains(str, cs) ) + res << *it; + + return res; +} + + +#ifndef QT_NO_REGEXP +TQStringList TQStringList::grep( const QRegExp &rx ) const +{ + TQStringList res; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) + if ( (*it).find(rx) != -1 ) + res << *it; + + return res; +} +#endif + +TQStringList& TQStringList::gres( const QString &before, const QString &after, + bool cs ) +{ + TQStringList::Iterator it = begin(); + while ( it != end() ) { + (*it).replace( before, after, cs ); + ++it; + } + return *this; +} + +#ifndef QT_NO_REGEXP_CAPTURE +TQStringList& TQStringList::gres( const QRegExp &rx, const QString &after ) +{ + TQStringList::Iterator it = begin(); + while ( it != end() ) { + (*it).replace( rx, after ); + ++it; + } + return *this; +} +#endif + +QString TQStringList::join( const QString &sep ) const +{ + QString res; + bool alredy = FALSE; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) { + if ( alredy ) + res += sep; + alredy = TRUE; + res += *it; + } + + return res; +} + +#ifndef QT_NO_DATASTREAM +QDataStream &operator>>( QDataStream & s, TQStringList& l ) +{ + return s >> (TQValueList<QString>&)l; +} + +QDataStream &operator<<( QDataStream & s, const TQStringList& l ) +{ + return s << (const TQValueList<QString>&)l; +} +#endif + +TQStringList TQStringList::fromStrList(const TQStrList& ascii) +{ + TQStringList res; + const char * s; + for ( TQStrListIterator it(ascii); (s=it.current()); ++it ) + res << s; + return res; +} + +#endif // USE_QT4
\ No newline at end of file diff --git a/qtinterface/tqstringlist.h b/qtinterface/tqstringlist.h index 81ee9d1..a2b7750 100644 --- a/qtinterface/tqstringlist.h +++ b/qtinterface/tqstringlist.h @@ -26,7 +26,7 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT3 -// Reimplement the QStringList class +// Reimplement the TQStringList class // For Qt3, no changes are needed #include <qstringlist.h> @@ -35,11 +35,134 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 -// Reimplement the QStringList class +// Reimplement the TQStringList class // For Qt4, some changes are needed +#include <tqvaluelist.h> +#include <tqstrlist.h> +#include <tqtl.h> #include <Qt/qstringlist.h> +/**************************************************************************** +** +** Definition of TQStringList class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef QT_NO_STRINGLIST + +class QRegExp; +template <class T> class QDeepCopy; + +#if defined(Q_TEMPLATEDLL) +// MOC_SKIP_BEGIN +//Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList<QString>; +// MOC_SKIP_END +#endif + +class TQStringList : public TQValueList<QString> +{ +public: + TQStringList() { } + TQStringList( const TQStringList& l ) : TQValueList<QString>(l) { } + TQStringList( const TQValueList<QString>& l ) : TQValueList<QString>(l) { } + TQStringList( const QString& i ) { append(i); } +#ifndef QT_NO_CAST_ASCII + TQStringList( const char* i ) { append(i); } +#endif + + // Interoperability + TQStringList(const QStringList& l) + { + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + } + + TQStringList& operator= (const QStringList& l) + { + this->clear(); + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + return *this; + } + + operator QStringList() const { + QStringList list; + for (TQStringList::const_iterator it = TQStringList::constBegin(); + it != TQStringList::constEnd(); ++it) + list.append(*it); + return list; + } + + static TQStringList fromStrList(const TQStrList&); + + void sort(); + + static TQStringList split( const QString &sep, const QString &str, bool allowEmptyEntries = FALSE ); + static TQStringList split( const QChar &sep, const QString &str, bool allowEmptyEntries = FALSE ); +#ifndef QT_NO_REGEXP + static TQStringList split( const QRegExp &sep, const QString &str, bool allowEmptyEntries = FALSE ); +#endif + QString join( const QString &sep ) const; + + TQStringList grep( const QString &str, bool cs = TRUE ) const; +#ifndef QT_NO_REGEXP + TQStringList grep( const QRegExp &expr ) const; +#endif + + TQStringList& gres( const QString &before, const QString &after, + bool cs = TRUE ); +#ifndef QT_NO_REGEXP_CAPTURE + TQStringList& gres( const QRegExp &expr, const QString &after ); +#endif + +protected: + void detach() { TQValueList<QString>::detach(); } + friend class QDeepCopy< TQStringList >; +}; + +#ifndef QT_NO_DATASTREAM +class QDataStream; +extern QDataStream &operator>>( QDataStream &, TQStringList& ); +extern QDataStream &operator<<( QDataStream &, const TQStringList& ); +#endif + +#endif + +/**********************************************************************/ + #endif // USE_QT4 #endif /* TQSTRINGLIST_H */
\ No newline at end of file diff --git a/qtinterface/tqstrlist.h b/qtinterface/tqstrlist.h index a4f9a32..f0efaf3 100644 --- a/qtinterface/tqstrlist.h +++ b/qtinterface/tqstrlist.h @@ -26,7 +26,7 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT3 -// Reimplement the QStrList class +// Reimplement the TQStrList class // For Qt3, no changes are needed #include <qstrlist.h> @@ -35,10 +35,163 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 -// Reimplement the QStrList class +// Reimplement the TQStrList class // For Qt4, some changes are needed +#include <tqptrlist.h> #include <Qt/q3strlist.h> +#include <Qt/q3ptrcollection.h> + +/**************************************************************************** +** +** Definition of TQStrList, TQStrIList and TQStrListIterator classes +** +** Created : 920730 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(Q_QDOC) +class TQStrListIterator : public TQPtrListIterator<char> +{ +}; +#else +typedef TQPtrListIterator<char> TQStrListIterator; +#endif + +class TQStrList : public TQPtrList<char> +{ +public: + TQStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; } + TQStrList( const TQStrList & ); + ~TQStrList() { clear(); } + TQStrList& operator=( const TQStrList & ); + + // Interoperability + TQStrList(Q3StrList& l) + { + for (unsigned int i = 0; i < l.count(); ++i) append(l.at(i)); + } + + TQStrList& operator= (Q3StrList& l) + { + this->clear(); + for (unsigned int i = 0; i < l.count(); ++i) append(l.at(i)); + return *this; + } + + operator Q3StrList() { + Q3StrList list; + for (TQStrList::const_iterator it = TQStrList::constBegin(); + it != TQStrList::constEnd(); ++it) + list.append(*it); + return list; + } + + operator Q3StrList() const { + Q3StrList list; + for (TQStrList::const_iterator it = TQStrList::constBegin(); + it != TQStrList::constEnd(); ++it) + list.append(*it); + return list; + } + + // More interoperability + // Should convert to and from a QList<QByteArray> + TQStrList(const QList<QByteArray> &list) { + for (int i = 0; i < list.size(); ++i) + append(list.at(i).constData()); + } + + TQStrList &operator =(const QList<QByteArray> &list) { + clear(); + for (int i = 0; i < list.size(); ++i) + append(list.at(i).constData()); + return *this; + } + + operator QList<QByteArray>() const { + QList<QByteArray> list; + for (TQPtrListStdIterator<char> it = begin(); it != end(); ++it) + list.append(QByteArray(*it)); + return list; + } + +private: + Q3PtrCollection::Item newItem( Q3PtrCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; } + void deleteItem( Q3PtrCollection::Item d ) { if ( del_item ) delete[] (char*)d; } + int compareItems( Q3PtrCollection::Item s1, Q3PtrCollection::Item s2 ) { return qstrcmp((const char*)s1, + (const char*)s2); } +#ifndef QT_NO_DATASTREAM + QDataStream &read( QDataStream &s, Q3PtrCollection::Item &d ) + { s >> (char *&)d; return s; } + QDataStream &write( QDataStream &s, Q3PtrCollection::Item d ) const + { return s << (const char *)d; } +#endif + bool dc; +}; + + +class TQStrIList : public TQStrList // case insensitive string list +{ +public: + TQStrIList( bool deepCopies=TRUE ) : TQStrList( deepCopies ) {} + ~TQStrIList() { clear(); } +private: + int compareItems( Q3PtrCollection::Item s1, Q3PtrCollection::Item s2 ) + { return qstricmp((const char*)s1, + (const char*)s2); } +}; + + +inline TQStrList & TQStrList::operator=( const TQStrList &strList ) +{ + clear(); + dc = strList.dc; + del_item = dc; + TQPtrList<char>::operator=( strList ); + return *this; +} + +inline TQStrList::TQStrList( const TQStrList &strList ) + : TQPtrList<char>( strList ) +{ + dc = FALSE; + operator=( strList ); +} + +/**********************************************************************/ #endif // USE_QT4 diff --git a/qtinterface/tqt-replace b/qtinterface/tqt-replace index f7c4c5c..ed32a54 100755 --- a/qtinterface/tqt-replace +++ b/qtinterface/tqt-replace @@ -70,8 +70,8 @@ else sed -i 's/TQShared/Q3Shared/g' "$1" sed -i 's/TQColor/QColor/g' "$1" sed -i 's/TQColorDialog/QColorDialog/g' "$1" - sed -i 's/TQStrList/QStrList/g' "$1" - sed -i 's/TQStringList/QStringList/g' "$1" +# sed -i 's/TQStrList/QStrList/g' "$1" +# sed -i 's/TQStringList/QStringList/g' "$1" sed -i 's/TQStringPairList/Q3StringPairList/g' "$1" sed -i 's/TQLineEdit/QLineEdit/g' "$1" sed -i 's/TQValidator/QValidator/g' "$1" @@ -394,12 +394,12 @@ else sed -i 's/TQString/QString/g' "$1" sed -i 's/TQCharRef/QCharRef/g' "$1" sed -i 's/TQConstString/QConstString/g' "$1" - sed -i 's/TQStringList/QStringList/g' "$1" - sed -i 's/TQStrListIterator/Q3StrListIterator/g' "$1" - sed -i 's/TQStrIList/Q3StrIList/g' "$1" - sed -i 's/TQStrList/Q3StrList/g' "$1" - sed -i 's/TQStrVec/QStrVec/g' "$1" - sed -i 's/TQStrIVec/QStrIVec/g' "$1" +# sed -i 's/TQStringList/QStringList/g' "$1" +# sed -i 's/TQStrListIterator/Q3StrListIterator/g' "$1" +# sed -i 's/TQStrIList/Q3StrIList/g' "$1" +# sed -i 's/TQStrList/Q3StrList/g' "$1" +# sed -i 's/TQStrVec/QStrVec/g' "$1" +# sed -i 's/TQStrIVec/QStrIVec/g' "$1" sed -i 's/TQStyleFactory/QStyleFactory/g' "$1" sed -i 's/TQStyleOption/QStyleOption/g' "$1" sed -i 's/TQStyle/QStyle/g' "$1" diff --git a/qtinterface/tqt-replace-stream b/qtinterface/tqt-replace-stream index 9177069..68c8a22 100755 --- a/qtinterface/tqt-replace-stream +++ b/qtinterface/tqt-replace-stream @@ -71,8 +71,8 @@ else sed 's/TQShared/Q3Shared/g' | \ sed 's/TQColor/QColor/g' | \ sed 's/TQColorDialog/QColorDialog/g' | \ - sed 's/TQStrList/QStrList/g' | \ - sed 's/TQStringList/QStringList/g' | \ +# sed 's/TQStrList/QStrList/g' | \ +# sed 's/TQStringList/QStringList/g' | \ sed 's/TQStringPairList/Q3StringPairList/g' | \ sed 's/TQLineEdit/QLineEdit/g' | \ sed 's/TQValidator/QValidator/g' | \ @@ -395,12 +395,12 @@ else sed 's/TQString/QString/g' | \ sed 's/TQCharRef/QCharRef/g' | \ sed 's/TQConstString/QConstString/g' | \ - sed 's/TQStringList/QStringList/g' | \ - sed 's/TQStrListIterator/Q3StrListIterator/g' | \ - sed 's/TQStrIList/Q3StrIList/g' | \ - sed 's/TQStrList/Q3StrList/g' | \ - sed 's/TQStrVec/QStrVec/g' | \ - sed 's/TQStrIVec/QStrIVec/g' | \ +# sed 's/TQStringList/QStringList/g' | \ +# sed 's/TQStrListIterator/Q3StrListIterator/g' | \ +# sed 's/TQStrIList/Q3StrIList/g' | \ +# sed 's/TQStrList/Q3StrList/g' | \ +# sed 's/TQStrVec/QStrVec/g' | \ +# sed 's/TQStrIVec/QStrIVec/g' | \ sed 's/TQStyleFactory/QStyleFactory/g' | \ sed 's/TQStyleOption/QStyleOption/g' | \ sed 's/TQStyle/QStyle/g' | \ diff --git a/qtinterface/tqt.cpp b/qtinterface/tqt.cpp index 184c994..799ff43 100644 --- a/qtinterface/tqt.cpp +++ b/qtinterface/tqt.cpp @@ -25,6 +25,8 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 +static QColor tqblackptr_core = QColor(Qt::black); + template <typename T> QList<T>::operator bool() const { return !this.isEmpty(); diff --git a/qtinterface/tqt.h b/qtinterface/tqt.h index 40344c0..82a3a9d 100644 --- a/qtinterface/tqt.h +++ b/qtinterface/tqt.h @@ -159,7 +159,6 @@ Boston, MA 02110-1301, USA. #define TQShared QShared #define TQColor QColor #define TQColorDialog QColorDialog -#define TQStringList QStringList #define TQStringPairList QStringPairList #define TQLineEdit QLineEdit #define TQValidator QValidator @@ -394,6 +393,7 @@ Boston, MA 02110-1301, USA. #define TQPaintDevice QPaintDevice #define TQPaintDeviceMetrics QPaintDeviceMetrics #define TQColorGroup QColorGroup +#define TQPair QPair #define TQPalette QPalette #define TQPen QPen #define TQPicture QPicture @@ -584,7 +584,8 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 //#define TQT_QT_STRING_LIST_TYPE QStringList -#define TQT_QT_STRING_LIST_TYPE Q3StrList +//#define TQT_QT_STRING_LIST_TYPE Q3StrList +#define TQT_QT_STRING_LIST_TYPE TQStrList #ifdef __cplusplus class TQT_QT_STRING_LIST_TYPE; @@ -612,6 +613,7 @@ class QUObject; #include <tqt4/Qt/qpixmap.h> #include <tqt4/Qt/qwidget.h> #include <tqt4/Qt/q3painter.h> +#include <tqt4/Qt/qicon.h> #include <tqt4/Qt/qstyle.h> #include <tqt4/Qt/qtabbar.h> #include <tqt4/Qt/qstyleoption.h> @@ -628,6 +630,8 @@ class QUObject; #include <tqt4/Qt/qdir.h> #include <tqt4/Qt/qtooltip.h> #include <tqt4/Qt/qmovie.h> +#include <tqt4/Qt/q3whatsthis.h> +#include <tqt4/Qt/qtextcodec.h> #include <Qt/q3strlist.h> #include <Qt/qx11info_x11.h> @@ -642,6 +646,8 @@ class QUObject; #include <Qt/qevent.h> #include <tqlistiterator.h> + +#include <tqstringlist.h> #endif // __cplusplus #define tqchildren ptrchildren @@ -684,7 +690,8 @@ class QUObject; #define qt_xget_temp_gc QPaintDevice::qt_xget_temp_gc #define TickSetting TickPosition #define ButtonState Qt::ButtonState -#define qHeapSort qStableSort +//#define qHeapSort qStableSort +#define qHeapSort tqHeapSort #define ColorOnly Qt::ColorOnly #define MonoOnly Qt::MonoOnly @@ -703,15 +710,17 @@ class QUObject; #define tqdarkMagenta Qt::darkMagenta #define tqdarkYellow Qt::darkYellow #define tqwhite Qt::white -#define tqwhiteptr &((QColor)Qt::white) +// #define tqwhiteptr &((QColor)Qt::white) #define tqlightGray Qt::lightGray #define tqgray Qt::gray #define tqdarkGray Qt::darkGray #define tqblack Qt::black -#define tqblackptr &((QColor)Qt::black) +// #define tqblackptr &((QColor)Qt::black) #define tqcolor0 Qt::color0 #define tqcolor1 Qt::color1 +#define tqblackptr &tqblackptr_core + #define SubRect SubElement #define SR_PushButtonContents SE_PushButtonContents #define SR_PushButtonFocusRect SE_PushButtonFocusRect @@ -879,7 +888,6 @@ class QUObject; #define TQShared Q3Shared #define TQColor QColor #define TQColorDialog QColorDialog -#define TQStringList QStringList #define TQStringPairList Q3StringPairList #define TQLineEdit QLineEdit #define TQValidator QValidator @@ -1030,7 +1038,7 @@ class QUObject; #define TQHttpRequestHeader Q3HttpRequestHeader #define TQHttp Q3Http #define TQIconSet QIcon -#define TQIconFactory QIconFactory +//#define TQIconFactory QIconFactory #define TQIconDragItem Q3IconDragItem #define TQIconDrag Q3IconDrag #define TQIconViewItem Q3IconViewItem @@ -1074,11 +1082,13 @@ class QUObject; #define TQLocale QLocale #define TQLocalFs Q3LocalFs #define TQMainWindow Q3MainWindow -#define TQMapIterator QMapIterator -#define TQMapConstIterator QMapConstIterator -#define TQMapPrivateBase QMapPrivateBase -#define TQMapPrivate QMapPrivate -#define TQMap QMap +//#define TQMapIterator QMapIterator +//#define TQMapIterator QMap::iterator +//#define TQMapConstIterator QMapConstIterator +//#define TQMapConstIterator QMapIterator +//#define TQMapPrivateBase QMapPrivateBase +//#define TQMapPrivate QMapPrivate +//#define TQMap QMap #define TQMemArray Q3MemArray #define TQMenuBar QMenuBar #define TQMenuItem QMenuItem @@ -1109,13 +1119,16 @@ class QUObject; #define TQObject QObject #define TQObjectUserData QObjectUserData #define TQObject QObject -#define TQObjectList QObjectList -#define TQObjectListIterator TQListIterator<QObject *> +//#define TQObjectList QObjectList +#define TQObjectList TQPtrList<QObject> +//#define TQObjectListIterator TQListIterator<QObject *> +#define TQObjectListIterator TQPtrListIterator<QObject> #define TQObjectListIt TQObjectListIterator #define TQPaintDevice QPaintDevice #define TQPaintDeviceMetrics Q3PaintDeviceMetrics #define TQPainter Q3Painter #define TQColorGroup QColorGroup +//#define TQPair QPair #define TQPalette QPalette #define TQPen QPen #define TQPicture Q3Picture @@ -1136,9 +1149,10 @@ class QUObject; #define TQPtrCollection Q3PtrCollection #define TQPtrDict Q3PtrDict #define TQPtrDictIterator Q3PtrDictIterator -#define TQPtrListStdIterator Q3PtrListStdIterator -#define TQPtrList Q3PtrList -#define TQPtrListIterator Q3PtrListIterator +// #define TQPtrListStdIterator Q3PtrListStdIterator +// #define TQPtrList Q3PtrList +// #define TQPtrListIterator Q3PtrListIterator +//#define TQPtrListIterator QListIterator #define TQPtrQueue Q3PtrQueue #define TQPtrStack Q3PtrStack #define TQPtrVector Q3PtrVector @@ -1202,10 +1216,10 @@ class QUObject; #define TQString QString #define TQCharRef QCharRef #define TQConstString QConstString -#define TQStringList QStringList -#define TQStrListIterator Q3StrListIterator -#define TQStrIList Q3StrIList -#define TQStrList Q3StrList +//#define TQStringList QStringList +// #define TQStrListIterator Q3StrListIterator +// #define TQStrIList Q3StrIList +// #define TQStrList Q3StrList #define TQStrVec QStrVec #define TQStrIVec QStrIVec #define TQStyleFactory QStyleFactory @@ -1261,11 +1275,11 @@ class QUObject; #define TQIntValidator QIntValidator #define TQDoubleValidator QDoubleValidator #define TQRegExpValidator QRegExpValidator -#define TQValueListNode QValueListNode -#define TQValueListIterator Q3ValueListIterator -#define TQValueListConstIterator Q3ValueListConstIterator -#define TQValueListPrivate QValueListPrivate -#define TQValueList Q3ValueList +// #define TQValueListNode QValueListNode +// #define TQValueListIterator Q3ValueListIterator +// #define TQValueListConstIterator Q3ValueListConstIterator +// #define TQValueListPrivate QValueListPrivate +// #define TQValueList Q3ValueList #define TQValueStack Q3ValueStack #define TQValueVectorPrivate QValueVectorPrivate #define TQValueVector Q3ValueVector @@ -1279,8 +1293,8 @@ class QUObject; #define TQWidget QWidget #define TQWidgetIntDict QWidgetIntDict #define TQWidgetIntDictIt QWidgetIntDictIt -#define TQWidgetList QWidgetList -#define TQWidgetListIt QWidgetListIt +// #define TQWidgetList QWidgetList +// #define TQWidgetListIt QWidgetListIt #define TQWidgetPlugin QWidgetPlugin #define TQWidgetContainerPlugin QWidgetContainerPlugin #define TQWidgetStack Q3WidgetStack diff --git a/qtinterface/tqt4/Qt/q3whatsthis.h b/qtinterface/tqt4/Qt/q3whatsthis.h new file mode 100644 index 0000000..c6c6086 --- /dev/null +++ b/qtinterface/tqt4/Qt/q3whatsthis.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation ([email protected]) +** +** This file is part of the Qt3Support module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.1, 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 have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q3WHATSTHIS_H +#define Q3WHATSTHIS_H + +#include <QtGui/qcursor.h> +#include <QtGui/qwhatsthis.h> +#include <QtGui/qwidget.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Qt3SupportLight) + +#ifndef QT_NO_WHATSTHIS + +class QToolButton; + +class Q_COMPAT_EXPORT Q3WhatsThis: public QObject +{ + Q_OBJECT +public: + Q3WhatsThis(QWidget *); + ~Q3WhatsThis(); + bool eventFilter(QObject *, QEvent *); + + static inline void enterWhatsThisMode() { QWhatsThis::enterWhatsThisMode(); } + static inline bool inWhatsThisMode() { return QWhatsThis::inWhatsThisMode(); } + + static inline void add(QWidget *w, const QString &s) { w->setWhatsThis(s); } + static inline void remove(QWidget *w) { w->setWhatsThis(QString()); } + static QToolButton * whatsThisButton(QWidget * parent); + static inline void leaveWhatsThisMode(const QString& text = QString(), const QPoint& pos = QCursor::pos(), QWidget* w = 0) + { QWhatsThis::showText(pos, text, w); } + static inline void display(const QString& text, const QPoint& pos = QCursor::pos(), QWidget* w = 0) + { QWhatsThis::showText(pos, text, w); } + + virtual QString text(const QPoint &); + virtual bool clicked(const QString& href); + + static QString textFor( QWidget *, const QPoint & pos = QPoint(), bool includeParents = FALSE ); +}; + +#endif // QT_NO_WHATSTHIS + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // Q3WHATSTHIS_H diff --git a/qtinterface/tqt4/Qt/qicon.h b/qtinterface/tqt4/Qt/qicon.h new file mode 100644 index 0000000..7485a9a --- /dev/null +++ b/qtinterface/tqt4/Qt/qicon.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation ([email protected]) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.1, 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 have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QICON_H +#define QICON_H + +#include <QtCore/qglobal.h> +#include <QtCore/qsize.h> +#include <QtCore/qlist.h> +#include <QtGui/qpixmap.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QIconPrivate; +class QIconEngine; +class QIconEngineV2; +class TQIconFactory; + +class Q_GUI_EXPORT QIcon +{ +public: + enum Mode { Normal, Disabled, Active, Selected }; + enum State { On, Off }; + + QIcon(); + QIcon(const QPixmap &pixmap); + QIcon(const QIcon &other); + explicit QIcon(const QString &fileName); // file or resource name + explicit QIcon(QIconEngine *engine); + explicit QIcon(QIconEngineV2 *engine); + ~QIcon(); + QIcon &operator=(const QIcon &other); + operator QVariant() const; + + QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const; + inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const + { return pixmap(QSize(w, h), mode, state); } + inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const + { return pixmap(QSize(extent, extent), mode, state); } + + QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const; + + void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const; + inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const + { paint(painter, QRect(x, y, w, h), alignment, mode, state); } + + bool isNull() const; + bool isDetached() const; + void detach(); + + int serialNumber() const; + qint64 cacheKey() const; + + void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off); + void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off); + + QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const; + + static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon()); + static bool hasThemeIcon(const QString &name); + + static QStringList themeSearchPaths(); + static void setThemeSearchPaths(const QStringList &searchpath); + + static QString themeName(); + static void setThemeName(const QString &path); + + +#ifdef QT3_SUPPORT + enum Size { Small, Large, Automatic = Small }; + static QT3_SUPPORT void setPixmapSize(Size which, const QSize &size); + static QT3_SUPPORT QSize pixmapSize(Size which); + inline QT3_SUPPORT void reset(const QPixmap &pixmap, Size /*size*/) { *this = QIcon(pixmap); } + inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap, Size, Mode mode = Normal, State state = Off) + { addPixmap(pixmap, mode, state); } + inline QT3_SUPPORT void setPixmap(const QString &fileName, Size, Mode mode = Normal, State state = Off) + { addPixmap(QPixmap(fileName), mode, state); } + QT3_SUPPORT QPixmap pixmap(Size size, Mode mode, State state = Off) const; + QT3_SUPPORT QPixmap pixmap(Size size, bool enabled, State state = Off) const; + QT3_SUPPORT QPixmap pixmap() const; + + void installIconFactory( TQIconFactory *factory ); +#endif + + Q_DUMMY_COMPARISON_OPERATOR(QIcon) + +private: + QIconPrivate *d; +#if !defined(QT_NO_DATASTREAM) + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); +#endif + +public: + typedef QIconPrivate * DataPtr; + inline DataPtr &data_ptr() { return d; } +}; + +Q_DECLARE_SHARED(QIcon) +Q_DECLARE_TYPEINFO(QIcon, Q_MOVABLE_TYPE); + +#if !defined(QT_NO_DATASTREAM) +Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); +Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); +#endif + +#ifdef QT3_SUPPORT +typedef QIcon QIconSet; +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QICON_H diff --git a/qtinterface/tqt4/Qt/qlist.h b/qtinterface/tqt4/Qt/qlist.h index 39e44d9..9a16b9e 100644 --- a/qtinterface/tqt4/Qt/qlist.h +++ b/qtinterface/tqt4/Qt/qlist.h @@ -163,8 +163,8 @@ public: 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]; } + inline T next() { current_index++; return this[current_index]; } + inline T prev() { current_index--; return this[current_index]; } class const_iterator; @@ -448,7 +448,7 @@ inline void QList<T>::insert(iterator pos, int n, const T &x) { int q; for (q=0;q<n;q++) { - this.insert(pos, x); + this->insert(pos, x); } } diff --git a/qtinterface/tqt4/Qt/qtabbar.h b/qtinterface/tqt4/Qt/qtabbar.h index c05497f..216f8c9 100644 --- a/qtinterface/tqt4/Qt/qtabbar.h +++ b/qtinterface/tqt4/Qt/qtabbar.h @@ -140,6 +140,7 @@ public: QRect tabRect(int index) const; int tabAt(const QPoint &pos) const; int tabAt(const int &pos) const; +// QTab * tabAt( int ) const; int currentIndex() const; int count() const; diff --git a/qtinterface/tqt4/Qt/qtextcodec.h b/qtinterface/tqt4/Qt/qtextcodec.h new file mode 100644 index 0000000..100b50c --- /dev/null +++ b/qtinterface/tqt4/Qt/qtextcodec.h @@ -0,0 +1,205 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation ([email protected]) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.1, 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 have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTEXTCODEC_H +#define QTEXTCODEC_H + +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +#ifndef QT_NO_TEXTCODEC + +class QTextCodec; +class QIODevice; + +class QTextDecoder; +class QTextEncoder; + +class Q_CORE_EXPORT QTextCodec +{ + Q_DISABLE_COPY(QTextCodec) +public: + static QTextCodec* codecForName(const QByteArray &name); + static QTextCodec* codecForName(const char *name) { return codecForName(QByteArray(name)); } + static QTextCodec* codecForMib(int mib); + + static QList<QByteArray> availableCodecs(); + static QList<int> availableMibs(); + + static QTextCodec* codecForLocale(); + static void setCodecForLocale(QTextCodec *c); + + static QTextCodec* codecForTr(); + static void setCodecForTr(QTextCodec *c); + + static QTextCodec* codecForCStrings(); + static void setCodecForCStrings(QTextCodec *c); + + static QTextCodec *codecForHtml(const QByteArray &ba); + static QTextCodec *codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec); + + static QTextCodec *codecForUtfText(const QByteArray &ba); + static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec); + + QTextDecoder* makeDecoder() const; + QTextEncoder* makeEncoder() const; + + bool canEncode(QChar) const; + bool canEncode(const QString&) const; + + QString toUnicode(const QByteArray&) const; + QString toUnicode(const char* chars) const; + QByteArray fromUnicode(const QString& uc) const; + enum ConversionFlag { + DefaultConversion, + ConvertInvalidToNull = 0x80000000, + IgnoreHeader = 0x1, + FreeFunction = 0x2 + }; + Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) + + struct Q_CORE_EXPORT ConverterState { + ConverterState(ConversionFlags f = DefaultConversion) + : flags(f), remainingChars(0), invalidChars(0), d(0) { state_data[0] = state_data[1] = state_data[2] = 0; } + ~ConverterState(); + ConversionFlags flags; + int remainingChars; + int invalidChars; + uint state_data[3]; + void *d; + private: + Q_DISABLE_COPY(ConverterState) + }; + + QString toUnicode(const char *in, int length, ConverterState *state = 0) const + { return convertToUnicode(in, length, state); } + QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const + { return convertFromUnicode(in, length, state); } + + virtual QByteArray name() const = 0; + virtual QList<QByteArray> aliases() const; + virtual int mibEnum() const = 0; + virtual int heuristicNameMatch(const char* hint) const; + +#ifndef QT_NO_CODECS + static QTextCodec* loadCharmap(QIODevice*); + static QTextCodec* loadCharmapFile(QString filename); +#endif //QT_NO_CODECS + +protected: + virtual QString convertToUnicode(const char *in, int length, ConverterState *state) const = 0; + virtual QByteArray convertFromUnicode(const QChar *in, int length, ConverterState *state) const = 0; + + static int simpleHeuristicNameMatch(const char* name, const char* hint); + + QTextCodec(); + virtual ~QTextCodec(); + +public: +#ifdef QT3_SUPPORT + static QT3_SUPPORT QTextCodec* codecForContent(const char*, int) { return 0; } + static QT3_SUPPORT const char* locale(); + static QT3_SUPPORT QTextCodec* codecForName(const char* hint, int) { return codecForName(QByteArray(hint)); } + QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut) const; + QT3_SUPPORT QString toUnicode(const QByteArray&, int len) const; + QT3_SUPPORT QByteArray mimeName() const { return name(); } + static QT3_SUPPORT QTextCodec *codecForIndex(int i) { return codecForName(availableCodecs().value(i)); } +#endif + +private: + friend class QTextCodecCleanup; + static QTextCodec *cftr; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QTextCodec::ConversionFlags) + +inline QTextCodec* QTextCodec::codecForTr() { return cftr; } +inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; } +inline QTextCodec* QTextCodec::codecForCStrings() { return QString::codecForCStrings; } +inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { QString::codecForCStrings = c; } + +class Q_CORE_EXPORT QTextEncoder { + Q_DISABLE_COPY(QTextEncoder) +public: + explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {} + ~QTextEncoder(); + QByteArray fromUnicode(const QString& str); + QByteArray fromUnicode(const QChar *uc, int len); +#ifdef QT3_SUPPORT + QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut); +#endif + bool hasFailure() const; +private: + const QTextCodec *c; + QTextCodec::ConverterState state; + + friend class QXmlStreamWriter; + friend class QXmlStreamWriterPrivate; + friend class QCoreXmlStreamWriter; + friend class QCoreXmlStreamWriterPrivate; +}; + +class Q_CORE_EXPORT QTextDecoder { + Q_DISABLE_COPY(QTextDecoder) +public: + explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {} + ~QTextDecoder(); + QString toUnicode(const char* chars, int len); + QString toUnicode(const QByteArray &ba); + void toUnicode(QString *target, const char *chars, int len); + bool hasFailure() const; +private: + const QTextCodec *c; + QTextCodec::ConverterState state; +}; + +#endif // QT_NO_TEXTCODEC + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QTEXTCODEC_H diff --git a/qtinterface/tqtextcodec.cpp b/qtinterface/tqtextcodec.cpp index 7958168..6e047a5 100644 --- a/qtinterface/tqtextcodec.cpp +++ b/qtinterface/tqtextcodec.cpp @@ -21,3 +21,495 @@ Boston, MA 02110-1301, USA. #include <tqt.h> #include <tqtextcodec.h> + +#ifdef USE_QT4 + +// returns a string containing the letters and numbers from input, +// with a space separating run of a character class. e.g. "iso8859-1" +// becomes "iso 8859 1" +static QString lettersAndNumbers( const char * input ) +{ + QString result; + QChar c; + + while( input && *input ) { + c = *input; + if ( c.isLetter() || c.isNumber() ) + result += c.lower(); + if ( input[1] ) { + // add space at character class transition, except + // transition from upper-case to lower-case letter + QChar n( input[1] ); + if ( c.isLetter() && n.isLetter() ) { + if ( c == c.lower() && n == n.upper() ) + result += ' '; + } else if ( c.category() != n.category() ) { + result += ' '; + } + } + input++; + } + return result.simplifyWhiteSpace(); +} + +#define CHAINED 0xffff + +struct QMultiByteUnicodeTable { + // If multiByte, ignore unicode and index into multiByte + // with the next character. + QMultiByteUnicodeTable() : unicode(0xfffd), multiByte(0) { } + + ~QMultiByteUnicodeTable() + { + if ( multiByte ) + delete [] multiByte; + } + + ushort unicode; + QMultiByteUnicodeTable* multiByte; +}; + +static int getByte(char* &cursor) +{ + int byte = 0; + if ( *cursor ) { + if ( cursor[1] == 'x' ) + byte = strtol(cursor+2,&cursor,16); + else if ( cursor[1] == 'd' ) + byte = strtol(cursor+2,&cursor,10); + else + byte = strtol(cursor+2,&cursor,8); + } + return byte&0xff; +} + +class QTextCodecFromIOD; + +class QTextCodecFromIODDecoder : public QTextDecoder { + const QTextCodecFromIOD* codec; + QMultiByteUnicodeTable* mb; +public: + QTextCodecFromIODDecoder(const QTextCodecFromIOD* c); + //QString toUnicode(const char* chars, int len); + QString convertToUnicode(const char* chars, int len, int *state); +}; + +class QTextCodecFromIOD : public QTextCodec { + friend class QTextCodecFromIODDecoder; + + TQCString n; + + // If from_unicode_page[row()][cell()] is 0 and from_unicode_page_multiByte, + // use from_unicode_page_multiByte[row()][cell()] as string. + char** from_unicode_page; + char*** from_unicode_page_multiByte; + char unkn; + + // Only one of these is used + ushort* to_unicode; + QMultiByteUnicodeTable* to_unicode_multiByte; + int max_bytes_per_char; + TQStrList aliases; + + bool stateless() const { return !to_unicode_multiByte; } + +public: + QTextCodecFromIOD(QIODevice* iod) + { + from_unicode_page = 0; + to_unicode_multiByte = 0; + to_unicode = 0; + from_unicode_page_multiByte = 0; + max_bytes_per_char = 1; + + const int maxlen=100; + char line[maxlen]; + char esc='\\'; + char comm='%'; + bool incmap = FALSE; + while (iod->readLine(line,maxlen) > 0) { + if (0==qstrnicmp(line,"<code_set_name>",15)) + n = line+15; + else if (0==qstrnicmp(line,"<escape_char> ",14)) + esc = line[14]; + else if (0==qstrnicmp(line,"<comment_char> ",15)) + comm = line[15]; + else if (line[0]==comm && 0==qstrnicmp(line+1," alias ",7)) { + aliases.append(line+8); + } else if (0==qstrnicmp(line,"CHARMAP",7)) { + if (!from_unicode_page) { + from_unicode_page = new char*[256]; + for (int i=0; i<256; i++) + from_unicode_page[i]=0; + } + if (!to_unicode) { + to_unicode = new ushort[256]; + } + incmap = TRUE; + } else if (0==qstrnicmp(line,"END CHARMAP",11)) + break; + else if (incmap) { + char* cursor = line; + int byte=-1,unicode=-1; + ushort* mb_unicode=0; + const int maxmb=8; // more -> we'll need to improve datastructures + char mb[maxmb+1]; + int nmb=0; + + while (*cursor) { + if (cursor[0]=='<' && cursor[1]=='U' && + cursor[2]>='0' && cursor[2]<='9' && + cursor[3]>='0' && cursor[3]<='9') { + + unicode = strtol(cursor+2,&cursor,16); + + } else if (*cursor==esc) { + + byte = getByte(cursor); + + if ( *cursor == esc ) { + if ( !to_unicode_multiByte ) { + to_unicode_multiByte = + new QMultiByteUnicodeTable[256]; + for (int i=0; i<256; i++) { + to_unicode_multiByte[i].unicode = + to_unicode[i]; + to_unicode_multiByte[i].multiByte = 0; + } + delete [] to_unicode; + to_unicode = 0; + } + QMultiByteUnicodeTable* mbut = + to_unicode_multiByte+byte; + mb[nmb++] = byte; + while ( nmb < maxmb && *cursor == esc ) { + // Always at least once + + mbut->unicode = CHAINED; + byte = getByte(cursor); + mb[nmb++] = byte; + if (!mbut->multiByte) { + mbut->multiByte = + new QMultiByteUnicodeTable[256]; + } + mbut = mbut->multiByte+byte; + mb_unicode = & mbut->unicode; + } + + if ( nmb > max_bytes_per_char ) + max_bytes_per_char = nmb; + } + } else { + cursor++; + } + } + + if (unicode >= 0 && unicode <= 0xffff) + { + QChar ch((ushort)unicode); + if (!from_unicode_page[ch.row()]) { + from_unicode_page[ch.row()] = new char[256]; + for (int i=0; i<256; i++) + from_unicode_page[ch.row()][i]=0; + } + if ( mb_unicode ) { + from_unicode_page[ch.row()][ch.cell()] = 0; + if (!from_unicode_page_multiByte) { + from_unicode_page_multiByte = new char**[256]; + for (int i=0; i<256; i++) + from_unicode_page_multiByte[i]=0; + } + if (!from_unicode_page_multiByte[ch.row()]) { + from_unicode_page_multiByte[ch.row()] = new char*[256]; + for (int i=0; i<256; i++) + from_unicode_page_multiByte[ch.row()][i] = 0; + } + mb[nmb++] = 0; + from_unicode_page_multiByte[ch.row()][ch.cell()] + = qstrdup(mb); + *mb_unicode = unicode; + } else { + from_unicode_page[ch.row()][ch.cell()] = (char)byte; + if ( to_unicode ) + to_unicode[byte] = unicode; + else + to_unicode_multiByte[byte].unicode = unicode; + } + } else { + } + } + } + n = n.stripWhiteSpace(); + + unkn = '?'; // ##### Might be a bad choice. + } + + ~QTextCodecFromIOD() + { + if ( from_unicode_page ) { + for (int i=0; i<256; i++) + if (from_unicode_page[i]) + delete [] from_unicode_page[i]; + } + if ( from_unicode_page_multiByte ) { + for (int i=0; i<256; i++) + if (from_unicode_page_multiByte[i]) + for (int j=0; j<256; j++) + if (from_unicode_page_multiByte[i][j]) + delete [] from_unicode_page_multiByte[i][j]; + } + if ( to_unicode ) + delete [] to_unicode; + if ( to_unicode_multiByte ) + delete [] to_unicode_multiByte; + } + + bool ok() const + { + return !!from_unicode_page; + } + + QTextDecoder* makeDecoder() const + { + if ( stateless() ) + return QTextCodec::makeDecoder(); + else + return new QTextCodecFromIODDecoder(this); + } + + const char* qtio_name() const + { + return n; + } + + int mibEnum() const + { + return 0; // #### Unknown. + } + + int heuristicContentMatch(const char*, int) const + { + return 0; + } + + int heuristicNameMatch(const char* hint) const + { + int bestr = QTextCodec::heuristicNameMatch(hint); + TQStrListIterator it(aliases); + char* a; + while ((a=it.current())) { + ++it; + int r = simpleHeuristicNameMatch(a,hint); + if (r > bestr) + bestr = r; + } + return bestr; + } + + QString toUnicode(const char* chars, int len) const + { + const uchar* uchars = (const uchar*)chars; + QString result; + QMultiByteUnicodeTable* multiByte=to_unicode_multiByte; + if ( multiByte ) { + while (len--) { + QMultiByteUnicodeTable& mb = multiByte[*uchars]; + if ( mb.multiByte ) { + // Chained multi-byte + multiByte = mb.multiByte; + } else { + result += QChar(mb.unicode); + multiByte=to_unicode_multiByte; + } + uchars++; + } + } else { + while (len--) + result += QChar(to_unicode[*uchars++]); + } + return result; + } + + QString convertToUnicode(const char* chars, int len, ConverterState *state) const + { + return toUnicode(chars, len); + } + +#if !defined(Q_NO_USING_KEYWORD) + using QTextCodec::fromUnicode; +#endif + TQCString fromUnicode(const QString& uc, int& lenInOut) const + { + if (lenInOut > (int)uc.length()) + lenInOut = uc.length(); + int rlen = lenInOut*max_bytes_per_char; + TQCString rstr(rlen+1); + char* cursor = rstr.data(); + char* s=0; + int l = lenInOut; + int lout = 0; + for (int i=0; i<l; i++) { + QChar ch = uc[i]; + if ( ch == QChar() ) { + // special + *cursor++ = 0; + } else if ( from_unicode_page[ch.row()] && + from_unicode_page[ch.row()][ch.cell()] ) + { + *cursor++ = from_unicode_page[ch.row()][ch.cell()]; + lout++; + } else if ( from_unicode_page_multiByte && + from_unicode_page_multiByte[ch.row()] && + (s=from_unicode_page_multiByte[ch.row()][ch.cell()]) ) + { + while (*s) { + *cursor++ = *s++; + lout++; + } + } else { + *cursor++ = unkn; + lout++; + } + } + *cursor = 0; + lenInOut = lout; + return rstr; + } + + QByteArray convertFromUnicode(const QChar *charin, int len, ConverterState *state) const + { + return fromUnicode(charin, len); + } + + QByteArray name() const + { + return qtio_name(); + } +}; + +// QTextCodecFromIODDecoder::QTextCodecFromIODDecoder(const QTextCodecFromIOD* c) : +// codec(c) +// { +// mb = codec->to_unicode_multiByte; +// } + +QString QTextCodecFromIODDecoder::convertToUnicode(const char* chars, int len, int *state) +{ + const uchar* uchars = (const uchar*)chars; + QString result; + while (len--) { + QMultiByteUnicodeTable& t = mb[*uchars]; + if ( t.multiByte ) { + // Chained multi-byte + mb = t.multiByte; + } else { + if ( t.unicode ) + result += QChar(t.unicode); + mb=codec->to_unicode_multiByte; + } + uchars++; + } + return result; +} + +#ifndef QT_NO_CODECS +// Cannot use <pre> or \code +/*! + Reads a POSIX2 charmap definition from \a iod. + The parser recognizes the following lines: + +<font name="sans"> + <code_set_name> <i>name</i></br> + <escape_char> <i>character</i></br> + % alias <i>alias</i></br> + CHARMAP</br> + <<i>token</i>> /x<i>hexbyte</i> <U<i>unicode</i>> ...</br> + <<i>token</i>> /d<i>decbyte</i> <U<i>unicode</i>> ...</br> + <<i>token</i>> /<i>octbyte</i> <U<i>unicode</i>> ...</br> + <<i>token</i>> /<i>any</i>/<i>any</i>... <U<i>unicode</i>> ...</br> + END CHARMAP</br> +</font> + + The resulting QTextCodec is returned (and also added to the global + list of codecs). The name() of the result is taken from the + code_set_name. + + Note that a codec constructed in this way uses much more memory + and is slower than a hand-written QTextCodec subclass, since + tables in code are kept in memory shared by all Qt applications. + + \sa loadCharmapFile() +*/ +QTextCodec* QTextCodec::loadCharmap(QIODevice* iod) +{ + QTextCodecFromIOD* r = new QTextCodecFromIOD(iod); + if ( !r->ok() ) { + delete r; + r = 0; + } + return r; +} + +/*! + A convenience function for loadCharmap() that loads the charmap + definition from the file \a filename. +*/ +QTextCodec* QTextCodec::loadCharmapFile(QString filename) +{ + QFile f(filename); + if (f.open(IO_ReadOnly)) { + QTextCodecFromIOD* r = new QTextCodecFromIOD(&f); + if ( !r->ok() ) + delete r; + else + return r; + } + return 0; +} + +/*! + Returns a value indicating how likely it is that this decoder is + appropriate for decoding some format that has the given name. The + name is compared with the \a hint. + + A good match returns a positive number around the length of the + string. A bad match is negative. + + The default implementation calls simpleHeuristicNameMatch() with + the name of the codec. +*/ +int QTextCodec::heuristicNameMatch(const char* hint) const +{ + return simpleHeuristicNameMatch(name(),hint); +} + +/*! + A simple utility function for heuristicNameMatch(): it does some + very minor character-skipping so that almost-exact matches score + high. \a name is the text we're matching and \a hint is used for + the comparison. +*/ +int QTextCodec::simpleHeuristicNameMatch(const char* name, const char* hint) +{ + // if they're the same, return a perfect score. + if ( name && hint && *name && *hint && qstricmp( name, hint ) == 0 ) + return qstrlen( hint ); + + // if the letters and numbers are the same, we have an "almost" + // perfect match. + QString h( lettersAndNumbers( hint ) ); + QString n( lettersAndNumbers( name ) ); + if ( h == n ) + return qstrlen( hint )-1; + + if ( h.stripWhiteSpace() == n.stripWhiteSpace() ) + return qstrlen( hint )-2; + + // could do some more here, but I don't think it's worth it + + return 0; +} + +#endif //QT_NO_CODECS + +#endif // USE_QT4
\ No newline at end of file diff --git a/qtinterface/tqtextcodec.h b/qtinterface/tqtextcodec.h index 2dde117..fac0a89 100644 --- a/qtinterface/tqtextcodec.h +++ b/qtinterface/tqtextcodec.h @@ -38,7 +38,7 @@ Boston, MA 02110-1301, USA. // Reimplement the QTextCodec class // For Qt4, some changes are needed -#include <Qt/qtextcodec.h> +#include <tqt4/Qt/qtextcodec.h> #endif // USE_QT4 diff --git a/qtinterface/tqtl.h b/qtinterface/tqtl.h index 3f90727..40efda6 100644 --- a/qtinterface/tqtl.h +++ b/qtinterface/tqtl.h @@ -35,9 +35,328 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 +#include <Qt/qtextstream.h> + // Reimplement the Qtl class // For Qt4, this class was removed! +/**************************************************************************** +** +** Definition of Qt template library classes +** +** Created : 990128 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef QT_NO_TEXTSTREAM +template <class T> +class TQTextOStreamIterator +{ +protected: + QTextOStream& stream; + QString separator; + +public: + TQTextOStreamIterator( QTextOStream& s) : stream( s ) {} + TQTextOStreamIterator( QTextOStream& s, const QString& sep ) + : stream( s ), separator( sep ) {} + TQTextOStreamIterator<T>& operator= ( const T& x ) { + stream << x; + if ( !separator.isEmpty() ) + stream << separator; + return *this; + } + TQTextOStreamIterator<T>& operator*() { return *this; } + TQTextOStreamIterator<T>& operator++() { return *this; } + TQTextOStreamIterator<T>& operator++(int) { return *this; } +}; +#endif //QT_NO_TEXTSTREAM + +template <class InputIterator, class OutputIterator> +inline OutputIterator tqCopy( InputIterator _begin, InputIterator _end, + OutputIterator _dest ) +{ + while( _begin != _end ) + *_dest++ = *_begin++; + return _dest; +} + +template <class BiIterator, class BiOutputIterator> +inline BiOutputIterator tqCopyBackward( BiIterator _begin, BiIterator _end, + BiOutputIterator _dest ) +{ + while ( _begin != _end ) + *--_dest = *--_end; + return _dest; +} + +template <class InputIterator1, class InputIterator2> +inline bool tqEqual( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 ) +{ + // ### compare using !(*first1 == *first2) in Qt 4.0 + for ( ; first1 != last1; ++first1, ++first2 ) + if ( *first1 != *first2 ) + return FALSE; + return TRUE; +} + +template <class ForwardIterator, class T> +inline void tqFill( ForwardIterator first, ForwardIterator last, const T& val ) +{ + for ( ; first != last; ++first ) + *first = val; +} + +#if 0 +template <class BiIterator, class OutputIterator> +inline OutputIterator qReverseCopy( BiIterator _begin, BiIterator _end, + OutputIterator _dest ) +{ + while ( _begin != _end ) { + --_end; + *_dest = *_end; + ++_dest; + } + return _dest; +} +#endif + + +template <class InputIterator, class T> +inline InputIterator tqFind( InputIterator first, InputIterator last, + const T& val ) +{ + while ( first != last && *first != val ) + ++first; + return first; +} + +template <class InputIterator, class T, class Size> +inline void tqCount( InputIterator first, InputIterator last, const T& value, + Size& n ) +{ + for ( ; first != last; ++first ) + if ( *first == value ) + ++n; +} + +template <class T> +inline void tqSwap( T& _value1, T& _value2 ) +{ + T tmp = _value1; + _value1 = _value2; + _value2 = tmp; +} + + +template <class InputIterator> +void tqBubbleSort( InputIterator b, InputIterator e ) +{ + // Goto last element; + InputIterator last = e; + --last; + // only one element or no elements ? + if ( last == b ) + return; + + // So we have at least two elements in here + while( b != last ) { + bool swapped = FALSE; + InputIterator swap_pos = b; + InputIterator x = e; + InputIterator y = x; + y--; + do { + --x; + --y; + if ( *x < *y ) { + swapped = TRUE; + tqSwap( *x, *y ); + swap_pos = y; + } + } while( y != b ); + if ( !swapped ) + return; + b = swap_pos; + b++; + } +} + + +template <class Container> +inline void tqBubbleSort( Container &c ) +{ + tqBubbleSort( c.begin(), c.end() ); +} + + +template <class Value> +void tqHeapSortPushDown( Value* heap, int first, int last ) +{ + int r = first; + while ( r <= last / 2 ) { + if ( last == 2 * r ) { + // node r has only one child + if ( heap[2 * r] < heap[r] ) + tqSwap( heap[r], heap[2 * r] ); + r = last; + } else { + // node r has two children + if ( heap[2 * r] < heap[r] && !(heap[2 * r + 1] < heap[2 * r]) ) { + // swap with left child + tqSwap( heap[r], heap[2 * r] ); + r *= 2; + } else if ( heap[2 * r + 1] < heap[r] + && heap[2 * r + 1] < heap[2 * r] ) { + // swap with right child + tqSwap( heap[r], heap[2 * r + 1] ); + r = 2 * r + 1; + } else { + r = last; + } + } + } +} + + +template <class InputIterator, class Value> +void tqHeapSortHelper( InputIterator b, InputIterator e, Value, uint n ) +{ + // Create the heap + InputIterator insert = b; + Value* realheap = new Value[n]; + // Wow, what a fake. But I want the heap to be indexed as 1...n + Value* heap = realheap - 1; + int size = 0; + for( ; insert != e; ++insert ) { + heap[++size] = *insert; + int i = size; + while( i > 1 && heap[i] < heap[i / 2] ) { + tqSwap( heap[i], heap[i / 2] ); + i /= 2; + } + } + + // Now do the sorting + for( uint i = n; i > 0; i-- ) { + *b++ = heap[1]; + if ( i > 1 ) { + heap[1] = heap[i]; + tqHeapSortPushDown( heap, 1, (int)i - 1 ); + } + } + + delete[] realheap; +} + + +template <class InputIterator> +void tqHeapSort( InputIterator b, InputIterator e ) +{ + // Empty ? + if ( b == e ) + return; + + // How many entries have to be sorted ? + InputIterator it = b; + uint n = 0; + while ( it != e ) { + ++n; + ++it; + } + + // The second last parameter is a hack to retrieve the value type + // Do the real sorting here + tqHeapSortHelper( b, e, *b, n ); +} + + +template <class Container> +void tqHeapSort( Container &c ) +{ + if ( c.begin() == c.end() ) + return; + + // The second last parameter is a hack to retrieve the value type + // Do the real sorting here + tqHeapSortHelper( c.begin(), c.end(), *(c.begin()), (uint)c.count() ); +} + +template <class Container> +class TQBackInsertIterator +{ +public: + TQBackInsertIterator( Container &c ) + : container( &c ) + { + } + + TQBackInsertIterator<Container>& + operator=( const Q_TYPENAME Container::value_type &value ) + { + container->push_back( value ); + return *this; + } + + TQBackInsertIterator<Container>& operator*() + { + return *this; + } + + TQBackInsertIterator<Container>& operator++() + { + return *this; + } + + TQBackInsertIterator<Container>& operator++(int) + { + return *this; + } + +protected: + Container *container; +}; + +template <class Container> +inline TQBackInsertIterator<Container> qBackInserter( Container &c ) +{ + return TQBackInsertIterator<Container>( c ); +} + +/**********************************************************************/ + #endif // USE_QT4 #endif /* TQTL_H */
\ No newline at end of file diff --git a/qtinterface/tqvaluelist.h b/qtinterface/tqvaluelist.h index 3224e5f..916a55f 100644 --- a/qtinterface/tqvaluelist.h +++ b/qtinterface/tqvaluelist.h @@ -39,7 +39,681 @@ Boston, MA 02110-1301, USA. // Reimplement the QValueList class // For Qt4, some changes are needed +#include <Qt/q3shared.h> #include <Qt/q3valuelist.h> +#include <Qt/qlist.h> + +/**************************************************************************** +** $Id: qt/qvaluelist.h 3.3.7 edited Aug 31 2005 $ +** +** Definition of TQValueList class +** +** Created : 990406 +** +** Copyright (C) 1992-2005 Trolltech AS. All rights reserved. +** +** This file is part of the tools module of the Qt GUI Toolkit. +** +** This file may be distributed under the terms of the Q Public License +** as defined by Trolltech AS of Norway and appearing in the file +** LICENSE.QPL included in the packaging of this file. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition +** licenses may use this file in accordance with the Qt Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/pricing.html or email [email protected] for +** information about Qt Commercial License Agreements. +** See http://www.trolltech.com/qpl/ for QPL licensing information. +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact [email protected] if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +//#define QT_CHECK_VALUELIST_RANGE + +#if defined(Q_CC_MSVC) +#pragma warning(disable:4284) // "return type for operator -> is not a UDT" +#endif + +template <class T> +class TQValueListNode +{ +public: + TQValueListNode( const T& t ) : data( t ) { } + TQValueListNode() { } +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual ~TQValueListNode() { } +#endif + + TQValueListNode<T>* next; + TQValueListNode<T>* prev; + T data; +}; + +template<class T> +class TQValueListIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode<T>* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListIterator() : node( 0 ) {} + TQValueListIterator( NodePtr p ) : node( p ) {} + TQValueListIterator( const TQValueListIterator<T>& it ) : node( it.node ) {} + + bool operator==( const TQValueListIterator<T>& it ) const { return node == it.node; } + bool operator!=( const TQValueListIterator<T>& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + T& operator*() { return node->data; } + // UDT for T = x* + // T* operator->() const { return &node->data; } + + TQValueListIterator<T>& operator++() { + node = node->next; + return *this; + } + + TQValueListIterator<T> operator++(int) { + TQValueListIterator<T> tmp = *this; + node = node->next; + return tmp; + } + + TQValueListIterator<T>& operator--() { + node = node->prev; + return *this; + } + + TQValueListIterator<T> operator--(int) { + TQValueListIterator<T> tmp = *this; + node = node->prev; + return tmp; + } + + TQValueListIterator<T>& operator+=( int j ) { + while ( j-- ) + node = node->next; + return *this; + } + + TQValueListIterator<T>& operator-=( int j ) { + while ( j-- ) + node = node->prev; + return *this; + } + +}; + +template<class T> +class TQValueListConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode<T>* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListConstIterator() : node( 0 ) {} + TQValueListConstIterator( NodePtr p ) : node( p ) {} + TQValueListConstIterator( const TQValueListConstIterator<T>& it ) : node( it.node ) {} + TQValueListConstIterator( const TQValueListIterator<T>& it ) : node( it.node ) {} + + bool operator==( const TQValueListConstIterator<T>& it ) const { return node == it.node; } + bool operator!=( const TQValueListConstIterator<T>& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + TQValueListConstIterator<T>& operator++() { + node = node->next; + return *this; + } + + TQValueListConstIterator<T> operator++(int) { + TQValueListConstIterator<T> tmp = *this; + node = node->next; + return tmp; + } + + TQValueListConstIterator<T>& operator--() { + node = node->prev; + return *this; + } + + TQValueListConstIterator<T> operator--(int) { + TQValueListConstIterator<T> tmp = *this; + node = node->prev; + return tmp; + } +}; + +template <class T> +class TQValueListPrivate : public Q3Shared +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator<T> Iterator; + typedef TQValueListConstIterator<T> ConstIterator; + typedef TQValueListNode<T> Node; + typedef TQValueListNode<T>* NodePtr; + typedef size_t size_type; + + /** + * Functions + */ + TQValueListPrivate(); + TQValueListPrivate( const TQValueListPrivate<T>& _p ); + + void derefAndDelete() // ### hack to get around hp-cc brain damage + { + if ( deref() ) + delete this; + } + +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual +#endif + ~TQValueListPrivate(); + + Iterator insert( Iterator it, const T& x ); + Iterator remove( Iterator it ); + NodePtr find( NodePtr start, const T& x ) const; + int findIndex( NodePtr start, const T& x ) const; + uint contains( const T& x ) const; + uint remove( const T& x ); + NodePtr at( size_type i ) const; + void clear(); + + NodePtr node; + size_type nodes; +}; + +template <class T> +TQValueListPrivate<T>::TQValueListPrivate() +{ + node = new Node; node->next = node->prev = node; nodes = 0; +} + +template <class T> +TQValueListPrivate<T>::TQValueListPrivate( const TQValueListPrivate<T>& _p ) + : Q3Shared() +{ + node = new Node; node->next = node->prev = node; nodes = 0; + Iterator b( _p.node->next ); + Iterator e( _p.node ); + Iterator i( node ); + while( b != e ) + insert( i, *b++ ); +} + +template <class T> +TQValueListPrivate<T>::~TQValueListPrivate() { + NodePtr p = node->next; + while( p != node ) { + NodePtr x = p->next; + delete p; + p = x; + } + delete node; +} + +template <class T> +Q_TYPENAME TQValueListPrivate<T>::Iterator TQValueListPrivate<T>::insert( Q_TYPENAME TQValueListPrivate<T>::Iterator it, const T& x ) +{ + NodePtr p = new Node( x ); + p->next = it.node; + p->prev = it.node->prev; + it.node->prev->next = p; + it.node->prev = p; + nodes++; + return p; +} + +template <class T> +Q_TYPENAME TQValueListPrivate<T>::Iterator TQValueListPrivate<T>::remove( Q_TYPENAME TQValueListPrivate<T>::Iterator it ) +{ + Q_ASSERT ( it.node != node ); + NodePtr next = it.node->next; + NodePtr prev = it.node->prev; + prev->next = next; + next->prev = prev; + delete it.node; + nodes--; + return Iterator( next ); +} + +template <class T> +Q_TYPENAME TQValueListPrivate<T>::NodePtr TQValueListPrivate<T>::find( Q_TYPENAME TQValueListPrivate<T>::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + while( first != last) { + if ( *first == x ) + return first.node; + ++first; + } + return last.node; +} + +template <class T> +int TQValueListPrivate<T>::findIndex( Q_TYPENAME TQValueListPrivate<T>::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + int pos = 0; + while( first != last) { + if ( *first == x ) + return pos; + ++first; + ++pos; + } + return -1; +} + +template <class T> +uint TQValueListPrivate<T>::contains( const T& x ) const +{ + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) + ++result; + ++first; + } + return result; +} + +template <class T> +uint TQValueListPrivate<T>::remove( const T& _x ) +{ + const T x = _x; + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) { + first = remove( first ); + ++result; + } else + ++first; + } + return result; +} + +template <class T> +Q_TYPENAME TQValueListPrivate<T>::NodePtr TQValueListPrivate<T>::at( size_type i ) const +{ + Q_ASSERT( i <= nodes ); + NodePtr p = node->next; + for( size_type x = 0; x < i; ++x ) + p = p->next; + return p; +} + +template <class T> +void TQValueListPrivate<T>::clear() +{ + nodes = 0; + NodePtr p = node->next; + while( p != node ) { + NodePtr next = p->next; + delete p; + p = next; + } + node->next = node->prev = node; +} + +#ifdef QT_CHECK_RANGE +# if !defined( QT_NO_DEBUG ) && defined( QT_CHECK_VALUELIST_RANGE ) +# define QT_CHECK_INVALID_LIST_ELEMENT if ( empty() ) qWarning( "TQValueList: Warning invalid element" ) +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +# endif +#else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +#endif + +template <class T> class QDeepCopy; + +template <class T> +class TQValueList +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator<T> iterator; + typedef TQValueListConstIterator<T> const_iterator; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + + /** + * API + */ + TQValueList() { sh = new TQValueListPrivate<T>; } + TQValueList( const TQValueList<T>& l ) { sh = l.sh; sh->ref(); } +#ifndef QT_NO_STL + TQValueList( const std::list<T>& l ) + { + sh = new TQValueListPrivate<T>; + qCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + } +#endif + ~TQValueList() { sh->derefAndDelete(); } + + TQValueList<T>& operator= ( const TQValueList<T>& l ) + { + l.sh->ref(); + sh->derefAndDelete(); + sh = l.sh; + return *this; + } +#ifndef QT_NO_STL + TQValueList<T>& operator= ( const std::list<T>& l ) + { + detach(); + qCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + return *this; + } + bool operator== ( const std::list<T>& l ) const + { + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); +#if !defined(Q_CC_MIPS) + typename +#endif + std::list<T>::const_iterator it = l.begin(); + for ( ; it2 != end(); ++it2, ++it ) + if ( !((*it2) == (*it)) ) + return FALSE; + return TRUE; + } +#endif + + // Interoperability + TQValueList(const QList<T>& l) + { + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + } + + TQValueList<T>& operator= (const QList<T>& l) + { + this->clear(); + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + return *this; + } + + operator QList<T>() const { + QList<T> list; + for (typename TQValueList<T>::const_iterator it = this->constBegin(); + it != this->constEnd(); ++it) + list.append(*it); + return list; + } + + bool operator== ( const TQValueList<T>& l ) const; + bool operator!= ( const TQValueList<T>& l ) const { return !( *this == l ); } + iterator begin() { detach(); return iterator( sh->node->next ); } + const_iterator begin() const { return const_iterator( sh->node->next ); } + const_iterator constBegin() const { return const_iterator( sh->node->next ); } + iterator end() { detach(); return iterator( sh->node ); } + const_iterator end() const { return const_iterator( sh->node ); } + const_iterator constEnd() const { return const_iterator( sh->node ); } + iterator insert( iterator it, const T& x ) { detach(); return sh->insert( it, x ); } + uint remove( const T& x ) { detach(); return sh->remove( x ); } + void clear(); + + // ### 4.0: move out of class + TQValueList<T>& operator<< ( const T& x ) + { + append( x ); + return *this; + } + + size_type size() const { return sh->nodes; } + bool empty() const { return sh->nodes == 0; } + void push_front( const T& x ) { detach(); sh->insert( begin(), x ); } + void push_back( const T& x ) { detach(); sh->insert( end(), x ); } + iterator erase( iterator pos ) { detach(); return sh->remove( pos ); } + iterator erase( iterator first, iterator last ); + reference front() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + const_reference front() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + reference back() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + const_reference back() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + void pop_front() { QT_CHECK_INVALID_LIST_ELEMENT; erase( begin() ); } + void pop_back() { + QT_CHECK_INVALID_LIST_ELEMENT; + iterator tmp = end(); + erase( --tmp ); + } + void insert( iterator pos, size_type n, const T& x ); + // Some compilers (incl. vc++) would instantiate this function even if + // it is not used; this would constrain TQValueList to classes that provide + // an operator< + /* + void sort() + { + qHeapSort( *this ); + } + */ + + TQValueList<T> operator+ ( const TQValueList<T>& l ) const; + TQValueList<T>& operator+= ( const TQValueList<T>& l ); + + iterator fromLast() { detach(); return iterator( sh->node->prev ); } + const_iterator fromLast() const { return const_iterator( sh->node->prev ); } + + bool isEmpty() const { return ( sh->nodes == 0 ); } + + iterator append( const T& x ) { detach(); return sh->insert( end(), x ); } + iterator prepend( const T& x ) { detach(); return sh->insert( begin(), x ); } + + iterator remove( iterator it ) { detach(); return sh->remove( it ); } + + T& first() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->next->data; } + const T& first() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->next->data; } + T& last() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->prev->data; } + const T& last() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->prev->data; } + + T& operator[] ( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->at(i)->data; } + const T& operator[] ( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->at(i)->data; } + iterator at( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return iterator( sh->at(i) ); } + const_iterator at( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return const_iterator( sh->at(i) ); } + iterator find ( const T& x ) { detach(); return iterator( sh->find( sh->node->next, x) ); } + const_iterator find ( const T& x ) const { return const_iterator( sh->find( sh->node->next, x) ); } + iterator find ( iterator it, const T& x ) { detach(); return iterator( sh->find( it.node, x ) ); } + const_iterator find ( const_iterator it, const T& x ) const { return const_iterator( sh->find( it.node, x ) ); } + int findIndex( const T& x ) const { return sh->findIndex( sh->node->next, x) ; } + size_type contains( const T& x ) const { return sh->contains( x ); } + + size_type count() const { return sh->nodes; } + + TQValueList<T>& operator+= ( const T& x ) + { + append( x ); + return *this; + } + typedef TQValueListIterator<T> Iterator; + typedef TQValueListConstIterator<T> ConstIterator; + typedef T ValueType; + +protected: + /** + * Helpers + */ + void detach() { if ( sh->count > 1 ) detachInternal(); } + + /** + * Variables + */ + TQValueListPrivate<T>* sh; + +private: + void detachInternal(); + + friend class QDeepCopy< TQValueList<T> >; +}; + +template <class T> +bool TQValueList<T>::operator== ( const TQValueList<T>& l ) const +{ + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); + const_iterator it = l.begin(); + for( ; it != l.end(); ++it, ++it2 ) + if ( !( *it == *it2 ) ) + return FALSE; + return TRUE; +} + +template <class T> +void TQValueList<T>::clear() +{ + if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new TQValueListPrivate<T>; } +} + +template <class T> +Q_TYPENAME TQValueList<T>::iterator TQValueList<T>::erase( Q_TYPENAME TQValueList<T>::iterator first, Q_TYPENAME TQValueList<T>::iterator last ) +{ + while ( first != last ) + erase( first++ ); + return last; +} + + +template <class T> +void TQValueList<T>::insert( Q_TYPENAME TQValueList<T>::iterator pos, size_type n, const T& x ) +{ + for ( ; n > 0; --n ) + insert( pos, x ); +} + +template <class T> +TQValueList<T> TQValueList<T>::operator+ ( const TQValueList<T>& l ) const +{ + TQValueList<T> l2( *this ); + for( const_iterator it = l.begin(); it != l.end(); ++it ) + l2.append( *it ); + return l2; +} + +template <class T> +TQValueList<T>& TQValueList<T>::operator+= ( const TQValueList<T>& l ) +{ + TQValueList<T> copy = l; + for( const_iterator it = copy.begin(); it != copy.end(); ++it ) + append( *it ); + return *this; +} + +template <class T> +void TQValueList<T>::detachInternal() +{ + sh->deref(); sh = new TQValueListPrivate<T>( *sh ); +} + +#ifndef QT_NO_DATASTREAM +template <class T> +QDataStream& operator>>( QDataStream& s, TQValueList<T>& l ) +{ + l.clear(); + Q_UINT32 c; + s >> c; + for( Q_UINT32 i = 0; i < c; ++i ) + { + T t; + s >> t; + l.append( t ); + if ( s.atEnd() ) + break; + } + return s; +} + +template <class T> +QDataStream& operator<<( QDataStream& s, const TQValueList<T>& l ) +{ + s << (Q_UINT32)l.size(); + TQValueListConstIterator<T> it = l.begin(); + for( ; it != l.end(); ++it ) + s << *it; + return s; +} +#endif // QT_NO_DATASTREAM + +/****************************************************************************/ #endif // USE_QT4 diff --git a/qtinterface/tqwhatsthis.cpp b/qtinterface/tqwhatsthis.cpp index 3f1bfde..1a170c5 100644 --- a/qtinterface/tqwhatsthis.cpp +++ b/qtinterface/tqwhatsthis.cpp @@ -21,3 +21,15 @@ Boston, MA 02110-1301, USA. #include <tqt.h> #include <tqwhatsthis.h> + +#ifdef USE_QT4 + +static QString textFor( QWidget * widget, const QPoint & pos, bool includeParents ) { + QString text; + Q3WhatsThis *wt = new Q3WhatsThis(widget); + text = wt->text(pos); + delete wt; + return text; +} + +#endif // USE_QT4
\ No newline at end of file diff --git a/qtinterface/tqwhatsthis.h b/qtinterface/tqwhatsthis.h index 7d6c21f..8bb1367 100644 --- a/qtinterface/tqwhatsthis.h +++ b/qtinterface/tqwhatsthis.h @@ -38,7 +38,7 @@ Boston, MA 02110-1301, USA. // Reimplement the QWhatsThis class // For Qt4, some changes are needed -#include <Qt/q3whatsthis.h> +#include <tqt4/Qt/q3whatsthis.h> #endif // USE_QT4 diff --git a/qtinterface/tqwidgetlist.h b/qtinterface/tqwidgetlist.h index 9770e3a..a88c018 100644 --- a/qtinterface/tqwidgetlist.h +++ b/qtinterface/tqwidgetlist.h @@ -26,7 +26,7 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT3 -// Reimplement the QWidgetList class +// Reimplement the TQWidgetList class // For Qt3, no changes are needed #include <qwidgetlist.h> @@ -35,9 +35,57 @@ Boston, MA 02110-1301, USA. #ifdef USE_QT4 -// Reimplement the QWidgetList class +// Reimplement the TQWidgetList class // For Qt4, this class was removed! +#include <tqwidget.h> +#include <tqptrlist.h> + +class TQWidgetList : public TQPtrList<QWidget> +{ +public: + TQWidgetList() : TQPtrList<QWidget>() {} + TQWidgetList( const TQWidgetList &list ) : TQPtrList<QWidget>(list) {} + ~TQWidgetList() { clear(); } + TQWidgetList &operator=(const TQWidgetList &list) + { return (TQWidgetList&)TQPtrList<QWidget>::operator=(list); } + + // Interoperability + TQWidgetList(const QWidgetList& l) + { + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + } + + TQWidgetList& operator= (const QWidgetList& l) + { + this->clear(); + for (int i = 0; i < l.size(); ++i) append(l.at(i)); + return *this; + } + + operator QWidgetList() const { + QWidgetList list; + for (TQWidgetList::const_iterator it = TQWidgetList::constBegin(); + it != TQWidgetList::constEnd(); ++it) + list.append(*it); + return list; + } + + operator TQWidgetList*() { + TQWidgetList *qwl; + qwl = new TQWidgetList(*this); + return qwl; + } +}; + +class TQWidgetListIt : public TQPtrListIterator<QWidget> +{ +public: + TQWidgetListIt( const TQWidgetList &l ) : TQPtrListIterator<QWidget>(l) {} + TQWidgetListIt &operator=(const TQWidgetListIt &i) + { return (TQWidgetListIt&)TQPtrListIterator<QWidget>::operator=(i); } +}; + #endif // USE_QT4 #endif /* TQWIDGETLIST_H */
\ No newline at end of file |