-rw-r--r-- | korganizer/searchdialog.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index ef2fc1c..7b3b543 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -9,194 +9,211 @@ (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 <qlistview.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 "klineedit.h" #include "calendarview.h" #include "koviewmanager.h" #include "searchdialog.h" SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) : QVBox( 0 ) { mCalendar = calendar; 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); */ QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); //OkButton->setDefault( true ); connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); subLayout->addWidget(OkButton); searchEdit = new KLineEdit(topFrame); subLayout->addWidget(searchEdit); mAddItems = new QCheckBox(i18n("Add items"),topFrame); subLayout->addWidget(mAddItems); + QPushButton *togButton = new QPushButton( "", topFrame ); + subLayout->addWidget(togButton); + connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); + togButton->setPixmap(SmallIcon("1updownarrow")); + togButton->setMinimumWidth( togButton->sizeHint().height() ); 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 ); + 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 ); + subjectGroup = new QHBox( topFrame ); layout->addWidget(subjectGroup); mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); mSummaryCheck->setChecked(true); mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); - QHBox *attendeeGroup = new QHBox( topFrame ); + 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,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); QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); rangeLayout->addWidget( (QWidget*)wt ); layout->addWidget(rangeWidget); // Results list view listView = new KOListView(mCalendar,topFrame); layout->addWidget(listView); //layout->setStretchFactor( listView, 333 ); //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); //listView->setMaximumHeight( 50 ); listView->readSettings(KOGlobals::config(),"SearchListView Layout"); connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 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::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 ); } } 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 "); } } |