Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 108 |
1 files changed, 73 insertions, 35 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 6dd8918..cf1eeca 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -233,37 +233,53 @@ DateBook::~DateBook() } 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); + 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 defined (Q_WS_QWS) || defined(_WS_QWS_) frmSettings.showMaximized(); #endif if ( frmSettings.exec() ) { 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 @@ -376,26 +392,28 @@ void DateBook::viewWeek() { } void DateBook::viewWeekLst() { view(WEEKLST,currentDate()); } void DateBook::viewMonth() { view(MONTH,currentDate()); } void DateBook::insertEvent( const Event &e ) { - qWarning("Adding Event!"); - db->addEvent(e); + Event dupEvent=e; + dupEvent.setLocation(defaultLocation); + dupEvent.setCategories(defaultCategories); + db->addEvent(dupEvent); emit newEvent(); } void DateBook::duplicateEvent( const Event &e ) { qWarning("Hmmm..."); // 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; } @@ -597,38 +615,54 @@ void DateBook::loadSettings() 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 @@ -816,66 +850,70 @@ void DateBook::slotNewEventFromKey( const QString &str ) start = end = d; start.setTime( QTime( 10, 0 ) ); end.setTime( QTime( 12, 0 ) ); } else if ( views->visibleWidget() == weekLstView ) { QDate d = weekLstView->date(); start = end = d; start.setTime( QTime( 10, 0 ) ); end.setTime( QTime( 12, 0 ) ); } slotNewEntry(start, end, str); } void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { - // argh! This really needs to be encapsulated in a class - // or function. - QDialog newDlg( this, 0, TRUE ); - newDlg.setCaption( DateEntryBase::tr("New Event") ); - DateEntry *e; - QVBoxLayout *vb = new QVBoxLayout( &newDlg ); - QScrollView *sv = new QScrollView( &newDlg ); - sv->setResizePolicy( QScrollView::AutoOneFit ); - sv->setFrameStyle( QFrame::NoFrame ); - sv->setHScrollBarMode( QScrollView::AlwaysOff ); - vb->addWidget( sv ); + // argh! This really needs to be encapsulated in a class + // or function. + QDialog newDlg( this, 0, TRUE ); + newDlg.setCaption( DateEntryBase::tr("New Event") ); + DateEntry *e; + QVBoxLayout *vb = new QVBoxLayout( &newDlg ); + QScrollView *sv = new QScrollView( &newDlg ); + sv->setResizePolicy( QScrollView::AutoOneFit ); + sv->setFrameStyle( QFrame::NoFrame ); + sv->setHScrollBarMode( QScrollView::AlwaysOff ); + vb->addWidget( sv ); - Event ev; - ev.setDescription( str ); - // When the new gui comes in, change this... + Event ev; + ev.setDescription( str ); + // When the new gui comes in, change this... if(location==0) { - ev.setLocation( tr("(Unknown)") ); + if(defaultLocation.isEmpty()) { + ev.setLocation(tr("(Unknown)")); + } else { + ev.setLocation( defaultLocation ); + } } else { ev.setLocation(location); } - ev.setStart( start ); - ev.setEnd( end ); + ev.setCategories(defaultCategories); + ev.setStart( start ); + ev.setEnd( end ); - e = new DateEntry( onMonday, ev, ampm, &newDlg ); - e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); - sv->addChild( e ); + e = new DateEntry( onMonday, ev, ampm, &newDlg ); + e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); + sv->addChild( e ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) - newDlg.showMaximized(); + newDlg.showMaximized(); #endif - while (newDlg.exec()) { - ev = e->event(); - ev.assignUid(); - QString error = checkEvent( ev ); - if ( !error.isNull() ) { - if ( QMessageBox::warning( this, tr("Error!"), - error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) - continue; + while (newDlg.exec()) { + ev = e->event(); + ev.assignUid(); + QString error = checkEvent( ev ); + if ( !error.isNull() ) { + if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) + continue; + } + db->addEvent( ev ); + emit newEvent(); + break; } - db->addEvent( ev ); - emit newEvent(); - break; - } } void DateBook::setDocument( const QString &filename ) { if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; QValueList<Event> tl = Event::readVCalendar( filename ); for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { db->addEvent( *it ); } } |