summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp66
1 files changed, 59 insertions, 7 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7e0b216..73ee5cb 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -168,7 +168,18 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
const char *name,WFlags f) :
QScrollView(parent,name,f)
{
-
+ 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 );
+
mColumns = columns;
mRows = rows;
mGridSpacingY = rowSize;
@@ -187,7 +198,16 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
QScrollView(parent,name,f)
{
-
+ 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 );
blockResize = false;
mColumns = columns;
mRows = 1;
@@ -418,8 +438,24 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
} else {
selectItem(0);
mActionItem = 0;
- setCursor(arrowCursor);
- startSelectAction(viewportPos);
+ if (me->button() == RightButton ) {
+ blockNewEvent = true;
+ qDebug("right ");
+ 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;
+ mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
+
+ } else {
+ blockNewEvent = false;
+ setCursor(arrowCursor);
+ startSelectAction(viewportPos);
+ }
}
break;
@@ -456,7 +492,11 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
}
endItemAction();
} else if ( mActionType == SELECT ) {
- endSelectAction();
+ if (me->button() == RightButton ) {
+
+ } else {
+ endSelectAction( !blockNewEvent );
+ }
}
break;
@@ -520,6 +560,16 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
return true;
}
+void KOAgenda::newItem( int item )
+{
+ qDebug("new %d ", item);
+ if ( item == 1 ) { //new event
+ newEventSignal(mStartCellX ,mStartCellY );
+ }
+ if ( item == 2 ) { //new event
+ newTodoSignal(mStartCellX ,mStartCellY );
+ }
+}
void KOAgenda::startSelectAction(QPoint viewportPos)
{
//emit newStartSelectSignal();
@@ -609,13 +659,15 @@ void KOAgenda::performSelectAction(QPoint viewportPos)
}
}
-void KOAgenda::endSelectAction()
+void KOAgenda::endSelectAction( bool emitNewEvent )
{
mActionType = NOP;
mScrollUpTimer.stop();
mScrollDownTimer.stop();
emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
+ if ( emitNewEvent && mStartCellY < mCurrentCellY )
+ emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
}
void KOAgenda::startItemAction(QPoint viewportPos)
@@ -1660,7 +1712,7 @@ void KOAgenda::scrollDown()
void KOAgenda::popupAlarm()
{
if (!mClickedItem) {
- kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
+ qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
return;
}
// TODO: deal correctly with multiple alarms