summaryrefslogtreecommitdiffstats
path: root/qtinterface/tqtimer.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-13 07:21:42 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-13 07:21:42 +0000
commit2816be9dc2eded3ed8c183abb65dc8668690c43b (patch)
treee75eabce5aee961e0067ab97ef9fe909f5b0cf78 /qtinterface/tqtimer.h
parent4ae6b1ec19cab82c5c5e1e6cf6f47d8ee3a8ea83 (diff)
downloadtqtinterface-2816be9dc2eded3ed8c183abb65dc8668690c43b.tar.gz
tqtinterface-2816be9dc2eded3ed8c183abb65dc8668690c43b.zip
Initial development version for Qt3
HIGHLY EXPERIMENTAL API subject to rapid and substantial change Test code is included; be warned git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1149288 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtinterface/tqtimer.h')
-rw-r--r--qtinterface/tqtimer.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/qtinterface/tqtimer.h b/qtinterface/tqtimer.h
new file mode 100644
index 0000000..4df2502
--- /dev/null
+++ b/qtinterface/tqtimer.h
@@ -0,0 +1,111 @@
+/*
+
+Copyright (C) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with this library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef TQTIMER_H
+#define TQTIMER_H
+
+#include <tqt.h>
+
+#ifdef USE_QT3
+
+// Reimplement the QTimer class
+// For Qt3, no changes are needed
+
+// Linker tricks required to override a class without changing its name
+#define QTimer IQTimer
+#include <qtimer.h>
+#undef QTimer
+
+class QTimer : public IQTimer {
+// This is taken straight from the Qt header file, with all Q_OBJECT, slot, and similar keywords stripped out.
+// This is the last and most obnoxious part of the linker tricks mentioned above
+// Essentially, the compiler needs to know that these Q functions exist so that the above I functions
+// are not attempted to link. Instead, these empty declarations allow the linker to pull in the complete Q function
+// from the Qt toolkit in use. Convoluted, yes, but it should make maintinance MUCH easier as the Qt API changes.
+public:
+ QTimer( QObject *parent=0, const char *name=0 );
+ ~QTimer();
+
+ bool isActive() const;
+
+ int start( int msec, bool sshot = FALSE );
+ void changeInterval( int msec );
+ void stop();
+
+ static void singleShot( int msec, QObject *receiver, const char *member );
+
+ int timerId() const { return id; }
+
+ void timeout();
+
+protected:
+ bool event( QEvent * );
+
+private:
+ int id;
+ uint single : 1;
+ uint nulltimer : 1;
+
+private: // Disabled copy constructor and operator=
+#if defined(Q_DISABLE_COPY)
+ QTimer( const QTimer & );
+ QTimer &operator=( const QTimer & );
+#endif
+// End Qt header file copy
+
+// This is where the new member functions should be placed
+// Unlike the above copied block, these members must be defined in the associated .cpp file,
+// and they should usually do something. Feel free to include as many Qt files as needed
+// in the cpp source file, but DO NOT include them in this header file.
+ int myNewFunction(int parameter_one);
+};
+
+inline bool QTimer::isActive() const
+{
+ return id >= 0;
+}
+
+#endif // USE_QT3
+
+// #ifdef USE_QT4
+//
+// // Reimplement the QTimer class
+// // For Qt4, a few overrides are required
+// // Specifically, these functions were altered:
+// // OLD: NEW:
+// //
+//
+// #include <qtimer.h>
+//
+// class Q_EXPORT TQTimer : public QTimer
+// {
+// Q_OBJECT
+// public:
+// TQTimer( QObject *parent=0, const char *name=0 );
+// ~TQTimer();
+//
+// // FIXME: Example ONLY
+// virtual void oldFunction ();
+// };
+//
+// #endif // USE_QT4
+
+#endif /* TQTIMER_H */ \ No newline at end of file