summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-29 23:23:11 (UTC)
committer zautrix <zautrix>2005-01-29 23:23:11 (UTC)
commitd94b52aa95cc52aa1bef7c9cd99f43c725ed8042 (patch) (side-by-side diff)
tree9443dfbc790a76e5d707ce762e075cdb21096f50 /korganizer
parent74c808f288bf81bc68c92a377ce64953603c2d40 (diff)
downloadkdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.zip
kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.gz
kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.bz2
todo dnd
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp8
-rw-r--r--korganizer/korganizer.pro4
-rw-r--r--korganizer/kotodoview.cpp61
-rw-r--r--korganizer/kotodoview.h11
4 files changed, 48 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 0c39590..74aefb7 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1510,49 +1510,49 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
}
}
bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
{
//qDebug("addAnni ");
Event * ev = new Event();
if ( a ) {
ev->addAttendee( a );
}
QString kind;
if ( birthday ) {
kind = i18n( "Birthday" );
ev->setSummary( name + " (" + QString::number(date.year()) +")");
}
else {
kind = i18n( "Anniversary" );
ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
}
- ev->setOrganizer(a->email());
+ //ev->setOrganizer(a->email());
ev->setCategories( kind );
ev->setDtStart( QDateTime(date) );
ev->setDtEnd( QDateTime(date) );
ev->setFloats( true );
Recurrence * rec = ev->recurrence();
rec->setYearly(Recurrence::rYearlyMonth,1,-1);
rec->addYearlyNum( date.month() );
if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
delete ev;
return false;
}
return true;
}
bool CalendarView::importQtopia( const QString &categories,
const QString &datebook,
const QString &todolist )
{
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
@@ -2193,78 +2193,78 @@ int CalendarView::msgItemDelete(const QString name)
{
return KMessageBox::warningContinueCancel(this,name +"\n\n"+
i18n("This item will be\npermanently deleted."),
i18n("KO/Pi Confirmation"),i18n("Delete"));
}
void CalendarView::edit_cut()
{
Event *anEvent=0;
Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
- factory.cutEvent(anEvent);
+ factory.cutIncidence(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
}
void CalendarView::edit_copy()
{
Event *anEvent=0;
Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
- factory.copyEvent(anEvent);
+ factory.copyIncidence(anEvent);
}
void CalendarView::edit_paste()
{
QDate date = mNavigator->selectedDates().first();
DndFactory factory( mCalendar );
- Event *pastedEvent = factory.pasteEvent( date );
+ Event *pastedEvent = (Event *)factory.pasteIncidence( date );
changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
}
void CalendarView::edit_options()
{
mDialogManager->showOptionsDialog();
//writeSettings();
}
void CalendarView::slotSelectPickerDate( QDate d)
{
mDateFrame->hide();
if ( mDatePickerMode == 1 ) {
mNavigator->slotDaySelect( d );
} else if ( mDatePickerMode == 2 ) {
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
QTime tim;
if ( to->hasDueDate() )
tim = to->dtDue().time();
else {
tim = QTime ( 0,0,0 );
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 4d67dca..3c7a1fb 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,38 +1,38 @@
TEMPLATE = app
CONFIG += qt warn_off
TARGET = kopi
OBJECTS_DIR = _obj/
MOC_DIR = _moc
DESTDIR= ../bin
include( ../variables.pri )
INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
#../qtcompat
-DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
+DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
-#KORG_NOPRINTER KORG_NOKABC
+#KORG_NOPRINTER KORG_NOKABC KORG_NODND
DEFINES += KORG_NOLVALTERNATION
DEFINES += DESKTOP_VERSION
unix : {
LIBS += ../bin/libmicrokdepim.so
LIBS += ../bin/libmicrokcal.so
LIBS += ../bin/libmicrokde.so
LIBS += ../bin/libmicrokabc.so
#LIBS += -lbluetooth
#LIBS += -lsdp
#LIBS += -lldap
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
RC_FILE = winicons.rc
DEFINES += _WIN32_
LIBS += ../bin/microkdepim.lib
LIBS += ../bin/microkcal.lib
LIBS += ../bin/microkde.lib
LIBS += ../bin/microkabc.lib
LIBS += ../libical/lib/ical.lib
LIBS += ../libical/lib/icalss.lib
#LIBS += atls.lib
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1fb480d..8c1953d 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -118,145 +118,147 @@ 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) {
-// kdDebug() << "Drop existing Todo" << endl;
Incidence *to = destinationEvent;
while(to) {
if (to->uid() == todo->uid()) {
KMessageBox::sorry(this,
- i18n("Cannot move To-Do to itself or a child of itself"),
+ i18n("Cannot move To-Do to itself\nor a child of itself"),
i18n("Drop To-Do"));
delete todo;
return;
}
to = to->relatedTo();
}
- existingTodo->setRelatedTo(destinationEvent);
- emit todoDropped(todo);
+ internalDrop = true;
+ if ( destinationEvent )
+ reparentTodoSignal( destinationEvent, existingTodo );
+ else
+ unparentTodoSignal(existingTodo);
delete todo;
} else {
-// kdDebug() << "Drop new Todo" << endl;
- todo->setRelatedTo(destinationEvent);
mCalendar->addTodo(todo);
-
- emit todoDropped(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()) ));
- kdDebug() << "Dropped : " << text << endl;
+ qDebug("Dropped : " + text);
QStringList emails = QStringList::split(",",text);
for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
- kdDebug() << " Email: " << (*it) << endl;
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 {
- kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
+ qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
e->ignore();
}
}
#endif
}
void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
{
- QListView::contentsMousePressEvent(e);
#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) {
mPressPos = e->pos();
mMousePressed = true;
}
}
}
#endif
+ QListView::contentsMousePressEvent(e);
}
void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
{
#ifndef KORG_NODND
-// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
QListView::contentsMouseMoveEvent(e);
if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
QApplication::startDragDistance()) {
mMousePressed = false;
QListViewItem *item = itemAt(contentsToViewport(mPressPos));
if (item) {
-// kdDebug() << "Start Drag for item " << item->text(0) << endl;
DndFactory factory( mCalendar );
- ICalDrag *vd = factory.createDragTodo(
+ 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()) {
- kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
+ 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");
}
-/*
- QString source = fullPath(item);
- if ( QFile::exists(source) ) {
- QUriDrag* ud = new QUriDrag(viewport());
- ud->setFilenames( source );
- if ( ud->drag() )
- QMessageBox::information( this, "Drag source",
- QString("Delete ")+source, "Not implemented" );
-*/
}
}
#endif
}
void KOTodoListView::keyPressEvent ( QKeyEvent * e )
{
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->nextSibling();
if ( cn ) {
setCurrentItem ( cn );
ensureItemVisible ( cn );
}
}
@@ -468,63 +470,70 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
// Double clicking conflicts with opening/closing the subtree
connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
SLOT( editItem( QListViewItem *) ) );
/*
connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
const QPoint &,int ) ),
SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
*/
connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
const QPoint &,int ) ),
SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
SLOT( itemClicked( QListViewItem * ) ) );
connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
SLOT( itemDoubleClicked( QListViewItem * ) ) );
- connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ),
+ connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
SLOT( updateView() ) );
+ connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
+ SLOT( todoModified(Todo *, int) ) );
connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
SLOT( itemStateChanged( QListViewItem * ) ) );
connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
SLOT( itemStateChanged( QListViewItem * ) ) );
#if 0
connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
SLOT(selectionChanged(QListViewItem *)));
connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
SLOT(selectionChanged(QListViewItem *)));
connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
SLOT(selectionChanged(QListViewItem *)));
#endif
+
+ connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
+ connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
+ connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
+
connect( mTodoListView, SIGNAL(selectionChanged() ),
SLOT( processSelectionChange() ) );
connect( mQuickAdd, SIGNAL( returnPressed () ),
SLOT( addQuickTodo() ) );
}
KOTodoView::~KOTodoView()
{
delete mDocPrefs;
}
void KOTodoView::jumpToDate ()
{
// if (mActiveItem) {
// mActiveItem->todo());
// if ( mActiveItem->todo()->hasDueDate() )
// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
}
void KOTodoView::updateView()
{
pendingSubtodo = 0;
if ( mBlockUpdate ) {
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index f11518d..68e29bb 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -39,63 +39,66 @@
#include <libkcal/todo.h>
#include <korganizer/baseview.h>
#include "kotodoviewitem.h"
#include "koprefs.h"
#include "koglobals.h"
#include "datenavigator.h"
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class DocPrefs;
class KOTodoListView : public KListView
{
Q_OBJECT
public:
KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
virtual ~KOTodoListView() {}
signals:
- void todoDropped(Todo *);
+ void todoDropped(Todo *, int);
void double_Clicked(QListViewItem *item);
-
+ void reparentTodoSignal( Todo *,Todo * );
+ void unparentTodoSignal(Todo *);
+ void deleteTodo( Todo * );
protected:
void contentsDragEnterEvent(QDragEnterEvent *);
void contentsDragMoveEvent(QDragMoveEvent *);
void contentsDragLeaveEvent(QDragLeaveEvent *);
void contentsDropEvent(QDropEvent *);
void contentsMousePressEvent(QMouseEvent *);
void contentsMouseMoveEvent(QMouseEvent *);
void contentsMouseReleaseEvent(QMouseEvent *);
void contentsMouseDoubleClickEvent(QMouseEvent *);
private:
+ bool internalDrop;
QString mName;
Calendar *mCalendar;
QPoint mPressPos;
bool mMousePressed;
QListViewItem *mOldCurrent;
void keyPressEvent ( QKeyEvent * ) ;
};
/**
This is the line-edit on top of the todoview for fast addition of new todos
*/
class KOQuickTodo : public QLineEdit
{
public:
KOQuickTodo(QWidget *parent=0);
protected:
void focusInEvent(QFocusEvent *ev);
void focusOutEvent(QFocusEvent *ev);
};
/**
This class provides a multi-column list view of todo events.
@@ -176,69 +179,69 @@ class KOTodoView : public KOrg::BaseView
void modified(bool);
void itemDoubleClicked(QListViewItem *item);
signals:
void newTodoSignal();
void newSubTodoSignal(Todo *);
void unparentTodoSignal(Todo *);
void reparentTodoSignal( Todo *,Todo * );
void showTodoSignal(Todo *);
void editTodoSignal(Todo *);
void deleteTodoSignal(Todo *);
void todoModifiedSignal (Todo *, int);
void isModified(bool);
void cloneTodoSignal( Incidence * );
void cancelTodoSignal( Incidence * );
void moveTodoSignal( Incidence * );
void beamTodoSignal( Incidence * );
void purgeCompletedSignal();
protected slots:
void processSelectionChange();
void addQuickTodo();
+ void setTodoModified( Todo* );
+ void todoModified(Todo *, int );
private:
/*
* the TodoEditor approach is rather unscaling in the long
* run.
* Korganizer keeps it in memory and we need to update
* 1. make KOTodoViewItem a QObject again?
* 2. add a public method for setting one todo modified?
* 3. add a private method for setting a todo modified + friend here?
* -- zecke 2002-07-08
*/
friend class KOTodoViewItem;
- void setTodoModified( Todo* );
QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
void restoreItemState( QListViewItem * );
bool checkTodo( Todo * );
bool isFlatDisplay;
void setOpen( QListViewItem*, bool setOpen);
KOTodoListView *mTodoListView;
QPopupMenu *mItemPopupMenu;
QPopupMenu *mPopupMenu;
QPopupMenu *mPriorityPopupMenu;
QPopupMenu *mPercentageCompletedPopupMenu;
QPopupMenu *mCategoryPopupMenu;
QMap<int, int> mPercentage;
QMap<int, int> mPriority;
QMap<int, QString> mCategory;
KOTodoViewItem *mActiveItem;
QMap<Todo *,KOTodoViewItem *> mTodoMap;
QString mName;
DocPrefs *mDocPrefs;
QString mCurrentDoc;
KOQuickTodo *mQuickAdd;
bool mBlockUpdate;
- void todoModified(Todo *, int );
void keyPressEvent ( QKeyEvent * ) ;
KOTodoViewItem * pendingSubtodo;
DateNavigator* mNavigator;
};
#endif