author | zautrix <zautrix> | 2005-04-21 11:44:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-21 11:44:00 (UTC) |
commit | 4d96d7b681ce99d76746a843c289b75f5e7dba64 (patch) (side-by-side diff) | |
tree | 71b6953625d8b096e62177bf93379c3ca6c74d66 | |
parent | f23afbb9c09b4ee0f00af8f04ee4458181792cd0 (diff) | |
download | kdepimpi-4d96d7b681ce99d76746a843c289b75f5e7dba64.zip kdepimpi-4d96d7b681ce99d76746a843c289b75f5e7dba64.tar.gz kdepimpi-4d96d7b681ce99d76746a843c289b75f5e7dba64.tar.bz2 |
memory leaks fixed
-rw-r--r-- | korganizer/koagendaitem.cpp | 8 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 8 | ||||
-rw-r--r-- | korganizer/kolistview.h | 3 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 8 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
8 files changed, 34 insertions, 6 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 1801d7e..df2e478 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -1,543 +1,547 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qlabel.h> #include <qlayout.h> #include <qhbox.h> #include <qvbox.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qdragobject.h> #include <qdrawutil.h> #include <qpainter.h> #include <kiconloader.h> #include <kdebug.h> #include <kglobal.h> #include <klocale.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #define AGENDA_ICON_SIZE 5 #else #include <qapplication.h> #define AGENDA_ICON_SIZE 7 #endif #include <libkcal/icaldrag.h> #include <libkcal/vcaldrag.h> #include <libkcal/kincidenceformatter.h> extern int globalFlagBlockAgenda; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; #include "koprefs.h" #include "koagendaitem.h" //#include "koagendaitem.moc" //-------------------------------------------------------------------------- QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; //-------------------------------------------------------------------------- class KOAgendaItemWhatsThis :public QWhatsThis { public: KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; protected: virtual QString text( const QPoint& ) { return _view->getWhatsThisText() ; } private: KOAgendaItem * _view; }; KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, const char *name,WFlags) : QWidget(parent, name), mIncidence(incidence), mDate(qd) { #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); #endif mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase setWFlags ( wflags); mAllDay = allday; init ( incidence, qd ); //setMouseTracking(true); //setAcceptDrops(true); xPaintCoord = -1; yPaintCoord = -1; } QString KOAgendaItem::getWhatsThisText() { if ( mIncidence ) return KIncidenceFormatter::instance()->getFormattedText( mIncidence, KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); return "KOAgendaItem::getWhatsThisText()::internal error"; } void KOAgendaItem::init ( Incidence *incidence, QDate qd ) { mIncidence = incidence; mDate = qd; mFirstMultiItem = 0; mNextMultiItem = 0; mLastMultiItem = 0; computeText(); if ( (incidence->type() == "Todo") && ( !((static_cast<Todo*>(incidence))->isCompleted()) && ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; else mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; } else { QStringList categories = mIncidence->categories(); QString cat = categories.first(); if (cat.isEmpty()) { if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; else mBackgroundColor =KOPrefs::instance()->mEventColor; } else { mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; } } } mColorGroup = QColorGroup( mBackgroundColor.light(), mBackgroundColor.dark(),mBackgroundColor.light(), mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; setBackgroundColor( mBackgroundColor ); mConflictItems.clear(); setCellXY(0,0,1); setCellXWidth(0); setSubCell(0); setSubCells(1); setMultiItem(0,0,0); startMove(); mSelected = true; select(false); QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); mFontPixelSize = fontinf.height();; hide(); xPaintCoord = -1; yPaintCoord = -1; } KOAgendaItem::~KOAgendaItem() { - // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); - // delete mKOAgendaItemWhatsThis; +#if QT_VERSION >= 0x030000 + +#else + delete mKOAgendaItemWhatsThis; +#endif + } void KOAgendaItem::recreateIncidence() { #if 0 Incidence* newInc = mIncidence->clone(); newInc->recreate(); if ( mIncidence->doesRecur() ) { mIncidence->addExDate( mDate ); newInc->recurrence()->unsetRecurs(); int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); QTime tim = mIncidence->dtStart().time(); newInc->setDtStart( QDateTime(mDate, tim) ); ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); } #endif mIncidence = mIncidence->recreateCloneException( mDate ); } bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) { int size = AGENDA_ICON_SIZE; int yOff = 0; int xOff = 0; int x = pos().x() +3; int y; if ( mAllDay ) y = pos().y()+3; else y = mCellYTop * ( height() / cellHeight() ) +3; if (mIncidence->cancelled()) { int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->isAlarmEnabled()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->recurrence()->doesRecur()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->description().length() > 0) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->isReadOnly()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->attendeeCount()>0) { if (mIncidence->organizer() == KOPrefs::instance()->email()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); if ( horLayout ) ++xOff; else ++yOff; } else { Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { } else { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); if ( horLayout ) ++xOff; else ++yOff; } p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); if ( horLayout ) ++xOff; else ++yOff; } } return ( yOff || xOff ); } void KOAgendaItem::select(bool selected) { //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); if (mSelected == selected) return; mSelected = selected; if ( ! isVisible() ) return; if ( firstMultiItem() ) firstMultiItem()->select( selected ); if ( !firstMultiItem() && nextMultiItem() ) { KOAgendaItem * placeItem = nextMultiItem(); while ( placeItem ) { placeItem->select( selected ); placeItem = placeItem->nextMultiItem(); } } globalFlagBlockAgendaItemUpdate = 0; paintMe( selected ); globalFlagBlockAgendaItemUpdate = 1; repaint( false ); } /* The eventFilter has to filter the mouse events of the agenda item childs. The events are fed into the event handling method of KOAgendaItem. This allows the KOAgenda to handle the KOAgendaItems by using an eventFilter. */ bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) { if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick || e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::MouseMove) { QMouseEvent *me = (QMouseEvent *)e; QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> mapToGlobal(me->pos())); QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); return event(&returnEvent); } else { return false; } } void KOAgendaItem::repaintMe( ) { paintMe ( mSelected ); } void KOAgendaItem::paintMe( bool selected, QPainter* paint ) { if ( globalFlagBlockAgendaItemUpdate && ! selected) return; QPainter pa; if ( mSelected ) { pa.begin( paintPixSel() ); } else { if ( mAllDay ) pa.begin( paintPixAllday() ); else pa.begin( paintPix() ); } int x, yy, w, h; float nfh = 7.0; x = pos().x(); w = width(); h = height (); if ( mAllDay ) yy = y(); else yy = mCellYTop * ( height() / cellHeight() ); xPaintCoord= x; yPaintCoord = yy; wPaintCoord = width(); hPaintCoord = height(); //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); if ( paint == 0 ) paint = &pa; bool horLayout = ( w < h ); int maxhei = mFontPixelSize+4; if ( horLayout ) maxhei += AGENDA_ICON_SIZE -4; bool small = ( h < maxhei ); if ( ! small ) paint->setFont(KOPrefs::instance()->mAgendaViewFont); else { QFont f = KOPrefs::instance()->mAgendaViewFont; f.setBold( false ); int fh = f.pointSize(); nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; if ( nfh < 6 ) nfh = 6; f.setPointSize( nfh ); paint->setFont(f); } paint->fillRect ( x, yy, w, h, mBackgroundColor ); static const QPixmap completedPxmp = SmallIcon("greenhook16"); static const QPixmap overduePxmp = SmallIcon("redcross16"); if ( mIncidence->type() == "Todo" ) { Todo* tempTodo = static_cast<Todo*>(mIncidence); int xx = pos().x()+(width()-completedPxmp.width()-3 ); int yyy = yy+3; if ( tempTodo->isCompleted() ) paint->drawPixmap ( xx, yyy, completedPxmp ); else { paint->drawPixmap ( xx, yyy, overduePxmp ); } } bool addIcon = false; if ( ! small || w > 3 * h || h > 3* w ) addIcon = updateIcons( paint, horLayout ); qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); if ( ! small ) { x += 3; yy += 3;w -= 6; h-= 5; } else { x += 2; yy += 1;w -= 4; h-= 4; if ( nfh < 6.01 ) { yy -= 2; h += 4; } else if ( nfh < h -2 ) ++yy; } int align; #ifndef DESKTOP_VERSION align = ( AlignLeft|WordBreak|AlignTop); #else align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); #endif if ( addIcon ) { if ( ! horLayout ) { x += AGENDA_ICON_SIZE+3; w -= (AGENDA_ICON_SIZE+3); } else { yy+= AGENDA_ICON_SIZE+2; h -=(AGENDA_ICON_SIZE+3); } } int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); if ( colsum < 250 ) paint->setPen ( white); if ( x < 0 ) { w = w+x-3; x = 3; if ( w > parentWidget()->width() ){ w = parentWidget()->width() - 6; #ifndef DESKTOP_VERSION align = ( AlignHCenter|WordBreak|AlignTop); #else align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); #endif } } QRect dr; if ( w + x > parentWidget()->width() ) w = parentWidget()->width()-x; paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); //qDebug("%d %d %d %d ", x, yy, w, h ); if ( mIncidence->cancelled() ){ small = ( height() < 20 ); if ( ! small ) { QFontMetrics fm ( paint->font() ); paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); } } pa.end(); } void KOAgendaItem::resizePixmap( int w , int h ) { paintPix()->resize( w, h ); paintPixSel()->resize( w, h ); } QPixmap * KOAgendaItem::paintPix() { static QPixmap* mPaintPix = 0; if ( ! mPaintPix ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); mPaintPix = new QPixmap(w,h); } return mPaintPix ; } QPixmap * KOAgendaItem::paintPixAllday() { static QPixmap* mPaintPixA = 0; if ( ! mPaintPixA ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height()/3; mPaintPixA = new QPixmap(w,h); } return mPaintPixA ; } QPixmap * KOAgendaItem::paintPixSel() { static QPixmap* mPaintPixSel = 0; if ( ! mPaintPixSel ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); mPaintPixSel = new QPixmap(w,h); } return mPaintPixSel ; } void KOAgendaItem::paintEvent ( QPaintEvent *e ) { if ( globalFlagBlockAgendaItemPaint ) return; if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) return; int yy; if ( mAllDay ) yy = y(); else yy = mCellYTop * ( height() / cellHeight() ); int xx = x(); if ( xPaintCoord != xx || yPaintCoord != yy || wPaintCoord != width() || hPaintCoord != height()) { xPaintCoord= xx; yPaintCoord = yy; wPaintCoord = width(); hPaintCoord = height(); globalFlagBlockAgendaItemUpdate = 0; paintMe( mSelected ); //qDebug("calling paintMe "); globalFlagBlockAgendaItemUpdate = 1; } int rx, ry, rw, rh; rx = e->rect().x(); ry = e->rect().y(); rw = e->rect().width(); rh = e->rect().height(); //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); QPixmap* paintFrom ; if ( mSelected ) { paintFrom = paintPixSel(); } else { if ( mAllDay ) paintFrom = paintPixAllday(); else paintFrom = paintPix(); } xx += rx; if ( xx < 0 ) { rw = rw + xx; rx -= xx; xx = 0; if ( rw <= 1 ) { //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); return; } } if ( paintFrom->width() < xx+rw ) { rw = paintFrom->width() - xx; if ( rw <= 1 ) { //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); return; } } //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); } void KOAgendaItem::computeText() { mDisplayedText = mIncidence->summary(); if ( (mIncidence->type() == "Todo") ) { if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; else if ( !(mIncidence->doesFloat())) diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index c32a2a4..53ebdb2 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -1,450 +1,450 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> Parts of the source code have been copied from kdpdatebutton.cpp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License 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 ode for Qt in the source distribution. */ #include <qevent.h> #include <qpainter.h> #include <qptrlist.h> #include <qtimer.h> #include <qwhatsthis.h> #include <kglobal.h> #include <kdebug.h> #include <klocale.h> #include <libkcal/vcaldrag.h> #include <libkcal/icaldrag.h> #include <libkcal/dndfactory.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <kcalendarsystem.h> #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koprefs.h" #include "koglobals.h" #include "kodaymatrix.h" // ============================================================================ // D Y N A M I C T I P // ============================================================================ DynamicTip::DynamicTip( QWidget * parent ) : QToolTip( parent ) { matrix = (KODayMatrix*)parent; } class KODaymatrixWhatsThis :public QWhatsThis { public: KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; - ~KODaymatrixWhatsThis() { qDebug("DELETE KODaymatrixWhatsThis "); }; + ~KODaymatrixWhatsThis() { ; }; protected: virtual QString text( const QPoint& p ) { return _view->getWhatsThisText( p ) ; } private: KODayMatrix * _view; }; void DynamicTip::maybeTip( const QPoint &pos ) { //calculate which cell of the matrix the mouse is in QRect sz = matrix->frameRect(); int dheight = sz.height()*7 / 42; int dwidth = sz.width() / 7; int row = pos.y()/dheight; int col = pos.x()/dwidth; QRect rct(col*dwidth, row*dheight, dwidth, dheight); // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << // col << "][" << row << "] => " <<(col+row*7) << endl; //show holiday names only QString str = matrix->getHolidayLabel(col+row*7); if (str.isEmpty()) return; tip(rct, str); } // ============================================================================ // K O D A Y M A T R I X // ============================================================================ const int KODayMatrix::NOSELECTION = -1000; const int KODayMatrix::NUMDAYS = 42; KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) { mLastView = -1; oldW = 0; oldH = 0; myPix.resize( 150, 120 ); mRedrawNeeded = true; mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); mPendingUpdateBeforeRepaint = false; mouseDown = false; // initialize dynamic arrays bDays.resize ( NUMDAYS ); pDays.resize ( NUMDAYS ); hDays.resize ( NUMDAYS ); eDays.resize ( NUMDAYS ); days = new QDate[NUMDAYS]; daylbls = new QString[NUMDAYS]; //events = new int[NUMDAYS]; mToolTip = new DynamicTip(this); // set default values used for drawing the matrix mDefaultBackColor = palette().active().base(); mDefaultTextColor = palette().active().foreground(); mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); mSelectedDaysColor = QColor("white"); mTodayMarginWidth = 2; mSelEnd = mSelStart = NOSELECTION; setAcceptDrops(true); //setFont( QFont("Arial", 10) ); mUpdateTimer = new QTimer( this ); connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); mRepaintTimer = new QTimer( this ); connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); mDayChanged = false; updateView(); } QString KODayMatrix::getWhatsThisText( QPoint p ) { int tmp = getDayIndexFrom(p.x(), p.y()); if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) return QString(); QDate mDate = days[tmp]; QPtrList<Event> eventlist = mCalendar->events(mDate); Event *event; QStringList mToolTip; for(event=eventlist.first();event != 0;event=eventlist.next()) { QString mToolTipText; QString text; int multiday = 0;// 1 = start, 2 = midddle, 3 = end day if (event->isMultiDay()) { QString prefix = "<->";multiday = 2; QString time; if ( event->doesRecur() ) { if ( event->recursOn( mDate) ) { prefix ="->" ;multiday = 1; } else { int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); if ( event->recursOn( mDate.addDays( -days)) ) { prefix ="<-" ;multiday = 3; } } } else { if (mDate == event->dtStart().date()) { prefix ="->" ;multiday = 1; } else if (mDate == event->dtEnd().date()) { prefix ="<-" ;multiday = 3; } } if ( !event->doesFloat() ) { if ( mDate == event->dtStart().date () ) time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; else if ( mDate == event->dtEnd().date () ) time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; } text = time + event->summary(); mToolTipText += prefix + text; } else { if (event->doesFloat()) { text = event->summary(); mToolTipText += text; } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } if ( !event->location().isEmpty() ) mToolTipText += " (" + event->location() + ")"; #if QT_VERSION >= 0x030000 mToolTipText.replace( '<' , "<" ); mToolTipText.replace( '>' , ">" ); #else if ( mToolTipText.find ('<') >= 0 ) { mToolTipText.replace( QRegExp("<") , "<" ); } if ( mToolTipText.find ('>') >= 0 ) { mToolTipText.replace( QRegExp(">") , ">" ); } #endif //qDebug("TTT: %s ", mToolTipText.latin1()); mToolTip.append( mToolTipText ); } mToolTip.sort(); return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); } void KODayMatrix::setCalendar( Calendar *cal ) { mCalendar = cal; setAcceptDrops( mCalendar ); updateEvents(); } QColor KODayMatrix::getShadedColor(QColor color) { QColor shaded; int h=0; int s=0; int v=0; color.hsv(&h,&s,&v); s = s/4; v = 192+v/4; shaded.setHsv(h,s,v); return shaded; } KODayMatrix::~KODayMatrix() { #if QT_VERSION >= 0x030000 #else delete mKODaymatrixWhatsThis; #endif // delete mKODaymatrixWhatsThis; delete [] days; delete [] daylbls; //delete [] events; delete mToolTip; } /* void KODayMatrix::setStartDate(QDate start) { updateView(start); } */ void KODayMatrix::addSelectedDaysTo(DateList& selDays) { if (mSelStart == NOSELECTION) { return; } //cope with selection being out of matrix limits at top (< 0) int i0 = mSelStart; if (i0 < 0) { for (int i = i0; i < 0; i++) { selDays.append(days[0].addDays(i)); } i0 = 0; } //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) if (mSelEnd > NUMDAYS-1) { for (int i = i0; i <= NUMDAYS-1; i++) { selDays.append(days[i]); } for (int i = NUMDAYS; i < mSelEnd; i++) { selDays.append(days[0].addDays(i)); } // apply normal routine to selection being entirely within matrix limits } else { for (int i = i0; i <= mSelEnd; i++) { selDays.append(days[i]); } } } bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) { mRedrawNeeded = true; bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); mSelStart = startdate.daysTo(start); if ( mSelStart < 0 ) mSelStart = 0; mSelEnd = startdate.daysTo(end); if ( mSelEnd > NUMDAYS-1 ) mSelEnd = NUMDAYS-1; if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { clearSelection(); if ( noSel ) return false; } return true; } void KODayMatrix::clearSelection() { mSelEnd = mSelStart = NOSELECTION; } void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { //events[i] = 0; days[i] = startdate.addDays(i); daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); // if today is in the currently displayed month, hilight today if (days[i].year() == QDate::currentDate().year() && days[i].month() == QDate::currentDate().month() && days[i].day() == QDate::currentDate().day()) { today = i; } } // qDebug(QString("Today is visible at %1.").arg(today)); } void KODayMatrix::updateView() { updateView(startdate); } void KODayMatrix::repaintViewTimed() { mRedrawNeeded = true; // bDays.fill( false); //pDays.fill( false); //hDays.fill( false); //eDays.fill( false); mRepaintTimer->stop(); int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday int i; for(i = 0; i < NUMDAYS; i++) { if ( ( (i+startDay) % 7 == 0 ) ) { pDays.setBit(i); } } repaint(false); } void KODayMatrix::computeEvent(Event *event, int i ) { QString holiStr = mHolidays[i]; if ( event->isHoliday()) { pDays.setBit(i); hDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; mHolidays[i] =holiStr ; eDays.setBit(i); } if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { if ( event->isBirthday()) { pDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Birthday") + ": "+event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; bDays.setBit(i); mHolidays[i] =holiStr ; } } if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) eDays.setBit(i); } void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); if ( !mCalendar ) { qDebug("NOT CAL "); return; } #if 1 int i; int timeSpan = NUMDAYS-1; QPtrList<Event> events = mCalendar->events(); Event *event; QDateTime dt; bool ok; bDays.fill( false); pDays.fill( false); hDays.fill( false); eDays.fill( false); mHolidays.clear(); QDate mStartDate = days[0]; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event ushort recurType = event->recurrence()->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { continue; } if ( event->doesRecur() ) { bool last; QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( incidenceEnd.date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); for ( iii = st;iii<= end;++iii) { computeEvent( event, iii ); } } } } else { if ( invalid ) break; invalid = true; //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; } if ( last ) diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index fd86095..b94916a 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -1,724 +1,729 @@ /* This file is part of KOrganizer. Copyright (c) 1999 Preston Brown Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License 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 <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 <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" 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()); 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()); 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) ); 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->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); - new KOListViewWhatsThis(mListView->viewport(),this); + mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); int iii = 0; for ( iii = 0; iii< 10 ; ++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->insertSeparator(); 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::updateList() { // qDebug(" KOListView::updateList() "); } 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->type() != "Journal" ) { if ( inc->type() == "Todo" ) { 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()) { if (inc->alarms().count() == 0) inc->newAlarm(); QPtrList<Alarm> alarms = inc->alarms(); Alarm *alarm; for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { alarm->setEnabled(true); int j = kap.mAlarmTimeEdit->value()* -60; if (kap.mAlarmIncrCombo->currentItem() == 1) j = j * 60; else if (kap.mAlarmIncrCombo->currentItem() == 2) j = j * (60 * 24); alarm->setStartOffset( j ); if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { alarm->setProcedureAlarm(kap.mAlarmProgram); } else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) alarm->setAudioAlarm(kap.mAlarmSound); else alarm->setType(Alarm::Invalid); //alarm->setAudioAlarm("default"); // TODO: Deal with multiple alarms break; // For now, stop after the first alarm } } else { Alarm* alarm = inc->alarms().first(); if ( alarm ) { alarm->setEnabled(false); alarm->setType(Alarm::Invalid); } } ListItemVisitor v(item, mStartDate ); inc->accept(v); item = sel.next(); } topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); qDebug("KO: Set alarm for %d items", count); calendar()->reInitAlarmSettings(); QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); } void KOListView::setCategories( bool removeOld ) { KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); csd->setColorEnabled(); if (! csd->exec()) { delete csd; return; } QStringList catList = csd->selectedCategories(); delete csd; // if ( catList.count() == 0 ) // return; //catList.sort(); QString categoriesStr = catList.join(","); int i; QStringList itemList; QPtrList<KOListViewItem> sel ; QListViewItem *qitem = mListView->firstChild (); while ( qitem ) { if ( qitem->isSelected() ) { sel.append(((KOListViewItem *)qitem)); } qitem = qitem->nextSibling(); } KOListViewItem * item, *temp; item = sel.first(); if( item ) { Incidence* inc = item->data() ; bool setSub = false; if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { int result = KMessageBox::warningYesNoCancel(this, i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), i18n("Todo has subtodos"), i18n("Yes"), i18n("No")); if (result == KMessageBox::Cancel) item = 0; if (result == KMessageBox::Yes) setSub = true; } while ( item ) { inc = item->data(); if ( removeOld ) { inc->setCategories( catList, setSub ); } else { inc->addCategories( catList, setSub ); } ListItemVisitor v(item, mStartDate ); inc->accept(v); item = sel.next(); } } QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); } void KOListView::beamSelected() { int icount = 0; QPtrList<Incidence> delSel ; QListViewItem *item = mListView->firstChild (); while ( item ) { if ( item->isSelected() ) { delSel.append(((KOListViewItem *)item)->data()); ++icount; } item = item->nextSibling(); } if ( icount ) { emit beamIncidenceList( delSel ); return; QString fn ; fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; QString mes; bool createbup = true; if ( createbup ) { QString description = "\n"; CalendarLocal* cal = new CalendarLocal(); cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); Incidence *incidence = delSel.first(); while ( incidence ) { Incidence *in = incidence->clone(); description += in->summary() + "\n"; cal->addIncidence( in ); incidence = delSel.next(); } FileStorage storage( cal, fn, new VCalFormat ); storage.save(); delete cal; mes = i18n("KO/Pi: Ready for beaming"); topLevelWidget()->setCaption(mes); #ifndef DESKTOP_VERSION Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); ir->send( fn, description, "text/x-vCalendar" ); #endif } } } void KOListView::beamDone( Ir *ir ) { #ifndef DESKTOP_VERSION delete ir; #endif topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); } void KOListView::saveDescriptionToFile() { int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), i18n("Continue"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { return; } int icount = 0; QPtrList<Incidence> delSel ; QListViewItem *item = mListView->firstChild (); while ( item ) { if ( item->isSelected() ) { delSel.append(((KOListViewItem *)item)->data()); ++icount; } item = item->nextSibling(); } if ( icount ) { QString fn = KOPrefs::instance()->mLastSaveFile; fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); Incidence *incidence = delSel.first(); icount = 0; while ( incidence ) { if ( incidence->type() == "Journal" ) { text += "\n************************************\n"; text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); ++icount; } else { if ( !incidence->description().isEmpty() ) { text += "\n************************************\n"; if ( incidence->type() == "Todo" ) text += i18n("To-Do: "); text += incidence->summary(); if ( incidence->hasStartDate() ) text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); if ( !incidence->location().isEmpty() ) text += "\n" +i18n("Location: ") + incidence->location(); text += "\n" + i18n("Description: ") + "\n" + incidence->description(); ++icount; } } incidence = delSel.next(); } QFile file( fn ); if (!file.open( IO_WriteOnly ) ) { topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); return; } QTextStream ts( &file ); ts << text; file.close(); //qDebug("%s ", text.latin1()); mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); KOPrefs::instance()->mLastSaveFile = fn; topLevelWidget()->setCaption(mes); } } } void KOListView::saveToFileVCS() { writeToFile( false ); } void KOListView::saveToFile() { writeToFile( true ); } void KOListView::writeToFile( bool iCal ) { int icount = 0; QPtrList<Incidence> delSel ; QListViewItem *item = mListView->firstChild (); bool journal = iCal; // warn only for vCal while ( item ) { if ( item->isSelected() ) { if ( !journal ) if ( ((KOListViewItem *)item)->data()->type() == "Journal") journal = true; delSel.append(((KOListViewItem *)item)->data()); ++icount; } item = item->nextSibling(); } if ( !iCal && journal ) { int result = KMessageBox::warningContinueCancel(this, i18n("The journal entries can not be\nexported to a vCalendar file."), i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), true); if (result != KMessageBox::Continue) return; } if ( icount ) { QString fn = KOPrefs::instance()->mLastSaveFile; QString extension; if ( iCal ) { if ( fn.right( 4 ).lower() == ".vcs" ) { fn = fn.left( fn.length() -3) + "ics"; } } else { if ( fn.right( 4 ).lower() == ".ics" ) { fn = fn.left( fn.length() -3) + "vcs"; } } fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { CalendarLocal cal; cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); Incidence *incidence = delSel.first(); while ( incidence ) { cal.addIncidence( incidence->clone() ); incidence = delSel.next(); } if ( iCal ) { ICalFormat format; format.save( &cal, fn ); } else { VCalFormat format; format.save( &cal, fn ); } mes = i18n("KO/Pi:Saved %1").arg(fn ); KOPrefs::instance()->mLastSaveFile = fn; topLevelWidget()->setCaption(mes); } } QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); } void KOListView::deleteAll() { int icount = 0; QPtrList<Incidence> delSel ; QListViewItem *item = mListView->firstChild (); while ( item ) { if ( item->isSelected() ) { delSel.append(((KOListViewItem *)item)->data()); ++icount; @@ -800,468 +805,469 @@ QPtrList<Incidence> KOListView::selectedIncidences() return eventList; } DateList KOListView::selectedDates() { DateList eventList; return eventList; } void KOListView::showDates(bool show) { // Shouldn't we set it to a value greater 0? When showDates is called with // show == true at first, then the columnwidths are set to zero. static int oldColWidth1 = 0; static int oldColWidth3 = 0; if (!show) { oldColWidth1 = mListView->columnWidth(1); oldColWidth3 = mListView->columnWidth(3); mListView->setColumnWidth(1, 0); mListView->setColumnWidth(3, 0); } else { mListView->setColumnWidth(1, oldColWidth1); mListView->setColumnWidth(3, oldColWidth3); } mListView->repaint(); } void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Day, fd, td); #endif } void KOListView::showDates() { showDates(true); } void KOListView::hideDates() { showDates(false); } void KOListView::resetFocus() { topLevelWidget()->setActiveWindow(); topLevelWidget()->raise(); mListView->setFocus(); } void KOListView::updateView() { mListView->setFocus(); if ( mListView->firstChild () ) mListView->setCurrentItem( mListView->firstChild () ); } void KOListView::updateConfig() { mListView->setFont ( KOPrefs::instance()->mListViewFont ); updateView(); } void KOListView::setStartDate(const QDate &start) { mStartDate = start; } void KOListView::showDates(const QDate &start, const QDate &end) { clear(); mStartDate = start; QDate date = start; QPtrList<Journal> j_list; while( date <= end ) { addEvents(calendar()->events(date)); addTodos(calendar()->todos(date)); Journal* jo = calendar()->journal(date); if ( jo ) j_list.append( jo ); date = date.addDays( 1 ); } addJournals(j_list); emit incidenceSelected( 0 ); updateView(); } void KOListView::addEvents(QPtrList<Event> eventList) { Event *ev; for(ev = eventList.first(); ev; ev = eventList.next()) { addIncidence(ev); } if ( !mListView->currentItem() ){ updateView(); } } void KOListView::addTodos(QPtrList<Todo> eventList) { Todo *ev; for(ev = eventList.first(); ev; ev = eventList.next()) { addIncidence(ev); } if ( !mListView->currentItem() ){ updateView(); } } void KOListView::addJournals(QPtrList<Journal> eventList) { Journal *ev; for(ev = eventList.first(); ev; ev = eventList.next()) { addIncidence(ev); } if ( !mListView->currentItem() ){ updateView(); } } void KOListView::addIncidence(Incidence *incidence) { if ( mUidDict.find( incidence->uid() ) ) return; // mListView->setFont ( KOPrefs::instance()->mListViewFont ); mUidDict.insert( incidence->uid(), incidence ); KOListViewItem *item = new KOListViewItem( incidence, mListView ); ListItemVisitor v(item, mStartDate ); 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 *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->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 *) { KOListViewItem *item = static_cast<KOListViewItem *>( mListView->currentItem() ); if ( !item ) { emit incidenceSelected( 0 ); } else { emit incidenceSelected( item->data() ); } } void KOListView::clearSelection() { mListView->selectAll( false ); } void KOListView::allSelection() { mListView->selectAll( true ); } void KOListView::clear() { mListView->clear(); mUidDict.clear(); } Incidence* KOListView::currentItem() { if ( mListView->currentItem() ) return ((KOListViewItem*) mListView->currentItem())->data(); return 0; } void KOListView::keyPressEvent ( QKeyEvent *e) { if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { deleteAll(); return; } e->ignore(); } void KOListViewListView::keyPressEvent ( QKeyEvent *e) { switch ( e->key() ) { case Qt::Key_Down: if ( e->state() == ShiftButton ) { QListViewItem* cn = currentItem(); if ( !cn ) cn = firstChild(); if ( !cn ) return; while ( cn->nextSibling() ) cn = cn->nextSibling(); setCurrentItem ( cn ); ensureItemVisible ( cn ); e->accept(); return; } if ( e->state() == ControlButton ) { int count = childCount (); int jump = count / 5; QListViewItem* cn; cn = currentItem(); if ( ! cn ) return; if ( jump == 0 ) jump = 1; while ( jump && cn->nextSibling() ) { cn = cn->nextSibling(); --jump; } setCurrentItem ( cn ); ensureItemVisible ( cn ); } else QListView::keyPressEvent ( e ) ; e->accept(); break; case Qt::Key_Up: if ( e->state() == ShiftButton ) { QListViewItem* cn = firstChild(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } e->accept(); return; } if ( e->state() == ControlButton ) { int count = childCount (); int jump = count / 5; QListViewItem* cn; cn = currentItem(); if ( ! cn ) return; if ( jump == 0 ) jump = 1; while ( jump && cn->itemAbove ()) { cn = cn->itemAbove (); --jump; } setCurrentItem ( cn ); ensureItemVisible ( cn ); } else QListView::keyPressEvent ( e ) ; e->accept(); break; case Qt::Key_I: { QListViewItem* cn; cn = currentItem(); if ( cn ) { KOListViewItem* ci = (KOListViewItem*)( cn ); if ( ci ){ //emit showIncidence( ci->data()); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } emit showIncidence( ci->data()); } } e->accept(); } break; case Qt::Key_Return: case Qt::Key_Enter: { QListViewItem* cn; cn = currentItem(); if ( cn ) { KOListViewItem* ci = (KOListViewItem*)( cn ); if ( ci ){ if ( e->state() == ShiftButton ) ci->setSelected( false ); else ci->setSelected( true ); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } } } e->accept(); } break; default: e->ignore(); } } KOListViewListView::KOListViewListView(KOListView * lv ) : KListView( lv, "kolistlistview", false ) { + mYMousePos = 0; mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif setSelectionMode( QListView::Multi ); setMultiSelection( true); } void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); if (!item) { emit newEvent(); return; } KListView::contentsMouseDoubleClickEvent(e); } #if 0 void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) { //qDebug("contentsMousePressEvent++++ "); KListView::contentsMousePressEvent( e ); if ( e->button() == RightButton ) { QListViewItem* ci = currentItem(); clearSelection () ; if ( ci ) ci->setSelected( true ); } } void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) { KListView::contentsMouseReleaseEvent(e); } void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) { KListView::contentsMouseMoveEvent(e); } #endif void KOListViewListView::popupMenu() { mPopupTimer->stop(); QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); QApplication::postEvent( this->viewport(), e ); } void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) { //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); mYMousePos = mapToGlobal( (e->pos())).y(); if ( e->button() == LeftButton ) { mPopupTimer->start( 600 ); mEventPos = contentsToViewport(e->pos()); mEventGlobalPos = e->globalPos(); } KListView::contentsMousePressEvent( e ); if ( e->button() == RightButton ) { QListViewItem* ci = currentItem(); //clearSelection(); if ( ci ) ci->setSelected( true ); } } void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) { mPopupTimer->stop(); KListView::contentsMouseReleaseEvent(e); } void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) { // qDebug("contentsMouseMoveEv....... "); // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); int diff = mYMousePos - mapToGlobal( (e->pos())).y(); if ( diff < 0 ) diff = -diff; if ( diff > 15 ) mPopupTimer->stop(); else { mEventPos = contentsToViewport(e->pos()); mEventGlobalPos = e->globalPos(); } KListView::contentsMouseMoveEvent(e); } diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index eb5bb6e..2051d60 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -1,311 +1,312 @@ /* This file is part of KOrganizer. Copyright (c) 1999 Preston Brown Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License 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. */ #ifndef _KOLISTVIEW_H #define _KOLISTVIEW_H #include <qlistview.h> #include <qmap.h> #include <qdict.h> #include <klistview.h> #ifndef DESKTOP_VERSION #include <qtopia/ir.h> #else #define Ir char #endif #include <libkcal/incidence.h> #include "koeventview.h" #include "customlistviewitem.h" using namespace KCal; - +class KOListViewWhatsThis; #include <qpushbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qtimer.h> #include <qcombobox.h> #include <qspinbox.h> #include <qtooltip.h> #include <qcheckbox.h> #include <qhbox.h> #include <qlabel.h> #include <kiconloader.h> #include "kfiledialog.h" #include "koprefs.h" class KOAlarmPrefs : public QDialog { Q_OBJECT public: KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : QDialog( par, name, true ) { setCaption( i18n("Alarm Options") ); QVBoxLayout* alarmLayout = new QVBoxLayout( this ); alarmLayout->setSpacing( 3 ); alarmLayout->setMargin( 3 ); QWidget *parent = this; mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); alarmLayout->addWidget(mAlarmButton); mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; mAlarmTimeEdit->setValue( 15 ); alarmLayout->addWidget(mAlarmTimeEdit); mAlarmIncrCombo = new QComboBox(false, parent); mAlarmIncrCombo->insertItem(i18n("minute(s)")); mAlarmIncrCombo->insertItem(i18n("hour(s)")); mAlarmIncrCombo->insertItem(i18n("day(s)")); alarmLayout->addWidget(mAlarmIncrCombo); QHBox * hb = new QHBox ( parent ); alarmLayout->addWidget(hb); mAlarmSoundButton = new QPushButton(hb); mAlarmSoundButton->setPixmap(SmallIcon("playsound")); mAlarmSoundButton->setToggleButton(true); connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); mAlarmProgramButton = new QPushButton(hb); mAlarmProgramButton->setPixmap(SmallIcon("run")); mAlarmProgramButton->setToggleButton(true); connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); mAlarmLabel = new QLabel( this ); alarmLayout->addWidget( mAlarmLabel ); mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; mAlarmSoundButton->setOn( true ); QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); alarmLayout->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); alarmLayout->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } QString mAlarmSound, mAlarmProgram ; QCheckBox* mAlarmButton; QSpinBox* mAlarmTimeEdit; QLabel* mAlarmLabel; QComboBox* mAlarmIncrCombo ; QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; private slots: void pickAlarmSound() { //QString prefix = mAlarmSound; if (!mAlarmSoundButton->isOn()) { //mAlarmSound = ""; QToolTip::remove(mAlarmSoundButton); QToolTip::add(mAlarmSoundButton, i18n("No sound set")); mAlarmProgramButton->setOn(true); mAlarmSoundButton->setOn(false); } else { QString fileName(KFileDialog::getOpenFileName(mAlarmSound, i18n("*.wav|Wav Files"), 0)); if (!fileName.isEmpty()) { mAlarmSound = fileName; mAlarmLabel->setText( "..."+fileName.right( 30 ) ); QToolTip::remove(mAlarmSoundButton); QString dispStr = i18n("Playing '%1'").arg(fileName); QToolTip::add(mAlarmSoundButton, dispStr); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); } else { mAlarmProgramButton->setOn(true); mAlarmSoundButton->setOn(false); } } }; void pickAlarmProgram() { if (!mAlarmProgramButton->isOn()) { //mAlarmProgram = ""; QToolTip::remove(mAlarmProgramButton); QToolTip::add(mAlarmProgramButton, i18n("No program set")); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); } else { QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); if (!fileName.isEmpty()) { mAlarmProgram = fileName; mAlarmLabel->setText( "..."+fileName.right( 30 ) ); QToolTip::remove(mAlarmProgramButton); QString dispStr = i18n("Running '%1'").arg(fileName); QToolTip::add(mAlarmProgramButton, dispStr); mAlarmSoundButton->setOn(false); mAlarmProgramButton->setOn(true); } else { mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); } } }; }; typedef CustomListViewItem<Incidence *> KOListViewItem; /** This class provides the initialisation of a KOListViewItem for calendar components using the Incidence::Visitor. */ class ListItemVisitor : public Incidence::Visitor { public: ListItemVisitor(KOListViewItem *, QDate d); ~ListItemVisitor(); bool visit(Event *); bool visit(Todo *); bool visit(Journal *); private: KOListViewItem *mItem; QDate mDate; }; /** This class provides a multi-column list view of events. It can display events from one particular day or several days, it doesn't matter. To use a view that only handles one day at a time, use KODayListView. @short multi-column list view of various events. @author Preston Brown <pbrown@kde.org> @see KOBaseView, KODayListView */ class KOListView; class KOListViewListView : public KListView { Q_OBJECT public: KOListViewListView(KOListView * lv ); signals: void newEvent(); void showIncidence( Incidence* ); public slots: void popupMenu(); private: QPoint mEventPos; QPoint mEventGlobalPos; QTimer* mPopupTimer; int mYMousePos; void keyPressEvent ( QKeyEvent * ) ; void contentsMouseDoubleClickEvent(QMouseEvent *e); void contentsMousePressEvent(QMouseEvent *e); void contentsMouseReleaseEvent(QMouseEvent *e); void contentsMouseMoveEvent(QMouseEvent *e); bool mMouseDown; }; class KOListView : public KOEventView { Q_OBJECT public: KOListView(Calendar *calendar, QWidget *parent = 0, const char *name = 0); ~KOListView(); virtual int maxDatesHint(); virtual int currentDateCount(); virtual QPtrList<Incidence> selectedIncidences(); virtual DateList selectedDates(); 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 setStartDate(const QDate &start); int count(); QString getWhatsThisText(QPoint p); signals: void signalNewEvent(); void beamIncidenceList(QPtrList<Incidence>); public slots: 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); protected slots: void processSelectionChange(QListViewItem *); protected: void writeToFile( bool iCal ); void addEvents(QPtrList<Event> eventList); void addIncidence(Incidence *); KOListViewItem *getItemForEvent(Event *event); private: + KOListViewWhatsThis *mKOListViewWhatsThis; KOListViewListView *mListView; KOEventPopupMenu *mPopupMenu; KOListViewItem *mActiveItem; QDict<Incidence> mUidDict; QDate mStartDate; void keyPressEvent ( QKeyEvent * ) ; }; #endif diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ae61db6..7927307 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -1,476 +1,480 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpopupmenu.h> #include <qfont.h> #include <qfontmetrics.h> #include <qkeycode.h> #include <qhbox.h> #include <qvbox.h> #include <qwidgetstack.h> #include <qpushbutton.h> #include <qtooltip.h> #include <qpainter.h> #include <qtimer.h> #include <qwhatsthis.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kiconloader.h> #include <kcalendarsystem.h> #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koprefs.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koglobals.h" #include <libkcal/kincidenceformatter.h> #include "komonthview.h" #define PIXMAP_SIZE 5 #ifdef DESKTOP_VERSION QToolTipGroup *MonthViewCell::mToolTipGroup = 0; #endif class KNOWhatsThis :public QWhatsThis { public: KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; protected: virtual QString text( const QPoint& p) { return _wid->getWhatsThisText(p) ; }; private: KNoScrollListBox* _wid; }; KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) : QListBox(parent, name, WRepaintNoErase) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mWT = new KNOWhatsThis(this); resetOnFocusIn = true; setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() { +#if QT_VERSION >= 0x030000 +#else + delete mWT; +#endif } void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) { QListBox::focusInEvent ( e ); if ( count() ){ int ci = currentItem(); if ( ci < 0 ) ci = 0; setCurrentItem( ci ); setSelected ( ci, true ); emit highlighted( item ( ci ) ); resetOnFocusIn = true; if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); } else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); } else { setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } } } void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) { int i = currentItem (); if ( i >= 0 ) { setSelected ( i, false ); } QListBox::focusOutEvent ( e ); setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } QString KNoScrollListBox::getWhatsThisText(QPoint p) { QListBoxItem* item = itemAt ( p ); if ( ! item ) { return i18n("Click in the cell\nto add an event!"); } return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { //qDebug("KNoScrollListBox::keyPressEvent "); switch(e->key()) { case Key_Right: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(10,0); break; case Key_Left: if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(-10,0); break; case Key_Up: if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count() ) { if ( currentItem() == 0 ) { emit prevCell(); } else { setCurrentItem((currentItem()+count()-1)%count()); if(!itemVisible(currentItem())) { if((unsigned int) currentItem() == (count()-1)) { setTopItem(currentItem()-numItemsVisible()+1); } else { setTopItem(topItem()-1); } } } } break; case Key_Down: if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count () ) { if ( currentItem()+1 == count () ) { emit nextCell(); } else { setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } } } break; case Key_I: QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); e->ignore(); break; case Key_Return: case Key_Enter: { if ( currentItem() >= 0 ) { emit doubleClicked( item( currentItem() ) ); e->accept(); } else { e->ignore(); } } break; case Key_Shift: emit shiftDown(); break; default: e->ignore(); break; } } void KNoScrollListBox::oneDown() { if ( count () ) { if ( currentItem()+1 == count () ) { emit nextCell(); } else { resetOnFocusIn = false; setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } } } } void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) { switch(e->key()) { case Key_Shift: emit shiftUp(); break; default: break; } } void KNoScrollListBox::mousePressEvent(QMouseEvent *e) { QListBox::mousePressEvent(e); if(e->button() == RightButton) { emit rightClick(); } } MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) : QListBoxItem() { mblockRepaint = true; setText( s ); mMultiday = 0; mIncidence = incidence; mDate = qd; mRecur = false; mAlarm = false; mReply = false; mInfo = false; mdayPos = 0; isWeekItem = KOPrefs::instance()->mMonthViewWeek; } void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) { setText( s ); mMultiday = 0; mIncidence = incidence; mDate = qd; mRecur = false; mAlarm = false; mReply = false; mInfo = false; mdayPos = 0; } void MonthViewItem::paint(QPainter *p) { if ( mblockRepaint ) { return; } #if QT_VERSION >= 0x030000 bool sel = isSelected(); #else bool sel = selected(); #endif if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { p->setBackgroundColor( palette().color( QPalette::Normal, \ sel ? QColorGroup::Highlight : QColorGroup::Background ) ); p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); } int x = 1; //int y = 3;//(height() - mRecurPixmap.height()) /2; int size = PIXMAP_SIZE; if ( QApplication::desktop()->width() < 300 ) size = 3; int heihei = height( listBox () ); int y = (heihei - size -1 ) /2; if ( KOPrefs::instance()->mMonthShowIcons ) { if ( mInfo ) { p->fillRect ( x, y,size,size, Qt::darkGreen ); x += size + 1; } if ( mRecur ) { p->fillRect ( x, y,size,size, Qt::blue ); x += size + 1; } if ( mAlarm ) { p->fillRect ( x, y,size,size, Qt::red ); x += size + 1; } if ( mReply ) { p->fillRect ( x, y,size,size, Qt::yellow ); x += size + 1; } } if ( mMultiday ) { int yyy = y+(size/2); int sizeM = size+2; p->setBrush( QBrush::SolidPattern ); p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; if ( mMultiday == 2 || mMultiday == 3 ) { QPointArray pa ( 3 ); pa.setPoint (0, x, yyy ); pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); p->drawPolygon( pa ); } if ( mMultiday == 2 || mMultiday == 1 ) { QPointArray pa ( 3 ); pa.setPoint (0, x+sizeM +sizeM/2, yyy ); pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); p->drawPolygon( pa ); } if ( mMultiday == 1 ) { // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); } if ( mMultiday == 3 ) { // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); } x += sizeM/2 + 1; x += sizeM + 1; } if ( mIncidence->type() == "Todo" ){ Todo* td = ( Todo* ) mIncidence; if ( td->isCompleted() ) { int half = size/2; p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; x += half+half + 4; } else { int val = td->percentComplete()/20; p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); p->drawRect ( x, y-2,7,size+4); x += size + 3; } } QFontMetrics fm = p->fontMetrics(); int yPos; int pmheight = size; if( pmheight < fm.height() ) yPos = fm.ascent() + fm.leading()/2; else yPos = pmheight/2 - fm.height()/2 + fm.ascent(); p->setPen( palette().color( QPalette::Normal, sel ? \ QColorGroup::HighlightedText : QColorGroup::Foreground ) ); if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { p->drawText( x, yPos, text() ); if ( mIncidence->cancelled() ) { int wid = fm.width( text() ); p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); } } else { QString pText = text(); if( pText.mid(2,1) == ":" ) pText = pText.mid( 6 ); p->drawText( x, yPos, pText ); if ( mIncidence->cancelled() ) { int wid = fm.width( pText ); p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); } } } int MonthViewItem::height(const QListBox *lb) const { int ret = 10; if ( lb ) ret = lb->fontMetrics().lineSpacing()+1; return ret; } int MonthViewItem::width(const QListBox *lb) const { if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { int size = PIXMAP_SIZE; if ( QApplication::desktop()->width() < 300 ) size = 3; int x = 1; if ( KOPrefs::instance()->mMonthShowIcons ) { if ( mInfo ) { x += size + 1; } if( mRecur ) { x += size+1; } if( mAlarm ) { x += size+1; } if( mReply ) { x += size+1; } } if( mMultiday ) { x += size+1+2+size/2; } return( x + lb->fontMetrics().width( text() ) + 1 ); } if ( ! lb ) return 10; return lb->width(); } MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) : KNoScrollListBox( par ), mMonthView( parent ) { //QVBoxLayout *topLayout = new QVBoxLayout( this ); currentPalette = 0; // mLabel = new QLabel( this );QPushButton mLabel = new QPushButton( this ); //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); //mLabel->setLineWidth( 1 ); //mLabel->setAlignment( AlignCenter ); mLabel->setFlat( true ); mLabel->setFocusPolicy(NoFocus); //mItemList = new KNoScrollListBox( this ); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index f26d16d..e95039d 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -207,769 +207,775 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) void KOTodoListView::wheelEvent (QWheelEvent *e) { QListView::wheelEvent (e); } void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) { QPoint p(contentsToViewport(e->pos())); QListViewItem *i = itemAt(p); bool rootClicked = true; if (i) { // if the user clicked into the root decoration of the item, don't // try to start a drag! int X = p.x(); //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); if (X > header()->sectionPos(0) + treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() +i->height()|| X < header()->sectionPos(0)) { rootClicked = false; } } else { rootClicked = false; } #ifndef KORG_NODND mMousePressed = false; if (! rootClicked && !( e->button() == RightButton) ) { mPressPos = e->pos(); mMousePressed = true; } else { mMousePressed = false; } #endif //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); #ifndef DESKTOP_VERSION if (!( e->button() == RightButton && rootClicked) ) QListView::contentsMousePressEvent(e); #else QListView::contentsMousePressEvent(e); #endif } void KOTodoListView::paintEvent(QPaintEvent* e) { emit paintNeeded(); QListView::paintEvent( e); } void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { #ifndef KORG_NODND //QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()*3) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { DndFactory factory( mCalendar ); ICalDrag *vd = factory.createDrag( ((KOTodoViewItem *)item)->todo(),viewport()); internalDrop = false; // we cannot do any senseful here, because the DnD is still broken in Qt if (vd->drag()) { if ( !internalDrop ) { //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); qDebug("Dnd: External move: Delete drag source "); } else qDebug("Dnd: Internal move "); } else { if ( !internalDrop ) { qDebug("Dnd: External Copy"); } else qDebug("DnD: Internal copy: Copy pending"); } } } #endif } void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void KOTodoListView::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; QListViewItem* cn; if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { cn = currentItem(); if ( cn ) { KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); if ( ci ){ if ( e->state() == ShiftButton ) ci->setOn( false ); else ci->setOn( true ); cn = cn->itemBelow(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } } } return; } if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { switch ( e->key() ) { case Qt::Key_Down: case Qt::Key_Up: QListView::keyPressEvent ( e ); break; case Qt::Key_Left: case Qt::Key_Right: QListView::keyPressEvent ( e ); e->accept(); return; break; default: e->ignore(); break; } return; } e->ignore(); } void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) { QListView::contentsMouseReleaseEvent(e); mMousePressed = false; } void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); emit double_Clicked(item); if (!item) return; emit doubleClicked(item,vp,0); } ///////////////////////////////////////////////////////////////////////////// KOQuickTodo::KOQuickTodo(QWidget *parent) : QLineEdit(parent) { setText(i18n("Click to add a new Todo")); } void KOQuickTodo::focusInEvent(QFocusEvent *ev) { if ( text()==i18n("Click to add a new Todo") ) setText(""); QLineEdit::focusInEvent(ev); } void KOQuickTodo::focusOutEvent(QFocusEvent *ev) { setText(i18n("Click to add a new Todo")); QLineEdit::focusOutEvent(ev); } ///////////////////////////////////////////////////////////////////////////// KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { mPendingUpdateBeforeRepaint = false; isFlatDisplay = false; mNavigator = 0; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickAdd = new KOQuickTodo(this); topLayout->addWidget(mQuickAdd); if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); mTodoListView = new KOTodoListView(calendar,this, name ); topLayout->addWidget(mTodoListView); //mTodoListView->header()->setMaximumHeight(30); mTodoListView->setRootIsDecorated(true); mTodoListView->setAllColumnsShowFocus(true); mTodoListView->setShowSortIndicator(true); mTodoListView->addColumn(i18n("Todo")); mTodoListView->addColumn(i18n("Prio")); mTodoListView->setColumnAlignment(1,AlignHCenter); mTodoListView->addColumn(i18n("Complete")); mTodoListView->setColumnAlignment(2,AlignCenter); mTodoListView->addColumn(i18n("Due Date")); mTodoListView->setColumnAlignment(3,AlignLeft); mTodoListView->addColumn(i18n("Due Time")); mTodoListView->setColumnAlignment(4,AlignHCenter); mTodoListView->addColumn(i18n("Start Date")); mTodoListView->setColumnAlignment(5,AlignLeft); mTodoListView->addColumn(i18n("Start Time")); mTodoListView->setColumnAlignment(6,AlignHCenter); mTodoListView->addColumn(i18n("Cancelled")); mTodoListView->addColumn(i18n("Categories")); #if 0 mTodoListView->addColumn(i18n("Sort Id")); mTodoListView->setColumnAlignment(4,AlignHCenter); #endif mTodoListView->setMinimumHeight( 60 ); mTodoListView->setItemsRenameable( true ); mTodoListView->setRenameable( 0 ); mTodoListView->setColumnWidth( 0, 120 ); mTodoListView->setColumnWidthMode(0, QListView::Manual); mTodoListView->setColumnWidthMode(1, QListView::Manual); mTodoListView->setColumnWidthMode(2, QListView::Manual); mTodoListView->setColumnWidthMode(3, QListView::Manual); mTodoListView->setColumnWidthMode(4, QListView::Manual); mTodoListView->setColumnWidthMode(5, QListView::Manual); mTodoListView->setColumnWidthMode(6, QListView::Manual); mTodoListView->setColumnWidthMode(7, QListView::Manual); mTodoListView->setColumnWidthMode(8, QListView::Manual); mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); mPriorityPopupMenu = new QPopupMenu(this); for (int i = 1; i <= 5; i++) { QString label = QString ("%1").arg (i); mPriority[mPriorityPopupMenu->insertItem (label)] = i; } connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); mPercentageCompletedPopupMenu = new QPopupMenu(this); for (int i = 0; i <= 100; i+=20) { QString label = QString ("%1 %").arg (i); mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; } connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); mItemPopupMenu = new QPopupMenu(this); mItemPopupMenu->insertItem(i18n("Show..."), this, SLOT (showTodo())); mItemPopupMenu->insertItem(i18n("Edit..."), this, SLOT (editTodo())); mItemPopupMenu->insertItem( i18n("Delete"), this, SLOT (deleteTodo())); mItemPopupMenu->insertItem( i18n("Clone..."), this, SLOT (cloneTodo())); mItemPopupMenu->insertItem( i18n("Move..."), this, SLOT (moveTodo())); mItemPopupMenu->insertItem( i18n("Beam..."), this, SLOT (beamTodo())); mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, SLOT (cancelTodo())); mItemPopupMenu->insertSeparator(); mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, SLOT (toggleRunningItem())); mItemPopupMenu->insertSeparator(); /* mItemPopupMenu->insertItem( i18n("New Todo..."), this, SLOT (newTodo())); */ mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, SLOT (newSubTodo())); mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, SLOT (unparentTodo()),0,21); mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, SLOT (reparentTodo()),0,22); mItemPopupMenu->insertSeparator(); #if 0 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), this, SLOT( purgeCompleted() ) ); mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), this, SLOT( toggleCompleted() ),0, 33 ); mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0, 34 ); mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), this, SLOT( toggleRunning() ),0, 35 ); #endif mPopupMenu = new QPopupMenu(this); mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, SLOT (newTodo()),0,1); mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), this, SLOT(purgeCompleted()),0,2); mPopupMenu->insertItem(i18n("Show Completed"), this, SLOT( toggleCompleted() ),0,3 ); mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), this, SLOT( toggleRunning() ),0,5 ); mPopupMenu->insertItem(i18n(" set all open","Display all opened"), this, SLOT( setAllOpen() ),0,6 ); mPopupMenu->insertItem(i18n(" set all close","Display all closed"), this, SLOT( setAllClose() ),0,7 ); mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), this, SLOT( setAllFlat() ),0,8 ); mPopupMenu->insertSeparator(); mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0,4 ); mDocPrefs = new DocPrefs( name ); mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); mPopupMenu->setCheckable( true ); mItemPopupMenu->setCheckable( true ); mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); // Double clicking conflicts with opening/closing the subtree connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), SLOT( editItem( QListViewItem *) ) ); /* connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, const QPoint &,int ) ), SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); */ connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, const QPoint &,int ) ), SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), SLOT( itemClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), SLOT( itemDoubleClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), SLOT( updateView() ) ); connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), SLOT( todoModified(Todo *, int) ) ); connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( paintNeeded() ), SLOT( paintNeeded()) ); #if 0 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); #endif connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); connect( mTodoListView, SIGNAL(selectionChanged() ), SLOT( processSelectionChange() ) ); connect( mQuickAdd, SIGNAL( returnPressed () ), SLOT( addQuickTodo() ) ); } KOTodoView::~KOTodoView() { - // delete mKOTodoViewWhatsThis; + +#if QT_VERSION >= 0x030000 + +#else + delete mKOTodoViewWhatsThis; +#endif + delete mDocPrefs; } QString KOTodoView::getWhatsThisText(QPoint p) { KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); if ( item ) return KIncidenceFormatter::instance()->getFormattedText( item->todo(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); return i18n("That is the todo view" ); } void KOTodoView::jumpToDate () { // if (mActiveItem) { // mActiveItem->todo()); // if ( mActiveItem->todo()->hasDueDate() ) // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); } void KOTodoView::paintNeeded() { if ( mPendingUpdateBeforeRepaint ) { updateView(); mPendingUpdateBeforeRepaint = false; } } void KOTodoView::paintEvent(QPaintEvent * pevent) { if ( mPendingUpdateBeforeRepaint ) { updateView(); mPendingUpdateBeforeRepaint = false; } KOrg::BaseView::paintEvent( pevent); } void KOTodoView::updateView() { pendingSubtodo = 0; if ( mBlockUpdate ) { return; } if ( !isVisible() ) { mPendingUpdateBeforeRepaint = true; return; } storeCurrentItem(); //qDebug("KOTodoView::updateView() %x", this); if ( isFlatDisplay ) { displayAllFlat(); resetCurrentItem(); return; } //qDebug("update "); // kdDebug() << "KOTodoView::updateView()" << endl; QFont fo = KOPrefs::instance()->mTodoViewFont; mTodoListView->clear(); if ( mName == "todolistsmall" ) { if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { int ps = fo.pointSize() -2; if ( ps > 12 ) ps -= 2; fo.setPointSize( ps ); } } mTodoListView->setFont( fo ); // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); //mTodoListView->header()->setMaximumHeight(fm.height()); QPtrList<Todo> todoList = calendar()->todos(); /* kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; Event *t; for(t = todoList.first(); t; t = todoList.next()) { kdDebug() << " " << t->getSummary() << endl; if (t->getRelatedTo()) { kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; } QPtrList<Event> l = t->getRelations(); Event *c; for(c=l.first();c;c=l.next()) { kdDebug() << " - relation: " << c->getSummary() << endl; } } */ // Put for each Event a KOTodoViewItem in the list view. Don't rely on a // specific order of events. That means that we have to generate parent items // recursively for proper hierarchical display of Todos. mTodoMap.clear(); Todo *todo; todo = todoList.first();// todo; todo = todoList.next()) { while ( todo ) { bool next = true; // qDebug("todo %s ", todo->summary().latin1()); Incidence *incidence = todo->relatedTo(); while ( incidence ) { if ( incidence->type() == "Todo") { //qDebug("related %s ",incidence->summary().latin1() ); if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { //qDebug("related not found "); todoList.remove( ); todo = todoList.current(); next = false; incidence = 0; } else { //qDebug("related found "); incidence = incidence->relatedTo(); } } else incidence = 0; } if ( next ) todo = todoList.next(); } for(todo = todoList.first(); todo; todo = todoList.next()) { if (!mTodoMap.contains(todo) && checkTodo( todo ) ) { insertTodoItem(todo); } } // Restore opened/closed state mTodoListView->blockSignals( true ); if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); resetCurrentItem(); processSelectionChange(); } void KOTodoView::storeCurrentItem() { mCurItem = 0; mCurItemRootParent = 0; mCurItemParent = 0; mCurItemAbove = 0; mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); if (mActiveItem) { mCurItem = mActiveItem->todo(); KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); if ( activeItemAbove ) mCurItemAbove = activeItemAbove->todo(); mCurItemRootParent = mCurItem; mCurItemParent = mCurItemRootParent->relatedTo(); while ( mCurItemRootParent->relatedTo() != 0 ) mCurItemRootParent = mCurItemRootParent->relatedTo(); } mActiveItem = 0; } void KOTodoView::resetCurrentItem() { mTodoListView->setFocus(); KOTodoViewItem* foundItem = 0; KOTodoViewItem* foundItemRoot = 0; KOTodoViewItem* foundItemParent = 0; KOTodoViewItem* foundItemAbove = 0; if ( mTodoListView->firstChild () ) { if ( mCurItem ) { KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); while ( item ) { if ( item->todo() == mCurItem ) { foundItem = item; break; } else if ( item->todo() == mCurItemAbove ) { foundItemAbove = item; } if ( item->todo() == mCurItemRootParent ) { foundItemRoot = item; } if ( item->todo() == mCurItemParent ) { foundItemParent = item; } item = (KOTodoViewItem*)item->itemBelow(); } if ( ! foundItem ) { if ( foundItemParent ) { foundItem = foundItemParent; } else { if ( foundItemRoot ) foundItem = foundItemRoot; else foundItem = foundItemAbove; } } } if ( foundItem ) { mTodoListView->setCurrentItem( foundItem ); mTodoListView->ensureItemVisible( foundItem ); } else { mTodoListView->setCurrentItem( mTodoListView->firstChild () ); } } mTodoListView->setFocus(); } //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; bool KOTodoView::checkTodo( Todo * todo ) { if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) return false; if ( !todo->isCompleted() ) { if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) return true; } if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { if ( todo->hasStartDate() ) if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) return false; if ( todo->hasDueDate() ) if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) return false; } return true; } void KOTodoView::restoreItemState( QListViewItem *item ) { pendingSubtodo = 0; while( item ) { KOTodoViewItem *todoItem = (KOTodoViewItem *)item; todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); item = item->nextSibling(); } } QMap<Todo *,KOTodoViewItem *>::ConstIterator KOTodoView::insertTodoItem(Todo *todo) { // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; // TODO: Check, if dynmaic cast is necessary pendingSubtodo = 0; Incidence *incidence = todo->relatedTo(); if (incidence && incidence->type() == "Todo") { Todo *relatedTodo = static_cast<Todo *>(incidence); // kdDebug() << " has Related" << endl; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(relatedTodo); if (itemIterator == mTodoMap.end()) { // kdDebug() << " related not yet in list" << endl; itemIterator = insertTodoItem (relatedTodo); } // isn't this pretty stupid? We give one Todo to the KOTodoViewItem // and one into the map. Sure finding is more easy but why? -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); return mTodoMap.insert(todo,todoItem); } else { // kdDebug() << " no Related" << endl; // see above -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); return mTodoMap.insert(todo,todoItem); } } void KOTodoView::updateConfig() { updateView(); mTodoListView->repaintContents(); } QPtrList<Incidence> KOTodoView::selectedIncidences() { QPtrList<Incidence> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } QPtrList<Todo> KOTodoView::selectedTodos() { QPtrList<Todo> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } void KOTodoView::changeEventDisplay(Event *, int) { updateView(); } void KOTodoView::showDates(const QDate &, const QDate &) { } void KOTodoView::showEvents(QPtrList<Event>) { kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; } void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Todolist, fd, td); #endif } void KOTodoView::editItem(QListViewItem *item ) { emit editTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) { emit showTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) { pendingSubtodo = 0; mActiveItem = (KOTodoViewItem *)item; if (item) { switch (column){ case 1: mPriorityPopupMenu->popup(QCursor::pos ()); break; case 2: mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; case 3: moveTodo(); break; case 8: getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); } } else mPopupMenu->popup(QCursor::pos()); } void KOTodoView::newTodo() { emit newTodoSignal(); } void KOTodoView::newSubTodo() { if (mActiveItem) { emit newSubTodoSignal(mActiveItem->todo()); } } void KOTodoView::unparentTodo() { if (mActiveItem) { emit unparentTodoSignal(mActiveItem->todo()); } } void KOTodoView::reparentTodo() { if (mActiveItem) { topLevelWidget()->setCaption(i18n("Click on new parent item")); pendingSubtodo = mActiveItem; } } void KOTodoView::editTodo() { if (mActiveItem) { emit editTodoSignal(mActiveItem->todo()); } } void KOTodoView::cloneTodo() { if (mActiveItem) { emit cloneTodoSignal((Incidence*)mActiveItem->todo()); } diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 87cef20..68e5e5a 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -209,768 +209,774 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : filterMenubar = 0; filterPopupMenu = 0; } if ( p->mShowIconOnetoolbar ) { viewToolBar = iconToolBar ; navigatorToolBar = iconToolBar ; } else { #ifndef DESKTOP_VERSION setToolBarsMovable( false ); #endif if ( p->mToolBarHorV ) { if ( p->mToolBarUpV ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpV ) tbd = Right; else tbd = Left; } viewToolBar = new QPEToolBar( this ); addToolBar (viewToolBar , tbd ); if ( p->mToolBarHorN ) { if ( p->mToolBarUpN ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpN ) tbd = Right; else tbd = Left; } navigatorToolBar = new QPEToolBar( this ); addToolBar (navigatorToolBar , tbd ); } mCalendarModifiedFlag = false; QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); splash->setAlignment ( AlignCenter ); setCentralWidget( splash ); #ifndef DESKTOP_VERSION showMaximized(); #endif //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); setDefaultPreferences(); mCalendar = new CalendarLocal(); mView = new CalendarView( mCalendar, this,"mCalendar " ); mView->hide(); //mView->resize(splash->size() ); initActions(); mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); mSyncManager->setBlockSave(false); mView->setSyncManager(mSyncManager); #ifndef DESKTOP_VERSION iconToolBar->show(); qApp->processEvents(); #endif //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); int vh = height() ; int vw = width(); //qDebug("Toolbar hei %d ",iconToolBar->height() ); if ( iconToolBar->orientation () == Qt:: Horizontal ) { vh -= iconToolBar->height(); } else { vw -= iconToolBar->height(); } //mView->setMaximumSize( splash->size() ); //mView->resize( splash->size() ); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); mView->readSettings(); bool newFile = false; if( !QFile::exists( defaultFileName() ) ) { QFileInfo finfo ( defaultFileName() ); QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } else { oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } } mView->saveCalendar( defaultFileName() ); newFile = true; } QTime neededSaveTime = QDateTime::currentDateTime().time(); mView->openCalendar( defaultFileName() ); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Calendar loading time: %d ms",msNeeded ); if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { KOPrefs::instance()->setAllDefaults(); int count = mView->addCategories(); } processIncidenceSelection( 0 ); connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processIncidenceSelection( Incidence * ) ) ); connect( mView, SIGNAL( modifiedChanged( bool ) ), SLOT( slotModifiedChanged( bool ) ) ); connect( mView, SIGNAL( tempDisableBR(bool) ), SLOT( disableBR(bool) ) ); connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); mView->setModified( false ); mBlockAtStartup = false; mView->setModified( false ); setCentralWidget( mView ); globalFlagBlockStartup = 0; mView->show(); delete splash; if ( newFile ) mView->updateConfig(); // qApp->processEvents(); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); //fillSyncMenu(); connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); mSyncManager->setDefaultFileName( sentSyncFile()); connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); mSyncManager->fillSyncMenu(); mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); if ( showWarning ) { KMessageBox::information( this, "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); qApp->processEvents(); mView->dialogManager()->showSyncOptions(); } //US listen for result adressed from Ka/Pi #ifndef DESKTOP_VERSION connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); #endif #ifndef DESKTOP_VERSION infrared = 0; #endif updateFilterToolbar(); updateWeek( mView->startDate() ); connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( updateWeekNum( const KCal::DateList & ) ) ); mBRdisabled = false; //toggleBeamReceive(); } MainWindow::~MainWindow() { //qDebug("MainWindow::~MainWindow() "); //save toolbar location delete mCalendar; delete mSyncManager; #ifndef DESKTOP_VERSION if ( infrared ) delete infrared; #endif } void MainWindow::disableBR(bool b) { #ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive(); mBRdisabled = true; } mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; //makes no sense,because other cal ap is probably running // toggleBeamReceive(); } } #endif } bool MainWindow::beamReceiveEnabled() { #ifndef DESKTOP_VERSION return ( infrared != 0 ); #endif return false; } void MainWindow::toggleBeamReceive() { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("KO: Disable BeamReceive "); delete infrared; infrared = 0; brAction->setOn(false); return; } qDebug("KO: Enable BeamReceive "); brAction->setOn(true); infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); #endif } void MainWindow::showMaximized () { #ifndef DESKTOP_VERSION if ( ! globalFlagBlockStartup ) if ( mClosed ) mView->goToday(); #endif QWidget::showMaximized () ; mClosed = false; } void MainWindow::closeEvent( QCloseEvent* ce ) { if ( ! KOPrefs::instance()->mAskForQuit ) { saveOnClose(); mClosed = true; ce->accept(); return; } switch( QMessageBox::information( this, "KO/Pi", i18n("Do you really want\nto close KO/Pi?"), i18n("Close"), i18n("No"), 0, 0 ) ) { case 0: saveOnClose(); mClosed = true; ce->accept(); break; case 1: ce->ignore(); break; case 2: default: break; } } void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) { QDataStream stream( data, IO_ReadOnly ); // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); //QString datamess; //qDebug("message "); qDebug("KO: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; //qDebug("filename %s ", fileName.latin1()); showMaximized(); raise(); KOPrefs::instance()->mLastSyncedLocalFile = fileName ; mSyncManager->slotSyncMenu( 1002 ); return; } if ( cmsg == "-writeFile" ) { // I made from the "-writeFile" an "-writeAlarm" mView->viewManager()->showWhatsNextView(); mCalendar->checkAlarmForIncidence( 0, true); showMaximized(); raise(); return; } if ( cmsg == "-writeFileSilent" ) { // I made from the "-writeFile" an "-writeAlarm" // mView->viewManager()->showWhatsNextView(); mCalendar->checkAlarmForIncidence( 0, true); //showMaximized(); //raise(); hide(); return; } if ( cmsg == "-newCountdown" ) { qDebug("newCountdown "); } QString msg ; QString allmsg = cmsg; while ( allmsg.length() > 0 ) { int nextC = allmsg.find( "-", 1 ); if ( nextC == -1 ) { msg = allmsg; allmsg = ""; } else{ msg = allmsg.left( nextC ); allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); } //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); if ( msg == "-newEvent" ) { mView->newEvent(); } if ( msg == "-newTodo" ) { mView->newTodo(); } if ( msg == "-showWN" ) { mView->viewManager()->showWhatsNextView(); } if ( msg == "-showTodo" ) { mView->viewManager()->showTodoView(); } if ( msg == "-showList" ) { mView->viewManager()->showListView(); } else if ( msg == "-showDay" ) { mView->viewManager()->showDayView(); } else if ( msg == "-showWWeek" ) { mView->viewManager()->showWorkWeekView(); } else if ( msg == "-ringSync" ) { mSyncManager->multiSync( false ); } else if ( msg == "-showWeek" ) { mView->viewManager()->showWeekView(); } else if ( msg == "-showTodo" ) { mView->viewManager()->showTodoView(); } else if ( msg == "-showJournal" ) { mView->dateNavigator()->selectDates( 1 ); mView->dateNavigator()->selectToday(); mView->viewManager()->showJournalView(); } else if ( msg == "-showKO" ) { mView->viewManager()->showNextXView(); } else if ( msg == "-showWNext" ) { mView->viewManager()->showWhatsNextView(); } else if ( msg == "nextView()" ) { mView->viewManager()->showNextView(); } else if ( msg == "-showNextXView" ) { mView->viewManager()->showNextXView(); } } showMaximized(); raise(); } QPixmap MainWindow::loadPixmap( QString name ) { return SmallIcon( name ); } +void MainWindow::setUsesBigPixmaps ( bool b ) +{ + qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); + if ( b ) + qDebug("KO: BigPixmaps are not supported "); +} void MainWindow::initActions() { //KOPrefs::instance()->mShowFullMenu iconToolBar->clear(); KOPrefs *p = KOPrefs::instance(); //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); QPopupMenu *viewMenu = new QPopupMenu( this ); QPopupMenu *actionMenu = new QPopupMenu( this ); QPopupMenu *importMenu = new QPopupMenu( this ); QPopupMenu *importMenu_X = new QPopupMenu( this ); QPopupMenu *exportMenu_X = new QPopupMenu( this ); QPopupMenu *beamMenu_X = new QPopupMenu( this ); selectFilterMenu = new QPopupMenu( this ); selectFilterMenu->setCheckable( true ); syncMenu = new QPopupMenu( this ); configureAgendaMenu = new QPopupMenu( this ); configureToolBarMenu = new QPopupMenu( this ); QPopupMenu *helpMenu = new QPopupMenu( this ); QIconSet icon; int pixWid = 22, pixHei = 22; QString pathString = ""; if ( !p->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) { pathString += "icons16/"; pixWid = 18; pixHei = 16; } } else { pathString += "iconsmini/"; pixWid = 18; pixHei = 16; } if ( KOPrefs::instance()->mShowFullMenu ) { QMenuBar *menuBar1; menuBar1 = menuBar(); menuBar1->insertItem( i18n("File"), importMenu ); menuBar1->insertItem( i18n("View"), viewMenu ); menuBar1->insertItem( i18n("Actions"), actionMenu ); #ifdef DESKTOP_VERSION menuBar1->insertItem( i18n("Synchronize"), syncMenu ); menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); #else menuBar1->insertItem( i18n("Sync"), syncMenu ); menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); #endif //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); menuBar1->insertItem( i18n("Help"), helpMenu ); } else { QPEMenuBar *menuBar1; menuBar1 = new QPEMenuBar( iconToolBar ); QPopupMenu *menuBar = new QPopupMenu( this ); icon = loadPixmap( pathString + "z_menu" ); menuBar1->insertItem( icon.pixmap(), menuBar); //menuBar1->insertItem( i18n("ME"), menuBar); menuBar->insertItem( i18n("File"), importMenu ); menuBar->insertItem( i18n("View"), viewMenu ); menuBar->insertItem( i18n("Actions"), actionMenu ); menuBar->insertItem( i18n("Synchronize"), syncMenu ); menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); menuBar->insertItem( i18n("Filter"),selectFilterMenu ); menuBar->insertItem( i18n("Help"), helpMenu ); //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); menuBar1->setMaximumSize( menuBar1->sizeHint( )); } connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); mWeekBgColor = iconToolBar->backgroundColor(); mWeekPixmap.resize( pixWid , pixHei ); mWeekPixmap.fill( mWeekBgColor ); icon = mWeekPixmap; mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); if ( p-> mShowIconWeekNum ) mWeekAction->addTo( iconToolBar ); mWeekFont = font(); int fontPoint = mWeekFont.pointSize(); QFontMetrics f( mWeekFont ); int fontWid = f.width( "30" ); while ( fontWid > pixWid ) { --fontPoint; mWeekFont.setPointSize( fontPoint ); QFontMetrics f( mWeekFont ); fontWid = f.width( "30" ); //qDebug("dec-- "); } connect( mWeekAction, SIGNAL( activated() ), this, SLOT( weekAction() ) ); connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); if ( p->mShowIconFilterview ) { icon = loadPixmap( pathString + "filter" ); actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); connect( actionFilterMenuTB, SIGNAL( activated() ), this, SLOT( fillFilterMenuTB() ) ); actionFilterMenuTB->addTo( iconToolBar ); selectFilterMenuTB = new QPopupMenu( this ); selectFilterMenuTB->setCheckable( true ); connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); } //#endif // ****************** QAction *action; // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); configureToolBarMenu->setCheckable( true ); configureAgendaMenu->setCheckable( true ); int iii ; for ( iii = 1;iii<= 10 ;++iii ){ configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); } //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); connect( configureAgendaMenu, SIGNAL( aboutToShow()), this, SLOT( showConfigureAgenda( ) ) ); icon = loadPixmap( pathString + "configure" ); action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); action->addTo( actionMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( edit_options() ) ); actionMenu->insertSeparator(); action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); action->addTo( actionMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( undo_delete() ) ); actionMenu->insertSeparator(); icon = loadPixmap( pathString + "newevent" ); configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); configureToolBarMenu->insertSeparator(); configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); configureToolBarMenu->insertSeparator(); configureToolBarMenu->insertItem(i18n("Week Number"), 400); configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); ne_action->addTo( actionMenu ); connect( ne_action, SIGNAL( activated() ), mView, SLOT( newEvent() ) ); icon = loadPixmap( pathString + "newtodo" ); configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); nt_action->addTo( actionMenu ); connect( nt_action, SIGNAL( activated() ), mView, SLOT( newTodo() ) ); icon = loadPixmap( pathString + "today" ); QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); today_action->addTo( viewMenu ); connect( today_action, SIGNAL( activated() ), mView, SLOT( goToday() ) ); viewMenu->insertSeparator(); // *********************** if ( KOPrefs::instance()->mVerticalScreen ) { icon = SmallIcon( "1updownarrow" ); } else { icon = SmallIcon("1leftrightarrow" ); } configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); FSaction->addTo( viewMenu ); connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); icon = loadPixmap( pathString + "navi" ); configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); action->addTo( viewMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( toggleDateNavigatorWidget() ) ); mToggleNav = action ; icon = loadPixmap( pathString + "filter" ); configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); action->addTo( viewMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( toggleFilter() ) ); mToggleFilter = action; icon = loadPixmap( pathString + "allday" ); configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); action->addTo( viewMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( toggleAllDaySize() ) ); mToggleAllday = action; connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), mToggleNav, SLOT( setEnabled ( bool ) ) ); connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), mToggleFilter, SLOT( setEnabled ( bool ) ) ); connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), mToggleAllday, SLOT( setEnabled ( bool ) ) ); viewMenu->insertSeparator(); icon = loadPixmap( pathString + "picker" ); action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); action->addTo( viewMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( showDatePicker() ) ); action->addTo( iconToolBar ); viewMenu->insertSeparator(); if ( p-> mShowIconToggleFull ) FSaction->addTo( iconToolBar ); if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); //******************** if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); icon = loadPixmap( pathString + "whatsnext" ); configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); whatsnext_action->addTo( viewMenu ); connect( whatsnext_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showWhatsNextView() ) ); icon = loadPixmap( pathString + "xdays" ); configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); xdays_action->addTo( viewMenu ); connect( xdays_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showNextXView() ) ); icon = loadPixmap( pathString + "journal" ); configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); viewjournal_action->addTo( viewMenu ); connect( viewjournal_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showJournalView() ) ); icon = loadPixmap( pathString + "day" ); configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); day1_action->addTo( viewMenu ); // action->addTo( toolBar ); connect( day1_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showDayView() ) ); icon = loadPixmap( pathString + "workweek" ); configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); day5_action->addTo( viewMenu ); connect( day5_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showWorkWeekView() ) ); icon = loadPixmap( pathString + "week" ); configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); day7_action->addTo( viewMenu ); connect( day7_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showWeekView() ) ); icon = loadPixmap( pathString + "workweek2" ); configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); day6_action->addTo( viewMenu ); connect( day6_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showMonthViewWeek() ) ); icon = loadPixmap( pathString + "month" ); configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); month_action->addTo( viewMenu ); connect( month_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showMonthView() ) ); icon = loadPixmap( pathString + "list" ); configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); showlist_action->addTo( viewMenu ); connect( showlist_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showListView() ) ); icon = loadPixmap( pathString + "todo" ); configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); todoview_action->addTo( viewMenu ); connect( todoview_action, SIGNAL( activated() ), mView->viewManager(), SLOT( showTodoView() ) ); #if 0 action = new QAction( "view_timespan", "Time Span", 0, this ); action->addTo( viewMenu ); connect( action, SIGNAL( activated() ), mView->viewManager(), SLOT( showTimeSpanView() ) ); #endif mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, this ); mNewSubTodoAction->addTo( actionMenu ); connect( mNewSubTodoAction, SIGNAL( activated() ), mView, SLOT( newSubTodo() ) ); actionMenu->insertSeparator(); mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); mShowAction->addTo( actionMenu ); connect( mShowAction, SIGNAL( activated() ), mView, SLOT( showIncidence() ) ); mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); mEditAction->addTo( actionMenu ); connect( mEditAction, SIGNAL( activated() ), mView, SLOT( editIncidence() ) ); mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); mDeleteAction->addTo( actionMenu ); connect( mDeleteAction, SIGNAL( activated() ), mView, SLOT( deleteIncidence() ) ); mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); mCloneAction->addTo( actionMenu ); connect( mCloneAction, SIGNAL( activated() ), mView, SLOT( cloneIncidence() ) ); mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); mMoveAction->addTo( actionMenu ); connect( mMoveAction, SIGNAL( activated() ), mView, SLOT( moveIncidence() ) ); mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); mBeamAction->addTo( actionMenu ); connect( mBeamAction, SIGNAL( activated() ), mView, SLOT( beamIncidence() ) ); mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); mCancelAction->addTo( actionMenu ); connect( mCancelAction, SIGNAL( activated() ), mView, SLOT( toggleCancelIncidence() ) ); actionMenu->insertSeparator(); action = new QAction( "purge_completed", i18n("Purge Completed"), 0, this ); action->addTo( actionMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); icon = loadPixmap( pathString + "search" ); QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); search_action->addTo( actionMenu ); connect( search_action, SIGNAL( activated() ), mView->dialogManager(), SLOT( showSearchDialog() ) ); if ( KOPrefs::instance()->mShowFullMenu ) { actionMenu->insertSeparator(); actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); } // actionMenu->insertSeparator(); action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); action = new QAction( "import_quick", i18n("Import last file"), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); importMenu_X->insertSeparator(); action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); //#ifndef DESKTOP_VERSION importMenu_X->insertSeparator(); action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, this ); action->addTo( importMenu_X ); connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); //#else #ifdef _OL_IMPORT_ diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 8fd3d24..6895e36 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -1,166 +1,167 @@ #ifndef KORGE_MAINWINDOW_H #define KORGE_MAINWINDOW_H #include <qmainwindow.h> #include <qtimer.h> #include <qdict.h> #include <qfile.h> #include <qmenubar.h> #include <qtextstream.h> #include <qregexp.h> #include <libkcal/incidence.h> #include <ksyncmanager.h> #ifndef DESKTOP_VERSION #include <qcopchannel_qws.h> #endif class QAction; class CalendarView; class KSyncProfile; #ifdef DESKTOP_VERSION #define QPEToolBar QToolBar #define QPEMenuBar QMenuBar #endif class QPEToolBar; class QPEMenuBar; namespace KCal { class CalendarLocal; } using namespace KCal; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); ~MainWindow(); bool beamReceiveEnabled(); static QString defaultFileName(); static QString syncFileName(); static QString resourcePath(); public slots: + void setUsesBigPixmaps ( bool ); void setCaption ( const QString & ); void updateWeekNum(const KCal::DateList &); void updateWeek(QDate); void updateFilterToolbar(); virtual void showMaximized (); void configureAgenda( int ); void recieve( const QCString& msg, const QByteArray& data ); protected slots: void setCaptionToDates(); void weekAction(); void about(); void licence(); void faq(); void usertrans(); void features(); void synchowto(); void storagehowto(); void timetrackinghowto(); void kdesynchowto(); void multisynchowto(); void whatsNew(); void keyBindings(); void aboutAutoSaving();; void aboutKnownBugs(); void processIncidenceSelection( Incidence * ); void importQtopia(); void importBday(); void importOL(); void importIcal(); void importFile( QString, bool ); void quickImportIcal(); void slotModifiedChanged( bool ); void save(); void saveStopTimer(); void configureToolBar( int ); void printSel(); void printCal(); void saveCalendar(); void loadCalendar(); void exportVCalendar(); void fillFilterMenu(); void fillFilterMenuTB(); void selectFilter( int ); void fillFilterMenuPopup(); void selectFilterPopup( int ); void exportToPhone( int ); void toggleBeamReceive(); void disableBR(bool); signals: void selectWeek ( int ); private slots: void showConfigureAgenda(); void getFile( bool ); void syncFileRequest(); protected: void hideEvent ( QHideEvent * ); QString sentSyncFile(); void displayText( QString, QString); void enableIncidenceActions( bool ); private: bool mBRdisabled; #ifndef DESKTOP_VERSION QCopChannel* infrared; #endif QAction* brAction; KSyncManager* mSyncManager; bool mClosed; void saveOnClose(); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; QPEToolBar *viewToolBar; QPEToolBar *navigatorToolBar; QPEToolBar *filterToolBar; QMenuBar *filterMenubar; QPopupMenu * filterPopupMenu; void initActions(); void setDefaultPreferences(); void resizeEvent( QResizeEvent* e); void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; QPopupMenu *configureToolBarMenu; QPopupMenu *selectFilterMenu; QPopupMenu *selectFilterMenuTB; QPopupMenu *configureAgendaMenu, *syncMenu; CalendarLocal *mCalendar; CalendarView *mView; QAction *mNewSubTodoAction; QAction *mWeekAction; QFont mWeekFont; QPixmap mWeekPixmap; QColor mWeekBgColor; QAction *mShowAction; QAction *mEditAction; QAction *mDeleteAction; QAction *mCloneAction; QAction *mMoveAction; QAction *mBeamAction; QAction *mCancelAction; QAction *mToggleNav; QAction *mToggleFilter; QAction *mToggleAllday; QAction *actionFilterMenuTB; void closeEvent( QCloseEvent* ce ); QTimer mSaveTimer; //bool mBlockSaveFlag; bool mCalendarModifiedFlag; QPixmap loadPixmap( QString ); }; #endif |