Drop almost all the Qt3 cruft.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 28 May 2006 12:17:57 +0000 (12:17 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 28 May 2006 12:17:57 +0000 (12:17 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@650 38d2e660-2303-0410-9eaa-f027e97ec537

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

index 8f3981e43face603578ff3f1db8e275e6da2d628..16d1eab8660bc83aa11cc470844190f93f1afdac 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.8  2006/05/28 12:17:57  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.7  2006/04/27 05:43:08  bernie
  *#* Fix naming conventions.
  *#*
@@ -34,7 +37,6 @@
  *#*
  *#* Revision 1.1  2006/01/16 03:51:35  bernie
  *#* Add LCD Qt emulator.
- *#*
  *#*/
 
 #include "lcd_gfx_qt.h"
 #include <cfg/debug.h>
 #include <gfx/gfx.h> // CONFIG_BITMAP_FMT
 
-#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
+#include <QtGui/QPainter>
+#include <QtGui/QImage>
+#include <QtGui/QSizePolicy>
+#include <QtCore/QSize>
 
 // Display colors
 #define LCD_FG_COLOR 0x0, 0x0, 0x0
@@ -121,7 +116,7 @@ void EmulLCD::writeRaster(uint8_t *new_raster)
                        uint8_t v = 0;
                        for (int xbit = 0; xbit < 8; ++xbit)
                                v |= (new_raster[(xbyte * 8 + xbit) + (y / 8) * WIDTH] & (1 << (y%8)) )
-                                       ? (1 << (7 - xbit)) : 0;
+                                       ? 0 : (1 << (7 - xbit));
 
                        raster[y * ((WIDTH + 7) / 8) + xbyte] = v;
                }
@@ -139,13 +134,13 @@ void EmulLCD::writeRaster(uint8_t *new_raster)
 #include <gfx/gfx.h>
 #include <cfg/debug.h>
 
-/*!
+DECLARE_WALL(wall_before_raster, WALL_SIZE)
+/**
  * Raster buffer to draw into.
  *
  * Bits in the bitmap bytes have vertical orientation,
  * as required by the LCD driver.
  */
-DECLARE_WALL(wall_before_raster, WALL_SIZE)
 static uint8_t lcd_raster[RASTER_SIZE(EmulLCD::WIDTH, EmulLCD::HEIGHT)];
 DECLARE_WALL(wall_after_raster, WALL_SIZE)
 
index 642dc7e8311d1e59397006c3dcdbf0b226d1f76c..51b97c28dc3bbe85f05070fed0692f82c76c0b01 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.5  2006/05/28 12:17:57  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.4  2006/02/20 02:00:40  bernie
  *#* Port to Qt 4.1.
  *#*
 #ifndef DRV_LCD_GFX_QT_H
 #define DRV_LCD_GFX_QT_H
 
-#if _QT < 4
-       #include <qframe.h>
-       #include <qcolor.h>
-#else
-       #include <QtGui/QColor>
-       #include <QtGui/QFrame>
-#endif
+#include <QtGui/QColor>
+#include <QtGui/QFrame>
 
 // fwd decls
 class QSizePolicy;
index c6ff698f0261d8b2110131d9e1b5fc16c622543d..5ca081fcf27f5d6003f718c3fc0b113e627cab2f 100755 (executable)
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.4  2006/05/28 12:17:57  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.3  2006/02/21 21:28:02  bernie
  *#* New time handling based on TIMER_TICKS_PER_SEC to support slow timers with ticks longer than 1ms.
  *#*
 #include <cfg/compiler.h> /* hptime.t */
 
 // Qt headers
-#if _QT < 4
-       #include <qdatetime.h>
-       #include <qtimer.h>
-#else
-       #include <QtCore/QDateTime>
-       #include <QtCore/QTimer>
-#endif
+#include <QtCore/QDateTime>
+#include <QtCore/QTimer>
 
 
 // The user interrupt server routine
index 77892ec715c36ef9314f122a94e42985899b7b7b..0603f851748b891d43aafdf09f93d341c3144b7f 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.6  2006/05/28 12:17:57  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.5  2006/05/27 22:30:56  bernie
  *#* Add some delay to slow things down.
  *#*
 
 #include <cstdlib> // std::exit()
 
-#if _QT < 4
-       #include <qapplication.h>
-#else
-       #include <QtGui/qapplication.h>
-#endif
+#include <QtGui/qapplication.h>
 
 
 /// The global emulator instance.
@@ -69,9 +68,6 @@ Emulator::Emulator(int &argc, char **argv) :
        emulApp(new QApplication(argc, argv)),
        emulWin(new EmulWin(this))
 {
-       #if QT_VERSION < ((4 << 16) + (0 << 8) + 0)
-               emulApp->setMainWidget(emulWin);
-       #endif
        emulWin->show();
 }
 
index 95b702148ebc9f980db66e06223684cc474c7745..fad4ee6ec3c2cdcd201643d77bafb47acb1d4769 100755 (executable)
 #include "emulkbd.h"
 #include "emul.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
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#include <QtGui/QSizePolicy>
+#include <QtGui/QLayout>
+#include <QtGui/QKeyEvent>
+#include <QtCore/QEvent>
+#include <QtCore/QSize>
+#include <QtCore/QRect>
 
 
 EmulKey::EmulKey(EmulKbd *kbd, const char *label, int _keycode, int _row, int _col) :
@@ -86,9 +76,9 @@ void EmulKey::keyReleased(void)
 }
 
 
-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)),
+EmulKbd::EmulKbd(QWidget *parent, Qt::WFlags f) :
+       QFrame(parent, f),
+       layout(new QGridLayout(this)),
        active_row(0)
 {
        setFrameStyle(QFrame::Box | QFrame::Sunken);
@@ -106,7 +96,7 @@ EmulKbd::~EmulKbd()
 
 QSizePolicy EmulKbd::sizePolicy() const
 {
-       return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, false);
+       return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
 }
 
 
@@ -190,6 +180,7 @@ int EmulKbd::readCols(void)
        EmulKey *key;
        int cols = 0;
 
+       // FIXME: QLayoutIterator is obsolete in Qt4
        for(QLayoutIterator it(layout->iterator()); (item = it.current()); ++it)
        {
                key = static_cast<EmulKey *>(item->widget());
index 0263db1d0bca5bf66000c206903523a5ce4ab7a3..d7caa0cb8f509db374faca9e0afd13331fb8a98f 100755 (executable)
 #pragma once
 #endif // _MSC_VER > 1000
 
-#if _QT < 4
-#include <qframe.h>
-#else
 #include <QtGui/QFrame>
-#endif
 
 // fwd decl
 class QGridLayout;
@@ -42,7 +38,7 @@ protected:
 
 // Construction
 public:
-       EmulKbd(QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0);
+       EmulKbd(QWidget *parent = 0, Qt::WFlags f = 0);
        virtual ~EmulKbd();
 
 // Public methods
@@ -67,11 +63,7 @@ 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 09b4687b58b361ab6821701957adba488bda20ef..6c5734904648eef35b2c574406ab90382cfa7a03 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.5  2006/05/28 12:17:56  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.4  2006/02/20 02:00:39  bernie
  *#* Port to Qt 4.1.
  *#*
 
 #include <cassert>
 
-#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
-)
+#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>
+using namespace Qt;
+
+EmulWin::EmulWin(Emulator *e)
 {
-       #if _QT >= 4
-               setAttribute(Qt::WA_DeleteOnClose);
-       #endif
+       setWindowTitle(tr("DevLib Emul Demo"));
+       setAttribute(Qt::WA_DeleteOnClose);
+
+       // Create the menu bar
+               QMenu *file_menu = menuBar()->addMenu(tr("&File"));
+               file_menu->addAction(tr("&Quit"),
+                               e->emulApp, SLOT(closeAllWindows()), CTRL+Key_Q);
 
-       // "File" menu
-       QPopupMenu * file = new QPopupMenu(this);
-       file->insertItem("&Quit", static_cast<QObject *>(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q);
+               menuBar()->addSeparator();
 
-       // "Help" menu
-       QPopupMenu * help = new QPopupMenu(this);
-       help->insertItem("&About", this, SLOT(about()), Key_F1);
+               QMenu *help_menu = menuBar()->addMenu(tr("&Help"));
+               help_menu->addAction(tr("&About"),
+                               this, SLOT(about()), Key_F1);
 
-       // Menu bar
-       QMenuBar * menu = new QMenuBar(this);
-       menu->insertItem("&File", file);
-       menu->insertSeparator();
-       menu->insertItem("&Help", help);
 
        // Make a central widget to contain the other widgets
        QWidget *central = new QWidget(this);
        setCentralWidget(central);
 
        // Create a layout to position the widgets
-       QHBoxLayout *box_main = new QHBoxLayout(central, 4);
+       QHBoxLayout *box_main = new QHBoxLayout(central);
 
        // Main layout
-       QVBoxLayout *box_right = new QVBoxLayout(box_main, 4);
+       QVBoxLayout *box_right = new QVBoxLayout();
+       box_main->addLayout(box_right);
 
                // LCD
-               QHBoxLayout *lay_lcd = new QHBoxLayout(box_right, 4);
-               lay_lcd->addWidget(e->emulLCD = new EmulLCD(central));
+               QHBoxLayout *lay_lcd = new QHBoxLayout();
+               box_right->addLayout(lay_lcd);
+                       lay_lcd->addStretch();
+                       lay_lcd->addWidget(e->emulLCD = new EmulLCD(central));
+                       lay_lcd->addStretch();
 
                // Keyboard
-               QHBoxLayout *lay_kbd = new QHBoxLayout(box_right, 4);
-                       lay_kbd->addWidget(e->emulKbd = new EmulKbd(central));
+               box_right->addWidget(e->emulKbd = new EmulKbd(central));
 
        // Setup keyboard: Label   Keycode     Row Col MRow MCol
        e->emulKbd->addKey("^",    Key_Up,     0,  0,  0,   0);
index 30865e547ecd9c5fbcfbc7cafc2579d3e5705dcb..13814ef50824cc49d9977cd0cd4e8ea9d8cdbba4 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.4  2006/05/28 12:17:56  bernie
+ *#* Drop almost all the Qt3 cruft.
+ *#*
  *#* Revision 1.3  2006/02/20 02:00:39  bernie
  *#* Port to Qt 4.1.
  *#*
 #ifndef EMUL_EMULWIN_H
 #define EMUL_EMULWIN_H
 
-#if _QT < 4
-       #include <qmainwindow.h>
-#else
-       #include <QtGui/QMainWindow>
-#endif
+#include <QtGui/QMainWindow>
 
 // fwd decls
 class Emulator;