summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index ff80afc..7ce3f1f 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -16,48 +16,49 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qdialog.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <libkcal/calfilter.h>
#include "kofilterview.h"
#include "koprefs.h"
#include <kiconloader.h>
#include <kglobal.h>
+#include <kglobalsettings.h>
#include <kcolorbutton.h>
#include <kmessagebox.h>
KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
const char* name,WFlags fl )
: KOFilterView_base(parent,name,fl)
{
mFilters = filterList;
connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
}
KOFilterView::~KOFilterView()
{
// no need to delete child widgets, Qt does it all for us
}
bool KOFilterView::filtersEnabled()
@@ -377,65 +378,81 @@ void KOCalEditView::addCal()
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
while ( kkf ) {
if ( kkf->mName == name ) {
KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
name = "";
tryagain = true;
break;
}
if ( kkf->mFileName == file ) {
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 );
QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
}
int KOCalEditView::addCalendar( QString name, QString file, bool ask )
{
QFileInfo fi ( file );
+ QString absFile = file;
+ bool isRelative = false;
+ if ( fi.isRelative() ) {
+ isRelative = true;
+ absFile = KGlobalSettings::calendarDir()+file;
+ fi.setFile( absFile );
+ } else {
+ QString cd = KGlobalSettings::calendarDir();
+ if ( file.left( cd.length() ) == cd ) {
+ isRelative = true;
+ file = fi.fileName ();
+ fi.setFile( absFile );
+ }
+ }
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 )
+ if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
return 0;
- QFile fileIn( file );
+ QFile fileIn( absFile );
if (!fileIn.open( IO_WriteOnly ) ) {
KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
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;
+ kkf->mFileName = absFile;
+ kkf->mSavedFileName = file;
+ kkf->isRelative = isRelative;
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()
{