-rw-r--r-- | core/launcher/desktop.cpp | 41 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 82 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 27 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 57 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 39 |
6 files changed, 150 insertions, 98 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index cf33011..43006f1 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -1,408 +1,409 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "desktop.h" #include "info.h" #include "launcher.h" #include "mrulist.h" #include "qcopbridge.h" #include "shutdownimpl.h" #include "startmenu.h" #include "taskbar.h" #include "transferserver.h" #include "irserver.h" #include "packageslave.h" #include <qpe/applnk.h> #include <qpe/mimetype.h> #include <qpe/password.h> #include <qpe/config.h> #include <qpe/power.h> +#include <qpe/timeconversion.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/global.h> #ifdef QT_QWS_CUSTOM #include "qpe/custom.h" #endif #include <qgfx_qws.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtimer.h> #include <qwindowsystem_qws.h> #include <qvaluelist.h> #include <stdlib.h> #include <unistd.h> class QCopKeyRegister { public: QCopKeyRegister() : keyCode(0) { } - QCopKeyRegister(int k, const QString &c, const QString &m) + QCopKeyRegister(int k, const QString &c, const QString &m) : keyCode(k), channel(c), message(m) { } int getKeyCode() const { return keyCode; } QString getChannel() const { return channel; } QString getMessage() const { return message; } private: int keyCode; QString channel, message; }; typedef QValueList<QCopKeyRegister> KeyRegisterList; KeyRegisterList keyRegisterList; static Desktop* qpedesktop = 0; static int loggedin=0; static void login(bool at_poweron) { if ( !loggedin ) { Global::terminateBuiltin("calibrate"); Password::authenticate(at_poweron); loggedin=1; QCopEnvelope e( "QPE/Desktop", "unlocked()" ); } } bool Desktop::screenLocked() { return loggedin == 0; } /* Priority is number of alerts that are needed to pop up alert. */ class DesktopPowerAlerter : public QMessageBox { public: DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) : QMessageBox( tr("Battery Status"), "Low Battery", QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton, parent, name, FALSE ) { currentPriority = INT_MAX; alertCount = 0; } void alert( const QString &text, int priority ); void hideEvent( QHideEvent * ); private: int currentPriority; int alertCount; }; void DesktopPowerAlerter::alert( const QString &text, int priority ) { alertCount++; if ( alertCount < priority ) return; if ( priority > currentPriority ) return; currentPriority = priority; setText( text ); show(); } void DesktopPowerAlerter::hideEvent( QHideEvent *e ) { QMessageBox::hideEvent( e ); alertCount = 0; currentPriority = INT_MAX; } DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) : QPEApplication( argc, argv, t ) { QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); t->start( 10000 ); ps = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); channel = new QCopChannel( "QPE/Desktop", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); } DesktopApplication::~DesktopApplication() { delete ps; delete pa; } void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if (msg == "keyRegister(int key, QString channel, QString message)") { int k; QString c, m; stream >> k; stream >> c; stream >> m; - + qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); keyRegisterList.append(QCopKeyRegister(k,c,m)); - } + } else if (msg == "suspend()"){ emit power(); } - + } enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; #ifdef Q_WS_QWS bool DesktopApplication::qwsEventFilter( QWSEvent *e ) { qpedesktop->checkMemory(); if ( e->type == QWSEvent::Key ) { QWSKeyEvent *ke = (QWSKeyEvent *)e; if ( !loggedin && ke->simpleData.keycode != Key_F34 ) return TRUE; bool press = ke->simpleData.is_press; if (!keyRegisterList.isEmpty()) { KeyRegisterList::Iterator it; for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { if ((*it).getKeyCode() == ke->simpleData.keycode) QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); } } if ( !keyboardGrabbed() ) { if ( ke->simpleData.keycode == Key_F9 ) { if ( press ) emit datebook(); return TRUE; } if ( ke->simpleData.keycode == Key_F10 ) { if ( !press && cardSendTimer ) { emit contacts(); delete cardSendTimer; } else if ( press ) { cardSendTimer = new QTimer(); cardSendTimer->start( 2000, TRUE ); connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); } return TRUE; } /* menu key now opens application menu/toolbar if ( ke->simpleData.keycode == Key_F11 ) { if ( press ) emit menu(); return TRUE; } */ if ( ke->simpleData.keycode == Key_F12 ) { while( activePopupWidget() ) activePopupWidget()->close(); if ( press ) emit launch(); return TRUE; } if ( ke->simpleData.keycode == Key_F13 ) { if ( press ) emit email(); return TRUE; } } if ( ke->simpleData.keycode == Key_F34 ) { if ( press ) emit power(); return TRUE; } if ( ke->simpleData.keycode == Key_SysReq ) { if ( press ) emit power(); return TRUE; } if ( ke->simpleData.keycode == Key_F35 ) { if ( press ) emit backlight(); return TRUE; } if ( ke->simpleData.keycode == Key_F32 ) { if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); return TRUE; } if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { if ( press ) emit symbol(); return TRUE; } if ( ke->simpleData.keycode == Key_NumLock ) { if ( press ) emit numLockStateToggle(); } if ( ke->simpleData.keycode == Key_CapsLock ) { if ( press ) emit capsLockStateToggle(); } if ( press ) qpedesktop->keyClick(); } else { if ( e->type == QWSEvent::Mouse ) { QWSMouseEvent *me = (QWSMouseEvent *)e; static bool up = TRUE; if ( me->simpleData.state&LeftButton ) { if ( up ) { up = FALSE; qpedesktop->screenClick(); } } else { up = TRUE; } } } - + return QPEApplication::qwsEventFilter( e ); } #endif void DesktopApplication::psTimeout() { qpedesktop->checkMemory(); // in case no events are being generated *ps = PowerStatusManager::readStatus(); if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { pa->alert( tr( "Battery is running very low." ), 6 ); } if ( ps->batteryStatus() == PowerStatus::Critical ) { pa->alert( tr( "Battery level is critical!\n" "Keep power off until power restored!" ), 1 ); } if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); } } void DesktopApplication::sendCard() { delete cardSendTimer; cardSendTimer = 0; QString card = getenv("HOME"); card += "/Applications/addressbook/businesscard.vcf"; if ( QFile::exists( card ) ) { QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); QString mimetype = "text/x-vCard"; e << tr("business card") << card << mimetype; } } #if defined(QPE_HAVE_MEMALERTER) QPE_MEMALERTER_IMPL #endif #if defined(CUSTOM_SOUND_IMPL) CUSTOM_SOUND_IMPL #endif //=========================================================================== Desktop::Desktop() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), qcopBridge( 0 ), transferServer( 0 ), packageSlave( 0 ) { #ifdef CUSTOM_SOUND_INIT CUSTOM_SOUND_INIT; #endif qpedesktop = this; // bg = new Info( this ); tb = new TaskBar; launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); int displayw = qApp->desktop()->width(); int displayh = qApp->desktop()->height(); QSize sz = tb->sizeHint(); setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); tb->show(); launcher->showMaximized(); launcher->show(); launcher->raise(); #if defined(QPE_HAVE_MEMALERTER) initMemalerter(); #endif // start services startTransferServer(); (void) new IrServer( this ); rereadVolumes(); packageSlave = new PackageSlave( this ); connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); qApp->installEventFilter( this ); } void Desktop::show() { login(TRUE); QWidget::show(); } Desktop::~Desktop() { delete launcher; delete tb; delete qcopBridge; delete transferServer; } bool Desktop::recoverMemory() { return tb->recoverMemory(); } void Desktop::checkMemory() { #if defined(QPE_HAVE_MEMALERTER) static bool ignoreNormal=FALSE; static bool existingMessage=FALSE; if(existingMessage) return; // don't show a second message while still on first existingMessage = TRUE; switch ( memstate ) { case Unknown: break; @@ -422,309 +423,317 @@ void Desktop::checkMemory() else QMessageBox::information ( 0 , "Memory Status", "There is enough memory again." ); break; case VeryLow: memstate = Unknown; QMessageBox::critical( 0 , "Memory Status", "The memory is very low. \n" "Please end this application \n" "immediately." ); recoverMemory(); } existingMessage = FALSE; #endif } static bool isVisibleWindow(int wid) { const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); } return FALSE; } static bool hasVisibleWindow(const QString& clientname) { const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->client()->identity() == clientname && !w->isFullyObscured() ) return TRUE; } return FALSE; } void Desktop::raiseLauncher() { Config cfg("qpe"); //F12 'Home' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("Middle","Home"); if(tempItem == "Home" || tempItem.isEmpty()) { if ( isVisibleWindow(launcher->winId()) ) launcher->nextView(); else launcher->raise(); } else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::executeOrModify(const QString& appLnkFile) { AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); if ( lnk.isValid() ) { QCString app = lnk.exec().utf8(); Global::terminateBuiltin("calibrate"); if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { MRUList::addTask(&lnk); if ( hasVisibleWindow(app) ) QCopChannel::send("QPE/Application/" + app, "nextView()"); else QCopChannel::send("QPE/Application/" + app, "raise()"); } else { lnk.execute(); } } } void Desktop::raiseDatebook() { Config cfg("qpe"); //F9 'Activity' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("LeftEnd","Calender"); if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::raiseContacts() { Config cfg("qpe"); //F10, 'Contacts' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("Left2nd","Address Book"); if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::raiseMenu() { Config cfg("qpe"); //F11, 'Menu' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("Right2nd","Popup Menu"); if(tempItem == "Popup Menu" || tempItem.isEmpty()) { Global::terminateBuiltin("calibrate"); tb->startMenu()->launch(); } else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } void Desktop::raiseEmail() { Config cfg("qpe"); //F13, 'Mail' cfg.setGroup("AppsKey"); QString tempItem; tempItem = cfg.readEntry("RightEnd","Mail"); if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } // autoStarts apps on resume and start -void Desktop::execAutoStart() -{ - QString appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - appName = cfg.readEntry("Apps", ""); - QCopEnvelope e("QPE/System", "execute(QString)"); - e << QString(appName); +void Desktop::execAutoStart() { + QString appName; + int delay; + QDateTime now = QDateTime::currentDateTime(); + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + appName = cfg.readEntry("Apps", ""); + delay = (cfg.readEntry("Delay", "0" )).toInt(); + // If the time between suspend and resume was longer then the + // value saved as delay, start the app + if ( suspendTime.secsTo(now) >= (delay*60) ) { + QCopEnvelope e("QPE/System", "execute(QString)"); + e << QString(appName); + } else { + } } #if defined(QPE_HAVE_TOGGLELIGHT) #include <qpe/config.h> #include <sys/ioctl.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <linux/ioctl.h> #include <time.h> #endif static bool blanked=FALSE; static void blankScreen() { if ( !qt_screen ) return; /* Should use a big black window instead. QGfx* g = qt_screen->screenGfx(); g->fillRect(0,0,qt_screen->width(),qt_screen->height()); delete g; */ blanked = TRUE; } static void darkScreen() { extern void qpe_setBacklight(int); qpe_setBacklight(0); // force off } void Desktop::togglePower() { bool wasloggedin = loggedin; loggedin=0; + suspendTime = QDateTime::currentDateTime(); darkScreen(); if ( wasloggedin ) blankScreen(); - + system("apm --suspend"); - - + + QWSServer::screenSaverActivate( FALSE ); { QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } if ( wasloggedin ) { login(TRUE); } sleep(1); execAutoStart(); //qcopBridge->closeOpenConnections(); //qDebug("called togglePower()!!!!!!"); } void Desktop::toggleLight() { QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -2; // toggle } void Desktop::toggleSymbolInput() { tb->toggleSymbolInput(); } void Desktop::toggleNumLockState() { tb->toggleNumLockState(); } void Desktop::toggleCapsLockState() { tb->toggleCapsLockState(); } void Desktop::styleChange( QStyle &s ) { QWidget::styleChange( s ); int displayw = qApp->desktop()->width(); int displayh = qApp->desktop()->height(); QSize sz = tb->sizeHint(); tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); } void DesktopApplication::shutdown() { if ( type() != GuiServer ) return; ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), this, SLOT(shutdown(ShutdownImpl::Type)) ); sd->showMaximized(); } void DesktopApplication::shutdown( ShutdownImpl::Type t ) { switch ( t ) { case ShutdownImpl::ShutdownSystem: execlp("shutdown", "shutdown", "-h", "now", (void*)0); break; case ShutdownImpl::RebootSystem: execlp("shutdown", "shutdown", "-r", "now", (void*)0); break; case ShutdownImpl::RestartDesktop: restart(); break; case ShutdownImpl::TerminateDesktop: prepareForTermination(FALSE); quit(); break; } } void DesktopApplication::restart() { prepareForTermination(TRUE); #ifdef Q_WS_QWS for ( int fd = 3; fd < 100; fd++ ) close( fd ); #if defined(QT_DEMO_SINGLE_FLOPPY) execl( "/sbin/init", "qpe", 0 ); #elif defined(QT_QWS_CASSIOPEIA) execl( "/bin/sh", "sh", 0 ); #else execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); #endif exit(1); #endif } void Desktop::startTransferServer() { // start qcop bridge server qcopBridge = new QCopBridge( 4243 ); if ( !qcopBridge->ok() ) { delete qcopBridge; qcopBridge = 0; } // start transfer server transferServer = new TransferServer( 4242 ); if ( !transferServer->ok() ) { delete transferServer; transferServer = 0; } if ( !transferServer || !qcopBridge ) startTimer( 2000 ); } void Desktop::timerEvent( QTimerEvent *e ) { killTimer( e->timerId() ); startTransferServer(); } void Desktop::terminateServers() { delete transferServer; delete qcopBridge; transferServer = 0; qcopBridge = 0; } void Desktop::rereadVolumes() diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index de0dbf0..e094dc0 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h @@ -1,134 +1,136 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __DESKTOP_H__ #define __DESKTOP_H__ #include "shutdownimpl.h" #include <qpe/qpeapplication.h> #include <qwidget.h> +#include <qdatetime.h> class Background; class Launcher; class TaskBar; class PowerStatus; class QCopBridge; class TransferServer; class DesktopPowerAlerter; class PackageSlave; class DesktopApplication : public QPEApplication { Q_OBJECT public: DesktopApplication( int& argc, char **argv, Type t ); ~DesktopApplication(); signals: void home(); void datebook(); void contacts(); void launch(); void email(); void backlight(); void power(); void symbol(); void numLockStateToggle(); void capsLockStateToggle(); void prepareForRestart(); protected: #ifdef Q_WS_QWS bool qwsEventFilter( QWSEvent * ); #endif void shutdown(); void restart(); public slots: void receive( const QCString &msg, const QByteArray &data ); protected slots: void shutdown(ShutdownImpl::Type); void psTimeout(); void sendCard(); private: DesktopPowerAlerter *pa; PowerStatus *ps; QTimer *cardSendTimer; QCopChannel *channel; }; class Desktop : public QWidget { Q_OBJECT public: Desktop(); ~Desktop(); static bool screenLocked(); void show(); void checkMemory(); void keyClick(); void screenClick(); static void soundAlarm(); public slots: void raiseDatebook(); void raiseContacts(); void raiseMenu(); void raiseLauncher(); void raiseEmail(); void execAutoStart(); void togglePower(); void toggleLight(); void toggleNumLockState(); void toggleCapsLockState(); void toggleSymbolInput(); void terminateServers(); void rereadVolumes(); protected: void executeOrModify(const QString& appLnkFile); void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); bool eventFilter( QObject *, QEvent * ); QWidget *bg; Launcher *launcher; TaskBar *tb; private: void startTransferServer(); bool recoverMemory(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageSlave *packageSlave; + QDateTime suspendTime; bool keyclick,touchclick; }; #endif // __DESKTOP_H__ diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 1449269..979eee6 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -1,228 +1,228 @@ /********************************************************************** ** Copyright (c) 2002 Holger zecke Freyther ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT // have this class. #define QTOPIA_INTERNAL_FSLP #include <opie/oconfig.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/storage.h> #include <qpe/palmtoprecord.h> #include <qdatetime.h> #include <qdir.h> #include <qwindowsystem_qws.h> #include <qtimer.h> #include <qcombobox.h> #include <qvbox.h> #include <qlayout.h> #include <qstyle.h> #include <qpushbutton.h> #include <qtabbar.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qregexp.h> #include <qmessagebox.h> #include <qframe.h> #include <qpainter.h> #include <qlabel.h> #include <qtextstream.h> #include "launcherview.h" #include "launcher.h" #include "syncdialog.h" #include "desktop.h" #include <qpe/lnkproperties.h> #include "mrulist.h" #include "qrsync.h" #include <stdlib.h> #include <unistd.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <stdio.h> #include <sys/vfs.h> #include <mntent.h> #endif #include <qpe/storage.h> #include "mediummountgui.h" //#define SHOW_ALL // uidGen // uidGen namespace { QStringList configToMime( Config *cfg ){ QStringList mimes; bool tmpMime; cfg->setGroup("mimetypes" ); tmpMime = cfg->readBoolEntry("all" ,false); if( tmpMime ){ mimes << QString::null; return mimes; }else{ tmpMime = cfg->readBoolEntry("audio", true ); if(tmpMime ) mimes.append("audio//*" ); tmpMime = cfg->readBoolEntry("image", true ); if(tmpMime ) mimes.append("image//*" ); tmpMime = cfg->readBoolEntry("text", true ); if(tmpMime ) mimes.append("text//*"); - + tmpMime = cfg->readBoolEntry("video", true ); if(tmpMime ) mimes.append("video//*" ); } return mimes; } } CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : QVBox( parent ) { categoryBar = 0; stack = 0; } void CategoryTabWidget::prevTab() { if ( categoryBar ) { int n = categoryBar->count(); int tab = categoryBar->currentTab(); if ( tab >= 0 ) categoryBar->setCurrentTab( (tab - 1 + n)%n ); } } void CategoryTabWidget::nextTab() { if ( categoryBar ) { int n = categoryBar->count(); int tab = categoryBar->currentTab(); categoryBar->setCurrentTab( (tab + 1)%n ); } } void CategoryTabWidget::addItem( const QString& linkfile ) { int i=0; AppLnk *app = new AppLnk(linkfile); if ( !app->isValid() ) { delete app; return; } if ( !app->file().isEmpty() ) { // A document delete app; app = new DocLnk(linkfile); ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); return; } for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { if ( !(*it).isEmpty() ) { QRegExp tf(*it,FALSE,TRUE); if ( tf.match(app->type()) >= 0 ) { ((LauncherView*)stack->widget(i))->addItem(app); return; } i++; } } } void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, const QList<FileSystem> &fs) { delete categoryBar; categoryBar = new CategoryTabBar( this ); QPalette pal = categoryBar->palette(); pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); categoryBar->setPalette( pal ); delete stack; stack = new QWidgetStack(this); tabs=0; ids.clear(); QStringList types = rootFolder->types(); for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { if ( !(*it).isEmpty() ) { newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); } } QListIterator<AppLnk> it( rootFolder->children() ); AppLnk* l; while ( (l=it.current()) ) { if ( l->type() == "Separator" ) { rootFolder->remove(l); delete l; } else { int i=0; for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { if ( *it == l->type() ) ((LauncherView*)stack->widget(i))->addItem(l,FALSE); i++; } } ++it; } rootFolder->detachChildren(); for (int i=0; i<tabs; i++) ((LauncherView*)stack->widget(i))->sort(); // all documents docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); docview->populate( docFolder, QString::null ); docFolder->detachChildren(); docview->setFileSystems(fs); docview->setToolsEnabled(TRUE); connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); ((LauncherView*)stack->widget(0))->setFocus(); categoryBar->show(); stack->show(); } void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) { docview->populate( docFolder, QString::null ); docFolder->detachChildren(); docview->setFileSystems(fs); docview->updateTools(); } @@ -424,520 +424,534 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&, QRect tr = r; if ( r.width() < 20 ) return; if ( t->isEnabled() && isEnabled() ) { #if defined(_WS_WIN32_) if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) p->setPen( colorGroup().buttonText() ); else p->setPen( colorGroup().foreground() ); #else p->setPen( colorGroup().foreground() ); #endif p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } else { p->setPen( palette().disabled().foreground() ); p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } } //--------------------------------------------------------------------------- Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption( tr("Launcher") ); syncDialog = 0; // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tabs = 0; rootFolder = 0; docsFolder = 0; int stamp = uidgen.generate(); // this is our timestamp to see which devices we know //uidgen.store( stamp ); m_timeStamp = QString::number( stamp ); tabs = new CategoryTabWidget( this ); tabs->setMaximumWidth( qApp->desktop()->width() ); setCentralWidget( tabs ); connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); #endif storage = new StorageInfo( this ); connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); updateTabs(); preloadApps(); in_lnk_props = FALSE; got_lnk_change = FALSE; } Launcher::~Launcher() { } static bool isVisibleWindow(int wid) { const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); } return FALSE; } void Launcher::showMaximized() { if ( isVisibleWindow( winId() ) ) doMaximize(); else QTimer::singleShot( 20, this, SLOT(doMaximize()) ); } void Launcher::doMaximize() { QMainWindow::showMaximized(); } void Launcher::updateMimeTypes() { MimeType::clear(); updateMimeTypes(rootFolder); } void Launcher::updateMimeTypes(AppLnkSet* folder) { for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { AppLnk *app = it.current(); if ( app->type() == "Folder" ) updateMimeTypes((AppLnkSet *)app); else { MimeType::registerApp(*app); } } } void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { qWarning("loading Documents" ); qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); delete docsFolder; docsFolder = new DocLnkSet; qWarning("new DocLnkSet" ); DocLnkSet *tmp = 0; QString home = QString(getenv("HOME")) + "/Documents"; tmp = new DocLnkSet( home , QString::null); docsFolder->appendFrom( *tmp ); delete tmp; // find out wich filesystems are new in this round // We will do this by having a timestamp inside each mountpoint - // if the current timestamp doesn't match this is a new file system and + // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); - + QString newStamp = QString::number( stamp ); // generates newtime Stamp StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); QListIterator<FileSystem> it ( fileSystems ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { // let's find out if we should search on it qWarning("%s is removeable", (*it)->path().latin1() ); OConfig cfg( (*it)->path() + "/.opiestorage.cf"); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); if( stamp == m_timeStamp ){ // ok we know this card cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp // we need to scan the list now. Hopefully the cache will be there // read the mimetypes from the config and search for documents QStringList mimetypes = configToMime( &cfg); tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; }else{ // come up with the gui cause this a new card MediumMountGui medium((*it)->path() ); if( medium.check() ){ // we did not ask before or ask again is off if( medium.exec() ){ // he clicked yes so search it // speicher cfg.read(); // cause of a race we need to reread cfg.writeEntry("timestamp", newStamp ); }// no else }else{ // we checked // do something different see what we need to do // let's see if we should check the device cfg.setGroup("main" ); bool check = cfg.readBoolEntry("autocheck", true ); if( check ){ // find the documents tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; } } - } + } } } m_timeStamp = newStamp; } void Launcher::updateTabs() { MimeType::updateApplications(); // ### reads all applnks twice delete rootFolder; rootFolder = new AppLnkSet( MimeType::appsFolderName() ); loadDocs(); tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); } void Launcher::updateDocs() { loadDocs(); tabs->updateDocs(docsFolder,storage->fileSystems()); } void Launcher::viewSelected(const QString& s) { setCaption( s + tr(" - Launcher") ); } void Launcher::nextView() { tabs->nextTab(); } void Launcher::select( const AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // Not supported: flat is simpler for the user } else { if ( appLnk->exec().isNull() ) { QMessageBox::information(this,tr("No application"), tr("<p>No application is defined for this document." "<p>Type is %1.").arg(appLnk->type())); return; } tabs->setBusy(TRUE); emit executing( appLnk ); appLnk->execute(); } } void Launcher::externalSelected(const AppLnk *appLnk) { tabs->setBusy(TRUE); emit executing( appLnk ); } void Launcher::properties( AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // Not supported: flat is simpler for the user } else { in_lnk_props = TRUE; got_lnk_change = FALSE; LnkProperties prop(appLnk); connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); prop.showMaximized(); prop.exec(); in_lnk_props = FALSE; if ( got_lnk_change ) { updateLink(lnk_change); } } } void Launcher::updateLink(const QString& link) { if (link.isNull()) updateTabs(); else if (link.isEmpty()) updateDocs(); else tabs->updateLink(link); } void Launcher::systemMessage( const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "closing(QString)" ){ QString app; stream >> app; qWarning("app closed %s", app.latin1() ); MRUList::removeTask( app ); }else if ( msg == "linkChanged(QString)" ) { QString link; - stream >> link; + stream >> link; if ( in_lnk_props ) { got_lnk_change = TRUE; lnk_change = link; } else { updateLink(link); } } else if ( msg == "busy()" ) { emit busy(); } else if ( msg == "notBusy(QString)" ) { QString app; stream >> app; tabs->setBusy(FALSE); emit notBusy(app); } else if ( msg == "mkdir(QString)" ) { QString dir; stream >> dir; if ( !dir.isEmpty() ) mkdir( dir ); } else if ( msg == "rdiffGenSig(QString,QString)" ) { QString baseFile, sigFile; stream >> baseFile >> sigFile; QRsync::generateSignature( baseFile, sigFile ); } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { QString baseFile, sigFile, deltaFile; stream >> baseFile >> sigFile >> deltaFile; QRsync::generateDiff( baseFile, sigFile, deltaFile ); } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { QString baseFile, deltaFile; stream >> baseFile >> deltaFile; if ( !QFile::exists( baseFile ) ) { QFile f( baseFile ); f.open( IO_WriteOnly ); f.close(); } QRsync::applyDiff( baseFile, deltaFile ); QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); e << baseFile; } else if ( msg == "rdiffCleanup()" ) { mkdir( "/tmp/rdiff" ); QDir dir; dir.setPath( "/tmp/rdiff" ); QStringList entries = dir.entryList(); for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) dir.remove( *it ); } else if ( msg == "sendHandshakeInfo()" ) { QString home = getenv( "HOME" ); QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); e << home; int locked = (int) Desktop::screenLocked(); e << locked; // register an app for autostart // if clear is send the list is cleared. } else if ( msg == "autoStart(QString)" ) { - QString appName; - stream >> appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - if ( appName.compare("clear") == 0){ - cfg.writeEntry("Apps", ""); - } + QString appName; + stream >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( appName.compare("clear") == 0){ + cfg.writeEntry("Apps", ""); + } } else if ( msg == "autoStart(QString,QString)" ) { - QString modifier, appName; - stream >> modifier >> appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - if ( modifier.compare("add") == 0 ){ - // only add it appname is entered - if (!appName.isEmpty()) { - cfg.writeEntry("Apps", appName); - } - } else if (modifier.compare("remove") == 0 ) { - // need to change for multiple entries - // actually remove is right now simular to clear, but in future there - // should be multiple apps in autostart possible. - QString checkName; - checkName = cfg.readEntry("Apps", ""); - if (checkName == appName) { - cfg.writeEntry("Apps", ""); - } - } - } else if ( msg == "sendCardInfo()" ) { + QString modifier, appName; + stream >> modifier >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( modifier.compare("add") == 0 ){ + // only add if appname is entered + if (!appName.isEmpty()) { + cfg.writeEntry("Apps", appName); + } + } else if (modifier.compare("remove") == 0 ) { + // need to change for multiple entries + // actually remove is right now simular to clear, but in future there + // should be multiple apps in autostart possible. + QString checkName; + checkName = cfg.readEntry("Apps", ""); + if (checkName == appName) { + cfg.writeEntry("Apps", ""); + } + } + // case the autostart feature should be delayed + } else if ( msg == "autoStart(QString, QString, QString)") { + QString modifier, appName, delay; + stream >> modifier >> appName >> delay; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( modifier.compare("add") == 0 ){ + // only add it appname is entered + if (!appName.isEmpty()) { + cfg.writeEntry("Apps", appName); + cfg.writeEntry("Delay", delay); + } + } else { + } + } else if ( msg == "sendCardInfo()" ) { QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString hardDiskHome; for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) s += (*it)->name() + "=" + (*it)->path() + "/Documents " + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + " " + (*it)->options() + ";"; else if ( (*it)->disk() == "/dev/mtdblock1" || (*it)->disk() == "/dev/mtdblock/1" ) s += (*it)->name() + "=" + homeDir + "/Documents " + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + " " + (*it)->options() + ";"; else if ( (*it)->name().contains( "Hard Disk") && homeDir.contains( (*it)->path() ) && (*it)->path().length() > hardDiskHome.length() ) hardDiskHome = (*it)->name() + "=" + homeDir + "/Documents " + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + " " + (*it)->options() + ";"; } if ( !hardDiskHome.isEmpty() ) s += hardDiskHome; e << s; } else if ( msg == "sendSyncDate(QString)" ) { QString app; stream >> app; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); e << app << cfg.readEntry( app ); //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), //cfg.readEntry( app ).latin1() ); } else if ( msg == "setSyncDate(QString,QString)" ) { QString app, date; stream >> app >> date; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); cfg.writeEntry( app, date ); //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); } else if ( msg == "startSync(QString)" ) { QString what; stream >> what; delete syncDialog; syncDialog = 0; syncDialog = new SyncDialog( this, "syncProgress", FALSE, WStyle_Tool | WStyle_Customize | Qt::WStyle_StaysOnTop ); syncDialog->showMaximized(); syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); connect( syncDialog->buttonCancel, SIGNAL( clicked() ), - SLOT( cancelSync() ) ); + SLOT( cancelSync() ) ); } else if ( msg == "stopSync()") { delete syncDialog; syncDialog = 0; } else if ( msg == "getAllDocLinks()" ) { loadDocs(); QString contents; for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { DocLnk *doc = it.current(); QFileInfo fi( doc->file() ); if ( !fi.exists() ) continue; bool fake = !doc->linkFileKnown(); if ( !fake ) { QFile f( doc->linkFile() ); if ( f.open( IO_ReadOnly ) ) { QTextStream ts( &f ); ts.setEncoding( QTextStream::UnicodeUTF8 ); contents += ts.read(); f.close(); } else fake = TRUE; } if (fake) { contents += "[Desktop Entry]\n"; contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; contents += "File = "+doc->file()+"\n"; contents += "Name = "+doc->name()+"\n"; contents += "Type = "+doc->type()+"\n"; } contents += QString("Size = %1\n").arg( fi.size() ); } //qDebug( "sending length %d", contents.length() ); QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); e << contents; - + qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); delete docsFolder; docsFolder = 0; } } void Launcher::cancelSync() { QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); } void Launcher::storageChanged() { if ( in_lnk_props ) { got_lnk_change = TRUE; lnk_change = ""; } else { updateDocs(); } } bool Launcher::mkdir(const QString &localPath) { QDir fullDir(localPath); if (fullDir.exists()) return true; // at this point the directory doesn't exist // go through the directory tree and start creating the direcotories // that don't exist; if we can't create the directories, return false QString dirSeps = "/"; int dirIndex = localPath.find(dirSeps); QString checkedPath; // didn't find any seps; weird, use the cur dir instead if (dirIndex == -1) { //qDebug("No seperators found in path %s", localPath.latin1()); checkedPath = QDir::currentDirPath(); } while (checkedPath != localPath) { // no more seperators found, use the local path if (dirIndex == -1) checkedPath = localPath; else { // the next directory to check checkedPath = localPath.left(dirIndex) + "/"; // advance the iterator; the next dir seperator dirIndex = localPath.find(dirSeps, dirIndex+1); } QDir checkDir(checkedPath); if (!checkDir.exists()) { //qDebug("mkdir making dir %s", checkedPath.latin1()); if (!checkDir.mkdir(checkedPath)) { qDebug("Unable to make directory %s", checkedPath.latin1()); return FALSE; } } } return TRUE; } void Launcher::preloadApps() { Config cfg("Launcher"); cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); } } diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 61bd0c4..f5ed8d2 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -1,389 +1,400 @@ /* * today.cpp : main class * * --------------------- * * begin : Sun 10 17:20:00 CEST 2002 * copyright : (c) 2002 by Maximilian Reiß * email : max.reiss@gmx.de * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "today.h" #include <qpe/timestring.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/qprocess.h> +//#include <qpe/qprocess.h> #include <qpe/resource.h> #include <qpe/contact.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qdatetime.h> #include <qtextstream.h> #include <qcheckbox.h> #include <qspinbox.h> #include <qpushbutton.h> #include <qlabel.h> #include <qtimer.h> #include <qpixmap.h> -#include <qfileinfo.h> +//#include <qfileinfo.h> #include <qlayout.h> #include <qtl.h> //#include <iostream.h> #include <unistd.h> #include <stdlib.h> int MAX_LINES_TASK; int MAX_CHAR_CLIP; int MAX_LINES_MEET; int SHOW_LOCATION; int SHOW_NOTES; // show only later dates int ONLY_LATER; int AUTOSTART; int NEW_START=1; +QString AUTOSTART_TIMER; /* * Constructs a Example which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); #endif #endif db = NULL; setOwnerField(); todo = new ToDoDB; getTodo(); draw(); autoStart(); } /* * Qcop receive method. */ void Today::channelReceived(const QCString &msg, const QByteArray & data) { QDataStream stream(data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString message; stream >> message; setOwnerField(message); } } /* * Initialises the owner field with the default value, the username */ void Today::setOwnerField() { QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(file)) { Contact cont = Contact::readVCard(file)[0]; QString returnString = cont.fullName(); OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); } else { OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); } } /* * Set the owner field with a given QString, for example per qcop. */ void Today::setOwnerField(QString &message) { if (!message.isEmpty()) { OwnerField->setText("<b>" + message + "</b>"); } } /* * Autostart, uses the new (opie only) autostart method in the launcher code. * If registered against that today ist started on each resume. */ void Today::autoStart() { - Config cfg("today"); - cfg.setGroup("Autostart"); - AUTOSTART = cfg.readNumEntry("autostart",1); + // Config cfg("today"); + //cfg.setGroup("Autostart"); + //AUTOSTART = cfg.readNumEntry("autostart",1); + if (AUTOSTART) { - QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); + QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); e << QString("add"); e << QString("today"); + e << AUTOSTART_TIMER; } else { - QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); + QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); e << QString("remove"); e << QString("today"); } } /* * Repaint method. Reread all fields. */ void Today::draw() { init(); getDates(); getMail(); // if the todolist.xml file was not modified in between, do not parse it. if (checkIfModified()) { if (todo) delete todo; todo = new ToDoDB; getTodo(); } // how often refresh QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); } /* * Check if the todolist.xml was modified (if there are new entries. * Returns true if it was modified. */ bool Today::checkIfModified() { QDir dir; QString homedir = dir.homeDirPath (); QString time; Config cfg("today"); cfg.setGroup("Files"); time = cfg.readEntry("todolisttimestamp", ""); QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); QDateTime fileTime = file.lastModified(); if (time.compare(fileTime.toString()) == 0) { return false; } else { cfg.writeEntry("todolisttimestamp", fileTime.toString() ); cfg.write(); return true; } } /* * Init stuff needed for today. Reads the config file. */ void Today::init() { QDate date = QDate::currentDate(); QString time = (tr( date.toString()) ); TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); // read config Config cfg("today"); cfg.setGroup("BaseConfig"); // -- config file section -- // how many lines should be showed in the task section MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); // after how many chars should the be cut off on tasks and notes MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); // how many lines should be showed in the datebook section MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); // If location is to be showed too, 1 to activate it. SHOW_LOCATION = cfg.readNumEntry("showlocation",1); // if notes should be shown SHOW_NOTES = cfg.readNumEntry("shownotes",0); // should only later appointments be shown or all for the current day. ONLY_LATER = cfg.readNumEntry("onlylater",1); + cfg.setGroup("Autostart"); + AUTOSTART = cfg.readNumEntry("autostart",1); + AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); + //db = new DateBookDB; } /* * The method for the configuration dialog. */ void Today::startConfig() { conf = new todayconfig ( this, "", true ); // read the config Config cfg("today"); cfg.setGroup("BaseConfig"); //init(); conf->SpinBox1->setValue(MAX_LINES_MEET); // location show box conf->CheckBox1->setChecked(SHOW_LOCATION); // notes show box conf->CheckBox2->setChecked(SHOW_NOTES); // task lines conf->SpinBox2->setValue(MAX_LINES_TASK); // clip when? conf->SpinBox7->setValue(MAX_CHAR_CLIP); // only later conf->CheckBox3->setChecked(ONLY_LATER); // if today should be autostarted conf->CheckBoxAuto->setChecked(AUTOSTART); + // autostart only if device has been suspended for X minutes + conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); conf->exec(); int maxlinestask = conf->SpinBox2->value(); int maxmeet = conf->SpinBox1->value(); int location = conf->CheckBox1->isChecked(); int notes = conf->CheckBox2->isChecked(); int maxcharclip = conf->SpinBox7->value(); int onlylater = conf->CheckBox3->isChecked(); - int autostart =conf->CheckBoxAuto->isChecked(); + int autostart = conf->CheckBoxAuto->isChecked(); + int autostartdelay = conf->SpinBoxTime->value(); cfg.writeEntry("maxlinestask",maxlinestask); cfg.writeEntry("maxcharclip", maxcharclip); cfg.writeEntry("maxlinesmeet",maxmeet); cfg.writeEntry("showlocation",location); cfg.writeEntry("shownotes", notes); cfg.writeEntry("onlylater", onlylater); cfg.setGroup("Autostart"); cfg.writeEntry("autostart", autostart); + cfg.writeEntry("autostartdelay", autostartdelay); // sync it to "disk" cfg.write(); NEW_START=1; draw(); autoStart(); } /* * Get all events that are in the datebook xml file for today */ void Today::getDates() { QDate date = QDate::currentDate(); if (AllDateBookEvents) delete AllDateBookEvents; AllDateBookEvents = new QWidget( ); QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); if (db) { delete db; } db = new DateBookDB; QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); qBubbleSort(list); // printf("Get dates\n"); Config config( "qpe" ); // if 24 h format //bool ampm = config.readBoolEntry( "AMPM", TRUE ); int count=0; if ( list.count() > 0 ) { for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { if ( count <= MAX_LINES_MEET ) { QTime time = QTime::currentTime(); if (!ONLY_LATER) { count++; DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); layoutDates->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SLOT(editEvent(const Event &))); } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { count++; // show only later appointments DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); layoutDates->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SLOT(editEvent(const Event &))); } } } if (ONLY_LATER && count==0) { QLabel* noMoreEvents = new QLabel(AllDateBookEvents); noMoreEvents->setText(tr("No more appointments today")); layoutDates->addWidget(noMoreEvents); } } else { QLabel* noEvents = new QLabel(AllDateBookEvents); noEvents->setText(tr("No appointments today")); layoutDates->addWidget(noEvents); } layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); sv1->addChild(AllDateBookEvents); AllDateBookEvents->show(); } void Today::getMail() { Config cfg("opiemail"); cfg.setGroup("today"); // how many lines should be showed in the task section int NEW_MAILS = cfg.readNumEntry("newmails",0); int OUTGOING = cfg.readNumEntry("outgoing",0); QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); MailField->setText(output); } /* * Get the todos */ void Today::getTodo() { QString output; QString tmpout; int count = 0; int ammount = 0; // get overdue todos first QValueList<ToDoEvent> overDueList = todo->overDue(); qBubbleSort(overDueList); for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); it!=overDueList.end(); ++it ) { if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; ammount++; } } // get total number of still open todos QValueList<ToDoEvent> open = todo->rawToDos(); qBubbleSort(open); for ( QValueList<ToDoEvent>::Iterator it=open.begin(); it!=open.end(); ++it ) { if (!(*it).isCompleted()){ count +=1; // not the overdues, we allready got them, and not if we are // over the maxlines if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; ammount++; } } diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 500e8fb..905ec4b 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -1,146 +1,151 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'todayconfig.ui' -** -** Created: Thu Feb 14 15:04:33 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ +/* + * todayconfig.cpp + * + * --------------------- + * + * begin : Sun 10 17:20:00 CEST 2002 + * copyright : (c) 2002 by Maximilian Reiß + * email : max.reiss@gmx.de + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + #include "todayconfig.h" #include <qcheckbox.h> #include <qframe.h> #include <qlabel.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qwidget.h> #include <qlayout.h> #include <qvariant.h> -#include <qwhatsthis.h> +//#include <qwhatsthis.h> -/* - * Constructs a todayconfig which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) -{ + : QDialog( parent, name, modal, fl ) { if ( !name ) - setName( "todayconfig" ); + setName( "todayconfig" ); resize( 175, 232 ); setCaption( tr( "Today config" ) ); TabWidget3 = new QTabWidget( this, "TabWidget3" ); TabWidget3->setGeometry( QRect( 0, 0, 220, 320 ) ); TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); TabWidget3->setAutoMask( FALSE ); TabWidget3->setTabShape( QTabWidget::Rounded ); tab = new QWidget( TabWidget3, "tab" ); Frame8 = new QFrame( tab, "Frame8" ); Frame8->setGeometry( QRect( -5, 0, 200, 300 ) ); Frame8->setFrameShape( QFrame::StyledPanel ); Frame8->setFrameShadow( QFrame::Raised ); TextLabel4 = new QLabel( Frame8, "TextLabel4" ); TextLabel4->setGeometry( QRect( 20, 65, 100, 60 ) ); TextLabel4->setText( tr( "Should the \n" "location \n" "be shown?" ) ); TextLabel5 = new QLabel( Frame8, "TextLabel5" ); TextLabel5->setGeometry( QRect( 20, 160, 120, 40 ) ); TextLabel5->setText( tr( "Should the notes \n" "be shown?" ) ); CheckBox2 = new QCheckBox( Frame8, "CheckBox2" ); CheckBox2->setGeometry( QRect( 158, 170, 27, 21 ) ); //CheckBox2->setText( tr( "" ) ); CheckBox1 = new QCheckBox( Frame8, "CheckBox1" ); CheckBox1->setGeometry( QRect( 158, 65, 27, 50 ) ); //CheckBox1->setText( tr( "" ) ); CheckBox3 = new QCheckBox (Frame8, "CheckBox3" ); CheckBox3->setGeometry( QRect( 158, 125, 27, 21 ) ); TextLabel6 = new QLabel( Frame8, "All Day"); TextLabel6->setGeometry( QRect( 20, 120, 100, 30 ) ); TextLabel6->setText( tr( "Show only later\n" "appointments") ); SpinBox1 = new QSpinBox( Frame8, "SpinBox1" ); SpinBox1->setGeometry( QRect( 115, 20, 58, 25 ) ); SpinBox1->setMaxValue( 10 ); SpinBox1->setValue( 5 ); TextLabel3 = new QLabel( Frame8, "TextLabel3" ); TextLabel3->setGeometry( QRect( 20, 10, 90, 60 ) ); TextLabel3->setText( tr( "How many \n" "appointment\n" "should\n" "be shown?" ) ); TabWidget3->insertTab( tab, tr( "Calendar" ) ); tab_2 = new QWidget( TabWidget3, "tab_2" ); Frame9 = new QFrame( tab_2, "Frame9" ); Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); Frame9->setFrameShape( QFrame::StyledPanel ); Frame9->setFrameShadow( QFrame::Raised ); TextLabel6 = new QLabel( Frame9, "TextLabel6" ); TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); TextLabel6->setText( tr( "How many\n" "tasks should \n" "be shown?" ) ); SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); SpinBox2->setMaxValue( 20 ); SpinBox2->setValue( 5 ); TabWidget3->insertTab( tab_2, tr( "Tasks" ) ); tab_3 = new QWidget( TabWidget3, "tab_3" ); Frame14 = new QFrame( tab_3, "Frame14" ); Frame14->setGeometry( QRect( -5, 0, 200, 220 ) ); Frame14->setFrameShape( QFrame::StyledPanel ); Frame14->setFrameShadow( QFrame::Raised ); TextLabel1 = new QLabel( Frame14, "TextLabel1" ); TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); TextLabel1->setText( tr( "Clip after how\n" "many letters" ) ); SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); SpinBox7->setMaxValue( 80 ); - SpinBox7->setValue( 30 ); TextLabel2 = new QLabel( Frame14, "AutoStart" ); TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); TextLabel2->setText( tr( "Should today be\n" "autostarted on\n" "resume?" " (Opie only)" ) ); CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); + TimeLabel = new QLabel( Frame14, "TimeLabel" ); + TimeLabel->setGeometry( QRect ( 20, 120, 120, 45 ) ); + TimeLabel->setText( tr( "Activate the \n" + "autostart after how\n" + "many minutes?" ) ); + SpinBoxTime = new QSpinBox( Frame14, "TimeSpinner"); + SpinBoxTime->setGeometry( QRect( 115, 120, 58, 25 ) ); + TabWidget3->insertTab( tab_3, tr( "Misc" ) ); } -/* - * Destroys the object and frees any allocated resources - */ -todayconfig::~todayconfig() -{ - // no need to delete child widgets, Qt does it all for us +todayconfig::~todayconfig() { } diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index 4739b5a..2986c4c 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h @@ -1,55 +1,66 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'todayconfig.ui' -** -** Created: Thu Feb 14 15:04:33 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ +/* + * todayconfig.h + * + * --------------------- + * + * begin : Sun 10 17:20:00 CEST 2002 + * copyright : (c) 2002 by Maximilian Reiß + * email : max.reiss@gmx.de + * + */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ #ifndef TODAYCONFIG_H #define TODAYCONFIG_H #include <qvariant.h> #include <qdialog.h> -//class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; +//class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; class QCheckBox; class QFrame; class QLabel; class QSpinBox; class QTabWidget; class QWidget; -class todayconfig : public QDialog -{ +class todayconfig : public QDialog { Q_OBJECT public: todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~todayconfig(); QTabWidget* TabWidget3; QWidget* tab; QFrame* Frame8; QLabel* TextLabel4; QLabel* TextLabel5; QLabel* TextLabel2; QCheckBox* CheckBox3; QCheckBox* CheckBox2; QCheckBox* CheckBox1; QCheckBox* CheckBoxAuto; QSpinBox* SpinBox1; QLabel* TextLabel3; QWidget* tab_2; QFrame* Frame9; QLabel* TextLabel6; QSpinBox* SpinBox2; QWidget* tab_3; QFrame* Frame14; QLabel* TextLabel1; QSpinBox* SpinBox7; + QLabel* TimeLabel; + QSpinBox* SpinBoxTime; }; -#endif // TODAYCONFIG_H +#endif |