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

quickeditimpl.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 <qaction.h>
00032 #include <qlineedit.h>
00033 #include <qwhatsthis.h>
00034 
00035 #include <opie2/oclickablelabel.h>
00036 #include <opie2/oresource.h>
00037 
00038 #include "mainwindow.h"
00039 #include "quickeditimpl.h"
00040 
00041 
00042 
00043 QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
00044     : QToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) {
00045     setHorizontalStretchable( TRUE );
00046 
00047     // Load priority icons
00048     // TODO - probably should be done globally somewhere else,
00049     //        see also tableview.cpp/h, taskeditoroverview.cpp/h
00050     priority1 = Opie::Core::OResource::loadPixmap( "todo/priority1" );
00051     priority3 = Opie::Core::OResource::loadPixmap( "todo/priority3" );
00052     priority5 = Opie::Core::OResource::loadPixmap( "todo/priority5" );
00053 
00054     m_lbl = new Opie::Ui::OClickableLabel( this );
00055     m_lbl->setMinimumWidth( 15 );
00056     m_lbl->setPixmap( priority3 );
00057     connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) );
00058     QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list.  This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
00059 
00060     m_edit = new QLineEdit( this );
00061     setStretchableWidget( m_edit );
00062     QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list.  This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
00063 
00064     /*
00065      * it's not implemented and won't be implemented for 1.0
00066      */
00067 #if 0
00068     QAction *a = new QAction( QWidget::tr( "More" ), Opie::Core::OResource::loadPixmap( "todo/more", Opie::Core::OResource::SmallIcon ),
00069                               QString::null, 0, this, 0 );
00070     connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) );
00071     a->addTo( this );
00072     a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list.  This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
00073 #endif
00074 
00075     QAction *a = new QAction( QWidget::tr( "Enter" ), Opie::Core::OResource::loadPixmap( "enter", Opie::Core::OResource::SmallIcon ),
00076                               QString::null, 0, this, 0 );
00077     connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) );
00078     a->addTo( this );
00079     a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list.  This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
00080 
00081     a = new QAction( QWidget::tr( "Cancel" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),
00082                      QString::null, 0, this, 0 );
00083     connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) );
00084     a->addTo( this );
00085     a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list.  This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
00086 
00087     m_visible = visible;
00088     if ( !m_visible ) {
00089         hide();
00090     }
00091 
00092     m_menu = 0l;
00093     reinit();
00094 }
00095 QuickEditImpl::~QuickEditImpl() {
00096 
00097 }
00098 OPimTodo QuickEditImpl::todo()const {
00099     return m_todo;
00100 }
00101 QWidget* QuickEditImpl::widget() {
00102     return this;
00103 }
00104 void QuickEditImpl::slotEnter() {
00105     OPimTodo todo;
00106 
00107 
00108     if (!m_edit->text().isEmpty() ) {
00109         todo.setUid(1 ); // new uid
00110         todo.setPriority( m_state );
00111         todo.setSummary( m_edit->text() );
00112         if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 )
00113             todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() );
00114 
00115         m_todo = todo;
00116        commit();
00117     }
00118     m_todo = todo;
00119     reinit();
00120 }
00121 void QuickEditImpl::slotPrio() {
00122     m_state -= 2;
00123     if ( m_state < 1 )
00124         m_state = 5;
00125 
00126     switch( m_state ) {
00127     case 1:
00128         m_lbl->setPixmap( priority1 );
00129         break;
00130     case 5:
00131         m_lbl->setPixmap( priority5 );
00132         break;
00133     case 3:
00134     default:
00135         m_lbl->setPixmap( priority3 );
00136         break;
00137     }
00138 }
00139 void QuickEditImpl::slotMore() {
00140     // TODO - implement
00141 }
00142 void QuickEditImpl::slotCancel() {
00143     reinit();
00144 }
00145 void QuickEditImpl::reinit() {
00146     m_state = 3;
00147     m_lbl->setPixmap( priority3 );
00148     m_edit->clear();
00149 }

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