summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-29 15:23:10 (UTC)
committer zautrix <zautrix>2005-01-29 15:23:10 (UTC)
commitc6548bb194a5e73b9b72505c2e952ef6346dec46 (patch) (side-by-side diff)
tree74039fb5cd5f1a64f6a7844c9ece030e6d76de87
parentf542fb5846520683e6241a522921e3d5eb24b833 (diff)
downloadkdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.zip
kdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.tar.gz
kdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.tar.bz2
todo
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koagenda.cpp66
-rw-r--r--korganizer/koagenda.h6
-rw-r--r--korganizer/koagendaview.cpp19
-rw-r--r--korganizer/koagendaview.h3
-rw-r--r--korganizer/koeditorgeneraltodo.cpp17
-rw-r--r--korganizer/koviewmanager.cpp9
8 files changed, 119 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 257a4dd..035d630 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2646,7 +2646,10 @@ void CalendarView::newEvent(QDate dt)
newEvent(QDateTime(dt, QTime(0,0,0)),
QDateTime(dt, QTime(0,0,0)), true);
}
-
+void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
+{
+ newEvent(fromHint, toHint, false);
+}
void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
{
@@ -2684,12 +2687,11 @@ void CalendarView::todoDeleted()
}
-
-void CalendarView::newTodo()
+void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
{
-
+ qDebug("datetime ");
showTodoEditor();
- mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
+ mTodoEditor->newTodo(dt,0,allday);
if ( mFilterView->filtersEnabled() ) {
CalFilter *filter = mFilterView->selectedFilter();
if (filter && filter->showCategories()) {
@@ -2700,6 +2702,11 @@ void CalendarView::newTodo()
}
}
+void CalendarView::newTodo()
+{
+ newTodoDateTime( QDateTime(),true );
+}
+
void CalendarView::newSubTodo()
{
Todo *todo = selectedTodo();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index c8d6bdd..7c59a8d 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -225,7 +225,8 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
/** create an editeventwin with supplied date/time, and if bool is true,
* make the event take all day. */
- void newEvent(QDateTime, QDateTime, bool allDay = false);
+ void newEvent(QDateTime, QDateTime, bool allDay );
+ void newEvent(QDateTime, QDateTime);
void newEvent(QDateTime fh);
void newEvent(QDate dt);
/** create new event without having a date hint. Takes current date as
@@ -260,6 +261,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void showTodo(Todo *);
/** create new todo */
void newTodo();
+ void newTodoDateTime(QDateTime, bool allday);
/** create new todo with a parent todo */
void newSubTodo();
/** create new todo with a parent todo */
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
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 111242f..12943d7 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -126,6 +126,7 @@ class KOAgenda : public QScrollView
public slots:
+ void newItem( int );
void moveChild( QWidget *, int, int );
void scrollUp();
void scrollDown();
@@ -145,6 +146,7 @@ class KOAgenda : public QScrollView
signals:
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();
@@ -180,7 +182,7 @@ class KOAgenda : public QScrollView
void performSelectAction(QPoint viewportPos);
/** Emd selecting time span. */
- void endSelectAction();
+ void endSelectAction( bool emitNewEvent = false );
/** Start moving/resizing agenda item */
void startItemAction(QPoint viewportPos);
@@ -207,6 +209,7 @@ class KOAgenda : public QScrollView
virtual void contentsMousePressEvent ( QMouseEvent * );
private:
+ bool blockNewEvent;
void init();
void marcus_bains();
bool mAllDayMode;
@@ -274,6 +277,7 @@ class KOAgenda : public QScrollView
QPtrList<KOAgendaItem> mUnusedItems;
KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
+ QPopupMenu *mNewItemPopup;
int mOldLowerScrollValue;
int mOldUpperScrollValue;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index f54f7bc..60ae41f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -488,10 +488,14 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
// 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)),
@@ -1283,6 +1287,21 @@ void KOAgendaView::newEventAllDay(int gx, int )
emit newEventSignal(day);
}
+void KOAgendaView::newTodoAllDay(int gx, int )
+{
+ if (!mSelectedDates.count()) return;
+
+ QDateTime day (mSelectedDates[gx] );
+ emit newTodoSignal(day, true);
+}
+void KOAgendaView::newTodo(int gx, int gy )
+{
+ if (!mSelectedDates.count()) return;
+ QDate dayStart = mSelectedDates[gx];
+ QTime timeStart = mAgenda->gyToTime(gy);
+ QDateTime dt (dayStart,timeStart);
+ emit newTodoSignal( dt, false );
+}
void KOAgendaView::updateEventIndicatorTop(int newY)
{
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 3cf938f..01d74a1 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -162,9 +162,11 @@ class KOAgendaView : public KOEventView {
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 *);
@@ -180,6 +182,7 @@ class KOAgendaView : public KOEventView {
void addToCalSlot(Incidence *, Incidence *);
signals:
+ void newTodoSignal( QDateTime ,bool );
void toggleExpand();
void todoMoved( Todo *, int );
void incidenceChanged(Incidence * , int );
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 158a7d3..b9a028b 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -195,9 +195,14 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
}
enableTimeEdits( !allDay );
-
- mDueCheck->setChecked(false);
- enableDueEdit(false);
+ if ( due.isValid() ) {
+ mDueCheck->setChecked(true);
+ enableDueEdit(true);
+ } else {
+ mDueCheck->setChecked(false);
+ enableDueEdit(false);
+ due = QDateTime::currentDateTime().addDays(7);
+ }
alarmDisable(true);
@@ -206,9 +211,9 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
mDueDateEdit->setDate(due.date());
mDueTimeEdit->setTime(due.time());
-
- mStartDateEdit->setDate(QDate::currentDate());
- mStartTimeEdit->setTime(QTime::currentTime());
+ due = due.addDays(-7);
+ mStartDateEdit->setDate(due.date());
+ mStartTimeEdit->setTime(due.time());
mPriorityCombo->setCurrentItem(2);
mCompletedLabel->setText(i18n("completed"));;
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index e8d5ab1..a88276e 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -307,10 +307,15 @@ void KOViewManager::showAgendaView( bool fullScreen )
mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
// SIGNALS/SLOTS FOR DAY/WEEK VIEW
+
+
+
+ connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
+ mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
mMainView, SLOT(newEvent(QDateTime)));
- // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
- // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
+ connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
+ mMainView, SLOT(newEvent(QDateTime,QDateTime)));
connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
mMainView, SLOT(newEvent(QDate)));