summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
authorzautrix <zautrix>2005-07-06 21:11:20 (UTC)
committer zautrix <zautrix>2005-07-06 21:11:20 (UTC)
commite1731d8790403a079613f291b4ac172d8f04c960 (patch) (side-by-side diff)
tree75b13b2235fb6045b5c4b29f3d65d761c46ff746 /korganizer/kotodoview.cpp
parent984e2132871c79990f6d9eac5702f7f32186f235 (diff)
downloadkdepimpi-e1731d8790403a079613f291b4ac172d8f04c960.zip
kdepimpi-e1731d8790403a079613f291b4ac172d8f04c960.tar.gz
kdepimpi-e1731d8790403a079613f291b4ac172d8f04c960.tar.bz2
fixes
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp108
1 files changed, 85 insertions, 23 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index a87e6fc..c23a8ee 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -483,52 +483,86 @@ 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();
+ mQuickBar = new QWidget( this );
+ topLayout->addWidget(mQuickBar);
+
+ mQuickAdd = new KOQuickTodo(mQuickBar);
+ QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
+ quickLayout->addWidget( mQuickAdd );
+ QPushButton * flat = new QPushButton( "F",mQuickBar );
+ int fixwid = flat->sizeHint().height();
+ if ( QApplication::desktop()->width() > 320 )
+ fixwid *= 2;
+ flat->setFixedWidth( fixwid );
+ connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
+ QPushButton * allopen = new QPushButton( "O",mQuickBar );
+ allopen->setFixedWidth( fixwid );
+ connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
+ QPushButton * allclose = new QPushButton( "C",mQuickBar );
+ allclose->setFixedWidth( fixwid );
+ connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
+ QPushButton * s_done = new QPushButton( "D",mQuickBar );
+ s_done->setFixedWidth( fixwid );
+ connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
+ QPushButton * s_run = new QPushButton( "R",mQuickBar );
+ s_run->setFixedWidth( fixwid );
+ connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
+
+ mNewSubBut = new QPushButton( "sub",mQuickBar );
+ mNewSubBut->setFixedWidth( fixwid*3/2 );
+ connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
+ mNewSubBut->setEnabled( false );
+ quickLayout->addWidget( mNewSubBut );
+ quickLayout->addWidget( s_done );
+ quickLayout->addWidget( s_run );
+
+ quickLayout->addWidget( allopen );
+ quickLayout->addWidget( allclose );
+ quickLayout->addWidget( flat );
+
+ if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->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);
@@ -1061,50 +1095,54 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
switch (column){
case 1:
mPriorityPopupMenu->popup(QCursor::pos ()); break;
case 2:
mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
case 3:
moveTodo();
break;
case 8:
mCategoryPopupMenu->popup(QCursor::pos ()); break;
case 9:
mCalPopupMenu->popup(QCursor::pos ()); break;
default:
mItemPopupMenu->popup(QCursor::pos());
}
} else mPopupMenu->popup(QCursor::pos());
}
void KOTodoView::newTodo()
{
emit newTodoSignal();
}
void KOTodoView::newSubTodo()
{
+ mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
if (mActiveItem) {
- emit newSubTodoSignal(mActiveItem->todo());
+ if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add a new Todo") ) {
+ addQuickTodoPar( mActiveItem->todo());
+ } else
+ emit newSubTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::unparentTodo()
{
if (mActiveItem) {
emit unparentTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::reparentTodo()
{
if (mActiveItem) {
topLevelWidget()->setCaption(i18n("Click on new parent item"));
pendingSubtodo = mActiveItem;
}
}
void KOTodoView::editTodo()
{
if (mActiveItem) {
emit editTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::cloneTodo()
{
@@ -1370,50 +1408,52 @@ void KOTodoView::itemStateChanged( QListViewItem *item )
// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
}
void KOTodoView::saveLayout(KConfig *config, const QString &group) const
{
mTodoListView->saveLayout(config,group);
}
void KOTodoView::restoreLayout(KConfig *config, const QString &group)
{
mTodoListView->restoreLayout(config,group);
}
void KOTodoView::processSelectionChange()
{
// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
KOTodoViewItem *item =
static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
if ( !item ) {
emit incidenceSelected( 0 );
+ mNewSubBut->setEnabled( false );
} else {
emit incidenceSelected( item->todo() );
+ mNewSubBut->setEnabled( true );
}
}
void KOTodoView::modified(bool b)
{
emit isModified(b);
}
void KOTodoView::setTodoModified( Todo* todo )
{
todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
}
void KOTodoView::clearSelection()
{
mTodoListView->selectAll( false );
}
void KOTodoView::setAllOpen()
{
if ( isFlatDisplay ) {
isFlatDisplay = false;
mPopupMenu->setItemChecked( 8,false );
updateView();
} else {
storeCurrentItem();
}
@@ -1459,95 +1499,117 @@ void KOTodoView::displayAllFlat()
KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
mTodoMap.insert(todo,todoItem);
}
resetCurrentItem();
}
void KOTodoView::setAllFlat()
{
if ( isFlatDisplay ) {
isFlatDisplay = false;
mPopupMenu->setItemChecked( 8,false );
updateView();
return;
}
displayAllFlat();
}
void KOTodoView::purgeCompleted()
{
emit purgeCompletedSignal();
}
void KOTodoView::toggleQuickTodo()
{
- if ( mQuickAdd->isVisible() ) {
- mQuickAdd->hide();
+ if ( mQuickBar->isVisible() ) {
+ mQuickBar->hide();
KOPrefs::instance()->mEnableQuickTodo = false;
}
else {
- mQuickAdd->show();
+ mQuickBar->show();
KOPrefs::instance()->mEnableQuickTodo = true;
}
mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
}
void KOTodoView::toggleRunning()
{
KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
updateView();
+ if ( KOPrefs::instance()->mHideNonStartedTodos )
+ topLevelWidget()->setCaption(i18n("Hide not Running"));
+ else
+ topLevelWidget()->setCaption(i18n("Show not Running"));
}
void KOTodoView::toggleCompleted()
{
KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
updateView();
+ if ( KOPrefs::instance()->mShowCompletedTodo )
+ topLevelWidget()->setCaption(i18n("Show Completed"));
+ else
+ topLevelWidget()->setCaption(i18n("Hide Completed"));
}
void KOTodoView::addQuickTodo()
{
- Todo *todo = new Todo();
- todo->setSummary(mQuickAdd->text());
- todo->setOrganizer(KOPrefs::instance()->email());
- CalFilter * cf = mCalendar->filter();
- if ( cf ) {
- if ( cf->isEnabled()&& cf->showCategories()) {
- todo->setCategories(cf->categoryList());
- }
- if ( cf->isEnabled() )
- todo->setSecrecy( cf->getSecrecy());
- }
- mCalendar->addTodo(todo);
- mQuickAdd->setText("");
- todoModified (todo, KOGlobals::EVENTADDED );
- updateView();
+ addQuickTodoPar( 0 );
}
+void KOTodoView::addQuickTodoPar( Todo * parentTodo)
+{
+ Todo *todo = new Todo();
+ todo->setSummary(mQuickAdd->text());
+ todo->setOrganizer(KOPrefs::instance()->email());
+ if ( parentTodo ) {
+ todo->setRelatedTo(parentTodo);
+
+ todo->setCategories (parentTodo->categoriesStr ());
+ todo->setSecrecy (parentTodo->secrecy ());
+ if ( parentTodo->priority() < 3 )
+ todo->setPriority( parentTodo->priority() );
+ todo->setCalID( parentTodo->calID() );
+ } else {
+ CalFilter * cf = mCalendar->filter();
+ if ( cf ) {
+ if ( cf->isEnabled()&& cf->showCategories()) {
+ todo->setCategories(cf->categoryList());
+ }
+ if ( cf->isEnabled() )
+ todo->setSecrecy( cf->getSecrecy());
+ }
+ }
+ mCalendar->addTodo(todo);
+ mQuickAdd->setText("");
+ todoModified (todo, KOGlobals::EVENTADDED );
+ updateView();
+}
void KOTodoView::keyPressEvent ( QKeyEvent * e )
{
// e->ignore();
//return;
//qDebug("KOTodoView::keyPressEvent ");
switch ( e->key() ) {
case Qt::Key_Down:
case Qt::Key_Up:
QWidget::keyPressEvent ( e );
break;
case Qt::Key_Q:
toggleQuickTodo();
break;
case Qt::Key_U:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
unparentTodo();
e->accept();
} else
e->ignore();
break;
case Qt::Key_S:
if ( e->state() == Qt::ControlButton ) {