author | zautrix <zautrix> | 2005-03-25 18:26:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 18:26:36 (UTC) |
commit | 89a72c007045dcfa5dbf57012b4cf0c2aebd1495 (patch) (side-by-side diff) | |
tree | 6accbe5706b724e307d1590152fa2d2c78cdef70 | |
parent | 3326831dbf6f962e97a978781361db5198f6a035 (diff) | |
download | kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.zip kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.gz kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.bz2 |
layout fixes
-rw-r--r-- | korganizer/koagenda.cpp | 77 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 46 | ||||
-rw-r--r-- | korganizer/kolistview.h | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 11 |
5 files changed, 48 insertions, 90 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 2820ca2..66ad4ec 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -114,129 +114,129 @@ void MarcusBains::updateLocation(bool recalculate) QTime tim = QTime::currentTime(); //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); if((tim.hour() == 0) && (oldTime.hour()==23)) recalculate = true; int mins = tim.hour()*60 + tim.minute(); int minutesPerCell = 24 * 60 / agenda->rows(); int y = mins*agenda->gridSpacingY()/minutesPerCell; int today = recalculate ? todayColumn() : oldToday; int x = agenda->gridSpacingX()*today; bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); oldTime = tim; oldToday = today; if(disabled || (today<0)) { hide(); mTimeBox->hide(); return; } else { show(); mTimeBox->show(); } if(recalculate) setFixedSize(agenda->gridSpacingX(),1); agenda->moveChild(this, x, y); raise(); if(recalculate) //mTimeBox->setFont(QFont("helvetica",10)); mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); mTimeBox->adjustSize(); // the -2 below is there because there is a bug in this program // somewhere, where the last column of this widget is a few pixels // narrower than the other columns. int offs = (today==agenda->columns()-1) ? -4 : 0; agenda->moveChild(mTimeBox, x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, y-mTimeBox->height()); mTimeBox->raise(); //mTimeBox->setAutoMask(true); minutes->start(5000,true); } //////////////////////////////////////////////////////////////////////////// /* Create an agenda widget with rows rows and columns columns. */ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, const char *name,WFlags f) : QScrollView(parent,name,f) { mColumns = columns; mRows = rows; mGridSpacingY = rowSize; mAllDayMode = false; #ifndef DESKTOP_VERSION - //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); + QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); } /* Create an agenda widget with columns columns and one row. This is used for all-day events. */ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { blockResize = false; mColumns = columns; mRows = 1; //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); mGridSpacingY = KOPrefs::instance()->mAllDaySize; mAllDayMode = true; #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); } KOAgenda::~KOAgenda() { if(mMarcusBains) delete mMarcusBains; } Incidence *KOAgenda::selectedIncidence() const { return (mSelectedItem ? mSelectedItem->incidence() : 0); } QDate KOAgenda::selectedIncidenceDate() const { return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); } void KOAgenda::init() { mNewItemPopup = new QPopupMenu( this ); connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) pathString += "icons16/"; } else pathString += "iconsmini/"; mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); mNewItemPopup->insertSeparator ( ); mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); @@ -337,281 +337,268 @@ void KOAgenda::marcus_bains() { if(mMarcusBains) mMarcusBains->updateLocation(true); } void KOAgenda::changeColumns(int columns) { if (columns == 0) { kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; return; } clear(); mColumns = columns; // setMinimumSize(mColumns * 10, mGridSpacingY + 1); // init(); // update(); //qDebug("KOAgenda::changeColumns "); computeSizes(); // QResizeEvent event( size(), size() ); //QApplication::sendEvent( this, &event ); } /* This is the eventFilter function, which gets all events from the KOAgendaItems contained in the agenda. It has to handle moving and resizing for all items. */ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) { // kdDebug() << "KOAgenda::eventFilter" << endl; switch(event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: case QEvent::MouseMove: return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); case (QEvent::Leave): if (!mActionItem) setCursor(arrowCursor); return true; default: return QScrollView::eventFilter(object,event); } } bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) { //qDebug("KOAgenda::eventFilter_mous "); QPoint viewportPos; if (object != viewport()) { viewportPos = ((QWidget *)object)->mapToParent(me->pos()); } else { viewportPos = me->pos(); } static int startX = 0; static int startY = 0; static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); static bool blockMoving = true; static bool leftMouseDown = false; - static bool rightMouseDown = false; - static QTime rightClickTime; bool rightButtonPressed = false; switch (me->type()) { case QEvent::MouseButtonPress: - rightClickTime.restart(); if (me->button() == LeftButton) { leftMouseDown = true; } - else if (me->button() == RightButton) - rightMouseDown = true; + else if (me->button() == RightButton) { + leftMouseDown = false; + } blockMoving = true; startX = viewportPos.x(); startY = viewportPos.y(); - if (object != viewport()) { + if (object != viewport()) { // item clicked ************** if (me->button() == RightButton) { + leftMouseDown = false; mClickedItem = (KOAgendaItem *)object; + if (mActionItem ) { + endItemAction(); + } if (mClickedItem) { selectItem(mClickedItem); - } + emit showIncidencePopupSignal(mClickedItem->incidence()); + } + return true; } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { if ( mSelectionHeight > 0 ) { int selectionCellX = mSelectionCellX * mGridSpacingX; int selectionYTop = mSelectionYTop; int gridSpacingX = mGridSpacingX; int selectionHeight = mSelectionHeight; clearSelection(); repaintContents( selectionCellX, selectionYTop, gridSpacingX, selectionHeight,false ); } selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } } } } else { // ---------- viewport() selectItem(0); mActionItem = 0; if (me->button() == LeftButton ) { setCursor(arrowCursor); startSelectAction(viewportPos); + } else if (me->button() == RightButton ) { + setCursor(arrowCursor); + if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action + endSelectAction( false ); // do not emit new event signal + leftMouseDown = false; // no more leftMouse computation + } + int x,y; + viewportToContents(viewportPos.x(),viewportPos.y(),x,y); + int gx,gy; + contentsToGrid(x,y,gx,gy); + mCurrentCellX = gx; + mCurrentCellY = gy; + mStartCellX = gx; + mStartCellY = gy; + mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); } } break; case QEvent::MouseButtonRelease: - if ( rightClickTime.elapsed() > 500 && blockMoving ) - rightButtonPressed = true; + if (object != viewport()) { - if (me->button() == RightButton || rightButtonPressed ) { - if ( blockMoving ) { - mClickedItem = (KOAgendaItem *)object; - if (mActionItem ) { - endItemAction(); - } - leftMouseDown = false; // no more leftMouse computation - if (mClickedItem) { - selectItem(mClickedItem); - emit showIncidencePopupSignal(mClickedItem->incidence()); - } - } - } else if (me->button() == LeftButton && leftMouseDown) { + if (me->button() == LeftButton && leftMouseDown) { if (mActionItem) { QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { mScrollUpTimer.stop(); mScrollDownTimer.stop(); mActionItem->resetMove(); placeSubCells( mActionItem ); // emit startDragSignal( mActionItem->incidence() ); setCursor( arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; leftMouseDown = false; return true; } endItemAction(); } } } else { // ---------- viewport() - if (me->button() == RightButton || rightButtonPressed ) { //right click - if ( blockMoving ) { // we did mot moved the mouse much - popup menu - if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action - endSelectAction( false ); // do not emit new event signal - leftMouseDown = false; // no more leftMouse computation - } - int x,y; - viewportToContents(viewportPos.x(),viewportPos.y(),x,y); - int gx,gy; - contentsToGrid(x,y,gx,gy); - mCurrentCellX = gx; - mCurrentCellY = gy; - mStartCellX = gx; - mStartCellY = gy; - mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); - } - } - else if (me->button() == LeftButton && leftMouseDown ) { //left click + if (me->button() == LeftButton && leftMouseDown ) { //left click endSelectAction( true ); // emit new event signal } } if (me->button() == LeftButton) leftMouseDown = false; - else if (me->button() == RightButton) - rightMouseDown = false; + break; case QEvent::MouseMove: - if ( !rightMouseDown && !leftMouseDown ) + if ( !leftMouseDown ) return true; if ( blockMoving ) { int dX, dY; dX = startX - viewportPos.x(); if ( dX < 0 ) dX = -dX; dY = viewportPos.y() - startY; if ( dY < 0 ) dY = -dY; //qDebug("%d %d %d ", dX, dY , blockmoveDist ); if ( dX > blockmoveDist || dY > blockmoveDist ) { blockMoving = false; } } if (object != viewport()) { KOAgendaItem *moveItem = (KOAgendaItem *)object; if (!moveItem->incidence()->isReadOnly() ) { if (!mActionItem) setNoActionCursor(moveItem,viewportPos); else { if ( !blockMoving ) performItemAction(viewportPos); } } } else { // ---------- viewport() if ( mActionType == SELECT ) { performSelectAction( viewportPos ); } } break; case QEvent::MouseButtonDblClick: blockMoving = false; leftMouseDown = false; - rightMouseDown = false; if (object == viewport()) { selectItem(0); int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); emit newEventSignal(gx,gy); } else { KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; selectItem(doubleClickedItem); if ( KOPrefs::instance()->mEditOnDoubleClick ) emit editIncidenceSignal(doubleClickedItem->incidence()); else emit showIncidenceSignal(doubleClickedItem->incidence()); } break; default: break; } return true; } void KOAgenda::newItem( int item ) { if ( item == 1 ) { //new event newEventSignal(mStartCellX ,mStartCellY ); } else if ( item == 2 ) { //new event newTodoSignal(mStartCellX ,mStartCellY ); } else { QDate day = mSelectedDates[mStartCellX]; emit showDateView( item, day ); // 3Day view // 4Week view // 5Month view // 6Journal view } } void KOAgenda::startSelectAction(QPoint viewportPos) { //emit newStartSelectSignal(); mActionType = SELECT; int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); mStartCellX = gx; mStartCellY = gy; mCurrentCellX = gx; mCurrentCellY = gy; // Store coordinates of old selection int selectionX = mSelectionCellX * mGridSpacingX; int selectionYTop = mSelectionYTop; int selectionHeight = mSelectionHeight; // Store new selection mSelectionCellX = gx; mSelectionYTop = gy * mGridSpacingY; diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index b30ad75..905c1bf 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -14,129 +14,129 @@ 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 #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 ); + 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); diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 3519985..6b63d7f 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -247,129 +247,129 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, mListView->setColumnWidthMode(10, QListView::Manual); 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(rightButtonClicked ( 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; } 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; @@ -1098,130 +1098,98 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) 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 ) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif - mYMousePos = -1000; setSelectionMode( QListView::Multi ); setMultiSelection( true); - mAllowPopupMenu = true; - mMouseDown = false; - } 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); } - void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) { //qDebug("contentsMousePressEvent++++ "); - if (! mMouseDown ) { - mAllowPopupMenu = true; - mYMousePos = mapToGlobal( (e->pos())).y(); - } - if ( e->button() == RightButton && mMouseDown ) - return; - if ( e->button() == LeftButton ) - mMouseDown = true; KListView::contentsMousePressEvent( e ); + if ( e->button() == RightButton ) { + QListViewItem* ci = currentItem(); + clearSelection () ; + if ( ci ) + ci->setSelected( true ); + } } void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) { - //qDebug("contentsMouseReleaseEv---- "); - if ( ! mMouseDown ) { - if ( e->button() == RightButton && ! mAllowPopupMenu ) - return; - QListViewItem* ci = currentItem(); - if ( ci ) - ci->setSelected( true ); - KListView::contentsMouseReleaseEvent(e); - return; - } - if ( e->button() == LeftButton ) - mMouseDown = false; - if ( e->button() == RightButton && ! mAllowPopupMenu ) - return; - if ( e->button() == RightButton ) { - QListViewItem* ci = currentItem(); - if ( ci ) - ci->setSelected( true ); - } 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 > 20 ) - mAllowPopupMenu = false; KListView::contentsMouseMoveEvent(e); } diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index 0d9c525..eca71e2 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -162,131 +162,129 @@ void pickAlarmProgram() 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* ); private: void keyPressEvent ( QKeyEvent * ) ; void contentsMouseDoubleClickEvent(QMouseEvent *e); void contentsMousePressEvent(QMouseEvent *e); void contentsMouseReleaseEvent(QMouseEvent *e); void contentsMouseMoveEvent(QMouseEvent *e); - bool mAllowPopupMenu; bool mMouseDown; - int mYMousePos; }; 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); void resetFocus(); signals: void signalNewEvent(); void beamIncidenceList(QPtrList<Incidence>); public slots: 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 ); diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 12233ee..9085775 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -453,128 +453,133 @@ void MonthViewCell::setMyPalette() } else { if ( mPrimary ) { if ( currentPalette == 2 ) return; mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); //mLabel->setPalette( mPrimaryPalette ); setPalette( mPrimaryPalette ); currentPalette = 2; } else { if ( currentPalette == 3 ) return; setPalette( mNonPrimaryPalette ); mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); //mLabel->setPalette( mNonPrimaryPalette );; currentPalette = 3; } } //QPalette pal = palette(); //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); } QPalette MonthViewCell::getPalette () { if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) return mStandardPalette; if ( mHoliday) { return mHolidayPalette ; } else { if ( mPrimary ) { return mPrimaryPalette ; } } return mNonPrimaryPalette; } bool MonthViewCell::isPrimary() const { return mPrimary; } void MonthViewCell::setHoliday( bool holiday ) { mHoliday = holiday; //setMyPalette(); } void MonthViewCell::setHoliday( const QString &holiday ) { mHolidayString = holiday; if ( !holiday.isEmpty() ) { setHoliday( true ); } } void MonthViewCell::startUpdateCell() { setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( true ); mitem = (MonthViewItem *)mitem->next(); } + if ( mAvailItemList.count() > 20 ) { + mAvailItemList.setAutoDelete( true ); + mAvailItemList.clear(); + mAvailItemList.setAutoDelete( false ); + } /* if ( !isVisible() ){ return; } */ // qDebug("MonthViewCell::updateCell() "); setPrimary( mDate.month()%2 ); setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); if ( mDate == QDate::currentDate() ) { setLineWidth( 3 ); } else { setLineWidth( 1 ); } mCurrentAvailItem = (MonthViewItem*) firstItem (); //clear(); #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif mToolTip.clear(); //qApp->processEvents(); #if 0 if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); insertItem( item ); mToolTip.append ( mHolidayString ); } #endif } void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; bool insertNewItem = false; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) setLineWidth( 3 ); } 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; } } @@ -756,136 +761,136 @@ void MonthViewCell::finishUpdateCell() setMyPalette(); resizeEvent( 0 ); } void MonthViewCell::updateCell() { //qDebug("MonthViewCell::updateCell() "); if ( !mMonthView->isUpdatePossible() ) return; startUpdateCell(); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); Event *event; for( event = events.first(); event; event = events.next() ) { // for event insertEvent(event); } // insert due todos QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { insertTodo( todo ); } finishUpdateCell(); // if ( isVisible()) //qApp->processEvents(); } void MonthViewCell::updateConfig( bool bigFont ) // = false { if ( bigFont ) { QFont fo = KOPrefs::instance()->mMonthViewFont; int ps = fo.pointSize() + 2; if ( ps < 18 ) ps += 2; fo.setPointSize( ps ); setFont( fo ); } else setFont( KOPrefs::instance()->mMonthViewFont ); QFontMetrics fm( font() ); mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); mHolidayPalette = mStandardPalette; mPrimaryPalette = mStandardPalette; mNonPrimaryPalette = mStandardPalette; if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); } //updateCell(); } void MonthViewCell::enableScrollBars( bool enabled ) { if ( enabled ) { - QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; - if ( hei < height() - horizontalScrollBar()->height () ) + if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); - else + } + else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) setHScrollBarMode(QScrollView::AlwaysOff); else setHScrollBarMode(QScrollView::Auto); } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { int index = currentItem(); if ( index < 0 ) return 0; MonthViewItem *mitem = static_cast<MonthViewItem *>( item( index ) ); if ( !mitem ) return 0; return mitem->incidence(); } QDate MonthViewCell::selectedIncidenceDate() { QDate qd; int index = currentItem(); if ( index < 0 ) return qd; MonthViewItem *mitem = static_cast<MonthViewItem *>( item( index ) ); if ( !mitem ) return qd; return mitem->incidenceDate(); } void MonthViewCell::deselect() { clearSelection(); enableScrollBars( false ); // updateCell(); } void MonthViewCell::select() { ;// updateCell(); } void MonthViewCell::resizeEvent ( QResizeEvent * e ) { if ( !mMonthView->isUpdatePossible() ) return; //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); deselect(); mLabel->setMaximumHeight( height() - lineWidth()*2 ); QString text; mLabel->setText( text ); bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |