00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "findwidget_p.h"
00022
00023 #include <qpe/categoryselect.h>
00024 #include <qpe/datebookmonth.h>
00025
00026 #include <qcheckbox.h>
00027 #include <qlabel.h>
00028 #include <qlineedit.h>
00029
00030 FindWidget::FindWidget( const QString &appName, QWidget *parent,
00031 const char *name )
00032 : FindWidgetBase( parent, name ),
00033 mStrApp( appName ),
00034 mDate( QDate::currentDate() )
00035 {
00036 setMaximumSize( sizeHint() );
00037 QArray<int> vl(0);
00038 cmbCat->setCategories( vl, mStrApp );
00039 cmbCat->setRemoveCategoryEdit( TRUE );
00040 cmbCat->setAllCategories( TRUE );
00041
00042 lblStartDate->hide();
00043 cmdStartDate->hide();
00044 QPopupMenu *m1 = new QPopupMenu( this );
00045 dtPicker = new DateBookMonth( m1, 0, TRUE );
00046 dtPicker->setDate( mDate.year(), mDate.month(), mDate.day() );
00047 m1->insertItem( dtPicker );
00048 cmdStartDate->setPopup( m1 );
00049 cmdStartDate->setText( TimeString::shortDate(mDate) );
00050 QObject::connect( dtPicker, SIGNAL(dateClicked(int,int,int)),
00051 this, SLOT(slotDateChanged(int,int,int)) );
00052
00053 QObject::connect( cmdFind, SIGNAL(clicked()),
00054 this, SLOT(slotFindClicked()) );
00055 }
00056
00057 FindWidget::~FindWidget()
00058 {
00059 }
00060
00061 QString FindWidget::findText() const
00062 {
00063 return txtFind->text();
00064 }
00065
00066 void FindWidget::slotFindClicked()
00067 {
00068 lblStatus->setText( "" );
00069 if ( cmdStartDate->isVisible() )
00070 emit signalFindClicked( findText(),
00071 mDate,
00072 chkCase->isChecked(),
00073 chkBackwards->isChecked(),
00074 cmbCat->currentCategory() );
00075 else
00076 emit signalFindClicked( findText(), chkCase->isChecked(),
00077 chkBackwards->isChecked(),
00078 cmbCat->currentCategory() );
00079 }
00080
00081 void FindWidget::setUseDate( bool show )
00082 {
00083 if ( show ) {
00084 lblStartDate->show();
00085 cmdStartDate->show();
00086 } else {
00087 lblStartDate->hide();
00088 cmdStartDate->hide();
00089 }
00090 chkBackwards->setDisabled( show );
00091 }
00092
00093 void FindWidget::setDate( const QDate &dt )
00094 {
00095 slotDateChanged( dt.year(), dt.month(), dt.day() );
00096 }
00097
00098 void FindWidget::slotNotFound()
00099 {
00100 lblStatus->setText( tr("String Not Found.") );
00101 }
00102
00103 void FindWidget::slotWrapAround()
00104 {
00105 lblStatus->setText( tr("End reached, starting at %1", "Date using TimeString::shortDate")
00106 .arg(TimeString::shortDate( mDate ) ) );
00107 }
00108
00109 void FindWidget::slotDateChanged( int year, int month, int day )
00110 {
00111 mDate.setYMD( year, month, day );
00112 cmdStartDate->setText( TimeString::shortDate( mDate ) );
00113 dtPicker->setDate( year, month, day );
00114 }