summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 0e9f64c..72359df 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -157,128 +157,131 @@ SearchDialog::~SearchDialog()
}
void SearchDialog::slot_add( bool b )
{
if ( b ) {
if ( mSubItems->isOn() ) mSubItems->toggle();
if ( mRefineItems->isOn() ) mRefineItems->toggle();
setCaption( i18n("Matching items will be added to list"));
} else
setCaption( i18n("List will be cleared before search"));
}
void SearchDialog::slot_sub( bool b)
{
if ( b ) {
if ( mRefineItems->isOn() ) mRefineItems->toggle();
if ( mAddItems->isOn() ) mAddItems->toggle();
setCaption( i18n("Matching items will be removed from list"));
} else
setCaption( i18n("List will be cleared before search"));
}
void SearchDialog::slot_refine( bool b)
{
if ( b ) {
if ( mSubItems->isOn() ) mSubItems->toggle();
if ( mAddItems->isOn() ) mAddItems->toggle();
setCaption( i18n("Search on displayed list only"));
} else
setCaption( i18n("List will be cleared before search"));
}
void SearchDialog::toggleCheckboxes()
{
if ( incidenceGroup->isVisible() ) {
incidenceGroup->hide() ;
subjectGroup->hide() ;
attendeeGroup->hide() ;
} else {
incidenceGroup->show() ;
subjectGroup->show() ;
attendeeGroup->show() ;
}
}
void SearchDialog::raiseAndSelect()
{
static int currentState = 0;
if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
currentState = 0;
int newState = 0;
if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
newState = VIEW_J_VIEW;
}
else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
newState = VIEW_T_VIEW;
}
else {
newState = VIEW_A_VIEW;
}
if ( newState != currentState ) {
if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
if ( ! mSearchJournal->isChecked() ) {
mSearchJournal->setChecked( true );
mSearchTodo->setChecked( false );
mSearchEvent->setChecked( false );
+ mSummaryCheck->setChecked( true );
+ mDescriptionCheck->setChecked( true );
+
}
}
else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
if ( ! mSearchTodo->isChecked() ) {
mSearchTodo->setChecked( true );
mSearchJournal->setChecked( false );
mSearchEvent->setChecked( false );
}
}
else {
if ( ! mSearchEvent->isChecked() ) {
mSearchEvent->setChecked( true );
mSearchJournal->setChecked( false );
mSearchTodo->setChecked( false );
}
}
}
currentState = newState;
raise();
}
void SearchDialog::setFocusToList()
{
listView->resetFocus();
}
void SearchDialog::accept()
{
doSearch();
}
void SearchDialog::updateList()
{
//listView->updateList();
if ( isVisible() ) {
updateView();
//qDebug("SearchDialog::updated ");
}
else {
listView->clear();
//qDebug("SearchDialog::cleared ");
}
}
void SearchDialog::searchTextChanged( const QString &_text )
{
#if 0
enableButton( KDialogBase::User1, !_text.isEmpty() );
#endif
}
void SearchDialog::doSearch()
{
QRegExp re;
re.setWildcard(true); // most people understand these better.
re.setCaseSensitive(false);
QString st = searchEdit->text();
if ( st.right(1) != "*")
st += "*";
re.setPattern(st);
if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
KMessageBox::sorry(this,
i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
return;
}
if (!re.isValid() ) {
KMessageBox::sorry(this,
@@ -489,110 +492,126 @@ void SearchDialog::search(const QRegExp &re)
}
if (mCategoryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(tod->categoriesStr()) != -1)
#else
if (re.match(tod->categoriesStr()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedTodos.remove(tod);
else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
continue;
}
}
if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
QPtrList<Attendee> tmpAList = tod->attendees();
Attendee *a;
for (a = tmpAList.first(); a; a = tmpAList.next()) {
if (mSearchAName->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(a->name()) != -1)
#else
if (re.match(a->name()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedTodos.remove(tod);
else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
break;
}
}
if (mSearchAEmail->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(a->email()) != -1)
#else
if (re.match(a->email()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedTodos.remove(tod);
else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
break;
}
}
}
}
}
}
QPtrList<Journal> journals;
if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
if ( mRefineItems->isChecked() ) journals = mMatchedJournals ;
mMatchedJournals.clear();
}
if (mSearchJournal->isChecked() ) {
if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals();
Journal* journ;
for(journ=journals.first();journ;journ=journals.next()) {
if ( journ->dtStart().date() <= mEndDate->date()
&&journ->dtStart().date() >= mStartDate->date()) {
+ if (mDescriptionCheck->isChecked()) {
#if QT_VERSION >= 0x030000
- if (re.search(journ->description()) != -1)
+ if (re.search(journ->description()) != -1)
#else
- if (re.match(journ->description()) != -1)
+ if (re.match(journ->description()) != -1)
#endif
- {
- if ( mSubItems->isChecked() )
- mMatchedJournals.remove(journ);
- else if (!mMatchedJournals.contains( journ ))
- mMatchedJournals.append(journ);
- continue;
- }
+ {
+ if ( mSubItems->isChecked() )
+ mMatchedJournals.remove(journ);
+ else if (!mMatchedJournals.contains( journ ))
+ mMatchedJournals.append(journ);
+ continue;
+ }
+ }
+ if (mSummaryCheck->isChecked()) {
+#if QT_VERSION >= 0x030000
+ if (re.search(journ->summary()) != -1)
+#else
+ if (re.match(journ->summary()) != -1)
+#endif
+ {
+ if ( mSubItems->isChecked() )
+ mMatchedJournals.remove(journ);
+ else if (!mMatchedJournals.contains( journ ))
+ mMatchedJournals.append(journ);
+ continue;
+ }
+ }
}
}
}
if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) {
qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() );
if ( mRefineItems->isChecked() )
mRefineItems->setChecked( false );
else if ( mSubItems->isChecked() )
mSubItems->setChecked( false );
}
}
void SearchDialog::keyPressEvent ( QKeyEvent *e)
{
switch ( e->key() ) {
case Qt::Key_Escape:
close();
break;
case Qt::Key_F:
if ( e->state() == Qt::ControlButton ) {
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
doSearch();
break;
default:
e->ignore();
}
}
//mMatchedJournals;