-rw-r--r-- | korganizer/kotodoview.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 926a136..98c9bd9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -26,153 +26,153 @@ #include <qcursor.h> #include <qwhatsthis.h> #include <qdialog.h> #include <qlabel.h> #include <qpushbutton.h> #include <qinputdialog.h> #include <qvbox.h> #include <kdebug.h> #include "koprefs.h" #include <klocale.h> #include <kglobal.h> #include <kdateedit.h> #include "ktimeedit.h" #include <kiconloader.h> #include <kmessagebox.h> #include <libkcal/icaldrag.h> #include <libkcal/vcaldrag.h> #include <libkcal/calfilter.h> #include <libkcal/dndfactory.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <libkcal/kincidenceformatter.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "docprefs.h" #include "kotodoview.h" using namespace KOrg; KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : QDialog( parent, name, true ) { mTodo = todo; setCaption( i18n("Stop todo") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); - QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); + QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); lay->addWidget( lab ); lab->setAlignment( AlignHCenter ); lab = new QLabel( i18n("Additional Comment:"), this ); lay->addWidget( lab ); mComment = new QLineEdit( this ); lay->addWidget( mComment ); QHBox * start = new QHBox ( this ); lay->addWidget( start ); lab = new QLabel( i18n("Start:"), start ); QHBox * end = new QHBox ( this ); lay->addWidget( end ); lab = new QLabel( i18n("End:"), end ); sde = new KDateEdit( start ); ste = new KOTimeEdit( start ); connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); ede = new KDateEdit( end ); ete = new KOTimeEdit(end ); connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); sde->setDate( mTodo->runStart().date() ); ste->setTime( mTodo->runStart().time() ); ede->setDate( QDate::currentDate()); ete->setTime( QTime::currentTime() ); QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); lay->addWidget( ok ); ok->setDefault( true ); QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); ok = new QPushButton( i18n("Stop - do not save"), this ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); lay->addWidget( ok ); if (QApplication::desktop()->width() < 320 ) - resize( 240, 200 ); + resize( 240, sizeHint().height() ); else - resize( 320, 200 ); + resize( 320, sizeHint().height() ); } void KOStopTodoPrefs::accept() { QDateTime start = QDateTime( sde->date(), ste->getTime() ); QDateTime stop = QDateTime( ede->date(), ete->getTime() ); if ( start > stop ) { KMessageBox::sorry(this, i18n("The start time is\nafter the end time!"), i18n("Time mismatch!")); return; } mTodo->saveRunningInfo( mComment->text(), start, stop ); QDialog::accept(); } void KOStopTodoPrefs::doNotSave() { int result = KMessageBox::warningContinueCancel(this, - i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); + i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); if (result != KMessageBox::Continue) return; mTodo->stopRunning(); QDialog::accept(); } class KOTodoViewWhatsThis :public QWhatsThis { public: KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; protected: virtual QString text( const QPoint& p) { return _view->getWhatsThisText(p) ; } private: QWidget* _wid; KOTodoView * _view; }; KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, const char *name) : KListView(parent,name) { mName = QString ( name ); mCalendar = calendar; #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif mOldCurrent = 0; mMousePressed = false; setAcceptDrops(true); viewport()->setAcceptDrops(true); int size = 16; if (qApp->desktop()->width() < 300 ) size = 12; setTreeStepSize( size + 6 ); } void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && !QTextDrag::canDecode( e ) ) { @@ -1159,96 +1159,103 @@ void KOTodoView::changedCategories(int index) if ( categories.find ( colcat ) != categories.end () ) { categories.remove( colcat ); categories.prepend( colcat ); } } mActiveItem->todo()->setCategories (categories); mActiveItem->construct(); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); } } void KOTodoView::itemDoubleClicked(QListViewItem *item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); //qDebug("ROW %d ", row); if (!item) { newTodo(); return; } else { if ( row == 2 || row == 1 ) { mActiveItem = (KOTodoViewItem *) item; newSubTodo(); return; } if ( row == 5 || row == 6 ) { mActiveItem = (KOTodoViewItem *) item; toggleRunningItem(); return; } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::toggleRunningItem() { // qDebug("KOTodoView::toggleRunning() "); if ( ! mActiveItem ) return; Todo * t = mActiveItem->todo(); if ( t->isRunning() ) { KOStopTodoPrefs tp ( t, this ); + if (QApplication::desktop()->width() < 800 ){ + int wid = tp.width(); + int hei = tp.height(); + int xx = (QApplication::desktop()->width()-wid)/2; + int yy = (QApplication::desktop()->height()-hei)/2; + tp.setGeometry( xx,yy,wid,hei ); + } tp.exec(); mActiveItem->construct(); } else { int result = KMessageBox::warningContinueCancel(this, i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); if (result != KMessageBox::Continue) return; t->setRunning( true ); mActiveItem->construct(); } } void KOTodoView::itemClicked(QListViewItem *item) { //qDebug("KOTodoView::itemClicked %d", item); if (!item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; return; } KOTodoViewItem *todoItem = (KOTodoViewItem *)item; if ( pendingSubtodo != 0 ) { bool allowReparent = true; QListViewItem *par = item; while ( par ) { if ( par == pendingSubtodo ) { allowReparent = false; break; } par = par->parent(); } if ( !allowReparent ) { topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); pendingSubtodo = 0; } else { Todo* newParent = todoItem->todo(); Todo* newSub = pendingSubtodo->todo(); pendingSubtodo = 0; emit reparentTodoSignal( newParent,newSub ); return; } } } void KOTodoView::setDocumentId( const QString &id ) { |