summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp108
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
@@ -244,2 +244,16 @@ void DateBook::slotSettings()
244 244
245 bool found=false;
246 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
247 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
248 frmSettings.comboLocation->setCurrentItem(i);
249 found=true;
250 break;
251 }
252 }
253 if(!found) {
254 frmSettings.comboLocation->insertItem(defaultLocation);
255 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
256 }
257 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
258
245#if defined (Q_WS_QWS) || defined(_WS_QWS_) 259#if defined (Q_WS_QWS) || defined(_WS_QWS_)
@@ -257,2 +271,4 @@ void DateBook::slotSettings()
257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 271 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
272 defaultLocation=frmSettings.comboLocation->currentText();
273 defaultCategories=frmSettings.comboCategory->currentCategories();
258 274
@@ -387,4 +403,6 @@ void DateBook::insertEvent( const Event &e )
387{ 403{
388 qWarning("Adding Event!"); 404 Event dupEvent=e;
389 db->addEvent(e); 405 dupEvent.setLocation(defaultLocation);
406 dupEvent.setCategories(defaultCategories);
407 db->addEvent(dupEvent);
390 emit newEvent(); 408 emit newEvent();
@@ -608,2 +626,11 @@ void DateBook::loadSettings()
608 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 626 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
627
628 defaultLocation=config.readEntry("defaultLocation");
629 QString tmpString=config.readEntry("defaultCategories");
630 QStringList tmpStringList=QStringList::split(",",tmpString);
631 defaultCategories.truncate(0);
632 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
633 defaultCategories.resize(defaultCategories.count()+1);
634 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
635 }
609} 636}
@@ -622,2 +649,9 @@ void DateBook::saveSettings()
622 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 649 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
650
651 configDB.writeEntry("defaultLocation",defaultLocation);
652 QStringList tmpStringList;
653 for( uint i=0; i<defaultCategories.count(); i++) {
654 tmpStringList << QString::number(defaultCategories[i]);
655 }
656 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
623} 657}
@@ -827,19 +861,23 @@ void DateBook::slotNewEventFromKey( const QString &str )
827void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 861void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
828 // argh! This really needs to be encapsulated in a class 862 // argh! This really needs to be encapsulated in a class
829 // or function. 863 // or function.
830 QDialog newDlg( this, 0, TRUE ); 864 QDialog newDlg( this, 0, TRUE );
831 newDlg.setCaption( DateEntryBase::tr("New Event") ); 865 newDlg.setCaption( DateEntryBase::tr("New Event") );
832 DateEntry *e; 866 DateEntry *e;
833 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 867 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
834 QScrollView *sv = new QScrollView( &newDlg ); 868 QScrollView *sv = new QScrollView( &newDlg );
835 sv->setResizePolicy( QScrollView::AutoOneFit ); 869 sv->setResizePolicy( QScrollView::AutoOneFit );
836 sv->setFrameStyle( QFrame::NoFrame ); 870 sv->setFrameStyle( QFrame::NoFrame );
837 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 871 sv->setHScrollBarMode( QScrollView::AlwaysOff );
838 vb->addWidget( sv ); 872 vb->addWidget( sv );
839 873
840 Event ev; 874 Event ev;
841 ev.setDescription( str ); 875 ev.setDescription( str );
842 // When the new gui comes in, change this... 876 // When the new gui comes in, change this...
843 if(location==0) { 877 if(location==0) {
844 ev.setLocation( tr("(Unknown)") ); 878 if(defaultLocation.isEmpty()) {
879 ev.setLocation(tr("(Unknown)"));
880 } else {
881 ev.setLocation( defaultLocation );
882 }
845 } else { 883 } else {
@@ -847,24 +885,24 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const
847 } 885 }
848 ev.setStart( start ); 886 ev.setCategories(defaultCategories);
849 ev.setEnd( end ); 887 ev.setStart( start );
888 ev.setEnd( end );
850 889
851 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 890 e = new DateEntry( onMonday, ev, ampm, &newDlg );
852 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 891 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
853 sv->addChild( e ); 892 sv->addChild( e );
854#if defined(Q_WS_QWS) || defined(_WS_QWS_) 893#if defined(Q_WS_QWS) || defined(_WS_QWS_)
855 newDlg.showMaximized(); 894 newDlg.showMaximized();
856#endif 895#endif
857 while (newDlg.exec()) { 896 while (newDlg.exec()) {
858 ev = e->event(); 897 ev = e->event();
859 ev.assignUid(); 898 ev.assignUid();
860 QString error = checkEvent( ev ); 899 QString error = checkEvent( ev );
861 if ( !error.isNull() ) { 900 if ( !error.isNull() ) {
862 if ( QMessageBox::warning( this, tr("Error!"), 901 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
863 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 902 continue;
864 continue; 903 }
904 db->addEvent( ev );
905 emit newEvent();
906 break;
865 } 907 }
866 db->addEvent( ev );
867 emit newEvent();
868 break;
869 }
870} 908}