-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 24 | ||||
-rw-r--r-- | korganizer/kofilterview.h | 3 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 4 | ||||
-rw-r--r-- | korganizer/main.cpp | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 9 |
6 files changed, 50 insertions, 6 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 08909ed..f179c58 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1602,16 +1602,21 @@ void CalendarView::syncExternal( int mode ) } bool CalendarView::importBday() { #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION + int curCal = mCalendar->defaultCalendar(); + int bd = mCalEditView->getBirtdayID(); + if ( bd == 0 ) + return; + mCalendar->setDefaultCalendar( bd ); KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; int count = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); int w = 300; @@ -1640,16 +1645,17 @@ bool CalendarView::importBday() } QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); if ( anni.isValid() ){ a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) ++addCount; } } + mCalendar->setDefaultCalendar( curCal ); updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); #else //DESKTOP_VERSION ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertBirthdays #endif //DESKTOP_VERSION @@ -1661,19 +1667,27 @@ bool CalendarView::importBday() } // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList) { + //qDebug("KO::CalendarView::insertBirthdays"); if (uid == this->name()) { + int curCal = mCalendar->defaultCalendar(); + int bd = mCalEditView->getBirtdayID(); + if ( bd == 0 ) + return; + mCalendar->setDefaultCalendar( bd ); + + int count = birthdayList.count(); int addCount = 0; KCal::Attendee* a = 0; //qDebug("CalView 1 %i", count); QProgressBar bar(count,0 ); int w = 300; @@ -1726,16 +1740,17 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd if ( anniversary.isValid() ){ a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, KCal::Attendee::ReqParticipant,uid) ; if ( addAnniversary( anniversary, assembledName, a, false ) ) ++addCount; } } + mCalendar->setDefaultCalendar( curCal ); updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); } } diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index a8a3052..3cde103 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp @@ -373,37 +373,57 @@ void KOCalEditView::addCal() KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); tryagain = true; file = ""; break; } kkf = KOPrefs::instance()->mCalendars.next(); } } + addCalendar ( name, file ); +} +int KOCalEditView::addCalendar( QString name, QString file, bool ask ) +{ + QFileInfo fi ( file ); if (!fi.exists() ) { + if ( ask ) if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) - return; + return 0; QFile fileIn( file ); if (!fileIn.open( IO_WriteOnly ) ) { KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); - return; + return 0; } QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; fileIn.close(); } KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); kkf->mName = name; kkf->mFileName = file; emit calendarAdded( kkf->mCalNumber ); + if ( ask ) emit needsUpdate(); QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); + return kkf->mCalNumber; +} +int KOCalEditView::getBirtdayID() +{ + KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); + while ( kkf ) { + if ( kkf->mName == i18n("Birthdays") ) + return kkf->mCalNumber; + kkf = KOPrefs::instance()->mCalendars.next(); + } + QString file = locateLocal( "data", "korganizer/birthdays.ics" ); + return addCalendar( i18n("Birthdays"), file, false ); } + void KOCalEditView::enableAll() { toggleList( mEnabledB ); } void KOCalEditView::enableAlarm() { toggleList( mAlarmB ); } diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index b57a6e9..54fe2c5 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h @@ -203,17 +203,18 @@ class KOFilterView : public KOFilterView_base }; class KOCalEditView : public QScrollView { Q_OBJECT public: KOCalEditView( QWidget* parent=0,const char* name=0); ~KOCalEditView(); - + int addCalendar( QString calName, QString fileName, bool ask = true ); + int getBirtdayID(); public slots: void addCal(); void enableAll(); void enableAlarm(); void disableRO(); void deleteAll(); void selectStdCal(int,bool ); void selectCal(int,bool ); diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index a4ea3d3..7ba7269 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -455,16 +455,20 @@ void KOPrefs::usrReadConfig() kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); if ( kkf->mCalNumber == 1 ) { kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); } + //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); + if ( kkf->mName == i18n("Birthdays") ) { + kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); + } } KPimPrefs::usrReadConfig(); } KopiCalendarFile * KOPrefs::getCalendar( int num ) { return mDefCalColors[num-1]; diff --git a/korganizer/main.cpp b/korganizer/main.cpp index 2bf46b9..c9d1345 100644 --- a/korganizer/main.cpp +++ b/korganizer/main.cpp @@ -80,16 +80,17 @@ int main( int argc, char **argv ) KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); #else fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); #endif KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); + KPimGlobalPrefs::instance()->setGlobalConfig(); MainWindow m; #ifndef DESKTOP_VERSION QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); a.showMainWidget(&m ); #else a.setMainWidget(&m ); m.show(); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index b9d8742..68233e8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -168,17 +168,17 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : QString confFile = locateLocal("config","korganizerrc"); QFileInfo finf ( confFile ); bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; setCaption("KO/Pi"); KOPrefs *p = KOPrefs::instance(); - KPimGlobalPrefs::instance()->setGlobalConfig(); + //KPimGlobalPrefs::instance()->setGlobalConfig(); p->mCurrentDisplayedView = 0; if ( p->mHourSize > 22 ) p->mHourSize = 22; QMainWindow::ToolBarDock tbd; if ( p->mToolBarHor ) { if ( p->mToolBarUp ) tbd = Bottom; else @@ -1718,17 +1718,17 @@ void MainWindow::importOL() id->exec(); delete id; mView->calendar()->checkAlarmForIncidence( 0, true ); mView->updateView(); #endif } void MainWindow::importBday() { - int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), + int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { mView->importBday(); } @@ -2305,25 +2305,28 @@ void MainWindow::configureAgenda( int item ) if ( KOPrefs::instance()->mHourSize == item ) return; KOPrefs::instance()->mHourSize=item; mView->viewManager()->agendaView()->updateConfig(); } void MainWindow::saveCalendar() { - QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) bupDir = KGlobalSettings::backupDataDir(); bupDir = KGlobal::formatMessage ( bupDir, 0 ); QString bupHint; if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; + bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; + KPimGlobalPrefs::instance()->mBackupEnabled = false; + save(); + KPimGlobalPrefs::instance()->mBackupEnabled = enabled; backupAllFiles(); } void MainWindow::loadCalendar() { #if 0 QString fn = KOPrefs::instance()->mLastLoadFile; |