konsolekalendar Library API Documentation

konsolekalendarvariables.cpp

00001 /***************************************************************************
00002         konsolekalendarvariables.cpp  -  description
00003            -------------------
00004     begin                : Sun Jan 6 2002
00005     copyright            : (C) 2002-2003 by Tuukka Pasanen
00006     copyright            : (C) 2003 by Allen Winter
00007     email                : illuusio@mailcity.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #include <klocale.h>
00020 #include <kdebug.h>
00021 #include <kglobal.h>
00022 #include <kconfig.h>
00023 #include <kstandarddirs.h>
00024 #include <kglobalsettings.h>
00025 
00026 
00027 #include <qdatetime.h>
00028 #include <qstring.h>
00029 #include <qstringlist.h>
00030 
00031 #include <stdlib.h>
00032 #include <iostream>
00033 #include <stdio.h>
00034 
00035 
00036 
00037 
00038 #include "konsolekalendarvariables.h"
00039 
00040 using namespace KCal;
00041 using namespace std;
00042 
00043 KonsoleKalendarVariables::KonsoleKalendarVariables()
00044 {
00045   m_bIsUID = false;
00046   m_bIsStartDateTime = false;
00047   m_bIsEndDateTime = false;
00048   m_bNext = false;
00049   m_bVerbose = false;
00050   m_bDryRun = false;
00051   m_bDescription = false;
00052   m_description = "Default description";
00053   m_bSummary = false;
00054   m_summary = "Default summary";
00055   m_bFloating = true;
00056   m_export_type = TEXT_KONSOLEKALENDAR;
00057   m_bIsExportFile = false;
00058   m_bIsDefault = false;
00059   m_bIsCalendarResources = false;
00060 }
00061 
00062 KonsoleKalendarVariables::~KonsoleKalendarVariables()
00063 {
00064  // delete m_resource;
00065 }
00066 
00067 void KonsoleKalendarVariables::setUID(QString uid)
00068 {
00069   m_bIsUID = true;
00070   m_UID = uid;
00071 }
00072 
00073 QString KonsoleKalendarVariables::getUID()
00074 {
00075   return m_UID;
00076 }
00077   
00078 bool KonsoleKalendarVariables::isUID()
00079 {
00080   return m_bIsUID;
00081 }
00082 
00083 void KonsoleKalendarVariables::setStartDateTime(QDateTime start)
00084 {
00085   m_bIsStartDateTime = true;
00086   m_startDateTime = start;
00087 }
00088 
00089 QDateTime KonsoleKalendarVariables::getStartDateTime()
00090 {
00091   return m_startDateTime;
00092 }
00093   
00094 bool KonsoleKalendarVariables::isStartDateTime()
00095 {
00096   return m_bIsStartDateTime;
00097 }
00098 
00099 void KonsoleKalendarVariables::setEndDateTime(QDateTime end)
00100 {
00101   m_bIsEndDateTime = true;
00102   m_endDateTime = end;
00103 }
00104 
00105 QDateTime KonsoleKalendarVariables::getEndDateTime()
00106 {
00107   return m_endDateTime;
00108 }
00109 
00110 bool KonsoleKalendarVariables::isEndDateTime()
00111 {
00112   return m_bIsEndDateTime;
00113 }
00114 
00115 void KonsoleKalendarVariables::setNext(bool next)
00116 {
00117   m_bNext = next;
00118 }
00119 
00120 bool KonsoleKalendarVariables::isNext()
00121 {
00122   return m_bNext;
00123 }
00124 
00125 void KonsoleKalendarVariables::setVerbose(bool verbose)
00126 {
00127   m_bVerbose = verbose;
00128 }
00129 
00130 bool KonsoleKalendarVariables::isVerbose()
00131 {
00132   return m_bVerbose;
00133 }
00134 
00135 void KonsoleKalendarVariables::setDryRun(bool dryrun)
00136 {
00137   m_bDryRun = dryrun;
00138 }
00139 
00140 bool KonsoleKalendarVariables::isDryRun()
00141 {
00142   return m_bDryRun;
00143 }
00144 
00145 void KonsoleKalendarVariables::setCalendarFile(QString calendar)
00146 {
00147   m_calendar = calendar;
00148 }
00149 
00150 QString KonsoleKalendarVariables::getCalendarFile()
00151 {
00152   return m_calendar;
00153 }
00154 
00155 void KonsoleKalendarVariables::setImportFile(QString calendar)
00156 {
00157   m_import = calendar;
00158 }
00159 
00160 QString KonsoleKalendarVariables::getImportFile()
00161 {
00162   return m_import;
00163 }
00164 
00165 
00166 void KonsoleKalendarVariables::setCalendar( CalendarLocal *calendar )
00167 {
00168   m_calendarLocal = calendar;
00169 }
00170 
00171 CalendarLocal *KonsoleKalendarVariables::getCalendar()
00172 {
00173   return m_calendarLocal;
00174 }
00175 
00176 
00177 /*void KonsoleKalendarVariables::setExportFile( QString export_file )
00178 {
00179   m_export_file = export_file;
00180 }
00181 
00182 QString KonsoleKalendarVariables::getExportFile()
00183 {
00184   return m_export_file;
00185 }*/
00186 
00187 
00188 void KonsoleKalendarVariables::setExportType( int export_type )
00189 {
00190   m_export_type = export_type;
00191 }
00192 
00193 int KonsoleKalendarVariables::getExportType()
00194 {
00195   return m_export_type;
00196 }
00197 
00198 void KonsoleKalendarVariables::setExportFile( QString export_file )
00199 {
00200   m_exportFile = export_file;
00201   m_bIsExportFile = true;
00202 }
00203 
00204 bool KonsoleKalendarVariables::isExportFile()
00205 {
00206   return m_bIsExportFile;
00207 }
00208 
00209 QString KonsoleKalendarVariables::getExportFile()
00210 {
00211   return m_exportFile;
00212 }
00213 
00214 bool KonsoleKalendarVariables::isAll()
00215 {
00216   return m_bAll;
00217 }
00218 
00219 void KonsoleKalendarVariables::setAll( bool all)
00220 {
00221   m_bAll = all;
00222 }
00223 
00224 bool KonsoleKalendarVariables::getAll()
00225 {
00226   return m_bAll;
00227 }
00228 
00229 void KonsoleKalendarVariables::setDefault( bool def )
00230 {
00231  m_bIsDefault = def;    
00232 }
00233 
00234 
00235 bool KonsoleKalendarVariables::isDefault()
00236 {
00237   return m_bIsDefault;
00238 }
00239 
00240 void KonsoleKalendarVariables::setDescription(QString description)
00241 {
00242   m_bDescription = true;
00243   m_description = description;
00244 }
00245 
00246 QString KonsoleKalendarVariables::getDescription()
00247 {
00248   return m_description;
00249 }
00250 
00251 bool KonsoleKalendarVariables::isDescription()
00252 {
00253   return m_bDescription;
00254 }
00255 
00256 void KonsoleKalendarVariables::setSummary(QString summary)
00257 {
00258   m_bSummary = true;
00259   m_summary = summary;
00260 }
00261 
00262 QString KonsoleKalendarVariables::getSummary()
00263 {
00264   return m_summary;
00265 }
00266 
00267 bool KonsoleKalendarVariables::isSummary()
00268 {
00269   return m_bSummary;
00270 }
00271 
00272 void KonsoleKalendarVariables::setFloating(bool floating)
00273 {
00274   m_bFloating = floating;
00275 }
00276 
00277 bool KonsoleKalendarVariables::getFloating()
00278 {
00279   return m_bFloating;
00280 }
00281 
00282 void KonsoleKalendarVariables::setDaysCount( int count ){
00283   m_daysCount = count;
00284   m_bDaysCount = true;
00285 }
00286 
00287 int KonsoleKalendarVariables::getDaysCount(){
00288   return m_daysCount;
00289 }
00290 
00291 bool KonsoleKalendarVariables::isDaysCount(){
00292   return m_bDaysCount;
00293 }
00294 
00295 
00296 
00297 bool KonsoleKalendarVariables::addCalendarResources( ResourceCalendar *resource )
00298 {
00299  if ( m_resource ) {
00300    // In current state we support only one calendar
00301    // that's a fact and we have to live with that!
00302    kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Add to calendar resource!" << endl;
00303 
00304    CalendarResourceManager::ActiveIterator it;
00305    CalendarResourceManager *manager = getCalendarResourceManager();
00306    QString fileName = NULL;
00307      
00308    for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
00309        kdDebug() << "Resource name: " + (*it)->resourceName() << endl;
00310        
00311        if( !strcmp( (*it)->resourceName().local8Bit(), getCalendarFile().local8Bit() ) ){   
00312     kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | We allready have this resource" << endl;          
00313         return true;
00314        }
00315 
00316    }
00317      
00318    manager->add( resource );
00319  
00320    if( isDefault() ) {
00321     kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Make it default" << endl;     
00322     manager->setStandardResource( resource );
00323    }
00324  
00325  } else {
00326   kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Cannot add to calendar resources (Not created!)" << endl;
00327   return false;
00328  }
00329 
00330 return true;
00331 }
00332 
00333 bool KonsoleKalendarVariables::isCalendarResources()
00334 {
00335   return m_bIsCalendarResources;    
00336 }
00337 
00338 void KonsoleKalendarVariables::setCalendarResources( CalendarResources *resource )
00339 {
00340   m_resource = resource;
00341   setCalendar( ((CalendarLocal *)m_resource) );
00342   m_bIsCalendarResources = true;
00343 }
00344 
00345 CalendarResources *KonsoleKalendarVariables::getCalendarResources()
00346 {
00347  return m_resource; 
00348 }
00349 
00350 
00351 CalendarResourceManager *KonsoleKalendarVariables::getCalendarResourceManager( )
00352 {
00353   return m_resource->resourceManager();
00354 }
00355 
00356 bool KonsoleKalendarVariables::loadCalendarResources( KConfig *config )
00357 {
00358 
00359     if ( m_resource ) {
00360 
00361           kdDebug() << "konsoleKalendarvariables.cpp::loadCalendarResources() | loading resources" << endl;
00362           
00363           CalendarResourceManager *manager = m_resource->resourceManager();
00364           
00365               if ( manager->isEmpty() == true ) {
00366                   
00367                         config->setGroup("General");
00368                         QString fileName = config->readPathEntry( "Active Calendar" );
00369                   
00370                         QString resourceName;
00371                         if ( fileName.isEmpty() ) {
00372                                 fileName = locateLocal( "appdata", "std.ics" );
00373                                 resourceName = i18n("Default KOrganizer resource");
00374                     } else {
00375                                 resourceName = i18n("Active Calendar");
00376                     }
00377                   
00378                         kdDebug() << "konsoleKalendarvariables.cpp::loadCalendarResources() | Using as default resource: '" << fileName << "'" << endl;
00379                   
00380                   ResourceCalendar *defaultResource = new ResourceLocal( fileName );
00381                   //defaultResource->setTimeZoneId);
00382                   defaultResource->setResourceName( resourceName );
00383                   
00384                   manager->add( defaultResource );
00385                   manager->setStandardResource( defaultResource );
00386               }
00387       }
00388     
00389       return true;
00390 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Mar 6 17:18:34 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003