00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00048
00049
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
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 );
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
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 }