Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

taskeditorstatus.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include "taskeditorstatus.h"
00032 
00033 #include <opie2/opimmaintainer.h>
00034 #include <opie2/opimstate.h>
00035 
00036 #include <qpe/datebookmonth.h>
00037 
00038 #include <qcheckbox.h>
00039 #include <qcombobox.h>
00040 #include <qlabel.h>
00041 #include <qlayout.h>
00042 #include <qwhatsthis.h>
00043 
00044 // FIXME add the hack slots instead of setPopup!!!!
00045 // drw you shouldn't have removed them
00046 
00047 TaskEditorStatus::TaskEditorStatus( QWidget* parent,  const char* name, WFlags fl )
00048     : QWidget( parent, name, fl )
00049 {
00050     QDate curDate = QDate::currentDate();
00051     m_start = m_comp = m_due = curDate;
00052     QString curDateStr = TimeString::longDateString( curDate );
00053 
00054     QVBoxLayout *vb = new QVBoxLayout( this );
00055 
00056     QScrollView *sv = new QScrollView( this );
00057     vb->addWidget( sv );
00058     sv->setResizePolicy( QScrollView::AutoOneFit );
00059     sv->setFrameStyle( QFrame::NoFrame );
00060 
00061     QWidget *container = new QWidget( sv->viewport() );
00062     sv->addChild( container );
00063 
00064     QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 );
00065 
00066     // Status
00067     QLabel *label = new QLabel( tr( "Status:" ), container );
00068     layout->addWidget( label, 0, 0 );
00069     QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) );
00070     cmbStatus = new QComboBox( FALSE, container );
00071     cmbStatus->insertItem( tr( "Started" ) );
00072     cmbStatus->insertItem( tr( "Postponed" ) );
00073     cmbStatus->insertItem( tr( "Finished" ) );
00074     cmbStatus->insertItem( tr( "Not started" ) );
00075     layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 );
00076     QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) );
00077 
00078     // Progress
00079     label = new QLabel( tr( "Progress:" ), container );
00080     layout->addWidget( label, 1, 0 );
00081     QWhatsThis::add( label, tr( "Select progress made on this task here." ) );
00082     cmbProgress = new QComboBox( FALSE, container );
00083     cmbProgress->insertItem( tr( "0 %" ) );
00084     cmbProgress->insertItem( tr( "20 %" ) );
00085     cmbProgress->insertItem( tr( "40 %" ) );
00086     cmbProgress->insertItem( tr( "60 %" ) );
00087     cmbProgress->insertItem( tr( "80 %" ) );
00088     cmbProgress->insertItem( tr( "100 %" ) );
00089     layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 );
00090     QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) );
00091 
00092     // Start date
00093     ckbStart = new QCheckBox( tr( "Start Date:" ), container );
00094     layout->addWidget( ckbStart, 2, 0 );
00095     QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) );
00096     connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) );
00097     btnStart = new QPushButton( curDateStr, container );
00098     btnStart->setEnabled( FALSE );
00099     layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 );
00100     QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) );
00101     QPopupMenu *popup = new QPopupMenu( this );
00102     m_startBook = new DateBookMonth( popup, 0, TRUE );
00103     popup->insertItem( m_startBook );
00104     btnStart->setPopup( popup );
00105     connect( m_startBook, SIGNAL( dateClicked(int,int,int) ),
00106              this, SLOT( slotStartChanged(int,int,int) ) );
00107 
00108     // Due date
00109     ckbDue = new QCheckBox( tr( "Due Date:" ), container );
00110     layout->addWidget( ckbDue, 3, 0 );
00111     QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) );
00112     connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) );
00113     btnDue = new QPushButton( curDateStr, container );
00114     btnDue->setEnabled( FALSE );
00115     layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 );
00116     QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) );
00117     popup = new QPopupMenu( this );
00118     m_dueBook = new DateBookMonth( popup, 0, TRUE );
00119     popup->insertItem( m_dueBook );
00120     btnDue->setPopup( popup );
00121     connect( m_dueBook, SIGNAL( dateClicked(int,int,int) ),
00122              this, SLOT( slotDueChanged(int,int,int) ) );
00123 
00124     // Completed
00125     ckbComp = new QCheckBox( tr( "Completed:" ), container );
00126     layout->addWidget( ckbComp, 4, 0 );
00127     QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) );
00128     connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) );
00129     btnComp = new QPushButton( curDateStr, container );
00130     btnComp->setEnabled( FALSE );
00131     layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 );
00132     QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) );
00133     popup = new QPopupMenu( this );
00134     m_compBook = new DateBookMonth( popup, 0, TRUE );
00135     popup->insertItem( m_compBook );
00136     btnComp->setPopup( popup );
00137     connect( m_compBook, SIGNAL( dateClicked(int,int,int) ),
00138              this, SLOT( slotCompChanged(int,int,int) ) );
00139 
00140     QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
00141     layout->addItem( spacer, 5, 0 );
00142 
00143     // Maintainer mode
00144 #if 0
00145     label = new QLabel( tr( "Maintainer Mode:" ), container );
00146     layout->addWidget( label, 6, 0 );
00147     QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
00148     cmbMaintMode = new QComboBox( FALSE, container );
00149     cmbMaintMode->insertItem( tr( "Nothing" ) );
00150     cmbMaintMode->insertItem( tr( "Responsible" ) );
00151     cmbMaintMode->insertItem( tr( "Done By" ) );
00152     cmbMaintMode->insertItem( tr( "Coordinating" ) );
00153 //    layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
00154     QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
00155 
00156     // Maintainer
00157     label = new QLabel( tr( "Maintainer:" ), container );
00158     layout->addWidget( label, 7, 0 );
00159     QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
00160     txtMaintainer = new QLabel( tr( "test" ), container );
00161     txtMaintainer->setTextFormat( QLabel::RichText );
00162     layout->addWidget( txtMaintainer, 7, 1 );
00163     QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
00164     tbtMaintainer = new QToolButton( container );
00165     tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
00166 //    layout->addWidget( tbtMaintainer, 7, 2 );
00167     QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
00168 #endif
00169 }
00170 
00171 TaskEditorStatus::~TaskEditorStatus()
00172 {
00173 }
00174 
00175 void TaskEditorStatus::load( const OPimTodo &todo )
00176 {
00177     QDate date = QDate::currentDate();
00178     QString str = TimeString::longDateString( date );
00179 
00180     // Status
00181     int state = todo.hasState()? todo.state().state() : OPimState::NotStarted;
00182     if ( state == OPimState::Undefined )
00183         state = OPimState::NotStarted;
00184     cmbStatus->setCurrentItem( state );
00185 
00186     // Progress
00187     cmbProgress->setCurrentItem( todo.progress() / 20 );
00188 
00189     // Start date
00190     ckbStart->setChecked( todo.hasStartDate() );
00191     btnStart->setEnabled( todo.hasStartDate() );
00192     if ( todo.hasStartDate() )
00193     {
00194         m_start = todo.startDate();
00195         btnStart->setText( TimeString::longDateString( m_start ) );
00196     }
00197     else
00198         btnStart->setText( str );
00199 
00200     // Due date
00201     ckbDue->setChecked( todo.hasDueDate() );
00202     btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
00203     btnDue->setEnabled( todo.hasDueDate() );
00204     m_due = todo.dueDate();
00205 
00206     // Completed
00207     ckbComp->setChecked( todo.isCompleted() );
00208     btnComp->setEnabled( todo.hasCompletedDate() );
00209     if ( todo.hasCompletedDate() )
00210     {
00211         m_comp = todo.completedDate();
00212         btnComp->setText( TimeString::longDateString( m_comp ) );
00213     }
00214     else
00215         btnComp->setText( str );
00216 
00217     // Maintainer Mode
00218 #if 0
00219     state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing;
00220     if ( state == OPimMaintainer::Undefined )
00221         state = OPimMaintainer::Nothing;
00222     cmbMaintMode->setCurrentItem( state );
00223 #endif
00224     // Maintainer - not implemented yet
00225 }
00226 
00227 void TaskEditorStatus::save( OPimTodo &todo )
00228 {
00229     QDate inval;
00230 
00231     // Status
00232     todo.setState( OPimState( cmbStatus->currentItem() ) );
00233 
00234     // Progress
00235     todo.setProgress( cmbProgress->currentItem() * 20 );
00236 
00237     // Start date
00238     if ( ckbStart->isChecked() )
00239     {
00240         todo.setStartDate( m_start );
00241     }
00242     else
00243         todo.setStartDate( inval );
00244 
00245     // Due date
00246     if ( ckbDue->isChecked() )
00247     {
00248         todo.setDueDate( m_due );
00249         todo.setHasDueDate( true );
00250     }
00251     else
00252         todo.setHasDueDate( false );
00253 
00254     // Completed
00255     todo.setCompleted( ckbComp->isChecked() );
00256     if ( ckbComp->isChecked() )
00257     {
00258         todo.setCompletedDate( m_comp );
00259     }
00260     else
00261         todo.setCompletedDate( inval );
00262 
00263 #if 0
00264     // Maintainer mode - not implemented yet
00265 
00266     // Maintainer
00267     /* TODO - resolve name to uid.....*/
00268     todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) );
00269 #endif
00270 }
00271 
00272 void TaskEditorStatus::slotStartChecked()
00273 {
00274     btnStart->setEnabled( ckbStart->isChecked() );
00275 }
00276 
00277 void TaskEditorStatus::slotCompChecked()
00278 {
00279     btnComp->setEnabled( ckbComp->isChecked() );
00280 }
00281 
00282 void TaskEditorStatus::slotDueChecked()
00283 {
00284     btnDue->setEnabled( ckbDue->isChecked() );
00285 }
00286 
00287 void TaskEditorStatus::slotStartChanged(int y, int m, int d)
00288 {
00289     m_start.setYMD( y, m, d );
00290     btnStart->setText( TimeString::longDateString( m_start ) );
00291 }
00292 
00293 void TaskEditorStatus::slotCompChanged(int y, int m, int d)
00294 {
00295     m_comp.setYMD( y, m, d );
00296     btnComp->setText( TimeString::longDateString( m_comp ) );
00297 }
00298 
00299 void TaskEditorStatus::slotDueChanged(int y, int m, int d)
00300 {
00301     m_due.setYMD( y, m, d );
00302     btnDue->setText( TimeString::longDateString( m_due ) );
00303     emit dueDateChanged( m_due );
00304 }

Generated on Sat Nov 5 16:15:56 2005 for OPIE by  doxygen 1.4.2