From: bernie Date: Sun, 28 May 2006 12:17:57 +0000 (+0000) Subject: Drop almost all the Qt3 cruft. X-Git-Tag: 1.0.0~591 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=04cdf83948ae2bf7d6404be4d5816707092619f3;p=bertos.git Drop almost all the Qt3 cruft. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@650 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/drv/lcd_gfx_qt.cpp b/drv/lcd_gfx_qt.cpp index 8f3981e4..16d1eab8 100755 --- a/drv/lcd_gfx_qt.cpp +++ b/drv/lcd_gfx_qt.cpp @@ -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" @@ -42,17 +44,10 @@ #include #include // CONFIG_BITMAP_FMT -#if _QT < 4 - #include - #include - #include - #include -#else - #include - #include - #include - #include -#endif +#include +#include +#include +#include // 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 #include -/*! +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) diff --git a/drv/lcd_gfx_qt.h b/drv/lcd_gfx_qt.h index 642dc7e8..51b97c28 100755 --- a/drv/lcd_gfx_qt.h +++ b/drv/lcd_gfx_qt.h @@ -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. *#* @@ -31,13 +34,8 @@ #ifndef DRV_LCD_GFX_QT_H #define DRV_LCD_GFX_QT_H -#if _QT < 4 - #include - #include -#else - #include - #include -#endif +#include +#include // fwd decls class QSizePolicy; diff --git a/drv/timer_qt.c b/drv/timer_qt.c index c6ff698f..5ca081fc 100755 --- a/drv/timer_qt.c +++ b/drv/timer_qt.c @@ -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. *#* @@ -28,13 +31,8 @@ #include /* hptime.t */ // Qt headers -#if _QT < 4 - #include - #include -#else - #include - #include -#endif +#include +#include // The user interrupt server routine diff --git a/emul/emul.cpp b/emul/emul.cpp index 77892ec7..0603f851 100755 --- a/emul/emul.cpp +++ b/emul/emul.cpp @@ -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. *#* @@ -44,11 +47,7 @@ #include // std::exit() -#if _QT < 4 - #include -#else - #include -#endif +#include /// 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(); } diff --git a/emul/emulkbd.cpp b/emul/emulkbd.cpp index 95b70214..fad4ee6e 100755 --- a/emul/emulkbd.cpp +++ b/emul/emulkbd.cpp @@ -16,24 +16,14 @@ #include "emulkbd.h" #include "emul.h" -#if _QT < 4 - #include - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include -#endif +#include +#include +#include +#include +#include +#include +#include +#include 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(item->widget()); diff --git a/emul/emulkbd.h b/emul/emulkbd.h index 0263db1d..d7caa0cb 100755 --- a/emul/emulkbd.h +++ b/emul/emulkbd.h @@ -20,11 +20,7 @@ #pragma once #endif // _MSC_VER > 1000 -#if _QT < 4 -#include -#else #include -#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 -#else #include -#endif class EmulKey : public QPushButton { Q_OBJECT diff --git a/emul/emulwin.cpp b/emul/emulwin.cpp index 09b4687b..6c573490 100755 --- a/emul/emulwin.cpp +++ b/emul/emulwin.cpp @@ -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. *#* @@ -37,78 +40,55 @@ #include -#if _QT < 4 - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - //#include - //#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +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(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); diff --git a/emul/emulwin.h b/emul/emulwin.h index 30865e54..13814ef5 100755 --- a/emul/emulwin.h +++ b/emul/emulwin.h @@ -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. *#* @@ -29,11 +32,7 @@ #ifndef EMUL_EMULWIN_H #define EMUL_EMULWIN_H -#if _QT < 4 - #include -#else - #include -#endif +#include // fwd decls class Emulator;