-rw-r--r-- | korganizer/calendarview.cpp | 9 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 68 | ||||
-rw-r--r-- | korganizer/kolistview.h | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 4 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 10 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 2 |
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 @@ -1820,40 +1820,33 @@ bool CalendarView::importQtopia( const QString &categories, } 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; } diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index b2b136a..93ff55e 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -649,33 +649,33 @@ KOAgendaButton* KOAgendaView::getNewDaylabel() 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 diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 1f3b4c6..c705c73 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -54,35 +54,32 @@ #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; }; @@ -127,32 +124,33 @@ bool ListItemVisitor::visit(Event *e) 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()) { @@ -176,32 +174,33 @@ bool ListItemVisitor::visit(Todo *t) 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; @@ -211,124 +210,134 @@ 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, @@ -358,32 +367,79 @@ KOListView::~KOListView() 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() { @@ -1026,33 +1082,33 @@ void KOListView::changeEventDisplay(Event *event, int action) 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() ); } diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index 9da5497..d384af0 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -282,37 +282,40 @@ class KOListView : public KOEventView 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 @@ -482,32 +482,36 @@ KopiCalendarFile * KOPrefs::getNewCalendar() 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); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 463fc33..5cc9bfa 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -86,32 +86,33 @@ class KOPrefs : public KPimPrefs 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 diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2243e28..3b7b183 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -63,32 +63,33 @@ class Calendar : public QObject, public CustomProperties, 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. */ diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 336c3e8..8c4dde1 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -65,32 +65,42 @@ void CalendarLocal::init() 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(); diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5bbe55f..0286b48 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -32,32 +32,33 @@ 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 ); /** diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 2ddbb01..96039df 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -128,32 +128,34 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) // 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 ) |