summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-02 12:16:34 (UTC)
committer zautrix <zautrix>2005-04-02 12:16:34 (UTC)
commit997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (side-by-side diff)
treef788b37459574b5cea0d2ab874882c6a396c240d /korganizer
parente0d51120d2f0c178115746e0c1357af40f95bc77 (diff)
downloadkdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2
more fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp57
-rw-r--r--korganizer/koagenda.h4
-rw-r--r--korganizer/koagendaview.cpp18
-rw-r--r--korganizer/koagendaview.h4
-rw-r--r--korganizer/kotodoview.cpp49
5 files changed, 97 insertions, 35 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index deadfc9..de964da 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -75,480 +75,519 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
QPalette pal = mTimeBox->palette();
pal.setColor(QColorGroup::Foreground, Qt::red);
mTimeBox->setPalette(pal);
//mTimeBox->setAutoMask(true);
agenda->addChild(mTimeBox);
oldToday = -1;
}
MarcusBains::~MarcusBains()
{
delete minutes;
}
int MarcusBains::todayColumn()
{
QDate currentDate = QDate::currentDate();
DateList dateList = agenda->dateList();
DateList::ConstIterator it;
int col = 0;
for(it = dateList.begin(); it != dateList.end(); ++it) {
if((*it) == currentDate)
return KOGlobals::self()->reverseLayout() ?
agenda->columns() - 1 - col : col;
++col;
}
return -1;
}
void MarcusBains::updateLoc()
{
updateLocation();
}
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)
{
-
+ mAllAgendaPopup = 0;
mColumns = columns;
mRows = rows;
mGridSpacingY = rowSize;
mAllDayMode = false;
#ifndef DESKTOP_VERSION
//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)
{
+ mAllAgendaPopup = 0;
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()
{
mPopupTimer = new QTimer(this);
connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
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("This month"),6 );
mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
#ifndef _WIN32_
int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
viewport()->setWFlags ( wflags);
#endif
mGridSpacingX = 80;
mResizeBorderWidth = 8;
mScrollBorderWidth = 8;
mScrollDelay = 30;
mScrollOffset = 10;
mPaintPixmap.resize( 20,20);
//enableClipper(true);
// Grab key strokes for keyboard navigation of agenda. Seems to have no
// effect. Has to be fixed.
setFocusPolicy(WheelFocus);
connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
mStartCellX = 0;
mStartCellY = 0;
mCurrentCellX = 0;
mCurrentCellY = 0;
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
mOldLowerScrollValue = -1;
mOldUpperScrollValue = -1;
mClickedItem = 0;
mActionItem = 0;
mActionType = NOP;
mItemMoved = false;
mSelectedItem = 0;
// mItems.setAutoDelete(true);
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
viewport()->update();
setMinimumSize(30, 1);
// setMaximumHeight(mGridSpacingY * mRows + 5);
// Disable horizontal scrollbar. This is a hack. The geometry should be
// controlled in a way that the contents horizontally always fits. Then it is
// not necessary to turn off the scrollbar.
setHScrollBarMode(AlwaysOff);
if ( ! mAllDayMode )
setVScrollBarMode(AlwaysOn);
else
setVScrollBarMode(AlwaysOff);
setStartHour(KOPrefs::instance()->mDayBegins);
calculateWorkingHours();
connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
SLOT(checkScrollBoundaries(int)));
// Create the Marcus Bains line.
if(mAllDayMode)
mMarcusBains = 0;
else {
mMarcusBains = new MarcusBains(this);
addChild(mMarcusBains);
}
mPopupKind = 0;
mPopupItem = 0;
}
void KOAgenda::clear()
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
mUnusedItems.append( item );
//item->hide();
}
mItems.clear();
mSelectedItem = 0;
clearSelection();
}
void KOAgenda::clearSelection()
{
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
}
void KOAgenda::marcus_bains()
{
if(mMarcusBains) mMarcusBains->updateLocation(true);
}
void KOAgenda::changeColumns(int columns)
{
if (columns == 0) {
qDebug("KOAgenda::changeColumns() called with argument 0 ");
return;
}
clear();
mColumns = columns;
computeSizes();
}
/*
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);
}
}
void KOAgenda::popupMenu()
{
mPopupTimer->stop();
if ( mPopupKind == 1 ) {
if (mActionItem ) {
endItemAction();
}
mLeftMouseDown = false; // no more leftMouse computation
if (mPopupItem) {
selectItem(mPopupItem);
+ if ( mAllAgendaPopup )
+ mAllAgendaPopup->installEventFilter( this );
emit showIncidencePopupSignal(mPopupItem->incidence());
}
} else if ( mPopupKind == 2 ) {
if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
endSelectAction( false ); // do not emit new event signal
mLeftMouseDown = false; // no more leftMouse computation
}
+ mNewItemPopup->installEventFilter( this );
mNewItemPopup->popup( mPopupPos);
+
}
mLeftMouseDown = false;
mPopupItem = 0;
mPopupKind = 0;
}
bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
{
- //qDebug("KOAgenda::eventFilter_mous ");
+ static int startX = 0;
+ static int startY = 0;
+ static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
+ static bool blockMoving = true;
+
+ //qDebug("KOAgenda::eventFilter_mous ");
+ if ( object == mNewItemPopup ) {
+ //qDebug("mNewItemPopup ");
+ if ( me->type() == QEvent::MouseButtonRelease ) {
+ mNewItemPopup->removeEventFilter( this );
+ int dX = me->globalPos().x() - mPopupPos.x();;
+ if ( dX < 0 )
+ dX = -dX;
+ int dY = me->globalPos().y() - mPopupPos.y();
+ if ( dY < 0 )
+ dY = -dY;
+ if ( dX > blockmoveDist || dY > blockmoveDist ) {
+ mNewItemPopup->hide();
+ }
+ }
+ return true;
+ }
+ if ( object == mAllAgendaPopup ) {
+ //qDebug(" mAllAgendaPopup ");
+ if ( me->type() == QEvent::MouseButtonRelease ) {
+ mAllAgendaPopup->removeEventFilter( this );
+ int dX = me->globalPos().x() - mPopupPos.x();;
+ if ( dX < 0 )
+ dX = -dX;
+ int dY = me->globalPos().y() - mPopupPos.y();
+ if ( dY < 0 )
+ dY = -dY;
+ if ( dX > blockmoveDist || dY > blockmoveDist ) {
+ mAllAgendaPopup->hide();
+ }
+ }
+ return true;
+ }
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;
+
switch (me->type()) {
case QEvent::MouseButtonPress:
if (me->button() == LeftButton) {
mPopupTimer->start( 600 );
mLeftMouseDown = true;
}
blockMoving = true;
startX = viewportPos.x();
- startY = viewportPos.y();
+ startY = viewportPos.y();
+ mPopupPos = me->globalPos();
if (object != viewport()) {
mPopupItem = (KOAgendaItem *)object;
mPopupKind = 1;
if (me->button() == RightButton) {
popupMenu();
} 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()
mPopupItem = 0;
mPopupKind = 2;
selectItem(0);
mActionItem = 0;
- mPopupPos = viewport()->mapToGlobal( me->pos() );
if (me->button() == RightButton) {
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;
popupMenu();
} else if (me->button() == LeftButton) {
setCursor(arrowCursor);
startSelectAction(viewportPos);
}
}
break;
case QEvent::MouseButtonRelease:
if (me->button() == LeftButton ) {
mPopupTimer->stop();
}
if (object != viewport()) {
if (me->button() == LeftButton && mLeftMouseDown) {
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;
mLeftMouseDown = false;
return true;
}
endItemAction();
}
}
} else { // ---------- viewport()
if (me->button() == LeftButton && mLeftMouseDown ) { //left click
endSelectAction( true ); // emit new event signal
}
}
if (me->button() == LeftButton)
mLeftMouseDown = false;
break;
case QEvent::MouseMove:
//qDebug("mm ");
if ( !mLeftMouseDown )
return false;
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 ( ! blockMoving )
mPopupTimer->stop();
if (object != viewport()) {
KOAgendaItem *moveItem = (KOAgendaItem *)object;
if (!moveItem->incidence()->isReadOnly() ) {
if (!mActionItem)
setNoActionCursor(moveItem,viewportPos);
else {
if ( !blockMoving )
performItemAction(viewportPos);
}
}
} else { // ---------- viewport()
mPopupPos = viewport()->mapToGlobal( me->pos() );
if ( mActionType == SELECT ) {
performSelectAction( viewportPos );
}
}
break;
case QEvent::MouseButtonDblClick:
mPopupTimer->stop();
if (object == viewport()) {
selectItem(0);
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 35c08b6..4f1fdb9 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,266 +1,268 @@
/*
This file is part of KOrganizer.
Copyright (c) 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 KOAGENDA_H
#define KOAGENDA_H
#include <qscrollview.h>
#include <qtimer.h>
#include <qmemarray.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include "koagendaitem.h"
+#include "koeventview.h"
class QPopupMenu;
class QTime;
class KConfig;
class QFrame;
class KOAgenda;
class KCal::Event;
class KCal::Todo;
using namespace KCal;
class MarcusBains : public QFrame {
Q_OBJECT
public:
MarcusBains(KOAgenda *agenda=0,const char *name=0);
virtual ~MarcusBains();
public slots:
void updateLocation(bool recalculate=false);
void updateLoc();
private:
int todayColumn();
QTimer *minutes;
QLabel *mTimeBox;
KOAgenda *agenda;
QTime oldTime;
int oldToday;
};
class KOAgenda : public QScrollView
{
Q_OBJECT
public:
enum MouseActionType { NOP, MOVE, SELECT,
RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
const char * name=0, WFlags f=0 );
KOAgenda ( int columns, QWidget * parent=0,
const char * name=0, WFlags f=0 );
virtual ~KOAgenda();
Incidence *selectedIncidence() const;
QDate selectedIncidenceDate() const;
virtual bool eventFilter ( QObject *, QEvent * );
void contentsToGrid (int x, int y, int& gx, int& gy);
void gridToContents (int gx, int gy, int& x, int& y);
int timeToY (const QTime &time);
QTime gyToTime (int y);
void setStartHour(int startHour);
KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
int YTop,int YBottom);
void changeColumns(int columns);
int columns() { return mColumns; }
int rows() { return mRows; }
int gridSpacingX() const { return mGridSpacingX; }
int gridSpacingY() const { return mGridSpacingY; }
// virtual QSizePolicy sizePolicy() const;
void clear();
void clearSelection();
void hideUnused();
/** Calculates the minimum width */
virtual int minimumWidth() const;
/** Update configuration from preference settings */
void updateConfig();
void checkScrollBoundaries();
void setHolidayMask(QMemArray<bool> *);
void setDateList(const DateList &selectedDates);
DateList dateList() const;
void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
void finishUpdate();
void printSelection();
void storePosition();
void restorePosition();
-
+ void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
public slots:
void popupMenu();
void newItem( int );
void moveChild( QWidget *, int, int );
void scrollUp();
void scrollDown();
void updateTodo( Todo * t, int , bool );
void popupAlarm();
void checkScrollBoundaries(int);
/** Deselect selected items. This function does not emit any signals. */
void deselectItem();
/** Select item. If the argument is 0, the currently selected item gets
deselected. This function emits the itemSelected(bool) signal to inform
about selection/deseelction of events. */
void selectItem(KOAgendaItem *);
void finishResize();
signals:
void showDateView( int, int);
void newEventSignal();
void newEventSignal(int gx,int gy);
void newTodoSignal(int gx,int gy);
void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
void newStartSelectSignal();
void showIncidenceSignal(Incidence *);
void editIncidenceSignal(Incidence *);
void deleteIncidenceSignal(Incidence *);
void showIncidencePopupSignal(Incidence *);
void itemModified(KOAgendaItem *item, int );
void incidenceSelected(Incidence *);
void lowerYChanged(int);
void upperYChanged(int);
void startDragSignal(Incidence *);
void addToCalSignal(Incidence *, Incidence *);
void resizedSignal();
protected:
+ KOEventPopupMenu * mAllAgendaPopup;
QPainter mPixPainter;
QPixmap mPaintPixmap;
QPixmap mHighlightPixmap;
void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
virtual void resizeEvent ( QResizeEvent * );
/** Handles mouse events. Called from eventFilter */
virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
/** Start selecting time span. */
void startSelectAction(QPoint viewportPos);
/** Select time span. */
void performSelectAction(QPoint viewportPos);
/** Emd selecting time span. */
void endSelectAction( bool emitNewEvent = false );
/** Start moving/resizing agenda item */
void startItemAction(QPoint viewportPos);
/** Move/resize agenda item */
void performItemAction(QPoint viewportPos);
/** End moving/resizing agenda item */
void endItemAction();
/** Set cursor, when no item action is in progress */
void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
/** Place agenda item in agenda and adjust other cells if necessary */
void placeSubCells(KOAgendaItem *placeItem);
/** Process the keyevent, including the ignored keyevents of eventwidgets.
* Implements pgup/pgdn and cursor key navigation in the view.
*/
void keyPressEvent( QKeyEvent * );
void calculateWorkingHours();
virtual void contentsMousePressEvent ( QMouseEvent * );
private:
void init();
void marcus_bains();
bool mAllDayMode;
bool blockResize;
bool mLeftMouseDown;
KOAgendaItem *mPopupItem;
QTimer* mPopupTimer;
int mPopupKind;
QPoint mPopupPos;
QTimer mResizeTimer;
double mContentPosition;
// Width and height of agenda cells
int mGridSpacingX;
int mGridSpacingY;
// size of border, where mouse action will resize the KOAgendaItem
int mResizeBorderWidth;
// size of border, where mouse mve will cause a scroll of the agenda
int mScrollBorderWidth;
int mScrollDelay;
int mScrollOffset;
QTimer mScrollUpTimer;
QTimer mScrollDownTimer;
// Number of Columns/Rows of agenda grid
int mColumns;
int mRows;
// Cells to store Move and Resize coordiantes
int mStartCellX;
int mStartCellY;
int mCurrentCellX;
int mCurrentCellY;
// Working Hour coordiantes
bool mWorkingHoursEnable;
int mWorkingHoursYTop;
int mWorkingHoursYBottom;
// Selection
int mSelectionCellX;
int mSelectionYTop;
int mSelectionHeight;
// List of dates to be displayed
DateList mSelectedDates;
// The KOAgendaItem, which has been right-clicked last
KOAgendaItem *mClickedItem;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8d32152..95388ef 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -412,356 +412,358 @@ void EventIndicator::drawContents(QPainter *p)
setColor = true;
int cellWidth = contentsRect().right()/mColumns;
int xOffset = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
i*cellWidth + cellWidth/2 -mPixmap.width()/2;
pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
//qDebug("222draw pix %d ",xOffset );
}
}
pa.end();
}
}
void EventIndicator::setXOffset( int x )
{
mXOffset = x;
}
void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
{
mPaintWidget = w;
setMaximumHeight(0);
setMinimumHeight(0);
}
void EventIndicator::changeColumns(int columns)
{
mColumns = columns;
mEnabled.resize(mColumns);
update();
}
void EventIndicator::enableColumn(int column, bool enable)
{
mEnabled[column] = enable;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
KOEventView (cal,parent,name)
{
mBlockUpdating = true;
mStartHour = 8;
mSelectedDates.append(QDate::currentDate());
mLayoutDayLabels = 0;
mDayLabelsFrame = 0;
mDayLabels = 0;
bool isRTL = KOGlobals::self()->reverseLayout();
QPixmap expandPix;
if ( KOPrefs::instance()->mVerticalScreen ) {
expandPix = SmallIcon( "1updownarrow" );
} else {
expandPix = SmallIcon("1leftrightarrow" );
}
QBoxLayout *topLayout = new QVBoxLayout(this);
// Create day name labels for agenda columns
// Create agenda splitter
mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
topLayout->addWidget( mSplitterAgenda );
mAllDayFrame = new QHBox(mSplitterAgenda);
mAllDayFrame->setFocusPolicy(NoFocus);
QWidget *agendaFrame = new QWidget(mSplitterAgenda);
agendaFrame->setFocusPolicy(NoFocus);
// Create all-day agenda widget
mDummyAllDayLeft = new QVBox( mAllDayFrame );
mExpandButton = new QPushButton(mDummyAllDayLeft);
mExpandButton->setPixmap( expandPix );
int widebut = mExpandButton->sizeHint().width()+4;
int heibut = mExpandButton->sizeHint().height()+4;
if ( heibut > widebut )
widebut = heibut ;
//mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
// QSizePolicy::Fixed ) );
mExpandButton->setFixedSize( widebut, widebut);
connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
mExpandButton->setFocusPolicy(NoFocus);
mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
mAllDayAgenda->setFocusPolicy(NoFocus);
QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
// Create event context menu for all day agenda
- mAllDayAgendaPopup = eventPopup();
- connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
- mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ //mAllDayAgendaPopup = eventPopup();
// Create agenda frame
QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
// QHBox *agendaFrame = new QHBox(splitterAgenda);
// create event indicator bars
mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
#ifndef DESKTOP_VERSION
// FIX
mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
#endif
mDayLabelsFrame = new QHBox(agendaFrame);
//topLayout->addWidget(mDayLabelsFrame);
mDayLabels = new QFrame (mDayLabelsFrame);
mLayoutDayLabels = new QHBoxLayout(mDayLabels);
agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
agendaLayout->addWidget(mEventIndicatorTop,1,1);
mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
agendaFrame);
agendaLayout->addWidget(mEventIndicatorBottom,3,1);
QWidget *dummyAgendaRight = new QWidget(agendaFrame);
agendaLayout->addWidget(dummyAgendaRight,1,2);
// Create time labels
mTimeLabels = new TimeLabels(24,agendaFrame);
agendaLayout->addWidget(mTimeLabels,2,0);
connect(mTimeLabels,SIGNAL( scaleChanged()),
this,SLOT(updateConfig()));
// Create agenda
mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
agendaLayout->setColStretch(1,1);
mAgenda->setFocusPolicy(NoFocus);
// Create event context menu for agenda
- mAgendaPopup = eventPopup();
+ mAllAgendaPopup = eventPopup();
- mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
+ mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
i18n("Toggle Alarm"),mAgenda,
SLOT(popupAlarm()),true);
connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
- mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
+ mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
+ mAgenda->setPopup( mAllAgendaPopup );
+ mAllDayAgenda->setPopup( mAllAgendaPopup );
// make connections between dependent widgets
mTimeLabels->setAgenda(mAgenda);
// Update widgets to reflect user preferences
// updateConfig();
// createDayLabels();
// these blank widgets make the All Day Event box line up with the agenda
dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
// Scrolling
connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
mTimeLabels, SLOT(positionChanged()));
connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
SLOT(setContentsPos(int)));
connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
// Create/Show/Edit/Delete Event
connect(mAgenda,SIGNAL(newEventSignal(int,int)),
SLOT(newEvent(int,int)));
connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
SLOT(newTodo(int,int)));
connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
SLOT(newEvent(int,int,int,int)));
connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
SLOT(newEventAllDay(int,int)));
connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
SLOT(newTodoAllDay(int,int)));
connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
SLOT(newEventAllDay(int,int)));
connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
SLOT(newTimeSpanSelected(int,int,int,int)));
connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
SIGNAL(editIncidenceSignal(Incidence *)));
connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
SIGNAL(editIncidenceSignal(Incidence *)));
connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
SIGNAL(showIncidenceSignal(Incidence *)));
connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
SIGNAL(showIncidenceSignal(Incidence *)));
connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
SIGNAL(deleteIncidenceSignal(Incidence *)));
connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
SIGNAL(deleteIncidenceSignal(Incidence *)));
connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
SLOT(updateEventDates(KOAgendaItem *, int )));
connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
SLOT(updateEventDates(KOAgendaItem *, int)));
// event indicator update
connect(mAgenda,SIGNAL(lowerYChanged(int)),
SLOT(updateEventIndicatorTop(int)));
connect(mAgenda,SIGNAL(upperYChanged(int)),
SLOT(updateEventIndicatorBottom(int)));
// drag signals
/*
connect(mAgenda,SIGNAL(startDragSignal(Event *)),
SLOT(startDrag(Event *)));
connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
SLOT(startDrag(Event *)));
*/
// synchronize selections
connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
mAllDayAgenda, SLOT( deselectItem() ) );
connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
mAgenda, SLOT( deselectItem() ) );
connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
SIGNAL( incidenceSelected( Incidence * ) ) );
connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
SIGNAL( incidenceSelected( Incidence * ) ) );
connect( mAgenda, SIGNAL( resizedSignal() ),
SLOT( updateConfig( ) ) );
connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
SLOT( addToCalSlot(Incidence * , Incidence *) ) );
// connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
//connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
}
void KOAgendaView::toggleAllDay()
{
if ( mSplitterAgenda->firstHandle() )
mSplitterAgenda->firstHandle()->toggle();
}
void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
{
calendar()->addIncidence( inc );
if ( incOld ) {
if ( incOld->type() == "Todo" )
emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
else
emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
}
}
KOAgendaView::~KOAgendaView()
{
- delete mAgendaPopup;
- delete mAllDayAgendaPopup;
+ delete mAllAgendaPopup;
+ //delete mAllDayAgendaPopup;
delete KOAgendaItem::paintPix();
delete KOAgendaItem::paintPixSel();
}
void KOAgendaView::resizeEvent( QResizeEvent* e )
{
//qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
bool uc = false;
int ow = e->oldSize().width();
int oh = e->oldSize().height();
int w = e->size().width();
int h = e->size().height();
if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
uc = true;
//qDebug("view changed %d %d %d %d ", ow, oh , w , h);
}
mUpcomingWidth = e->size().width() ;
if ( mBlockUpdating || uc ) {
mBlockUpdating = false;
//mAgenda->setMinimumSize(800 , 600 );
//qDebug("mAgenda->resize+++++++++++++++ ");
updateConfig();
//qDebug("KOAgendaView::Updating now possible ");
} else
createDayLabels();
//qDebug("resizeEvent end ");
}
void KOAgendaView::slotDaylabelClicked( int num )
{
QDate firstDate = mSelectedDates.first();
if ( num == -1 )
emit showDateView( 6, firstDate );
else if (num >= 0 ) {
if ( mSelectedDates.count() == 1)
emit showDateView( 9, firstDate.addDays( num ) );
else
emit showDateView( 3, firstDate.addDays( num ) );
}
else
showDateView( 10, firstDate.addDays(1) );
}
KOAgendaButton* KOAgendaView::getNewDaylabel()
{
KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
mDayLabelsList.append( dayLabel );
mLayoutDayLabels->addWidget(dayLabel);
return dayLabel ;
}
void KOAgendaView::createDayLabels()
{
if ( mBlockUpdating || globalFlagBlockLabel == 1) {
// qDebug(" KOAgendaView::createDayLabels() blocked ");
return;
}
int newHight;
// ### Before deleting and recreating we could check if mSelectedDates changed...
// It would remove some flickering and gain speed (since this is called by
// each updateView() call)
int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
if ( QApplication::desktop()->width() <= 320 )
maxWid -= 10;
mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
if ( maxWid < 0 )
maxWid = 20;
QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
QFontMetrics fm ( dlf );
int selCount = mSelectedDates.count();
QString dayTest = "Mon 20";
//QString dayTest = "Mon 20";
int wid = fm.width( dayTest );
//maxWid -= ( selCount * 3 ); //working for QLabels
maxWid -= ( selCount * 3 ); //working for QPushButton
if ( maxWid < 0 )
maxWid = 20;
int needWid = wid * selCount;
//qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
//if ( needWid > maxWid )
// qDebug("DAYLABELS TOOOOOOO BIG ");
while ( needWid > maxWid ) {
dayTest = dayTest.left( dayTest.length() - 1 );
wid = fm.width( dayTest );
needWid = wid * selCount;
}
int maxLen = dayTest.length();
int fontPoint = dlf.pointSize();
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 30c9b05..c6e6602 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -178,115 +178,115 @@ class KOAgendaView : public KOEventView {
bool selectedIsAllDay() {return mTimeSpanInAllDay;}
/** make selected start/end invalid */
void deleteSelectedDateTime();
void repaintAgenda();
public slots:
void setInitStartHour();
virtual void updateView();
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void updateTodo( Todo *, int );
void changeEventDisplay(Event *, int);
void clearSelection();
void newTodo(int gx,int gy);
void newEvent(int gx,int gy);
void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
void newEventAllDay(int gx, int gy);
void newTodoAllDay(int gx, int gy);
void startDrag(Event *);
void readSettings();
void readSettings(KConfig *);
void writeSettings(KConfig *);
void setContentsPos(int y);
void scrollOneHourUp();
void scrollOneHourDown();
void addToCalSlot(Incidence *, Incidence *);
void slotShowDateView( int, int );
signals:
void showDateView( int, QDate );
void newTodoSignal( QDateTime ,bool );
void toggleExpand();
void selectWeekNum( int );
void todoMoved( Todo *, int );
void incidenceChanged(Incidence * , int );
// void cloneIncidenceSignal(Incidence *);
protected:
KOAgendaButton* getNewDaylabel();
bool mBlockUpdating;
int mUpcomingWidth;
/** Fill agenda beginning with date startDate */
void fillAgenda(const QDate &startDate);
void resizeEvent( QResizeEvent* e );
/** Fill agenda using the current set value for the start date */
void fillAgenda();
/** Create labels for the selected dates. */
void createDayLabels();
/**
Set the masks on the agenda widgets indicating, which days are holidays.
*/
void setHolidayMasks();
protected slots:
void slotDaylabelClicked( int );
/** Update event belonging to agenda item */
void updateEventDates(KOAgendaItem *item, int mode = -1);
//void updateMovedTodo();
void updateEventIndicatorTop(int newY);
void updateEventIndicatorBottom(int newY);
/** Updates data for selected timespan */
void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
/** Updates data for selected timespan for all day event*/
void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
private:
// view widgets
QFrame *mDayLabels;
QHBox *mDayLabelsFrame;
QBoxLayout *mLayoutDayLabels;
QFrame *mAllDayFrame;
KOAgenda *mAllDayAgenda;
KOAgenda *mAgenda;
TimeLabels *mTimeLabels;
QWidget *mDummyAllDayLeft;
KDGanttMinimizeSplitter* mSplitterAgenda;
QPushButton *mExpandButton;
DateList mSelectedDates; // List of dates to be displayed
int mViewType;
bool mWeekStartsMonday;
int mStartHour;
- KOEventPopupMenu *mAgendaPopup;
- KOEventPopupMenu *mAllDayAgendaPopup;
+ KOEventPopupMenu *mAllAgendaPopup;
+ //KOEventPopupMenu *mAllDayAgendaPopup;
EventIndicator *mEventIndicatorTop;
EventIndicator *mEventIndicatorBottom;
QMemArray<int> mMinY;
QMemArray<int> mMaxY;
QMemArray<bool> mHolidayMask;
QPtrList<KOAgendaButton> mDayLabelsList;
QDateTime mTimeSpanBegin;
QDateTime mTimeSpanEnd;
bool mTimeSpanInAllDay;
void keyPressEvent ( QKeyEvent * e );
};
#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ccc4b01..0a315cb 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -114,211 +114,222 @@ void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
!QTextDrag::canDecode( e ) ) {
e->ignore();
return;
}
e->accept();
#endif
}
void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
{
#ifndef KORG_NODND
// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
setCurrentItem(mOldCurrent);
setSelected(mOldCurrent,true);
#endif
}
void KOTodoListView::contentsDropEvent(QDropEvent *e)
{
#ifndef KORG_NODND
// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
!QTextDrag::canDecode( e ) ) {
e->ignore();
return;
}
DndFactory factory( mCalendar );
Todo *todo = factory.createDropTodo(e);
if (todo) {
e->acceptAction();
KOTodoViewItem *destination =
(KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
Todo *destinationEvent = 0;
if (destination) destinationEvent = destination->todo();
Todo *existingTodo = mCalendar->todo(todo->uid());
if(existingTodo) {
Incidence *to = destinationEvent;
while(to) {
if (to->uid() == todo->uid()) {
KMessageBox::sorry(this,
i18n("Cannot move To-Do to itself\nor a child of itself"),
i18n("Drop To-Do"));
delete todo;
return;
}
to = to->relatedTo();
}
internalDrop = true;
if ( destinationEvent )
reparentTodoSignal( destinationEvent, existingTodo );
else
unparentTodoSignal(existingTodo);
delete todo;
} else {
mCalendar->addTodo(todo);
emit todoDropped(todo, KOGlobals::EVENTADDED);
if ( destinationEvent )
reparentTodoSignal( destinationEvent, todo );
}
}
else {
QString text;
if (QTextDrag::decode(e,text)) {
//QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
qDebug("Dropped : " + text);
QStringList emails = QStringList::split(",",text);
for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
int pos = (*it).find("<");
QString name = (*it).left(pos);
QString email = (*it).mid(pos);
if (!email.isEmpty() && todoi) {
todoi->todo()->addAttendee(new Attendee(name,email));
}
}
}
else {
qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
e->ignore();
}
}
#endif
}
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() ||
+ X < header()->sectionPos(0)) {
+ rootClicked = false;
+ }
+ }
#ifndef KORG_NODND
- QPoint p(contentsToViewport(e->pos()));
- QListViewItem *i = itemAt(p);
- mMousePressed = false;
- if (i) {
- // if the user clicked into the root decoration of the item, don't
- // try to start a drag!
- if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
- treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
- itemMargin() ||
- p.x() < header()->sectionPos(header()->mapToIndex(0))) {
- if (e->button()==Qt::LeftButton) {
+ mMousePressed = false;
+ if (! rootClicked ) {
mPressPos = e->pos();
mMousePressed = true;
- }
}
- }
#endif
- QListView::contentsMousePressEvent(e);
+ //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;
}
@@ -970,204 +981,212 @@ void KOTodoView::beamTodo()
void KOTodoView::showTodo()
{
if (mActiveItem) {
emit showTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::deleteTodo()
{
if (mActiveItem) {
emit deleteTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::setNewPriority(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
mActiveItem->todo()->setPriority(mPriority[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
void KOTodoView::setNewPercentage(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
mActiveItem->setOn( true );
return;
} else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
if ( par && par->isOn() )
par->setOn( false );
}
if (mPercentage[index] == 100) {
mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
} else {
mActiveItem->todo()->setCompleted(false);
}
mActiveItem->todo()->setPercentComplete(mPercentage[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
{
QPopupMenu* tempMenu = new QPopupMenu (this);
QStringList checkedCategories = todoItem->todo()->categories ();
tempMenu->setCheckable (true);
for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
it != KOPrefs::instance()->mCustomCategories.end ();
++it) {
int index = tempMenu->insertItem (*it);
mCategory[index] = *it;
if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
}
connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
return tempMenu;
}
void KOTodoView::changedCategories(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
QStringList categories = mActiveItem->todo()->categories ();
QString colcat = categories.first();
if (categories.find (mCategory[index]) != categories.end ())
categories.remove (mCategory[index]);
else
categories.insert (categories.end(), mCategory[index]);
categories.sort ();
if ( !colcat.isEmpty() ) {
if ( categories.find ( colcat ) != categories.end () ) {
categories.remove( colcat );
categories.prepend( colcat );
}
}
mActiveItem->todo()->setCategories (categories);
mActiveItem->construct();
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
}
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
+ int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
+ //qDebug("ROW %d ", row);
if (!item) {
newTodo();
return;
+ } else {
+ if ( row == 1 ) {
+ mActiveItem = (KOTodoViewItem *) item;
+ newSubTodo();
+ return;
+ }
}
if ( KOPrefs::instance()->mEditOnDoubleClick )
editItem( item );
else
showItem( item , QPoint(), 0 );
}
void KOTodoView::itemClicked(QListViewItem *item)
{
-
+ //qDebug("KOTodoView::itemClicked %d", item);
if (!item) {
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
return;
}
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
if ( pendingSubtodo != 0 ) {
bool allowReparent = true;
QListViewItem *par = item;
while ( par ) {
if ( par == pendingSubtodo ) {
allowReparent = false;
break;
}
par = par->parent();
}
if ( !allowReparent ) {
topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
qDebug("Recursive reparenting not possible ");
pendingSubtodo = 0;
} else {
Todo* newParent = todoItem->todo();
Todo* newSub = pendingSubtodo->todo();
pendingSubtodo = 0;
emit reparentTodoSignal( newParent,newSub );
return;
}
}
#if 0
// handled by the item itself
bool completed = todoItem->todo()->isCompleted(); // Completed or not?
qDebug("com %d ",completed );
qDebug("itemclicked ");
if (todoItem->isOn()) {
qDebug("on ");
if (!completed) {
qDebug("set true ");
todoItem->todo()->setCompleted(QDateTime::currentDateTime());
}
} else {
qDebug("not on ");
if (completed) {
qDebug("set false ");
todoItem->todo()->setCompleted(false);
}
}
#endif
}
void KOTodoView::setDocumentId( const QString &id )
{
kdDebug() << "KOTodoView::setDocumentId()" << endl;
mDocPrefs->setDoc( id );
}
void KOTodoView::itemStateChanged( QListViewItem *item )
{
if (!item) return;
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
}
void KOTodoView::saveLayout(KConfig *config, const QString &group) const
{
mTodoListView->saveLayout(config,group);
}
void KOTodoView::restoreLayout(KConfig *config, const QString &group)
{
mTodoListView->restoreLayout(config,group);
}
void KOTodoView::processSelectionChange()
{
// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
KOTodoViewItem *item =
static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
if ( !item ) {
emit incidenceSelected( 0 );
} else {
emit incidenceSelected( item->todo() );
}
}
void KOTodoView::modified(bool b)
{
emit isModified(b);