From: bernie Date: Mon, 20 Feb 2006 02:02:29 +0000 (+0000) Subject: Port to Qt 4.1. X-Git-Tag: 1.0.0~712 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=20d3c79024c12bb366270c0c1fdda53c4c55e734;p=bertos.git Port to Qt 4.1. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@529 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/drv/lcd_gfx_qt.cpp b/drv/lcd_gfx_qt.cpp index 9ec7f8a5..f838ac7d 100755 --- a/drv/lcd_gfx_qt.cpp +++ b/drv/lcd_gfx_qt.cpp @@ -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. *#* @@ -36,10 +39,17 @@ #include #include // CONFIG_BITMAP_FMT -#include -#include -#include -#include +#if _QT < 4 + #include + #include + #include + #include +#else + #include + #include + #include + #include +#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(); } diff --git a/drv/lcd_gfx_qt.h b/drv/lcd_gfx_qt.h index b6864e43..642dc7e8 100755 --- a/drv/lcd_gfx_qt.h +++ b/drv/lcd_gfx_qt.h @@ -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. *#* @@ -28,8 +31,13 @@ #ifndef DRV_LCD_GFX_QT_H #define DRV_LCD_GFX_QT_H -#include -#include +#if _QT < 4 + #include + #include +#else + #include + #include +#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: diff --git a/drv/timer_qt.c b/drv/timer_qt.c index a9e38be6..a11e9ca6 100755 --- a/drv/timer_qt.c +++ b/drv/timer_qt.c @@ -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. *#* @@ -22,8 +25,13 @@ #include /* hptime.t */ // Qt headers -#include -#include +#if _QT < 4 + #include + #include +#else + #include + #include +#endif // The user interrupt server routine diff --git a/drv/wdt.h b/drv/wdt.h index 9f57618f..85b37ebf 100755 --- 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. *#* @@ -52,7 +55,11 @@ #include #if OS_QT - #include + #if _QT < 4 + #include + #else + #include + #endif #elif OS_POSIX #include #elif CPU_AVR diff --git a/emul/emul.cpp b/emul/emul.cpp index d3336c68..b6cf30fa 100755 --- a/emul/emul.cpp +++ b/emul/emul.cpp @@ -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. *#* @@ -25,10 +28,17 @@ #include "emul.h" #include "emulwin.h" +#include -#include #include // std::exit() +#if _QT < 4 + #include +#else + #include +#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; } diff --git a/emul/emulkbd.cpp b/emul/emulkbd.cpp index 2c6c3f8c..1dfdd9d5 100755 --- a/emul/emulkbd.cpp +++ b/emul/emulkbd.cpp @@ -16,13 +16,24 @@ #include "emulkbd.h" #include "emul.h" -#include -#include -#include -#include -#include -#include -#include +#if _QT < 4 + #include + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include + #include + #include +#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(*it))) { key = static_cast(*it); diff --git a/emul/emulkbd.h b/emul/emulkbd.h index 1eb24322..0263db1d 100755 --- a/emul/emulkbd.h +++ b/emul/emulkbd.h @@ -20,7 +20,11 @@ #pragma once #endif // _MSC_VER > 1000 +#if _QT < 4 #include +#else +#include +#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 +#else +#include +#endif class EmulKey : public QPushButton { Q_OBJECT diff --git a/emul/emulwin.cpp b/emul/emulwin.cpp index b2bdc62f..09b4687b 100755 --- a/emul/emulwin.cpp +++ b/emul/emulwin.cpp @@ -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. *#* @@ -33,19 +36,48 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -EmulWin::EmulWin(Emulator *e) : QMainWindow(0, "DevLibEmul", WDestructiveClose) + +#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 +) { + #if _QT >= 4 + setAttribute(Qt::WA_DeleteOnClose); + #endif + // "File" menu QPopupMenu * file = new QPopupMenu(this); file->insertItem("&Quit", static_cast(e->emulApp), SLOT(closeAllWindows()), CTRL+Key_Q); diff --git a/emul/emulwin.h b/emul/emulwin.h index 957a0215..30865e54 100755 --- a/emul/emulwin.h +++ b/emul/emulwin.h @@ -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. *#* @@ -26,7 +29,11 @@ #ifndef EMUL_EMULWIN_H #define EMUL_EMULWIN_H -#include +#if _QT < 4 + #include +#else + #include +#endif // fwd decls class Emulator;