author | alwin <alwin> | 2005-03-19 13:44:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-19 13:44:30 (UTC) |
commit | 34e42590a8ef21c1377f89c7b82f25bcf0aec3cb (patch) (side-by-side diff) | |
tree | f5afdae31945ca2bac7339a339499fa87ece50d9 | |
parent | d9e8b9e797e3162ab564bb3b0f04663ef1167541 (diff) | |
download | opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.zip opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.gz opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.bz2 |
so....
I looked for a problem. could not found due the kind of code structure.
so I had reorganized the code into a more sensefull structure so every one
should be able to find some code sequences when searching for a bug.
yes - now I found the problem and can thinking about resolving it.
21 files changed, 736 insertions, 629 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 70dd7b5..0579279 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -1,825 +1,826 @@ /********************************************************************** ** 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. ** ** $Id$ ** **********************************************************************/ #define QTOPIA_INTERNAL_FD #include "datebook.h" #include "datebookday.h" #include "datebooksettings.h" #include "datebookweek.h" -#include "datebookweeklst.h" +#include "modules/weeklst/datebookweeklst.h" #include "dateentryimpl.h" #include <opie2/odebug.h> #include <opie2/oholidaypluginif.h> #include <opie2/oholidayplugin.h> #include <opie2/opluginloader.h> #include <opie2/todayplugininterface.h> #include <qpe/datebookmonth.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/finddialog.h> #include <qpe/ir.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/tzselect.h> +#include <qtopia/qlibrary.h> #include <qaction.h> #include <qcopchannel_qws.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtimer.h> #include <qtl.h> #include <qtoolbar.h> #include <qwidgetstack.h> #include <qdir.h> -#include <qtopia/qlibrary.h> +#include <qlabel.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> DateBook::DateBook( QWidget *parent, const char *, WFlags f ) : QMainWindow( parent, "datebook", f ), aPreset( FALSE ), presetTime( -1 ), startTime( 8 ), // an acceptable default rowStyle( 0 ), bJumpToCurTime(FALSE), syncing(FALSE), inSearch(FALSE), alarmCounter(0) { bool needEvilHack= false; // if we need an Evil Hack QTime t; t.start(); db = new DateBookDBHoliday; odebug << "loading db t=" << t.elapsed() << oendl; db_holiday = new DateBookHoliday(); db->db_holiday=db_holiday; loadSettings(); setCaption( tr("Calendar") ); setIcon( Resource::loadPixmap( "datebook_icon" ) ); setToolBarsMovable( FALSE ); views = new QWidgetStack( this ); setCentralWidget( views ); dayView = 0; weekView = 0; weekLstView = 0; monthView = 0; // QToolBar *bar = new QToolBar( this ); // bar->setHorizontalStretchable( TRUE ); // QMenuBar *mb = new QMenuBar( bar ); // mb->setMargin( 0 ); // QPopupMenu *view = new QPopupMenu( this ); // mb->insertItem( tr( "View" ), view ); QToolBar *sub_bar = new QToolBar(this); sub_bar->setHorizontalStretchable(TRUE); QActionGroup *g = new QActionGroup( this ); g->setExclusive( TRUE ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( sub_bar ); sub_bar->addSeparator(); a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); a->addTo( sub_bar ); // a->addTo( view ); sub_bar->addSeparator(); a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); a->setOn( TRUE ); dayAction = a; a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); weekAction = a; a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); weekLstAction = a; a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); a->addTo( sub_bar ); // a->addTo( view ); a->setToggleAction( TRUE ); monthAction = a; sub_bar->addSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( sub_bar ); a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( sub_bar ); if(defaultView==DAY) viewDay(); if(defaultView==WEEK) needEvilHack=true; // viewWeek(); if(defaultView==WEEKLST) viewWeekLst(); if(defaultView==MONTH) viewMonth(); connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); #endif // listen on QPE/System #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); channel = new QCopChannel( "QPE/Datebook", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); #endif #endif odebug << "done t=" << t.elapsed() << oendl; connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); /* * Here is a problem description: * When Weekview is the default view * a DateBookWeekView get's created * redraw() get's called. So what? * Remember that we're still in the c'tor * and no final layout has happened? Ok * now all Events get arranged. Their x * position get's determined by a QHeader * position. But the QHeader isn't layouted or * at the right position. redraw() is a slot * so we'll call it then via a singleShot * from view() */ if( needEvilHack ){ QTimer::singleShot( 500, this, SLOT(viewWeek()) ); } } void DateBook::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "timeChange(QString)" ) { // update active view! if ( dayAction->isOn() ) viewDay(); else if ( weekAction->isOn() ) viewWeek(); else if ( monthAction->isOn() ) viewMonth(); } else if (msg == "editEvent(int)") { int uid; stream >> uid; Event e=db->eventByUID(uid); editEvent(e); }else if (msg == "viewDefault(QDate)"){ QDate day; stream >> day; viewDefault(day); } } DateBook::~DateBook() { delete db_holiday; } void DateBook::slotSettings() { DateBookSettings frmSettings( ampm, this ); frmSettings.setStartTime( startTime ); frmSettings.setAlarmPreset( aPreset, presetTime ); frmSettings.setJumpToCurTime( bJumpToCurTime ); frmSettings.setRowStyle( rowStyle ); frmSettings.comboDefaultView->setCurrentItem(defaultView-1); frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); bool found=false; for (int i=0; i<(frmSettings.comboLocation->count()); i++) { if ( frmSettings.comboLocation->text(i) == defaultLocation ) { frmSettings.comboLocation->setCurrentItem(i); found=true; break; } } if(!found) { frmSettings.comboLocation->insertItem(defaultLocation); frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); } frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); if ( QPEApplication::execDialog( &frmSettings ) ) { frmSettings.savePlugins(); db_holiday->pluginManager()->save(); db_holiday->reloadPlugins(); aPreset = frmSettings.alarmPreset(); presetTime = frmSettings.presetTime(); startTime = frmSettings.startTime(); bJumpToCurTime = frmSettings.jumpToCurTime(); rowStyle = frmSettings.rowStyle(); defaultView=frmSettings.comboDefaultView->currentItem()+1; weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); defaultLocation=frmSettings.comboLocation->currentText(); defaultCategories=frmSettings.comboCategory->currentCategories(); if ( dayView ) { dayView->setStartViewTime( startTime ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setRowStyle( rowStyle ); } if ( weekView ) { weekView->setStartViewTime( startTime ); } saveSettings(); // make the change obvious if ( views->visibleWidget() ) { if ( views->visibleWidget() == dayView ) dayView->redraw(); else if ( views->visibleWidget() == weekView ) weekView->redraw(); else if ( views->visibleWidget() == weekLstView ) weekLstView->redraw(); } } } void DateBook::fileNew() { slotNewEventFromKey(""); } QString DateBook::checkEvent(const Event &e) { /* check if overlaps with itself */ bool checkFailed = FALSE; /* check the next 12 repeats. should catch most problems */ QDate current_date = e.start().date(); Event previous = e; for(int i = 0; i < 12; i++) { QDateTime next; if (!nextOccurance(previous, current_date.addDays(1), next)) { break; // no more repeats } if(next < previous.end()) { checkFailed = TRUE; break; } current_date = next.date(); } if(checkFailed) return tr("Event duration is potentially longer\n" "than interval between repeats."); return QString::null; } QDate DateBook::currentDate() { QDate d = QDate::currentDate(); if ( dayView && views->visibleWidget() == dayView ) { d = dayView->date(); } else if ( weekView && views->visibleWidget() == weekView ) { d = weekView->date(); } else if ( weekLstView && views->visibleWidget() == weekLstView ) { d = weekLstView->date(); } else if ( monthView && views->visibleWidget() == monthView ) { d = monthView->selectedDate(); } return d; } void DateBook::view(int v, const QDate &d) { if (v==DAY) { initDay(); dayAction->setOn( TRUE ); dayView->setDate( d ); views->raiseWidget( dayView ); dayView->redraw(); } else if (v==WEEK) { initWeek(); weekAction->setOn( TRUE ); weekView->setDate( d ); views->raiseWidget( weekView ); weekView->redraw(); } else if (v==WEEKLST) { initWeekLst(); weekLstAction->setOn( TRUE ); weekLstView->setDate(d); views->raiseWidget( weekLstView ); weekLstView->redraw(); } else if (v==MONTH) { initMonth(); monthAction->setOn( TRUE ); monthView->setDate( d.year(), d.month(), d.day() ); views->raiseWidget( monthView ); monthView->redraw(); } } void DateBook::viewDefault(const QDate &d) { view(defaultView,d); } void DateBook::viewDay() { view(DAY,currentDate()); } void DateBook::viewWeek() { view(WEEK,currentDate()); } void DateBook::viewWeekLst() { view(WEEKLST,currentDate()); } void DateBook::viewMonth() { view(MONTH,currentDate()); } void DateBook::insertEvent( const Event &e ) { Event dupEvent=e; if(!dupEvent.isValidUid() ) // tkcRom seems to be different dupEvent.assignUid(); dupEvent.setLocation(defaultLocation); dupEvent.setCategories(defaultCategories); db->addEvent(dupEvent); emit newEvent(); } void DateBook::duplicateEvent( const Event &e ) { // Alot of code duplication, as this is almost like editEvent(); if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } Event dupevent(e); // Make a duplicate. // workaround added for text input. QDialog editDlg( this, 0, TRUE ); DateEntry *entry; editDlg.setCaption( tr("Duplicate Event") ); QVBoxLayout *vb = new QVBoxLayout( &editDlg ); QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); sv->setResizePolicy( QScrollView::AutoOneFit ); // KLUDGE!!! sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); entry->timezone->setEnabled( FALSE ); sv->addChild( entry ); while ( QPEApplication::execDialog( &editDlg ) ) { Event newEv = entry->event(); QString error = checkEvent(newEv); if (!error.isNull()) { if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; } /* * The problem: * DateBookDB does remove repeating events not by uid but by the time * the recurrence was created * so we need to update that time as well */ Event::RepeatPattern rp = newEv.repeatPattern(); rp.createTime = ::time( NULL ); newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... if( newEv.uid() == e.uid() || !newEv.isValidUid() ) newEv.assignUid(); db->addEvent(newEv); emit newEvent(); break; } } void DateBook::editEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } // workaround added for text input. QDialog editDlg( this, 0, TRUE ); DateEntry *entry; editDlg.setCaption( tr("Edit Event") ); QVBoxLayout *vb = new QVBoxLayout( &editDlg ); QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); sv->setResizePolicy( QScrollView::AutoOneFit ); // KLUDGE!!! sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); entry->timezone->setEnabled( FALSE ); sv->addChild( entry ); while ( QPEApplication::execDialog( &editDlg ) ) { Event newEv = entry->event(); if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) break; newEv.setUid(e.uid()); // FIXME: Hack not to clear uid QString error = checkEvent(newEv); if (!error.isNull()) { if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; } db->editEvent(e, newEv); emit newEvent(); break; } } void DateBook::removeEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } QString strName = e.description(); if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) return; db->removeEvent( e ); if ( views->visibleWidget() == dayView && dayView ) dayView->redraw(); } void DateBook::addEvent( const Event &e ) { QDate d = e.start().date(); initDay(); dayView->setDate( d ); } void DateBook::showDay( int year, int month, int day ) { QDate d(year, month, day); view(DAY,d); } void DateBook::initDay() { if ( !dayView ) { dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); views->addWidget( dayView, DAY ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setStartViewTime( startTime ); dayView->setRowStyle( rowStyle ); connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); } } void DateBook::initWeek() { if ( !weekView ) { weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); weekView->setStartViewTime( startTime ); views->addWidget( weekView, WEEK ); connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); } //But also get it right: the year that we display can be different //from the year of the current date. So, first find the year //number of the current week. int yearNumber, totWeeks; calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); QDate d = QDate( yearNumber, 12, 31 ); calcWeek( d, totWeeks, yearNumber, onMonday ); while ( totWeeks == 1 ) { d = d.addDays( -1 ); calcWeek( d, totWeeks, yearNumber, onMonday ); } } void DateBook::initWeekLst() { if ( !weekLstView ) { weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); views->addWidget( weekLstView, WEEKLST ); //weekLstView->setStartViewTime( startTime ); connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); } } void DateBook::initMonth() { if ( !monthView ) { monthView = new DateBookMonth( views, "month view", FALSE, db ); views->addWidget( monthView, MONTH ); connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); qApp->processEvents(); } } void DateBook::loadSettings() { Config qpeconfig( "qpe" ); qpeconfig.setGroup("Time"); ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); onMonday = qpeconfig.readBoolEntry( "MONDAY" ); Config config("DateBook"); config.setGroup("Main"); startTime = config.readNumEntry("startviewtime", 8); aPreset = config.readBoolEntry("alarmpreset"); presetTime = config.readNumEntry("presettime"); bJumpToCurTime = config.readBoolEntry("jumptocurtime"); rowStyle = config.readNumEntry("rowstyle"); defaultView = config.readNumEntry("defaultview",DAY); weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); defaultLocation=config.readEntry("defaultLocation"); QString tmpString=config.readEntry("defaultCategories"); QStringList tmpStringList=QStringList::split(",",tmpString); defaultCategories.truncate(0); for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { defaultCategories.resize(defaultCategories.count()+1); defaultCategories[defaultCategories.count()-1]=(*i).toInt(); } } void DateBook::saveSettings() { Config config( "qpe" ); Config configDB( "DateBook" ); configDB.setGroup( "Main" ); configDB.writeEntry("startviewtime",startTime); configDB.writeEntry("alarmpreset",aPreset); configDB.writeEntry("presettime",presetTime); configDB.writeEntry("jumptocurtime", bJumpToCurTime); configDB.writeEntry("rowstyle", rowStyle); configDB.writeEntry("defaultview",defaultView); configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); configDB.writeEntry("defaultLocation",defaultLocation); QStringList tmpStringList; for( uint i=0; i<defaultCategories.count(); i++) { tmpStringList << QString::number(defaultCategories[i]); } configDB.writeEntry("defaultCategories",tmpStringList.join(",")); } void DateBook::appMessage(const QCString& msg, const QByteArray& data) { bool needShow = FALSE; if ( msg == "alarm(QDateTime,int)" ) { QDataStream ds(data,IO_ReadOnly); QDateTime when; int warn; ds >> when >> warn; // check to make it's okay to continue, // this is the case that the time was set ahead, and // we are forced given a stale alarm... QDateTime current = QDateTime::currentDateTime(); if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) return; QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); if ( list.count() > 0 ) { QString msg; bool bSound = FALSE; int stopTimer = 0; bool found = FALSE; for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { if ( (*it).event().hasAlarm() ) { found = TRUE; msg += "<CENTER><B>" + (*it).description() + "</B>" + "<BR>" + (*it).location() + "<BR>" + TimeString::dateString((*it).event().start(),ampm) + (warn ? tr(" (in " + QString::number(warn) + tr(" minutes)")) : QString("")) + "<BR>" + (*it).notes() + "</CENTER>"; if ( (*it).event().alarmSound() != Event::Silent ) { bSound = TRUE; } } } if ( found ) { if ( bSound ) { Sound::soundAlarm(); alarmCounter = 0; stopTimer = startTimer( 5000 ); } QDialog dlg( this, 0, TRUE ); QVBoxLayout *vb = new QVBoxLayout( &dlg ); QScrollView *view = new QScrollView( &dlg, "scrollView"); view->setResizePolicy( QScrollView::AutoOneFit ); vb->addWidget( view ); QLabel *lblMsg = new QLabel( msg, &dlg ); view->addChild( lblMsg ); QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); vb->addWidget( cmdOk ); needShow = QPEApplication::execDialog( &dlg ); if ( bSound ) killTimer( stopTimer ); } } } else if ( msg == "nextView()" ) { needShow = true; if ( !qApp-> activeWindow ( )) { needShow = TRUE; } else { QWidget* cur = views->visibleWidget(); if ( cur ) { if ( cur == dayView ) viewWeek(); else if ( cur == weekView ) viewWeekLst(); else if ( cur == weekLstView ) viewMonth(); else if ( cur == monthView ) viewDay(); needShow = TRUE; } } } else if (msg == "editEvent(int)") { /* simple copy from receive */ QDataStream stream(data,IO_ReadOnly); int uid; stream >> uid; Event e=db->eventByUID(uid); editEvent(e); } else if (msg == "viewDefault(QDate)"){ /* simple copy from receive */ QDataStream stream(data,IO_ReadOnly); QDate day; stream >> day; viewDefault(day); needShow = true; } if ( needShow ) { #if defined(Q_WS_QWS) || defined(_WS_QWS_) // showMaximized(); #else // show(); #endif // raise(); QPEApplication::setKeepRunning(); // setActiveWindow(); } } void DateBook::reload() { db->reload(); if ( dayAction->isOn() ) viewDay(); else if ( weekAction->isOn() ) viewWeek(); else if ( monthAction->isOn() ) viewMonth(); syncing = FALSE; } void DateBook::flush() { syncing = TRUE; db->save(); } void DateBook::timerEvent( QTimerEvent *e ) { if ( alarmCounter < 10 ) { alarmCounter++; Sound::soundAlarm(); } else { killTimer( e->timerId() ); } } void DateBook::changeClock( bool newClock ) { ampm = newClock; // repaint the affected objects... if (dayView) dayView->redraw(); if (weekView) weekView->redraw(); if (weekLstView) weekLstView->redraw(); } void DateBook::changeWeek( bool m ) { /* no need to redraw, each widget catches. Do need to store though for widgets we haven't made yet */ onMonday = m; } void DateBook::slotToday() { // we need to view today using default view view(defaultView,QDate::currentDate()); } void DateBook::closeEvent( QCloseEvent *e ) { if(syncing) { /* no need to save, did that at flush */ e->accept(); return; } // save settings will generate it's own error messages, no // need to do checking ourselves. saveSettings(); if ( db->save() ) { e->accept(); } else { if ( QMessageBox::critical( this, tr( "Out of space" ), tr("Calendar was unable to save\n" "your changes.\n" "Free up some space and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) e->accept(); else diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 3d7f5b5..fb8b083 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h @@ -1,137 +1,134 @@ /********************************************************************** ** 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 DATEBOOK_H #define DATEBOOK_H #include "datebooktypes.h" #include <qpe/datebookdb.h> #include <qmainwindow.h> -enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values -enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. - class QAction; class QWidgetStack; class DateBookDay; class DateBookWeek; class DateBookWeekLst; class DateBookMonth; class Event; class QDate; class Ir; class DateBook : public QMainWindow { Q_OBJECT public: static QString appName() { return QString::fromLatin1("datebook"); } DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~DateBook(); signals: void newEvent(); void signalNotFound(); void signalWrapAround(); protected: QDate currentDate(); void timerEvent( QTimerEvent *e ); void closeEvent( QCloseEvent *e ); void view(int v, const QDate &d); public slots: void flush(); void reload(); private slots: void fileNew(); void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); void slotSettings(); void slotToday(); // view today void changeClock( bool newClock ); void changeWeek( bool newDay ); void appMessage(const QCString& msg, const QByteArray& data); // handle key events in the day view... void slotNewEventFromKey( const QString &str ); void slotFind(); void slotDoFind( const QString &, const QDate &, bool, bool, int ); void viewDefault(const QDate &d); void viewDay(); void viewWeek(); void viewWeekLst(); void viewMonth(); void showDay( int y, int m, int d ); void insertEvent( const Event &e ); void editEvent( const Event &e ); void duplicateEvent( const Event &e ); void removeEvent( const Event &e ); void receive( const QCString &msg, const QByteArray &data ); void setDocument( const QString & ); void beamEvent( const Event &e ); void beamDone( Ir *ir ); private: void addEvent( const Event &e ); void initDay(); void initWeek(); void initWeekLst(); void initMonth(); void loadSettings(); void saveSettings(); private: DateBookDBHoliday *db; DateBookHoliday*db_holiday; QWidgetStack *views; DateBookDay *dayView; DateBookWeek *weekView; DateBookMonth *monthView; DateBookWeekLst *weekLstView; QAction *dayAction, *weekAction, *weekLstAction, *monthAction; int weeklistviewconfig; bool aPreset; // have everything set to alarm? int presetTime; // the standard time for the alarm int startTime; int rowStyle; int defaultView; QArray<int> defaultCategories; QString defaultLocation; bool bJumpToCurTime; //should jump to current time in dayview? bool ampm; bool onMonday; bool syncing; bool inSearch; int alarmCounter; QString checkEvent(const Event &); }; #endif diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 046bcdf..26f4d8d 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro @@ -1,42 +1,52 @@ CONFIG += qt warn_on quick-app HEADERS = datebookday.h \ datebook.h \ dateentryimpl.h \ datebookdayheaderimpl.h \ datebooksettings.h \ datebookweek.h \ - datebookweeklst.h \ + modules/weeklst/datebookweeklst.h \ + modules/weeklst/datebookweeklstdayhdr.h \ + modules/weeklst/datebookweeklstheader.h \ + modules/weeklst/datebookweeklstevent.h \ + modules/weeklst/datebookweeklstview.h \ + modules/weeklst/datebookweeklstdblview.h \ datebookweekheaderimpl.h \ repeatentry.h \ noteentryimpl.h \ onoteedit.h \ datebookdayallday.h \ namespace_hack.h \ datebooktypes.h SOURCES = main.cpp \ datebookday.cpp \ datebook.cpp \ dateentryimpl.cpp \ datebookdayheaderimpl.cpp \ datebooksettings.cpp \ datebookweek.cpp \ - datebookweeklst.cpp \ + modules/weeklst/datebookweeklst.cpp \ + modules/weeklst/datebookweeklstdayhdr.cpp \ + modules/weeklst/datebookweeklstheader.cpp \ + modules/weeklst/datebookweeklstevent.cpp \ + modules/weeklst/datebookweeklstview.cpp \ + modules/weeklst/datebookweeklstdblview.cpp \ datebookweekheaderimpl.cpp \ repeatentry.cpp \ noteentryimpl.cpp \ onoteedit.cpp \ datebookdayallday.cpp INTERFACES = dateentry.ui \ datebookdayheader.ui \ datebookweekheader.ui \ - datebookweeklstheader.ui \ - datebookweeklstdayhdr.ui \ + modules/weeklst/datebookweeklstheaderbase.ui \ + modules/weeklst/datebookweeklstdayhdrbase.ui \ repeatentrybase.ui \ datebooksettingsbase.ui \ noteentry.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 TARGET = datebook include( $(OPIEDIR)/include.pro ) diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h index 2966814..9453be8 100644 --- a/core/pim/datebook/datebooktypes.h +++ b/core/pim/datebook/datebooktypes.h @@ -1,70 +1,73 @@ #ifndef _DATEBOOK_TYPES_H
#define _DATEBOOK_TYPES_H
#include <qpe/datebookdb.h>
#include <qvaluelist.h>
#include <qstringlist.h>
namespace Opie {
namespace Datebook {
class HolidayPlugin;
class HolidayPluginIf;
}
namespace Core {
class OPluginLoader;
class OPluginManager;
}
}
class QLibrary;
+enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
+enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
+
class DateBookDBHack : virtual public DateBookDB {
public:
virtual ~DateBookDBHack(){}
Event eventByUID(int id);
};
class DateBookHoliday
{
public:
DateBookHoliday();
virtual ~DateBookHoliday();
QStringList holidaylist(const QDate&);
QStringList holidaylist(unsigned year, unsigned month, unsigned day);
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
void reloadPlugins();
Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;}
Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;}
protected:
void init();
void deinit();
struct HPlugin {
Opie::Datebook::HolidayPlugin*_plugin;
//QLibrary*_lib;
//Opie::Datebook::HolidayPluginIf*_if;
};
QValueList<HPlugin*>_pluginlist;
Opie::Core::OPluginLoader*m_pluginLoader;
Opie::Core::OPluginManager*m_pluginManager;
};
class DateBookDBHoliday:virtual public DateBookDBHack {
public:
DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
virtual ~DateBookDBHoliday(){}
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
DateBookHoliday*db_holiday;
};
#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp deleted file mode 100644 index 3c871ea..0000000 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/dev/null @@ -1,442 +0,0 @@ -#include "namespace_hack.h" -#include "datebookweeklst.h" - -#include "datebook.h" -#include "datebooktypes.h" - -#include <opie2/odebug.h> - -#include <qpe/datebookmonth.h> -#include <qpe/config.h> -#include <qpe/ir.h> -#include <qpe/resource.h> - -#include <qlayout.h> -#include <qtoolbutton.h> -#include <qtl.h> - -bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); - -using namespace Opie::Ui; -DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) - : DateBookWeekLstHeaderBase(parent, name, fl) -{ - setBackgroundMode( PaletteButton ); - labelDate->setBackgroundMode( PaletteButton ); - forwardweek->setBackgroundMode( PaletteButton ); - forwardweek->setPixmap( Resource::loadPixmap("forward") ); - forwardmonth->setBackgroundMode( PaletteButton ); - forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); - backweek->setBackgroundMode( PaletteButton ); - backweek->setPixmap( Resource::loadPixmap("back") ); - backmonth->setBackgroundMode( PaletteButton ); - backmonth->setPixmap( Resource::loadPixmap("fastback") ); - DateBookWeekLstHeaderBaseLayout->setSpacing(0); - DateBookWeekLstHeaderBaseLayout->setMargin(0); - //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - - connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); - connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); - connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); - connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); - connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); - connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); - bStartOnMonday=onM; -} -DateBookWeekLstHeader::~DateBookWeekLstHeader(){} - -void DateBookWeekLstHeader::setDate(const QDate &d) { - int year,week,dayofweek; - date=d; - dayofweek=d.dayOfWeek(); - if(bStartOnMonday) - dayofweek--; - else if( dayofweek == 7 ) - /* we already have the right day -7 would lead to the same week */ - dayofweek = 0; - - date=date.addDays(-dayofweek); - - calcWeek(date,week,year,bStartOnMonday); - QDate start=date; - QDate stop=start.addDays(6); - labelDate->setText( QString::number(start.day()) + "." + - Calendar::nameOfMonth( start.month() ) + "-" + - QString::number(stop.day()) + "." + - Calendar::nameOfMonth( stop.month()) +" ("+ - tr("w")+":"+QString::number( week ) +")"); - date = d; // bugfix: 0001126 - date has to be the selected date, not monday! - emit dateChanged(date); -} - -void DateBookWeekLstHeader::pickDate() { - static QPopupMenu *m1 = 0; - static DateBookMonth *picker = 0; - if ( !m1 ) { - m1 = new QPopupMenu( this ); - picker = new DateBookMonth( m1, 0, TRUE ); - m1->insertItem( picker ); - connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); - //connect( m1, SIGNAL( aboutToHide() ), - //this, SLOT( gotHide() ) ); - } - picker->setDate( date.year(), date.month(), date.day() ); - m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); - picker->setFocus(); -} -void DateBookWeekLstHeader::setDate(int y, int m, int d) { - setDate(QDate(y,m,d)); -} - -void DateBookWeekLstHeader::nextWeek() { - setDate(date.addDays(7)); -} -void DateBookWeekLstHeader::prevWeek() { - setDate(date.addDays(-7)); -} -void DateBookWeekLstHeader::nextMonth() -{ - setDate(date.addDays(28)); -} -void DateBookWeekLstHeader::prevMonth() -{ - setDate(date.addDays(-28)); -} - -DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, - QWidget* parent, - const char* name, - WFlags fl ) - : DateBookWeekLstDayHdrBase(parent, name, fl) { - - date=d; - - static const QString wdays=tr("MTWTFSSM", "Week days"); - char day=wdays[d.dayOfWeek()-1]; - - //dont use dayOfWeek() to save space ! - label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); - - add->setText("+"); - - if (d == QDate::currentDate()) { - QPalette pal=label->palette(); - pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); - label->setPalette(pal); - - /* - QFont f=label->font(); - f.setItalic(true); - label->setFont(f); - label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); - */ - } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday - QPalette pal=label->palette(); - pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); - label->setPalette(pal); - } - - connect (label, SIGNAL(clicked()), this, SLOT(showDay())); - connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); -} - -void DateBookWeekLstDayHdr::showDay() { - emit showDate(date.year(), date.month(), date.day()); -} - -void DateBookWeekLstDayHdr::newEvent() { - QDateTime start, stop; - start=stop=date; - start.setTime(QTime(10,0)); - stop.setTime(QTime(12,0)); - - emit addEvent(start,stop,"",0); -} -DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, - int weeklistviewconfig, - QWidget* parent, - const char* name, - WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) -{ - // old values... lastday = "__|__", middle=" |---", Firstday="00:00", - QString s,start,middle,end,day; - - odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; - if(weeklistviewconfig==NONE) { // No times displayed. -// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); -// middle.sprintf("<--->"); -// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); -// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); - } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. - start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); - middle.sprintf(" |---"); - end.sprintf("__|__"); - day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); - } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. - start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); - middle.sprintf("<--->"); - end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); - day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); - } - - if(ev.event().type() == Event::Normal) { - if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. - s=day; - } else if(ev.startDate()==ev.date()) { // start event. - s=start; - } else if(ev.endDate()==ev.date()) { // end event. - s=end; - } else { // middle day. - s=middle; - } - } else { - s=""; - } - setText(QString(s) + " " + ev.description()); -// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); - setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); -} -void DateBookWeekLstEvent::editMe() { - emit editEvent(event.event()); -} -void DateBookWeekLstEvent::duplicateMe() -{ - emit duplicateEvent(event.event()); -} -void DateBookWeekLstEvent::deleteMe() -{ - emit removeEvent(event.event()); - emit redraw(); -} -void DateBookWeekLstEvent::beamMe() -{ - emit beamEvent( event.event() ); -} -void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) -{ - if (!event.event().isValidUid()) { - // this is just such a holiday event. - return; - } - popmenue = new QPopupMenu; - - popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); - popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); - popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); - if(Ir::supported()) - popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); - popmenue->popup( mapToGlobal( e->pos() )); -} - -DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, - const QDate &d, bool onM, - QWidget* parent, - const char* name, WFlags fl) - : QWidget( parent, name, fl ) -{ - Config config("DateBook"); - config.setGroup("Main"); - int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); - odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; - - bStartOnMonday=onM; - setPalette(white); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); - - QVBoxLayout *layout = new QVBoxLayout( this ); - - qBubbleSort(ev); - QValueListIterator<EffectiveEvent> it; - it=ev.begin(); - - int dayOrder[7]; - if (bStartOnMonday) { - for (int d=0; d<7; d++) dayOrder[d]=d+1; - } else { - for (int d=0; d<7; d++) dayOrder[d]=d; - dayOrder[0]=7; - } - - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek(); - if(bStartOnMonday) dayoffset--; - else if( dayoffset == 7 ) dayoffset = 0; - - for (int i=0; i<7; i++) { - // Header - DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); - connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - layout->addWidget(hdr); - - // Events - while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { - if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. - DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); - layout->addWidget(l); - connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); - } - it++; - } - layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); - } -} -DateBookWeekLstView::~DateBookWeekLstView(){} -void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} - -DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, - QValueList<EffectiveEvent> &ev2, - QDate &d, bool onM, - QWidget* parent, - const char* name, WFlags fl) - : QWidget( parent, name, fl ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - - DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); - layout->addWidget(w); - connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); - connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - - - w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); - layout->addWidget(w); - connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); - connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); -} - -DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, - QWidget *parent, - const char *name ) - : QWidget( parent, name ), - db( newDB ), - startTime( 0 ), - ampm( ap ), - bStartOnMonday(onM) -{ - setFocusPolicy(StrongFocus); - layout = new QVBoxLayout( this ); - layout->setMargin(0); - - header=new DateBookWeekLstHeader(onM, this); - layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); - connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); - - scroll=new QScrollView(this); - scroll->setResizePolicy(QScrollView::AutoOneFit); - layout->addWidget(scroll); - - view=NULL; - Config config("DateBook"); - config.setGroup("Main"); - dbl=config.readBoolEntry("weeklst_dbl", false); - header->dbl->setOn(dbl); -} -DateBookWeekLst::~DateBookWeekLst(){ - Config config("DateBook"); - config.setGroup("Main"); - config.writeEntry("weeklst_dbl", dbl); -} - -void DateBookWeekLst::setDate(const QDate &d) { - bdate=d; - header->setDate(d); -} - -void DateBookWeekLst::setDbl(bool on) { - dbl=on; - redraw(); -} -void DateBookWeekLst::redraw() {getEvents();} - -QDate DateBookWeekLst::date() { - return bdate; -} - -// return the date at the beginning of the week... -// copied from DateBookWeek -QDate DateBookWeekLst::weekDate() const -{ - QDate d=bdate; - - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek(); - if(bStartOnMonday) dayoffset--; - else if( dayoffset == 7 ) - dayoffset = 0; - - return d.addDays(-dayoffset); -} - -void DateBookWeekLst::getEvents() { - QDate start = weekDate(); //date(); - QDate stop = start.addDays(6); - QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); - - if (view) delete view; - if (dbl) { - QDate start2=start.addDays(7); - stop=start2.addDays(6); - QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); - view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); - } else { - view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); - } - - connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (view, SIGNAL(redraw()), this, SLOT(redraw())); - connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - - scroll->addChild(view); - view->show(); - scroll->updateScrollBars(); -} - -void DateBookWeekLst::dateChanged(QDate &newdate) { - bdate=newdate; - getEvents(); -} - -void DateBookWeekLst::keyPressEvent(QKeyEvent *e) -{ - switch(e->key()) { - case Key_Up: - scroll->scrollBy(0, -20); - break; - case Key_Down: - scroll->scrollBy(0, 20); - break; - case Key_Left: - header->prevWeek(); - break; - case Key_Right: - header->nextWeek(); - break; - default: - e->ignore(); - } -} diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h deleted file mode 100644 index 38d7777..0000000 --- a/core/pim/datebook/datebookweeklst.h +++ b/dev/null @@ -1,178 +0,0 @@ -#ifndef DATEBOOKWEEKLST -#define DATEBOOKWEEKLST - -#include <qwidget.h> -#include <qdatetime.h> -#include <qpe/event.h> -#include <qlabel.h> -#include <qscrollview.h> - -#include "datebookweeklstheader.h" -#include "datebookweeklstdayhdr.h" - -#include <opie2/oclickablelabel.h> - -class QDateTime; -class DateBookDB; -class DateBookDBHoliday; - -class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase -{ - Q_OBJECT -public: - DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); - ~DateBookWeekLstHeader(); - void setDate(const QDate &d); - -public slots: - void nextWeek(); - void prevWeek(); - void nextMonth(); - void prevMonth(); - void pickDate(); - void setDate(int y, int m, int d); -signals: - void dateChanged(QDate &newdate); - void setDbl(bool on); -private: - QDate date; -// bool onMonday; - bool bStartOnMonday; -}; - -class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase -{ - Q_OBJECT -public: - DateBookWeekLstDayHdr(const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); -public slots: - void showDay(); - void newEvent(); -signals: - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); -private: - QDate date; -}; - -class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel -{ - Q_OBJECT -public: - DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0); -signals: - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); - void redraw(); -private slots: - void editMe(); - void duplicateMe(); - void deleteMe(); - void beamMe(); -private: - const EffectiveEvent event; - QPopupMenu* popmenue; -protected: - void mousePressEvent( QMouseEvent *e ); -}; - -class DateBookWeekLstView: public QWidget -{ - Q_OBJECT -public: - DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); - ~DateBookWeekLstView(); -signals: - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); - void redraw(); - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); -private: - bool bStartOnMonday; -protected slots: - void keyPressEvent(QKeyEvent *); -}; - -class DateBookWeekLstDblView: public QWidget { - Q_OBJECT -public: - DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, - QValueList<EffectiveEvent> &ev2, - QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); -signals: - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); - void redraw(); - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); -}; - -class DateBookWeekLst : public QWidget -{ - Q_OBJECT - -public: - DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, - QWidget *parent = 0, - const char *name = 0 ); - ~DateBookWeekLst(); - void setDate( int y, int w ); - void setDate(const QDate &d ); - int week() const { return _week; }; - QDate date(); - QDate weekDate() const; - -public slots: - void redraw(); - void dateChanged(QDate &date); - -protected slots: - void keyPressEvent(QKeyEvent *); - void setDbl(bool on); - -signals: - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); - -private: - DateBookDBHoliday *db; - int startTime; - bool ampm; - bool bStartOnMonday; - bool dbl; - QDate bdate; - int year, _week,dow; - DateBookWeekLstHeader *header; - QWidget *view; - QVBoxLayout *layout; - QScrollView *scroll; - - void getEvents(); -}; - -#endif - diff --git a/core/pim/datebook/modules/weeklst/.cvsignore b/core/pim/datebook/modules/weeklst/.cvsignore new file mode 100644 index 0000000..2da0b2b --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/.cvsignore @@ -0,0 +1,4 @@ +datebookweeklstdayhdrbase.cpp +datebookweeklstdayhdrbase.h +datebookweeklstheaderbase.cpp +datebookweeklstheaderbase.h diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp new file mode 100644 index 0000000..47bc597 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp @@ -0,0 +1,138 @@ +#include "namespace_hack.h" +#include "datebookweeklst.h" +#include "datebookweeklstheader.h" +#include "datebookweeklstview.h" +#include "datebookweeklstdblview.h" + +#include "datebook.h" + +#include <opie2/odebug.h> + +#include <qpe/datebookmonth.h> +#include <qpe/config.h> +#include <qpe/resource.h> + +#include <qlayout.h> +#include <qtoolbutton.h> + +using namespace Opie::Ui; + +DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, + QWidget *parent, + const char *name ) + : QWidget( parent, name ), + db( newDB ), + startTime( 0 ), + ampm( ap ), + bStartOnMonday(onM) +{ + setFocusPolicy(StrongFocus); + layout = new QVBoxLayout( this ); + layout->setMargin(0); + + header=new DateBookWeekLstHeader(onM, this); + layout->addWidget( header ); + connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); + connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); + + scroll=new QScrollView(this); + scroll->setResizePolicy(QScrollView::AutoOneFit); + layout->addWidget(scroll); + + view=NULL; + Config config("DateBook"); + config.setGroup("Main"); + dbl=config.readBoolEntry("weeklst_dbl", false); + header->dbl->setOn(dbl); +} +DateBookWeekLst::~DateBookWeekLst(){ + Config config("DateBook"); + config.setGroup("Main"); + config.writeEntry("weeklst_dbl", dbl); +} + +void DateBookWeekLst::setDate(const QDate &d) { + bdate=d; + header->setDate(d); +} + +void DateBookWeekLst::setDbl(bool on) { + dbl=on; + redraw(); +} +void DateBookWeekLst::redraw() {getEvents();} + +QDate DateBookWeekLst::date() { + return bdate; +} + +// return the date at the beginning of the week... +// copied from DateBookWeek +QDate DateBookWeekLst::weekDate() const +{ + QDate d=bdate; + + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek(); + if(bStartOnMonday) dayoffset--; + else if( dayoffset == 7 ) + dayoffset = 0; + + return d.addDays(-dayoffset); +} + +void DateBookWeekLst::getEvents() { + QDate start = weekDate(); //date(); + QDate stop = start.addDays(6); + QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); + + setUpdatesEnabled(false); + if (view) delete view; + if (dbl) { + QDate start2=start.addDays(7); + stop=start2.addDays(6); + QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); + view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); + } else { + view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); + } + + connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (view, SIGNAL(redraw()), this, SLOT(redraw())); + connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); + + scroll->addChild(view); + view->show(); + scroll->updateScrollBars(); + setUpdatesEnabled(true); +} + +void DateBookWeekLst::dateChanged(QDate &newdate) { + bdate=newdate; + getEvents(); +} + +void DateBookWeekLst::keyPressEvent(QKeyEvent *e) +{ + switch(e->key()) { + case Key_Up: + scroll->scrollBy(0, -20); + break; + case Key_Down: + scroll->scrollBy(0, 20); + break; + case Key_Left: + header->prevWeek(); + break; + case Key_Right: + header->nextWeek(); + break; + default: + e->ignore(); + } +} diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h new file mode 100644 index 0000000..3922fa1 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h @@ -0,0 +1,65 @@ +#ifndef DATEBOOKWEEKLST +#define DATEBOOKWEEKLST + +#include <qpe/event.h> + +#include <qwidget.h> +#include <qdatetime.h> + +class DateBookDB; +class DateBookDBHoliday; +class DateBookWeekLstHeader; +class DateBookWeekLstEvent; +class DateBookWeekLstView; +class QVBoxLayout; +class QScrollView; + +class DateBookWeekLst : public QWidget +{ + Q_OBJECT + +public: + DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, + QWidget *parent = 0, + const char *name = 0 ); + ~DateBookWeekLst(); + void setDate( int y, int w ); + void setDate(const QDate &d ); + int week() const { return _week; }; + QDate date(); + QDate weekDate() const; + +public slots: + void redraw(); + void dateChanged(QDate &date); + +protected slots: + void keyPressEvent(QKeyEvent *); + void setDbl(bool on); + +signals: + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str, const QString &location); + void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); + +private: + DateBookDBHoliday *db; + int startTime; + bool ampm; + bool bStartOnMonday; + bool dbl; + QDate bdate; + int year, _week,dow; + DateBookWeekLstHeader *header; + QWidget *view; + QVBoxLayout *layout; + QScrollView *scroll; + + void getEvents(); +}; + +#endif diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp new file mode 100644 index 0000000..d173444 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.cpp @@ -0,0 +1,53 @@ +#include "datebookweeklstdayhdr.h"
+
+#include "namespace_hack.h"
+
+DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
+ QWidget* parent,
+ const char* name,
+ WFlags fl )
+ : DateBookWeekLstDayHdrBase(parent, name, fl) {
+
+ date=d;
+
+ static const QString wdays=tr("MTWTFSSM", "Week days");
+ char day=wdays[d.dayOfWeek()-1];
+
+ //dont use dayOfWeek() to save space !
+ label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
+
+ add->setText("+");
+
+ if (d == QDate::currentDate()) {
+ QPalette pal=label->palette();
+ pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
+ label->setPalette(pal);
+
+ /*
+ QFont f=label->font();
+ f.setItalic(true);
+ label->setFont(f);
+ label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
+ */
+ } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
+ QPalette pal=label->palette();
+ pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
+ label->setPalette(pal);
+ }
+
+ connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
+ connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
+}
+
+void DateBookWeekLstDayHdr::showDay() {
+ emit showDate(date.year(), date.month(), date.day());
+}
+
+void DateBookWeekLstDayHdr::newEvent() {
+ QDateTime start, stop;
+ start=stop=date;
+ start.setTime(QTime(10,0));
+ stop.setTime(QTime(12,0));
+
+ emit addEvent(start,stop,"",0);
+}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h new file mode 100644 index 0000000..de046d8 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdr.h @@ -0,0 +1,26 @@ +#ifndef _DATEBOOKWEEKLSTDAYHDR_H
+#define _DATEBOOKWEEKLSTDAYHDR_H
+
+#include "datebookweeklstdayhdrbase.h"
+
+#include <qdatetime.h>
+
+class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstDayHdr(const QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+public slots:
+ void showDay();
+ void newEvent();
+signals:
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
+private:
+ QDate date;
+};
+
+#endif
diff --git a/core/pim/datebook/datebookweeklstdayhdr.ui b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui index 74ea584..74ea584 100644 --- a/core/pim/datebook/datebookweeklstdayhdr.ui +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdayhdrbase.ui diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp new file mode 100644 index 0000000..1cea602 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp @@ -0,0 +1,41 @@ +#include "datebookweeklstdblview.h"
+#include "datebookweeklstview.h"
+
+#include <qlayout.h>
+
+DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
+ QValueList<EffectiveEvent> &ev2,
+ QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
+ : QWidget( parent, name, fl )
+{
+ QHBoxLayout *layout = new QHBoxLayout( this );
+
+ DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
+ layout->addWidget(w);
+ connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+
+
+ w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
+ layout->addWidget(w);
+ connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+}
+
+DateBookWeekLstDblView::~DateBookWeekLstDblView()
+{
+}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h new file mode 100644 index 0000000..57e9690 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h @@ -0,0 +1,31 @@ +#ifndef _DATEBOOKWEEKLSTDBLVIEW_H
+#define _DATEBOOKWEEKLSTDBLVIEW_H
+
+#include <qpe/event.h>
+
+#include <qwidget.h>
+#include <qvaluelist.h>
+#include <qdatetime.h>
+#include <qstring.h>
+
+class DateBookWeekLstDblView: public QWidget {
+ Q_OBJECT
+public:
+ DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
+ QValueList<EffectiveEvent> &ev2,
+ QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+ virtual ~DateBookWeekLstDblView();
+signals:
+ void editEvent(const Event &e);
+ void duplicateEvent(const Event &e);
+ void removeEvent(const Event &e);
+ void beamEvent(const Event &e);
+ void redraw();
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
+};
+
+#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp new file mode 100644 index 0000000..797f766 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp @@ -0,0 +1,85 @@ +#include "datebookweeklstevent.h"
+#include "datebooktypes.h"
+
+#include <opie2/odebug.h>
+
+#include <qpe/ir.h>
+
+#include <qstring.h>
+#include <qpopupmenu.h>
+
+DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
+ int weeklistviewconfig,
+ QWidget* parent,
+ const char* name,
+ WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
+{
+ // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
+ QString s,start,middle,end,day;
+
+ odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
+ if(weeklistviewconfig==NONE) { // No times displayed.
+// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
+// middle.sprintf("<--->");
+// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
+// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
+ } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
+ start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ middle.sprintf(" |---");
+ end.sprintf("__|__");
+ day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
+ start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
+ middle.sprintf("<--->");
+ end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
+ day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
+ }
+
+ if(ev.event().type() == Event::Normal) {
+ if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
+ s=day;
+ } else if(ev.startDate()==ev.date()) { // start event.
+ s=start;
+ } else if(ev.endDate()==ev.date()) { // end event.
+ s=end;
+ } else { // middle day.
+ s=middle;
+ }
+ } else {
+ s="";
+ }
+ setText(QString(s) + " " + ev.description());
+// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
+ setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
+}
+void DateBookWeekLstEvent::editMe() {
+ emit editEvent(event.event());
+}
+void DateBookWeekLstEvent::duplicateMe()
+{
+ emit duplicateEvent(event.event());
+}
+void DateBookWeekLstEvent::deleteMe()
+{
+ emit removeEvent(event.event());
+ emit redraw();
+}
+void DateBookWeekLstEvent::beamMe()
+{
+ emit beamEvent( event.event() );
+}
+void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
+{
+ if (!event.event().isValidUid()) {
+ // this is just such a holiday event.
+ return;
+ }
+ popmenue = new QPopupMenu;
+
+ popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
+ popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
+ popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
+ if(Ir::supported())
+ popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
+ popmenue->popup( mapToGlobal( e->pos() ));
+}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h new file mode 100644 index 0000000..77f6283 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h @@ -0,0 +1,34 @@ +#ifndef _DATEBOOKWEEKLSTEVENT_H
+#define _DATEBOOKWEEKLSTEVENT_H
+
+#include <opie2/oclickablelabel.h>
+
+#include <qpe/event.h>
+
+class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+signals:
+ void editEvent(const Event &e);
+ void duplicateEvent(const Event &e);
+ void removeEvent(const Event &e);
+ void beamEvent(const Event &e);
+ void redraw();
+private slots:
+ void editMe();
+ void duplicateMe();
+ void deleteMe();
+ void beamMe();
+private:
+ const EffectiveEvent event;
+ QPopupMenu* popmenue;
+protected:
+ void mousePressEvent( QMouseEvent *e );
+};
+
+
+#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp new file mode 100644 index 0000000..81e0c31 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp @@ -0,0 +1,96 @@ +#include "datebookweeklstheader.h"
+
+#include <qpe/resource.h>
+#include <qpe/datebookmonth.h>
+
+#include <qtoolbutton.h>
+#include <qlayout.h>
+
+/* implenented in datebookweek.cpp - HELL */
+bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
+
+DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
+ : DateBookWeekLstHeaderBase(parent, name, fl)
+{
+ setBackgroundMode( PaletteButton );
+ labelDate->setBackgroundMode( PaletteButton );
+ forwardweek->setBackgroundMode( PaletteButton );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setBackgroundMode( PaletteButton );
+ forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
+ backweek->setBackgroundMode( PaletteButton );
+ backweek->setPixmap( Resource::loadPixmap("back") );
+ backmonth->setBackgroundMode( PaletteButton );
+ backmonth->setPixmap( Resource::loadPixmap("fastback") );
+ DateBookWeekLstHeaderBaseLayout->setSpacing(0);
+ DateBookWeekLstHeaderBaseLayout->setMargin(0);
+ //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
+
+ connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
+ connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
+ connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
+ connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
+ connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
+ connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
+ bStartOnMonday=onM;
+}
+DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
+
+void DateBookWeekLstHeader::setDate(const QDate &d) {
+ int year,week,dayofweek;
+ date=d;
+ dayofweek=d.dayOfWeek();
+ if(bStartOnMonday)
+ dayofweek--;
+ else if( dayofweek == 7 )
+ /* we already have the right day -7 would lead to the same week */
+ dayofweek = 0;
+
+ date=date.addDays(-dayofweek);
+
+ calcWeek(date,week,year,bStartOnMonday);
+ QDate start=date;
+ QDate stop=start.addDays(6);
+ labelDate->setText( QString::number(start.day()) + "." +
+ Calendar::nameOfMonth( start.month() ) + "-" +
+ QString::number(stop.day()) + "." +
+ Calendar::nameOfMonth( stop.month()) +" ("+
+ tr("w")+":"+QString::number( week ) +")");
+ date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
+ emit dateChanged(date);
+}
+
+void DateBookWeekLstHeader::pickDate() {
+ static QPopupMenu *m1 = 0;
+ static DateBookMonth *picker = 0;
+ if ( !m1 ) {
+ m1 = new QPopupMenu( this );
+ picker = new DateBookMonth( m1, 0, TRUE );
+ m1->insertItem( picker );
+ connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
+ //connect( m1, SIGNAL( aboutToHide() ),
+ //this, SLOT( gotHide() ) );
+ }
+ picker->setDate( date.year(), date.month(), date.day() );
+ m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
+ picker->setFocus();
+}
+void DateBookWeekLstHeader::setDate(int y, int m, int d) {
+ setDate(QDate(y,m,d));
+}
+
+void DateBookWeekLstHeader::nextWeek() {
+ setDate(date.addDays(7));
+}
+void DateBookWeekLstHeader::prevWeek() {
+ setDate(date.addDays(-7));
+}
+void DateBookWeekLstHeader::nextMonth()
+{
+ setDate(date.addDays(28));
+}
+void DateBookWeekLstHeader::prevMonth()
+{
+ setDate(date.addDays(-28));
+}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.h b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h new file mode 100644 index 0000000..818b825 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.h @@ -0,0 +1,34 @@ +#ifndef _DATEBOOKWEEKLSTHEADER_H
+#define _DATEBOOKWEEKLSTHEADER_H
+
+#include "datebookweeklstheaderbase.h"
+
+#include <qdatetime.h>
+
+class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+ ~DateBookWeekLstHeader();
+ void setDate(const QDate &d);
+
+public slots:
+ void nextWeek();
+ void prevWeek();
+ void nextMonth();
+ void prevMonth();
+ void pickDate();
+ void setDate(int y, int m, int d);
+signals:
+ void dateChanged(QDate &newdate);
+ void setDbl(bool on);
+protected:
+ QDate date;
+// bool onMonday;
+ bool bStartOnMonday;
+
+};
+
+#endif
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui index e925ec3..e925ec3 100644 --- a/core/pim/datebook/datebookweeklstheader.ui +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheaderbase.ui diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp new file mode 100644 index 0000000..efb4c01 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp @@ -0,0 +1,73 @@ +#include "datebookweeklstview.h"
+#include "datebooktypes.h"
+#include "datebookweeklstdayhdr.h"
+#include "datebookweeklstheader.h"
+#include "datebookweeklstevent.h"
+
+#include <opie2/odebug.h>
+
+#include <qpe/config.h>
+
+#include <qlayout.h>
+#include <qtl.h>
+
+DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
+ const QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
+ : QWidget( parent, name, fl )
+{
+ Config config("DateBook");
+ config.setGroup("Main");
+ int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
+ odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
+
+ bStartOnMonday=onM;
+ setPalette(white);
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
+
+ QVBoxLayout *layout = new QVBoxLayout( this );
+
+ qBubbleSort(ev);
+ QValueListIterator<EffectiveEvent> it;
+ it=ev.begin();
+
+ int dayOrder[7];
+ if (bStartOnMonday) {
+ for (int d=0; d<7; d++) dayOrder[d]=d+1;
+ } else {
+ for (int d=0; d<7; d++) dayOrder[d]=d;
+ dayOrder[0]=7;
+ }
+
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+ else if( dayoffset == 7 ) dayoffset = 0;
+
+ for (int i=0; i<7; i++) {
+ // Header
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
+ connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ layout->addWidget(hdr);
+
+ // Events
+ while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
+ if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
+ DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
+ layout->addWidget(l);
+ connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ }
+ it++;
+ }
+ layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ }
+}
+DateBookWeekLstView::~DateBookWeekLstView(){}
+void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h new file mode 100644 index 0000000..2428f1f --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h @@ -0,0 +1,36 @@ +#ifndef _DATEBOOKWEEKLISTVIEW_H
+#define _DATEBOOKWEEKLISTVIEW_H
+
+#include <qpe/event.h>
+
+#include <qwidget.h>
+#include <qvaluelist.h>
+#include <qstring.h>
+#include <qdatetime.h>
+
+class QKeyEvent;
+
+class DateBookWeekLstView: public QWidget
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+ ~DateBookWeekLstView();
+signals:
+ void editEvent(const Event &e);
+ void duplicateEvent(const Event &e);
+ void removeEvent(const Event &e);
+ void beamEvent(const Event &e);
+ void redraw();
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
+private:
+ bool bStartOnMonday;
+protected slots:
+ void keyPressEvent(QKeyEvent *);
+};
+
+#endif
|