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
@@ -170,3 +170,14 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
{
-
+ 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;
@@ -189,3 +200,12 @@ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags 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;
@@ -420,4 +440,20 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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);
+ }
}
@@ -458,3 +494,7 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
} else if ( mActionType == SELECT ) {
- endSelectAction();
+ if (me->button() == RightButton ) {
+
+ } else {
+ endSelectAction( !blockNewEvent );
+ }
}
@@ -522,2 +562,12 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
+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)
@@ -611,3 +661,3 @@ void KOAgenda::performSelectAction(QPoint viewportPos)
-void KOAgenda::endSelectAction()
+void KOAgenda::endSelectAction( bool emitNewEvent )
{
@@ -618,2 +668,4 @@ void KOAgenda::endSelectAction()
emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
+ if ( emitNewEvent && mStartCellY < mCurrentCellY )
+ emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
}
@@ -1662,3 +1714,3 @@ 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;