summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1bfdef9..873a776 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -452,96 +452,97 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
e->ignore();
}
void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
{
QListView::contentsMouseReleaseEvent(e);
mMousePressed = false;
}
void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
{
if (!e) return;
QPoint vp = contentsToViewport(e->pos());
QListViewItem *item = itemAt(vp);
emit double_Clicked(item);
if (!item) return;
emit doubleClicked(item,vp,0);
}
/////////////////////////////////////////////////////////////////////////////
KOQuickTodo::KOQuickTodo(QWidget *parent) :
QLineEdit(parent)
{
setText(i18n("Click to add a new Todo"));
}
void KOQuickTodo::focusInEvent(QFocusEvent *ev)
{
if ( text()==i18n("Click to add a new Todo") )
setText("");
QLineEdit::focusInEvent(ev);
}
void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
{
setText(i18n("Click to add a new Todo"));
QLineEdit::focusOutEvent(ev);
}
/////////////////////////////////////////////////////////////////////////////
KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
KOrg::BaseView(calendar,parent,name)
{
+ mCategoryPopupMenu = 0;
mPendingUpdateBeforeRepaint = false;
isFlatDisplay = false;
mNavigator = 0;
QBoxLayout *topLayout = new QVBoxLayout(this);
mName = QString ( name );
mBlockUpdate = false;
mQuickAdd = new KOQuickTodo(this);
topLayout->addWidget(mQuickAdd);
if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
mTodoListView = new KOTodoListView(calendar,this, name );
topLayout->addWidget(mTodoListView);
//mTodoListView->header()->setMaximumHeight(30);
mTodoListView->setRootIsDecorated(true);
mTodoListView->setAllColumnsShowFocus(true);
mTodoListView->setShowSortIndicator(true);
mTodoListView->addColumn(i18n("Todo"));
mTodoListView->addColumn(i18n("Prio"));
mTodoListView->setColumnAlignment(1,AlignHCenter);
mTodoListView->addColumn(i18n("Complete"));
mTodoListView->setColumnAlignment(2,AlignCenter);
mTodoListView->addColumn(i18n("Due Date"));
mTodoListView->setColumnAlignment(3,AlignLeft);
mTodoListView->addColumn(i18n("Due Time"));
mTodoListView->setColumnAlignment(4,AlignHCenter);
mTodoListView->addColumn(i18n("Start Date"));
mTodoListView->setColumnAlignment(5,AlignLeft);
mTodoListView->addColumn(i18n("Start Time"));
mTodoListView->setColumnAlignment(6,AlignHCenter);
mTodoListView->addColumn(i18n("Cancelled"));
mTodoListView->addColumn(i18n("Categories"));
mTodoListView->addColumn(i18n("Calendar"));
#if 0
mTodoListView->addColumn(i18n("Sort Id"));
mTodoListView->setColumnAlignment(4,AlignHCenter);
#endif
mTodoListView->setMinimumHeight( 60 );
mTodoListView->setItemsRenameable( true );
mTodoListView->setRenameable( 0 );
mTodoListView->setColumnWidth( 0, 120 );
int iii = 0;
@@ -1113,112 +1114,112 @@ void KOTodoView::showTodo()
emit showTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::deleteTodo()
{
if (mActiveItem) {
emit deleteTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::setNewPriority(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
mActiveItem->todo()->setPriority(mPriority[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
void KOTodoView::setNewPercentage(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
mActiveItem->setOn( true );
return;
} else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
if ( par && par->isOn() )
par->setOn( false );
}
if (mPercentage[index] == 100) {
mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
} else {
mActiveItem->todo()->setCompleted(false);
}
mActiveItem->todo()->setPercentComplete(mPercentage[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
{
- QPopupMenu* tempMenu = new QPopupMenu (this);
- QStringList checkedCategories = todoItem->todo()->categories ();
-
- tempMenu->setCheckable (true);
- for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
- it != KOPrefs::instance()->mCustomCategories.end ();
- ++it) {
- int index = tempMenu->insertItem (*it);
- mCategory[index] = *it;
- if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
- }
-
- connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
- return tempMenu;
-
-
+ if ( !mCategoryPopupMenu ) {
+ mCategoryPopupMenu = new QPopupMenu (this);
+ mCategoryPopupMenu->setCheckable (true);
+ connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
+ }
+ mCategoryPopupMenu->clear();
+ QStringList checkedCategories = todoItem->todo()->categories ();
+
+ for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
+ it != KOPrefs::instance()->mCustomCategories.end ();
+ ++it) {
+ int index = mCategoryPopupMenu->insertItem (*it);
+ mCategory[index] = *it;
+ if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
+ }
+ return mCategoryPopupMenu;
}
void KOTodoView::changedCategories(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
QStringList categories = mActiveItem->todo()->categories ();
QString colcat = categories.first();
if (categories.find (mCategory[index]) != categories.end ())
categories.remove (mCategory[index]);
else
categories.insert (categories.end(), mCategory[index]);
categories.sort ();
if ( !colcat.isEmpty() ) {
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 == 1 ) {
mActiveItem = (KOTodoViewItem *) item;
newSubTodo();
return;
}
if ( row == 5 || row == 6 || row == 2) {
mActiveItem = (KOTodoViewItem *) item;
Todo * t = mActiveItem->todo();
if ( t->isRunning() ) {
if ( t->runTime() < 15) {
t->stopRunning();
mActiveItem->construct();