summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp75
-rw-r--r--korganizer/koagendaitem.cpp2
-rw-r--r--korganizer/kolistview.cpp42
-rw-r--r--korganizer/kolistview.h2
-rw-r--r--korganizer/komonthview.cpp9
5 files changed, 44 insertions, 86 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 2820ca2..66ad4ec 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -166,25 +166,25 @@ void MarcusBains::updateLocation(bool recalculate)
*/
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)
{
@@ -389,44 +389,48 @@ 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 );
}
@@ -436,95 +440,79 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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;
@@ -541,25 +529,24 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
}
}
} 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());
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index b30ad75..905c1bf 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -66,25 +66,25 @@ protected:
{
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()
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 3519985..6b63d7f 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -299,25 +299,25 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
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()
{
@@ -1150,78 +1150,46 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e)
}
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 );
-}
-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();
+ clearSelection () ;
if ( ci )
ci->setSelected( true );
}
+}
+void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
+{
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
@@ -214,27 +214,25 @@ 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();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 12233ee..9085775 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -505,24 +505,29 @@ void MonthViewCell::setHoliday( const QString &holiday )
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 );
@@ -808,31 +813,31 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
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
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);