author | zautrix <zautrix> | 2005-02-22 01:14:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-22 01:14:35 (UTC) |
commit | df40d77f7407326221ba2848163c4f61b7bb1d2f (patch) (side-by-side diff) | |
tree | 1b46bf666f7371189ba421080f4dcd66dc9037f2 /korganizer/searchdialog.cpp | |
parent | ce261d6197d319d67f7b275813449f36ce42a730 (diff) | |
download | kdepimpi-df40d77f7407326221ba2848163c4f61b7bb1d2f.zip kdepimpi-df40d77f7407326221ba2848163c4f61b7bb1d2f.tar.gz kdepimpi-df40d77f7407326221ba2848163c4f61b7bb1d2f.tar.bz2 |
next
-rw-r--r-- | korganizer/searchdialog.cpp | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 3fd9740..aa1b244 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -1,209 +1,198 @@ /* This file is part of KOrganizer. Copyright (c) 1998 Preston Brown Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> +#include <qwhatsthis.h> #include <qlineedit.h> #include <qpushbutton.h> #include <klocale.h> #include <kmessagebox.h> #include <libkdepim/kdateedit.h> #include "koglobals.h" #include "koprefs.h" #include "calendarview.h" #include "koviewmanager.h" #include "searchdialog.h" SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) - : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, - i18n("&Find")) + : QVBox( 0 ) + { mCalendar = calendar; - QFrame *topFrame = plainPage(); - QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); + QFrame *topFrame = new QFrame( this ) ;//plainPage(); + QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); // Search expression QHBoxLayout *subLayout = new QHBoxLayout(); layout->addLayout(subLayout); - searchLabel = new QLabel(topFrame); searchLabel->setText(i18n("Search for:")); subLayout->addWidget(searchLabel); searchEdit = new QLineEdit(topFrame); subLayout->addWidget(searchEdit); + QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); + //OkButton->setDefault( true ); + connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); + subLayout->addWidget(OkButton); searchEdit->setText("*"); // Find all events by default searchEdit->setFocus(); connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); // Subjects to search // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), // topFrame); - - QHBox *incidenceGroup = new QHBox( topFrame ); layout->addWidget(incidenceGroup); mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); mSearchEvent->setChecked(true); mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); QHBox *subjectGroup = new QHBox( topFrame ); layout->addWidget(subjectGroup); mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); mSummaryCheck->setChecked(true); mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); QHBox *attendeeGroup = new QHBox( topFrame ); layout->addWidget(attendeeGroup ); new QLabel( i18n("Attendee:"),attendeeGroup ); mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); // Date range // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), // topFrame); // layout->addWidget(rangeGroup); QWidget *rangeWidget = new QWidget(topFrame); - QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); - + QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); mStartDate = new KDateEdit(rangeWidget); rangeLayout->addWidget(mStartDate); rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); mEndDate = new KDateEdit(rangeWidget); mEndDate->setDate(QDate::currentDate().addDays(365)); rangeLayout->addWidget(mEndDate); - - // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); - //mInclusiveCheck->setChecked(false); + QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); + rangeLayout->addWidget( (QWidget*)wt ); layout->addWidget(rangeWidget); - //layout->addWidget(mInclusiveCheck); - // Subjects to search - - // Results list view listView = new KOListView(mCalendar,topFrame); - //listView->showDates(); - - layout->addWidget(listView); - // if ( KOPrefs::instance()->mCompactDialogs ) { - // KOGlobals::fitDialogToScreen( this, true ); - // } - listView->readSettings(KOGlobals::config(),"SearchListView Layout"); - connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); - QPushButton *CloseButton = findButton( Close ); - //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); -#ifndef DESKTOP_VERSION - setCaption(i18n("Click OK to search ->")); - hideButtons(); + setCaption( i18n("KO/Pi Find: ")); +#ifdef DESKTOP_VERSION + OkButton = new QPushButton( i18n("Close"), this ); + connect(OkButton,SIGNAL(clicked()),SLOT(hide())); #endif } SearchDialog::~SearchDialog() { } 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); re.setPattern(searchEdit->text()); if (!re.isValid() ) { KMessageBox::sorry(this, i18n("Invalid search expression,\ncannot perform " "the search.\nPlease enter a search expression\n" "using the wildcard characters\n '*' and '?'" "where needed.")); return; } search(re); listView->setStartDate( mStartDate->date() ); listView->showEvents(mMatchedEvents); listView->addTodos(mMatchedTodos); listView->addJournals(mMatchedJournals); if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { setCaption(i18n("No items found. Use '*' and '?' where needed.")); } else { QString mess; mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); setCaption( i18n("KO/Pi Find: ") + mess); } searchEdit->setFocus(); } void SearchDialog::updateConfig() { listView->updateConfig(); } void SearchDialog::updateView() { QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern(searchEdit->text()); if (re.isValid()) { search(re); @@ -345,57 +334,72 @@ void SearchDialog::search(const QRegExp &re) if (mSearchAName->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { 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 { mMatchedTodos.append(tod); break; } } } } } } mMatchedJournals.clear(); if (mSearchJournal->isChecked() ) { QPtrList<Journal> 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 QT_VERSION >= 0x030000 if (re.search(journ->description()) != -1) #else if (re.match(journ->description()) != -1) #endif { mMatchedJournals.append(journ); continue; } } } } } -/* + void SearchDialog::keyPressEvent ( QKeyEvent *e) { - - e->ignore(); - + switch ( e->key() ) { + case Qt::Key_Escape: + hide(); + break; + case Qt::Key_F: + if ( e->state() == Qt::ControlButton ) { + qDebug("full "); + + } + break; + case Qt::Key_Return: + case Qt::Key_Enter: + doSearch(); + break; + + default: + e->ignore(); + } } -*/ + //mMatchedJournals; |