author | sandman <sandman> | 2002-10-13 16:06:24 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-13 16:06:24 (UTC) |
commit | 92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982 (patch) (side-by-side diff) | |
tree | e16b9cd59d51c8f1e159d830cb5c18ec4cd9420a | |
parent | cb816d85c54242f8958ff77fba334b43be0dcb3d (diff) | |
download | opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.zip opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.tar.gz opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.tar.bz2 |
reformated with astyle (this may not be everybodys prefered style, but IMHO
it's better than the mess before..)
-rw-r--r-- | library/qpeapplication.cpp | 189 |
1 files changed, 133 insertions, 56 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index f65f3ab..2432b65 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -87,5 +87,6 @@ -class QPEApplicationData { +class QPEApplicationData +{ public: QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), @@ -100,13 +101,18 @@ public: QWidget* presswidget; QPoint presspos; - bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke +bool rightpressed : + 1; // AEH why not use uint foobar :1; if it's tt style -zecke int kbgrabber; - bool kbregrab : 1; - bool notbusysent : 1; +bool kbregrab : + 1; +bool notbusysent : + 1; QString appName; - struct QCopRec { + struct QCopRec + { QCopRec( const QCString &ch, const QCString &msg, const QByteArray &d ) : - channel( ch ), message( msg ), data( d ) { } + channel( ch ), message( msg ), data( d ) + { } QCString channel; @@ -114,9 +120,13 @@ public: QByteArray data; }; - bool preloaded : 1; - bool forceshow : 1; - bool nomaximize : 1; +bool preloaded : + 1; +bool forceshow : + 1; +bool nomaximize : + 1; QWidget* qpe_main_widget; - bool keep_running : 1; +bool keep_running : + 1; QList<QCopRec> qcopq; @@ -126,16 +136,21 @@ public: qcopq.append( new QCopRec( ch, msg, data ) ); } - void sendQCopQ() { + void sendQCopQ() + { QCopRec * r; #ifndef QT_NO_COP + for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) QCopChannel::sendLocally( r->channel, r->message, r->data ); #endif + qcopq.clear(); } - static void show_mx(QWidget* mw, bool nomaximize) { + static void show_mx(QWidget* mw, bool nomaximize) + { if ( mw->layout() && mw->inherits("QDialog") ) { QPEApplication::showDialog((QDialog*)mw,nomaximize); - } else { + } + else { #ifdef Q_WS_QWS if ( !nomaximize ) @@ -143,4 +158,5 @@ public: else #endif + mw->show(); } @@ -176,10 +192,13 @@ public: qpe_main_widget = mw; #ifndef QT_NO_COP + sendQCopQ(); #endif + if ( preloaded ) { if(forceshow) show_mx(mw,nomax); - } else if ( keep_running ) { + } + else if ( keep_running ) { show_mx(mw,nomax); } @@ -201,5 +220,6 @@ public: // ### it exists now; need to remember if we can delete it } - } else { + } + else { lib->unload(); delete lib; @@ -223,5 +243,6 @@ public: // ### it exists now; need to remember if we can delete it } - } else { + } + else { lib->unload(); delete lib; @@ -233,5 +254,6 @@ public: }; -class ResourceMimeFactory : public QMimeSourceFactory { +class ResourceMimeFactory : public QMimeSourceFactory +{ public: ResourceMimeFactory() @@ -449,9 +471,11 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) AppLnk::setSmallIconSize( 10 ); AppLnk::setBigIconSize( 28 ); - }else if ( dw > 600 ) { + } + else if ( dw > 600 ) { setFont( QFont( "helvetica", 12 ) ); AppLnk::setSmallIconSize( 24 ); AppLnk::setBigIconSize( 48 ); - }else if ( dw > 200 ) { + } + else if ( dw > 200 ) { setFont( QFont( "helvetica", 12 ) ); AppLnk::setSmallIconSize( 16 ); @@ -548,4 +572,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) //###language/font hack; should look it up somewhere #ifdef QWS + if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { QFont fn = FontManager::unicodeFont( FontManager::Proportional ); @@ -553,4 +578,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) } #endif + } #endif @@ -622,6 +648,12 @@ class HackDialog : public QDialog { public: - void acceptIt() { accept(); } - void rejectIt() { reject(); } + void acceptIt() + { + accept(); + } + void rejectIt() + { + reject(); + } }; @@ -640,4 +672,5 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) #ifdef QWS + ke->simpleData.keycode = key; #endif @@ -648,5 +681,7 @@ class HackWidget : public QWidget public: bool needsOk() - { return ( getWState() & WState_Reserved1 ); } + { + return ( getWState() & WState_Reserved1 ); + } }; @@ -708,5 +743,6 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) } } - } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { + } + else if ( ke->simpleData.keycode == Qt::Key_F30 ) { // Use special "select" key to do whatever default action a widget has mapToDefaultAction( ke, Qt::Key_Space ); @@ -852,8 +888,12 @@ void QPEApplication::setDefaultRotation( int r ) config.setGroup( "Rotation" ); config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); - } else { + } + else { #ifndef QT_NO_COP - { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } + { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); + e << r; + } #endif + } } @@ -911,5 +951,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data if ( msg == "applyStyle()" ) { applyStyle(); - } else if ( msg == "setDefaultRotation(int)" ) { + } + else if ( msg == "setDefaultRotation(int)" ) { if ( type() == GuiServer ) { int r; @@ -917,17 +958,22 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data setDefaultRotation( r ); } - } else if ( msg == "shutdown()" ) { + } + else if ( msg == "shutdown()" ) { if ( type() == GuiServer ) shutdown(); - } else if ( msg == "quit()" ) { + } + else if ( msg == "quit()" ) { if ( type() != GuiServer ) tryQuit(); - } else if ( msg == "forceQuit()" ) { + } + else if ( msg == "forceQuit()" ) { if ( type() != GuiServer ) quit(); - } else if ( msg == "restart()" ) { + } + else if ( msg == "restart()" ) { if ( type() == GuiServer ) restart(); - } else if ( msg == "grabKeyboard(QString)" ) { + } + else if ( msg == "grabKeyboard(QString)" ) { QString who; stream >> who; @@ -938,5 +984,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data else d->kbgrabber = 2; - } else if ( msg == "language(QString)" ) { + } + else if ( msg == "language(QString)" ) { if ( type() == GuiServer ) { QString l; @@ -951,5 +998,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data } } - } else if ( msg == "timeChange(QString)" ) { + } + else if ( msg == "timeChange(QString)" ) { QString t; stream >> t; @@ -960,5 +1008,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data // emit the signal so everyone else knows... emit timeChanged(); - } else if ( msg == "execute(QString)" ) { + } + else if ( msg == "execute(QString)" ) { if ( type() == GuiServer ) { QString t; @@ -966,5 +1015,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data Global::execute( t ); } - } else if ( msg == "execute(QString,QString)" ) { + } + else if ( msg == "execute(QString,QString)" ) { if ( type() == GuiServer ) { QString t, d; @@ -972,5 +1022,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data Global::execute( t, d ); } - } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { + } + else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { if ( type() == GuiServer ) { QDateTime when; @@ -980,5 +1031,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data AlarmServer::addAlarm( when, channel, message, data ); } - } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { + } + else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { if ( type() == GuiServer ) { QDateTime when; @@ -988,31 +1040,38 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data AlarmServer::deleteAlarm( when, channel, message, data ); } - } else if ( msg == "clockChange(bool)" ) { + } + else if ( msg == "clockChange(bool)" ) { int tmp; stream >> tmp; emit clockChanged( tmp ); - } else if ( msg == "weekChange(bool)" ) { + } + else if ( msg == "weekChange(bool)" ) { int tmp; stream >> tmp; emit weekChanged( tmp ); - } else if ( msg == "setDateFormat(DateFormat)" ) { + } + else if ( msg == "setDateFormat(DateFormat)" ) { DateFormat tmp; stream >> tmp; emit dateFormatChanged( tmp ); - } else if ( msg == "setVolume(int,int)" ) { + } + else if ( msg == "setVolume(int,int)" ) { int t, v; stream >> t >> v; setVolume( t, v ); emit volumeChanged( muted ); - } else if ( msg == "volumeChange(bool)" ) { + } + else if ( msg == "volumeChange(bool)" ) { stream >> muted; setVolume(); emit volumeChanged( muted ); - } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> + } + else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> int t, v; stream >> t >> v; setMic( t, v ); emit micChanged( micMuted ); - } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> + } + else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> stream >> micMuted; setMic(); @@ -1031,5 +1090,6 @@ bool QPEApplication::raiseAppropriateWindow() // ########## it and then all childen. This belongs in Qt/Embedded QWidget *top = d->qpe_main_widget; - if ( !top ) top =mainWidget(); + if ( !top ) + top = mainWidget(); if ( top && d->keep_running ) { if ( top->isVisible() ) @@ -1066,19 +1126,24 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) if ( msg == "quit()" ) { tryQuit(); - } else if ( msg == "quitIfInvisible()" ) { + } + else if ( msg == "quitIfInvisible()" ) { if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) quit(); - } else if ( msg == "close()" ) { + } + else if ( msg == "close()" ) { hideOrQuit(); - } else if ( msg == "disablePreload()" ) { + } + else if ( msg == "disablePreload()" ) { d->preloaded = FALSE; d->keep_running = TRUE; /* so that quit will quit */ - } else if ( msg == "enablePreload()" ) { + } + else if ( msg == "enablePreload()" ) { if (d->qpe_main_widget) d->preloaded = TRUE; d->keep_running = TRUE; /* so next quit won't quit */ - } else if ( msg == "raise()" ) { + } + else if ( msg == "raise()" ) { d->keep_running = TRUE; d->notbusysent = FALSE; @@ -1087,12 +1152,15 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) QCopEnvelope e("QPE/System", "appRaised(QString)"); e << d->appName; - } else if ( msg == "flush()" ) { + } + else if ( msg == "flush()" ) { emit flush(); // we need to tell the desktop QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); e << d->appName; - } else if ( msg == "reload()" ) { + } + else if ( msg == "reload()" ) { emit reload(); - } else if ( msg == "setDocument(QString)" ) { + } + else if ( msg == "setDocument(QString)" ) { d->keep_running = TRUE; QDataStream stream( data, IO_ReadOnly ); @@ -1104,5 +1172,6 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) if ( mw ) Global::setDocument( mw, doc ); - } else if ( msg == "nextView()" ) { + } + else if ( msg == "nextView()" ) { qDebug("got nextView()"); /* @@ -1110,5 +1179,6 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) */ emit appMessage( msg, data); - } else { + } + else { emit appMessage( msg, data); } @@ -1409,5 +1479,6 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) ; } - }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { + } + else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { QKeyEvent *ke = (QKeyEvent *)e; if ( ke->key() == Key_Enter ) { @@ -1467,4 +1538,5 @@ void QPEApplication::ungrabKeyboard() e << QString::null; #endif + d->kbregrab = FALSE; d->kbgrabber = 0; @@ -1491,4 +1563,5 @@ void QPEApplication::grabKeyboard() e << d->appName; #endif + d->kbgrabber = 2; // me } @@ -1503,4 +1576,5 @@ int QPEApplication::exec() d->sendQCopQ(); #endif + if ( d->keep_running ) //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) @@ -1508,4 +1582,5 @@ int QPEApplication::exec() #ifndef QT_NO_COP + { QCopEnvelope e( "QPE/System", "closing(QString)" ); @@ -1527,4 +1602,5 @@ void QPEApplication::tryQuit() return ; // Inside modal loop or konsole. Too hard to save state. #ifndef QT_NO_COP + { QCopEnvelope e( "QPE/System", "closing(QString)" ); @@ -1551,4 +1627,5 @@ void QPEApplication::hideOrQuit() if ( d->preloaded && d->qpe_main_widget ) #ifndef QT_NO_COP + { QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |