Port to Qt 4.1.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Feb 2006 02:02:29 +0000 (02:02 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Feb 2006 02:02:29 +0000 (02:02 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@529 38d2e660-2303-0410-9eaa-f027e97ec537

drv/lcd_gfx_qt.cpp
drv/lcd_gfx_qt.h
drv/timer_qt.c
drv/wdt.h
emul/emul.cpp
emul/emulkbd.cpp
emul/emulkbd.h
emul/emulwin.cpp
emul/emulwin.h

index 9ec7f8a57f24acc9b7afac19b176e2947d83eb6e..f838ac7d4e23ae5522239ed25f6432d7e308b4da 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.6  2006/02/20 02:00:40  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.5  2006/02/15 09:13:16  bernie
  *#* Switch to BITMAP_FMT_PLANAR_V_LSB.
  *#*
 #include <cfg/debug.h>
 #include <gfx/gfx.h> // CONFIG_BITMAP_FMT
 
-#include <qpainter.h>
-#include <qimage.h>
-#include <qsizepolicy.h>
-#include <qsize.h>
+#if _QT < 4
+       #include <qpainter.h>
+       #include <qimage.h>
+       #include <qsizepolicy.h>
+       #include <qsize.h>
+#else
+       #include <QtGui/QPainter>
+       #include <QtGui/QImage>
+       #include <QtGui/QSizePolicy>
+       #include <QtCore/QSize>
+#endif
 
 // Display colors
 #define LCD_FG_COLOR 0x0, 0x0, 0x0
@@ -47,7 +57,7 @@
 
 
 EmulLCD::EmulLCD(QWidget *parent, const char *name) :
-       QFrame(parent, name, WRepaintNoErase | WResizeNoErase),
+       QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase),
        fg_color(LCD_FG_COLOR),
        bg_color(LCD_BG_COLOR)
 {
@@ -80,14 +90,15 @@ QSize EmulLCD::sizeHint() const
 }
 
 
-void EmulLCD::drawContents(QPainter *p)
+void EmulLCD::paintEvent(QPaintEvent * /*event*/)
 {
+       QPainter p(this);
        QImage img(raster, WIDTH, HEIGHT, 1, NULL, 0, QImage::BigEndian);
 
-       p->setBackgroundMode(OpaqueMode);
-       p->setPen(fg_color);
-       p->setBackgroundColor(bg_color);
-       p->drawImage(frame_width, frame_width, img);
+       p.setBackgroundMode(Qt::OpaqueMode);
+       p.setPen(fg_color);
+       p.setBackgroundColor(bg_color);
+       p.drawImage(frame_width, frame_width, img);
 }
 
 void EmulLCD::writeRaster(uint8_t *new_raster)
@@ -117,8 +128,7 @@ void EmulLCD::writeRaster(uint8_t *new_raster)
        #error Unsupported bitmap format
 #endif
 
-       QPainter p(this);
-       drawContents(&p);
+       repaint();
 }
 
 
index b6864e439bb01582f5a91f7b8eff2a22f80f944a..642dc7e8311d1e59397006c3dcdbf0b226d1f76c 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.4  2006/02/20 02:00:40  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.3  2006/02/15 09:13:16  bernie
  *#* Switch to BITMAP_FMT_PLANAR_V_LSB.
  *#*
 #ifndef DRV_LCD_GFX_QT_H
 #define DRV_LCD_GFX_QT_H
 
-#include <qframe.h>
-#include <qcolor.h>
+#if _QT < 4
+       #include <qframe.h>
+       #include <qcolor.h>
+#else
+       #include <QtGui/QColor>
+       #include <QtGui/QFrame>
+#endif
 
 // fwd decls
 class QSizePolicy;
@@ -53,8 +61,7 @@ public:
 protected:
        virtual QSizePolicy sizePolicy() const;
        virtual QSize sizeHint() const;
-//     virtual void paintEvent(QPaintEvent *event);
-       virtual void drawContents(QPainter *p);
+       virtual void paintEvent(QPaintEvent *event);
 
 // Operations
 public:
index a9e38be6a6141472e5b1172579ca401cc530f519..a11e9ca665147b0cfa76389b257e6a1ebfc6dde3 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.2  2006/02/20 02:01:35  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.1  2005/11/27 03:06:36  bernie
  *#* Qt timer emulation.
  *#*
 #include <cfg/compiler.h> /* hptime.t */
 
 // Qt headers
-#include <qdatetime.h>
-#include <qtimer.h>
+#if _QT < 4
+       #include <qdatetime.h>
+       #include <qtimer.h>
+#else
+       #include <QtCore/QDateTime>
+       #include <QtCore/QTimer>
+#endif
 
 
 // The user interrupt server routine
index 9f57618f663b26b46be162379a050e141ffb7839..85b37ebf5c235cf9aaf80e4124a56f16c547e07a 100755 (executable)
--- a/drv/wdt.h
+++ b/drv/wdt.h
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.8  2006/02/20 02:02:29  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.7  2005/11/27 03:58:40  bernie
  *#* Add POSIX timer emulator.
  *#*
        #include <cfg/os.h>
 
        #if OS_QT
-               #include <qapplication.h>
+               #if _QT < 4
+                       #include <qapplication.h>
+               #else
+                       #include <QtGui/QApplication>
+               #endif
        #elif OS_POSIX
                #include <sys/select.h>
        #elif CPU_AVR
index d3336c68f645bde74c8181c157ed3b74491d5f61..b6cf30fa4e6d9773549186fe67054c1770e2adf6 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.3  2006/02/20 02:00:40  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.2  2006/01/16 03:51:51  bernie
  *#* Fix boilerplate.
  *#*
 
 #include "emul.h"
 #include "emulwin.h"
+#include <cfg/module.h>
 
-#include <qapplication.h>
 #include <cstdlib> // std::exit()
 
+#if _QT < 4
+       #include <qapplication.h>
+#else
+       #include <QtGui/qapplication.h>
+#endif
+
+
 /// The global emulator instance.
 Emulator *emul;
 
@@ -36,7 +46,9 @@ Emulator::Emulator(int &argc, char **argv) :
        emulApp(new QApplication(argc, argv)),
        emulWin(new EmulWin(this))
 {
-       emulApp->setMainWidget(emulWin);
+       #if QT_VERSION < ((4 << 16) + (0 << 8) + 0)
+               emulApp->setMainWidget(emulWin);
+       #endif
        emulWin->show();
 }
 
@@ -49,7 +61,7 @@ Emulator::~Emulator()
 }
 
 
-void Emulator::quit()
+NORETURN void Emulator::quit()
 {
        // WHAT A KLUDGE!
        this->~Emulator();
@@ -59,19 +71,21 @@ void Emulator::quit()
        exit(0);
 }
 
+MOD_DEFINE(emul)
 
 /// Main emulator entry point.
 extern "C" void emul_init(int *argc, char *argv[])
 {
-       ASSERT(!emul);
-
        // setup global emulator pointer
        emul = new Emulator(*argc, argv);
+
+       MOD_INIT(emul);
 }
 
 extern "C" void emul_cleanup()
 {
-       ASSERT(emul);
+       MOD_CLEANUP(emul);
+
        delete emul;
        emul = NULL;
 }
index 2c6c3f8ce6665536296b3651ed2699c8b9d916a6..1dfdd9d5500cc92e0c2835e4be6ef945b9dbc2d0 100755 (executable)
 #include "emulkbd.h"
 #include "emul.h"
 
-#include <qpainter.h>
-#include <qpixmap.h>
-#include <qsizepolicy.h>
-#include <qsize.h>
-#include <qrect.h>
-#include <qlayout.h>
-#include <qobjectlist.h>
+#if _QT < 4
+       #include <qpainter.h>
+       #include <qpixmap.h>
+       #include <qsizepolicy.h>
+       #include <qsize.h>
+       #include <qrect.h>
+       #include <qlayout.h>
+       #include <qobjectlist.h>
+#else
+       #include <QtGui/QPainter>
+       #include <QtGui/QPixmap>
+       #include <QtGui/QSizePolicy>
+       #include <QtGui/QLayout>
+       #include <QtGui/QKeyEvent>
+       #include <QtCore/QEvent>
+       #include <QtCore/QSize>
+       #include <QtCore/QRect>
+#endif
 
 
 EmulKey::EmulKey(EmulKbd *kbd, const char *label, int _keycode, int _row, int _col) :
@@ -31,7 +42,7 @@ EmulKey::EmulKey(EmulKbd *kbd, const char *label, int _keycode, int _row, int _c
        keycode(_keycode)
 {
        // don't let the widget get focus
-       setFocusPolicy(QWidget::NoFocus);
+       setFocusPolicy(Qt::NoFocus);
 
        // unused
        connect(this, SIGNAL(pressed()), this, SLOT(keyPressed()));
@@ -76,14 +87,14 @@ void EmulKey::keyReleased(void)
 }
 
 
-EmulKbd::EmulKbd(QWidget *parent, const char *name, WFlags f) :
-       QFrame(parent, name, WRepaintNoErase | WResizeNoErase | f),
+EmulKbd::EmulKbd(QWidget *parent, const char *name, Qt::WFlags f) :
+       QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase | f),
        layout(new QGridLayout(this, 4, 4, 4)),
        active_row(0)
 {
        setFrameStyle(QFrame::Box | QFrame::Sunken);
        setLineWidth(1);
-       setFocusPolicy(StrongFocus);
+       setFocusPolicy(Qt::StrongFocus);
        frame_width = frameWidth();
 }
 
@@ -100,7 +111,7 @@ QSizePolicy EmulKbd::sizePolicy() const
 }
 
 
-void EmulKbd::resizeEvent(QResizeEvent * event)
+void EmulKbd::resizeEvent(QResizeEvent *event)
 {
        // Let our superclass process the event first
        QFrame::resizeEvent(event);
@@ -108,7 +119,7 @@ void EmulKbd::resizeEvent(QResizeEvent * event)
 
 
 // handle key presses for all keys in keyboard
-bool EmulKbd::event(QEvent * _e)
+bool EmulKbd::event(QEvent *_e)
 {
        switch (_e->type())
        {
@@ -123,10 +134,10 @@ bool EmulKbd::event(QEvent * _e)
                        if (!e->isAutoRepeat())
                        {
                                // scan all children
-                               for (QObjectListIt it(*children()); *it; ++it)
+                               for (QObjectList::const_iterator it(children().begin()); it != children().end(); ++it)
                                {
                                        // only keys, not other children!
-                                       if ((*it)->metaObject() == EmulKey::staticMetaObject())
+                                       if ((*it)->metaObject() == &EmulKey::staticMetaObject)
                                        // if ((key = dynamic_cast<EmulKey *>(*it)))
                                        {
                                                key = static_cast<EmulKey *>(*it);
index 1eb243229f111d276936bbacce6c6cb2ed277432..0263db1d0bca5bf66000c206903523a5ce4ab7a3 100755 (executable)
 #pragma once
 #endif // _MSC_VER > 1000
 
+#if _QT < 4
 #include <qframe.h>
+#else
+#include <QtGui/QFrame>
+#endif
 
 // fwd decl
 class QGridLayout;
@@ -38,7 +42,7 @@ protected:
 
 // Construction
 public:
-       EmulKbd(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+       EmulKbd(QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0);
        virtual ~EmulKbd();
 
 // Public methods
@@ -63,7 +67,11 @@ protected:
 
 // Private helper class for EmulKbd
 // NOTE: with protected inheritance, dynamic_cast<> does not work (gcc 2.96)
+#if _QT < 4
 #include <qpushbutton.h>
+#else
+#include <QtGui/qpushbutton.h>
+#endif
 class EmulKey : public QPushButton
 {
        Q_OBJECT
index b2bdc62fd3d012df577bbcf196db1ce68ba3833b..09b4687b58b361ab6821701957adba488bda20ef 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.4  2006/02/20 02:00:39  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.3  2006/02/15 09:11:17  bernie
  *#* Add keyboard emulator.
  *#*
 #include <emul/emulkbd.h>
 
 #include <cassert>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qslider.h>
-#include <qcheckbox.h>
-#include <qpopupmenu.h>
-#include <qmenubar.h>
-#include <qmessagebox.h>
-#include <qdatetime.h>
-#include <qtimer.h>
-#include <qapplication.h>
-
-EmulWin::EmulWin(Emulator *e) : QMainWindow(0, "DevLibEmul", WDestructiveClose)
+
+#if _QT < 4
+       #include <qlayout.h>
+       #include <qlabel.h>
+       #include <qslider.h>
+       #include <qcheckbox.h>
+       #include <qmenubar.h>
+       #include <qmessagebox.h>
+       #include <qdatetime.h>
+       #include <qtimer.h>
+       #include <qapplication.h>
+       #include <qpopupmenu.h>
+       #include <qevent.h>
+#else
+       #include <QtGui/QLayout>
+       #include <QtGui/QLabel>
+       #include <QtGui/QSlider>
+       #include <QtGui/QCheckBox>
+       #include <QtGui/QMenuBar>
+       #include <QtGui/QMessageBox>
+       #include <QtCore/QDateTime>
+       #include <QtCore/QTimer>
+       #include <QtGui/QApplication>
+       #include <QtGui/QCloseEvent>
+       //#include <Qt3Support/q3popupmenu.h>
+       //#define QPopupMenu Q3PopupMenu
+       #define QPopupMenu QMenu
+       using namespace Qt;
+#endif
+
+EmulWin::EmulWin(Emulator *e) : QMainWindow(0, "DevLibEmul",
+       #if _QT < 4
+               Qt::WDestructiveClose
+       #else
+               0
+       #endif
+)
 {
+       #if _QT >= 4
+               setAttribute(Qt::WA_DeleteOnClose);
+       #endif
+
        // "File" menu
        QPopupMenu * file = new QPopupMenu(this);
        file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
index 957a02156c8692126e93b68b29aaac62060318f2..30865e547ecd9c5fbcfbc7cafc2579d3e5705dcb 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.3  2006/02/20 02:00:39  bernie
+ *#* Port to Qt 4.1.
+ *#*
  *#* Revision 1.2  2006/01/16 03:51:51  bernie
  *#* Fix boilerplate.
  *#*
 #ifndef EMUL_EMULWIN_H
 #define EMUL_EMULWIN_H
 
-#include <qmainwindow.h>
+#if _QT < 4
+       #include <qmainwindow.h>
+#else
+       #include <QtGui/QMainWindow>
+#endif
 
 // fwd decls
 class Emulator;