summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/kolistview.cpp68
-rw-r--r--korganizer/kolistview.h5
-rw-r--r--korganizer/koprefs.cpp4
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp10
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/incidencebase.cpp2
10 files changed, 87 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 377a66f..2012e92 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1788,104 +1788,97 @@ bool CalendarView::importQtopia( const QString &categories,
#if 0
mGlobalSyncMode = SYNC_MODE_QTOPIA;
mCurrentSyncDevice = "qtopia-XML";
if ( mSyncManager->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
bool syncOK = false;
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
bool loadOk = true;
if ( !categories.isEmpty() )
loadOk = qtopiaFormat.load( calendar, categories );
if ( loadOk && !datebook.isEmpty() )
loadOk = qtopiaFormat.load( calendar, datebook );
if ( loadOk && !todolist.isEmpty() )
loadOk = qtopiaFormat.load( calendar, todolist );
if ( loadOk ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
if ( mSyncManager->mWriteBackFile )
{
// write back XML file
}
setModified( true );
}
} else {
QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
question, i18n("Ok")) ;
}
delete calendar;
updateView();
return syncOK;
#endif
}
void CalendarView::setSyncEventsReadOnly()
{
- Event * ev;
- QPtrList<Event> eL = mCalendar->rawEvents();
- ev = eL.first();
- while ( ev ) {
- if ( ev->uid().left(15) == QString("last-syncEvent-") )
- ev->setReadOnly( true );
- ev = eL.next();
- }
+ mCalendar->setSyncEventsReadOnly();
}
bool CalendarView::loadCalendars()
{
QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
KopiCalendarFile * cal = calendars.first();
mCalendar->setDefaultCalendar( 1 );
openCalendar( MainWindow::defaultFileName(), false );
cal = calendars.next();
while ( cal ) {
addCalendar( cal );
cal = calendars.next();
}
restoreCalendarSettings();
return true;
}
bool CalendarView::restoreCalendarSettings()
{
QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
KopiCalendarFile * cal = calendars.first();
while ( cal ) {
mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
if ( cal->isStandard )
mCalendar->setDefaultCalendar( cal->mCalNumber );
cal = calendars.next();
}
setSyncEventsReadOnly();
mCalendar->reInitAlarmSettings();
updateUnmanagedViews();
updateView();
return true;
}
void CalendarView::addCalendarId( int id )
{
KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
addCalendar( cal );
}
bool CalendarView::addCalendar( KopiCalendarFile * cal )
{
cal->mErrorOnLoad = false;
if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
cal->mLoadDt = QDateTime::currentDateTime();
return true;
}
qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b2b136a..93ff55e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -617,97 +617,97 @@ void KOAgendaView::resizeEvent( QResizeEvent* e )
updateConfig();
//qDebug("KOAgendaView::Updating now possible ");
} else
createDayLabels();
//qDebug("resizeEvent end ");
}
void KOAgendaView::slotDaylabelClicked( int num )
{
QDate firstDate = mSelectedDates.first();
if ( num == -1 )
emit showDateView( 6, firstDate );
else if (num >= 0 ) {
if ( mSelectedDates.count() == 1)
emit showDateView( 9, firstDate.addDays( num ) );
else
emit showDateView( 3, firstDate.addDays( num ) );
}
else
showDateView( 10, firstDate.addDays(1) );
}
KOAgendaButton* KOAgendaView::getNewDaylabel()
{
KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
mDayLabelsList.append( dayLabel );
mLayoutDayLabels->addWidget(dayLabel);
return dayLabel ;
}
void KOAgendaView::createDayLabels()
{
if ( mBlockUpdating || globalFlagBlockLabel == 1) {
// qDebug(" KOAgendaView::createDayLabels() blocked ");
return;
}
int newHight;
if ( !mSelectedDates.count())
return;
// ### Before deleting and recreating we could check if mSelectedDates changed...
// It would remove some flickering and gain speed (since this is called by
// each updateView() call)
-
+
int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
if ( maxWid < 20 )
maxWid = 20;
QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
QFontMetrics fm ( dlf );
int selCount = mSelectedDates.count();
int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
QString dayTest = "Mon 20";
//QString dayTest = "Mon 20";
int wid = fm.width( dayTest );
//maxWid -= ( selCount * 3 ); //working for QLabels
if ( QApplication::desktop()->width() <= 320 )
maxWid -= ( selCount * 3 ); //working for QPushButton
else
maxWid -= ( selCount * 3 ); //working for QPushButton
if ( maxWid < 0 )
maxWid = 20;
int needWid = wid * selCount;
//qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
//if ( needWid > maxWid )
// qDebug("DAYLABELS TOOOOOOO BIG ");
while ( needWid > maxWid ) {
dayTest = dayTest.left( dayTest.length() - 1 );
wid = fm.width( dayTest );
needWid = wid * selCount;
}
int maxLen = dayTest.length();
int fontPoint = dlf.pointSize();
if ( maxLen < 2 ) {
int fontPoint = dlf.pointSize();
while ( fontPoint > 4 ) {
--fontPoint;
dlf.setPointSize( fontPoint );
QFontMetrics f( dlf );
wid = f.width( "30" );
needWid = wid * selCount;
if ( needWid < maxWid )
break;
}
maxLen = 2;
}
//qDebug("Max len %d ", dayTest.length() );
QFontMetrics tempF( dlf );
newHight = tempF.height();
mDayLabels->setFont( dlf );
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 1f3b4c6..c705c73 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -22,400 +22,456 @@
without including the source code for Qt in the source distribution.
*/
#include <qlistview.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qfileinfo.h>
#include <qmessagebox.h>
#include <qdialog.h>
#include <qtextstream.h>
#include <qdir.h>
#include <qwhatsthis.h>
#include <qregexp.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
#include <klocale.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kglobal.h>
#include <libkdepim/kpimglobalprefs.h>
#include <libkcal/calendar.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
#include <libkcal/vcalformat.h>
#include <libkcal/recurrence.h>
#include <libkcal/filestorage.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkcal/kincidenceformatter.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
#endif
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#include "koglobals.h"
#include "koprefs.h"
#include "kfiledialog.h"
#include "kolistview.h"
#include "koeventviewer.h"
-
-
-
class KOListViewWhatsThis :public QWhatsThis
{
public:
KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
protected:
virtual QString text( const QPoint& p)
{
return _view->getWhatsThisText(p) ;
}
private:
QWidget* _wid;
KOListView * _view;
};
ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
{
mItem = item;
mDate = date;
}
ListItemVisitor::~ListItemVisitor()
{
}
bool ListItemVisitor::visit(Event *e)
{
bool ok = false;
QString start, end;
QDate ds, de;
if ( e->doesRecur() ) {
ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
if ( ok ) {
int days = e->dtStart().date().daysTo(e->dtEnd().date() );
start = KGlobal::locale()->formatDate(ds,true);
de = ds.addDays( days);
end = KGlobal::locale()->formatDate(de,true);
}
}
if ( ! ok ) {
start =e->dtStartDateStr();
end = e->dtEndDateStr();
ds = e->dtStart().date();
de = e->dtEnd().date();
}
mItem->setText(0,e->summary());
mItem->setText(1,start);
if ( e->doesFloat() )
mItem->setText(2,"---");
else
mItem->setText(2,e->dtStartTimeStr());
mItem->setText(3,end);
if ( e->doesFloat() )
mItem->setText(4,"---");
else
mItem->setText(4,e->dtEndTimeStr());
if ( e->isAlarmEnabled() ) {
mItem->setText(5,e->alarms().first()->offsetText() );
} else {
mItem->setText(5, i18n("No"));
}
mItem->setText(6, e->recurrence()->recurrenceText());
if( ! e->doesRecur() )
mItem->setSortKey( 6, "-" );
mItem->setText(7,"---");
mItem->setText(8,"---");
mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
mItem->setText(10,e->categoriesStr());
+ mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
QString key;
QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
mItem->setSortKey(1,key);
t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
mItem->setSortKey(3,key);
return true;
}
bool ListItemVisitor::visit(Todo *t)
{
mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
if (t->hasStartDate()) {
mItem->setText(1,t->dtStartDateStr());
if (t->doesFloat()) {
mItem->setText(2,"---");
} else {
mItem->setText(2,t->dtStartTimeStr());
}
} else {
mItem->setText(1,"---");
mItem->setText(2,"---");
}
mItem->setText(3,"---");
mItem->setText(4,"---");
if ( t->isAlarmEnabled() ) {
mItem->setText(5,t->alarms().first()->offsetText() );
} else {
mItem->setText(5, i18n("No"));
}
mItem->setText(6, t->recurrence()->recurrenceText());
if( ! t->doesRecur() )
mItem->setSortKey( 6, "-" );
if (t->hasDueDate()) {
mItem->setText(7,t->dtDueDateStr());
if (t->doesFloat()) {
mItem->setText(8,"---");
} else {
mItem->setText(8,t->dtDueTimeStr());
}
} else {
mItem->setText(7,"---");
mItem->setText(8,"---");
}
mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
mItem->setText(10,t->categoriesStr());
+ mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
QString key;
QDate d;
if (t->hasDueDate()) {
d = t->dtDue().date();
QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
mItem->setSortKey(7,key);
}
if ( t->hasStartDate() ) {
d = t->dtStart().date();
QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
mItem->setSortKey(1,key);
}
return true;
}
bool ListItemVisitor::visit(Journal * j)
{
QString des = j->description().left(30);
des = des.simplifyWhiteSpace ();
des.replace (QRegExp ("\\n"),"" );
des.replace (QRegExp ("\\r"),"" );
mItem->setText(0,i18n("Journal: ")+des.left(25));
mItem->setText(1,j->dtStartDateStr());
mItem->setText(2,"---");
mItem->setText(3,"---");
mItem->setText(4,"---");
mItem->setText(5,"---");
mItem->setText(6,"---");
mItem->setText(7,j->dtStartDateStr());
mItem->setText(8,"---");
mItem->setText(9,"---");
mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
+ mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
QString key;
QDate d = j->dtStart().date();
key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
mItem->setSortKey(1,key);
mItem->setSortKey(7,key);
return true;
}
KOListView::KOListView(Calendar *calendar, QWidget *parent,
const char *name)
: KOEventView(calendar, parent, name)
{
mActiveItem = 0;
mListView = new KOListViewListView(this);
mListView->addColumn(i18n("Summary"));
mListView->addColumn(i18n("Start Date"));
mListView->addColumn(i18n("Start Time"));
mListView->addColumn(i18n("End Date"));
mListView->addColumn(i18n("End Time"));
mListView->addColumn(i18n("Alarm")); // alarm set?
mListView->addColumn(i18n("Recurs")); // recurs?
mListView->addColumn(i18n("Due Date"));
mListView->addColumn(i18n("Due Time"));
mListView->addColumn(i18n("Cancelled"));
mListView->addColumn(i18n("Categories"));
+ mListView->addColumn(i18n("Calendar"));
mListView->setColumnAlignment(0,AlignLeft);
mListView->setColumnAlignment(1,AlignLeft);
mListView->setColumnAlignment(2,AlignHCenter);
mListView->setColumnAlignment(3,AlignLeft);
mListView->setColumnAlignment(4,AlignHCenter);
mListView->setColumnAlignment(5,AlignLeft);
mListView->setColumnAlignment(6,AlignLeft);
mListView->setColumnAlignment(7,AlignLeft);
mListView->setColumnAlignment(8,AlignLeft);
mListView->setColumnAlignment(9,AlignLeft);
mListView->setColumnAlignment(10,AlignLeft);
- mListView->setColumnWidthMode(10, QListView::Manual);
+ mListView->setColumnAlignment(11,AlignLeft);
mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
int iii = 0;
- for ( iii = 0; iii< 10 ; ++iii )
+ for ( iii = 0; iii< 12 ; ++iii )
mListView->setColumnWidthMode( iii, QListView::Manual );
QBoxLayout *layoutTop = new QVBoxLayout(this);
layoutTop->addWidget(mListView);
mListView->setFont ( KOPrefs::instance()->mListViewFont );
mPopupMenu = eventPopup();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Select all"),this,
SLOT(allSelection()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Deselect all"),this,
SLOT(clearSelection()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Delete all selected"),this,
SLOT(deleteAll()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Hide all selected"),this,
SLOT(hideAll()),true);
mPopupMenu->insertSeparator();
#ifdef DESKTOP_VERSION
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Print complete list"),this,
SLOT(printList()),true);
mPopupMenu->insertSeparator();
#endif
+ mCalPopup = new QPopupMenu ( this );
+ mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
+
+ QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
+ SLOT( populateCalPopup() ));
+ QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
+ SLOT( setCalendar( int ) ));
QPopupMenu * exportPO = new QPopupMenu ( this );
mPopupMenu->insertItem( i18n("Export selected"), exportPO );
exportPO->insertItem( i18n("As iCal (ics) file..."),this,
SLOT(saveToFile()));
exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
SLOT(saveToFileVCS()));
exportPO->insertItem( i18n("Journal/Details..."),this,
SLOT(saveDescriptionToFile()));
// mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Add Categ. to selected..."),this,
SLOT(addCat()),true);
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Set Categ. for selected..."),this,
SLOT(setCat()),true);
//mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Set alarm for selected..."),this,
SLOT(setAlarm()),true);
+
#ifndef DESKTOP_VERSION
mPopupMenu->insertSeparator();
mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("Beam selected via IR"),this,
SLOT(beamSelected()),true);
#endif
/*
mPopupMenu = new QPopupMenu;
mPopupMenu->insertItem(i18n("Edit Event"), this,
SLOT (editEvent()));
mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
SLOT (deleteEvent()));
mPopupMenu->insertSeparator();
mPopupMenu->insertItem(i18n("Show Dates"), this,
SLOT(showDates()));
mPopupMenu->insertItem(i18n("Hide Dates"), this,
SLOT(hideDates()));
*/
QObject::connect(mListView,SIGNAL( newEvent()),
this,SIGNAL(signalNewEvent()));
QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
this,SLOT(defaultItemAction(QListViewItem *)));
QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
const QPoint &, int )),
this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
SLOT(processSelectionChange(QListViewItem *)));
QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
SIGNAL(showIncidenceSignal(Incidence *)) );
readSettings(KOGlobals::config(),"KOListView Layout");
}
KOListView::~KOListView()
{
delete mPopupMenu;
#if QT_VERSION >= 0x030000
#else
delete mKOListViewWhatsThis;
#endif
}
QString KOListView::getWhatsThisText(QPoint p)
{
KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
if ( item )
return KIncidenceFormatter::instance()->getFormattedText( item->data(),
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
return i18n("That is the list view" );
}
+void KOListView::setCalendar( int c )
+{
+ int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
+ i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
+ i18n("Continue"), i18n("Cancel"), 0,
+ 0, 1 );
+ if ( result != 0 ) {
+ return;
+ }
+
+ QPtrList<Incidence> delSel = getSelectedIncidences() ;
+ int icount = delSel.count();
+ if ( icount ) {
+ Incidence *incidence = delSel.first();
+ while ( incidence ) {
+ incidence->setCalID( c );
+ KOListViewItem * item = getItemForEvent( incidence );
+ if ( item ) {
+ ListItemVisitor v(item, mStartDate );
+ incidence->accept(v);
+ }
+ incidence = delSel.next();
+ }
+ }
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ while ( cal ) {
+ mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
+ mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
+ mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
+ if ( cal->isStandard )
+ mCalendar->setDefaultCalendar( cal->mCalNumber );
+ cal = calendars.next();
+ }
+ mCalendar->setSyncEventsReadOnly();
+ mCalendar->reInitAlarmSettings();
+
+}
+void KOListView::populateCalPopup()
+{
+ mCalPopup->clear();
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+}
void KOListView::updateList()
{
// qDebug(" KOListView::updateList() ");
}
void KOListView::clearList()
{
clear ();
}
void KOListView::addCat( )
{
setCategories( false );
}
void KOListView::setCat()
{
setCategories( true );
}
void KOListView::setAlarm()
{
KOAlarmPrefs kap( this);
if ( !kap.exec() )
return;
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
Incidence* inc = ((KOListViewItem *) qitem)->data();
if ( inc->typeID() != journalID ) {
if ( inc->typeID() == todoID ) {
if ( ((Todo*)inc)->hasDueDate() )
sel.append(((KOListViewItem *)qitem));
} else
sel.append(((KOListViewItem *)qitem));
}
}
qitem = qitem->nextSibling();
}
int count = 0;
KOListViewItem * item, *temp;
item = sel.first();
Incidence* inc;
while ( item ) {
inc = item->data();
++count;
if (kap.mAlarmButton->isChecked()) {
@@ -994,97 +1050,97 @@ void KOListView::addIncidence(Incidence *incidence)
if (incidence->accept(v)) {
return;
}
else delete item;
}
void KOListView::showEvents(QPtrList<Event> eventList)
{
clear();
addEvents(eventList);
// After new creation of list view no events are selected.
emit incidenceSelected( 0 );
}
int KOListView::count()
{
return mListView->childCount();
}
void KOListView::changeEventDisplay(Event *event, int action)
{
KOListViewItem *item;
switch(action) {
case KOGlobals::EVENTADDED:
addIncidence( event );
break;
case KOGlobals::EVENTEDITED:
item = getItemForEvent(event);
if (item) {
mUidDict.remove( event->uid() );
delete item;
addIncidence( event );
}
break;
case KOGlobals::EVENTDELETED:
item = getItemForEvent(event);
if (item) {
mUidDict.remove( event->uid() );
delete item;
}
break;
default:
;
}
}
-KOListViewItem *KOListView::getItemForEvent(Event *event)
+KOListViewItem *KOListView::getItemForEvent(Incidence *event)
{
KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
while (item) {
if (item->data() == event) return item;
item = (KOListViewItem *)item->nextSibling();
}
return 0;
}
void KOListView::defaultItemAction(QListViewItem *i)
{
KOListViewItem *item = static_cast<KOListViewItem *>( i );
if ( item ) defaultAction( item->data() );
}
void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
{
mActiveItem = (KOListViewItem *)item;
if (mActiveItem) {
Incidence *incidence = mActiveItem->data();
mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
mPopupMenu->showIncidencePopup(incidence);
/*
if ( incidence && incidence->type() == "Event" ) {
Event *event = static_cast<Event *>( incidence );
mPopupMenu->showEventPopup(event);
}
*/
}
}
void KOListView::readSettings(KConfig *config, QString setting)
{
// qDebug("KOListView::readSettings ");
mListView->restoreLayout(config,setting);
}
void KOListView::writeSettings(KConfig *config, QString setting)
{
// qDebug("KOListView::writeSettings ");
mListView->saveLayout(config, setting);
}
void KOListView::processSelectionChange(QListViewItem *)
{
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 9da5497..d384af0 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -250,69 +250,72 @@ class KOListView : public KOEventView
void showDates(bool show);
Incidence* currentItem();
void addTodos(QPtrList<Todo> eventList);
void addJournals(QPtrList<Journal> eventList);
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
void readSettings(KConfig *config, QString setting = "KOListView Layout");
void writeSettings(KConfig *config, QString setting = "KOListView Layout");
void updateList();
void clearList();
void setStartDate(const QDate &start);
int count();
QString getWhatsThisText(QPoint p);
QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
signals:
void signalNewEvent();
void beamIncidenceList(QPtrList<Incidence>);
public slots:
void hideAll();
void printList();
void resetFocus();
virtual void updateView();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void clearSelection();
void allSelection();
void clear();
void beamDone( Ir *ir );
void showDates();
void hideDates();
void deleteAll();
void saveToFile();
void saveToFileVCS();
void saveDescriptionToFile();
void beamSelected();
void updateConfig();
void addCat();
void setCat();
void setAlarm();
void setCategories( bool removeOld );
void changeEventDisplay(Event *, int);
void defaultItemAction(QListViewItem *item);
void popupMenu(QListViewItem *item,const QPoint &,int);
+ void setCalendar( int c );
+ void populateCalPopup();
protected slots:
void processSelectionChange(QListViewItem *);
protected:
void writeToFile( bool iCal );
void addEvents(QPtrList<Event> eventList);
void addIncidence(Incidence *);
- KOListViewItem *getItemForEvent(Event *event);
+ KOListViewItem *getItemForEvent(Incidence *event);
private:
+ QPopupMenu* mCalPopup;
KOListViewWhatsThis *mKOListViewWhatsThis;
KOListViewListView *mListView;
KOEventPopupMenu *mPopupMenu;
KOListViewItem *mActiveItem;
QDict<Incidence> mUidDict;
QDate mStartDate;
void keyPressEvent ( QKeyEvent * ) ;
};
#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 65f0342..a4ea3d3 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -450,96 +450,100 @@ void KOPrefs::usrReadConfig()
//qDebug("Read cal #%d ", mNextAvailableCalendar );
QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
KopiCalendarFile *kkf = getNewCalendar();
kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
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" );
}
}
KPimPrefs::usrReadConfig();
}
KopiCalendarFile * KOPrefs::getCalendar( int num )
{
return mDefCalColors[num-1];
}
KopiCalendarFile * KOPrefs::getNewCalendar()
{
KopiCalendarFile * kkf = new KopiCalendarFile();
kkf->mCalNumber = mNextAvailableCalendar;
mDefCalColors.resize( mNextAvailableCalendar );
mDefCalColors[mNextAvailableCalendar-1] = kkf;
++mNextAvailableCalendar;
kkf->mDefaultColor = mEventColor;
kkf->mName = i18n("New Calendar");
mCalendars.append( kkf );
return kkf;
}
void KOPrefs::deleteCalendar( int num )
{
KopiCalendarFile * kkf = mCalendars.first();
while ( kkf ) {
if ( kkf->mCalNumber == num ) {
qDebug("KOPrefs::deleteCalendar %d ", num );
mCalendars.remove( kkf );
delete kkf;
return;
}
kkf = mCalendars.next();
}
}
+QString KOPrefs::calName( int calNum) const
+{
+ return (mDefCalColors[calNum-1])->mName;
+}
QColor KOPrefs::defaultColor( int calNum ) const
{
if ( calNum == 1 ) return mEventColor;
return (mDefCalColors[calNum-1])->mDefaultColor;
}
void KOPrefs::usrWriteConfig()
{
config()->setGroup("General");
config()->writeEntry("Custom Categories",mCustomCategories);
config()->setGroup("Personal Settings");
config()->writeEntry("user_name",mName);
config()->writeEntry("user_email",mEmail);
config()->setGroup("Category Colors");
QDictIterator<QColor> it(mCategoryColors);
while (it.current()) {
config()->writeEntry(it.currentKey(),*(it.current()));
++it;
}
KConfig fc (locateLocal("config","kopicalendarrc"));
fc.setGroup("CC");
fc.writeEntry("NumberCalendars",mCalendars.count());
int numCal = 1;
int writeCal = 0;
while ( numCal < mNextAvailableCalendar ) {
KopiCalendarFile * kkf = mCalendars.first();
while ( kkf ) {
//qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
if ( kkf->mCalNumber == numCal ) {
++writeCal;
//qDebug("Write calendar %d %d ", numCal , writeCal);
QString prefix = "Cal_" + QString::number( writeCal );
fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
fc.writeEntry( prefix+"_Name", kkf->mName);
fc.writeEntry( prefix+"_FileName", kkf->mFileName);
fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
}
kkf = mCalendars.next();
}
++numCal;
}
fc.sync();
KPimPrefs::usrWriteConfig();
}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 463fc33..5cc9bfa 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -54,96 +54,97 @@ class KopiCalendarFile : public QObject
isReadOnly = false;
mName = "Calendar";
mFileName = QDir::homeDirPath() + "/icalfile.ics";
mCalNumber = 0;
mDefaultColor = Qt::red;
mErrorOnLoad = false;
}
bool isStandard;
bool isEnabled;
bool isAlarmEnabled;
bool isReadOnly;
bool mErrorOnLoad;
QString mName;
QString mFileName;
int mCalNumber;
QColor mDefaultColor;
QDateTime mLoadDt;
};
class KOPrefs : public KPimPrefs
{
public:
enum { FormatVCalendar, FormatICalendar };
enum { MailClientKMail, MailClientSendmail };
enum { IMIPDummy, IMIPKMail };
enum { IMIPOutbox, IMIPdirectsend };
enum { neverAuto, addressbookAuto, selectedAuto };
enum { standardDestination, askDestination };
virtual ~KOPrefs();
/** Get instance of KOPrefs. It is made sure that there is only one
instance. */
static KOPrefs *instance();
/** Set preferences to default values */
void usrSetDefaults();
/** Read preferences from config file */
void usrReadConfig();
/** Write preferences to config file */
void usrWriteConfig();
void setCategoryDefaults();
void setAllDefaults();
KopiCalendarFile * getNewCalendar();
KopiCalendarFile * getCalendar( int );
void deleteCalendar( int );
QColor defaultColor( int ) const;
+ QString calName( int ) const;
protected:
void setTimeZoneIdDefault();
/** Fill empty mail fields with default values. */
void fillMailDefaults();
private:
/** Constructor disabled for public. Use instance() to create a KOPrefs
object. */
KOPrefs();
static KOPrefs *mInstance;
QStringList getDefaultList();
QStringList getLocationDefaultList();
public:
// preferences data
KConfig* getConfig();
void setFullName(const QString &);
QString fullName();
void setEmail(const QString &);
QString email();
QString mAdditional;
bool mEmailControlCenter;
bool mBcc;
bool mAutoSave;
int mAutoSaveInterval;
bool mConfirm;
bool mEnableGroupScheduling;
bool mEnableProjectView;
int mDefaultFormat;
int mMailClient;
int mStartTime;
int mDefaultDuration;
int mAlarmTime;
int mWorkingHoursStart;
int mWorkingHoursEnd;
bool mExcludeHolidays;
bool mExcludeSaturdays;
bool mMarcusBainsShowSeconds;
QFont mTimeBarFont;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2243e28..3b7b183 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -31,96 +31,97 @@
#include "customproperties.h"
#include "event.h"
#include "todo.h"
#include "journal.h"
#include "calfilter.h"
//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
class KConfig;
namespace KCal {
/**
This is the main "calendar" object class for KOrganizer. It holds
information like all appointments/events, user information, etc. etc.
one calendar is associated with each CalendarView (@see calendarview.h).
This is an abstract base class defining the interface to a calendar. It is
implemented by subclasses like @see CalendarLocal, which use different
methods to store and access the data.
Ownership of events etc. is handled by the following policy: As soon as an
event (or any other subclass of IncidenceBase) object is added to the
Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
care of deleting it. All Events returned by the query functions are returned
as pointers, that means all changes to the returned events are immediately
visible in the Calendar. You shouldn't delete any Event object you get from
Calendar.
*/
class Calendar : public QObject, public CustomProperties,
public IncidenceBase::Observer
{
Q_OBJECT
public:
Calendar();
Calendar(const QString &timeZoneId);
virtual ~Calendar();
Incidence * undoIncidence() { return mUndoIncidence; };
bool undoDeleteIncidence();
void deleteIncidence(Incidence *in);
void resetTempSyncStat();
void resetPilotStat(int id);
/**
Clears out the current calendar, freeing all used memory etc.
*/
virtual void close() = 0;
virtual void addCalendar( Calendar* ) = 0;
virtual bool addCalendarFile( QString name, int id ) = 0;
+ virtual void setSyncEventsReadOnly() = 0;
/**
Sync changes in memory to persistant storage.
*/
virtual void save() = 0;
virtual QPtrList<Event> getExternLastSyncEvents() = 0;
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool isSaving() { return false; }
/**
Return the owner of the calendar's full name.
*/
const QString &getOwner() const;
/**
Set the owner of the calendar. Should be owner's full name.
*/
void setOwner( const QString &os );
/**
Return the email address of the calendar owner.
*/
const QString &getEmail();
/**
Set the email address of the calendar owner.
*/
void setEmail( const QString & );
/**
Set time zone from a timezone string (e.g. -2:00)
*/
void setTimeZone( const QString &tz );
/**
Set time zone from a minutes value (e.g. -60)
*/
void setTimeZone( int tz );
/**
Return time zone as offest in minutes.
*/
int getTimeZone() const;
/**
Compute an ISO 8601 format string from the time zone.
*/
QString getTimeZoneStr() const;
/**
Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
values).
*/
void setTimeZoneId( const QString & );
/**
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 336c3e8..8c4dde1 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -33,96 +33,106 @@
#include "vcalformat.h"
#include "icalformat.h"
#include "exceptions.h"
#include "incidence.h"
#include "journal.h"
#include "filestorage.h"
#include "calfilter.h"
#include "calendarlocal.h"
// #ifndef DESKTOP_VERSION
// #include <qtopia/alarmserver.h>
// #endif
using namespace KCal;
CalendarLocal::CalendarLocal()
: Calendar()
{
init();
}
CalendarLocal::CalendarLocal(const QString &timeZoneId)
: Calendar(timeZoneId)
{
init();
}
void CalendarLocal::init()
{
mNextAlarmIncidence = 0;
}
CalendarLocal::~CalendarLocal()
{
if ( mDeleteIncidencesOnClose )
close();
}
bool CalendarLocal::addCalendarFile( QString name, int id )
{
CalendarLocal calendar( timeZoneId() );
calendar.setDefaultCalendar( id );
if ( calendar.load( name ) ) {
addCalendar( &calendar );
return true;
}
return false;
}
+void CalendarLocal::setSyncEventsReadOnly()
+{
+ Event * ev;
+ ev = mEventList.first();
+ while ( ev ) {
+ if ( ev->uid().left(15) == QString("last-syncEvent-") )
+ ev->setReadOnly( true );
+ ev = mEventList.next();
+ }
+}
void CalendarLocal::addCalendar( Calendar* cal )
{
cal->setDontDeleteIncidencesOnClose();
{
QPtrList<Event> EventList = cal->rawEvents();
Event * ev = EventList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mEventList.append( ev );
ev = EventList.next();
}
}
{
QPtrList<Todo> TodoList = cal->rawTodos();
Todo * ev = TodoList.first();
while ( ev ) {
QString rel = ev->relatedToUid();
if ( !rel.isEmpty() ){
ev->setRelatedTo ( 0 );
ev->setRelatedToUid( rel );
}
ev = TodoList.next();
}
//TodoList = cal->rawTodos();
ev = TodoList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mTodoList.append( ev );
setupRelations( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
setModified( true );
}
bool CalendarLocal::load( const QString &fileName )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 5bbe55f..0286b48 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,95 +1,96 @@
/*
This file is part of libkcal.
Copyright (c) 1998 Preston Brown
Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KCAL_CALENDARLOCAL_H
#define KCAL_CALENDARLOCAL_H
#include "calendar.h"
namespace KCal {
class CalFormat;
/**
This class provides a calendar stored as a local file.
*/
class CalendarLocal : public Calendar
{
public:
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal();
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal( const QString &timeZoneId );
~CalendarLocal();
void addCalendar( Calendar* );
bool addCalendarFile( QString name, int id );
+ void setSyncEventsReadOnly();
/**
Loads a calendar on disk in vCalendar or iCalendar format into the current
calendar. Any information already present is lost.
@return true, if successfull, false on error.
@param fileName the name of the calendar on disk.
*/
bool load( const QString &fileName );
/**
Writes out the calendar to disk in the specified \a format.
CalendarLocal takes ownership of the CalFormat object.
@return true, if successfull, false on error.
@param fileName the name of the file
*/
bool save( const QString &fileName, CalFormat *format = 0 );
/**
Clears out the current calendar, freeing all used memory etc. etc.
*/
void close();
void save() {}
/**
Add Event to calendar.
*/
void removeSyncInfo( QString syncProfile);
bool addAnniversaryNoDup( Event *event );
bool addEventNoDup( Event *event );
bool addEvent( Event *event );
/**
Deletes an event from this calendar.
*/
void deleteEvent( Event *event );
/**
Retrieves an event on the basis of the unique string ID.
*/
Event *event( const QString &uid );
/**
Return unfiltered list of all events in calendar.
*/
QPtrList<Event> rawEvents();
QPtrList<Event> getExternLastSyncEvents();
/**
Add a todo to the todolist.
*/
bool addTodo( Todo *todo );
bool addTodoNoDup( Todo *todo );
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 2ddbb01..96039df 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -96,96 +96,98 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
if ( !( (*a1) == (*a2)) )
{
//qDebug("Attendee not equal ");
return false;
}
a1 = i1.attendees().next();
a2 = i2.attendees().next();
}
}
//if ( i1.dtStart() != i2.dtStart() )
// return false;
#if 0
qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
qDebug("1 %d ",i1.duration() == i2.duration() );
qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
qDebug("6 %d ",i1.organizer() == i2.organizer() );
#endif
if ( i1.hasDuration() == i2.hasDuration() ) {
if ( i1.hasDuration() ) {
if ( i1.duration() != i2.duration() )
return false;
}
} else {
return false;
}
return ( i1.organizer() == i2.organizer() &&
// i1.uid() == i2.uid() &&
// Don't compare lastModified, otherwise the operator is not
// of much use. We are not comparing for identity, after all.
i1.doesFloat() == i2.doesFloat() &&
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver
}
QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
return dt;
}
void IncidenceBase::setCalID( int id )
{
+ if ( mCalID > 0 )
+ updated();
mCalID = id;
}
int IncidenceBase::calID() const
{
return mCalID;
}
void IncidenceBase::setCalEnabled( bool b )
{
mCalEnabled = b;
}
bool IncidenceBase::calEnabled() const
{
return mCalEnabled;
}
void IncidenceBase::setAlarmEnabled( bool b )
{
mAlarmEnabled = b;
}
bool IncidenceBase::alarmEnabled() const
{
return mAlarmEnabled;
}
void IncidenceBase::setUid(const QString &uid)
{
mUid = uid;
updated();
}
QString IncidenceBase::uid() const
{
return mUid;
}
void IncidenceBase::setLastModified(const QDateTime &lm)
{
// DON'T! updated() because we call this from
// Calendar::updateEvent().
mLastModified = getEvenTime(lm);
//qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
}
QDateTime IncidenceBase::lastModified() const
{
return mLastModified;
}