summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
authorzautrix <zautrix>2005-04-01 09:50:16 (UTC)
committer zautrix <zautrix>2005-04-01 09:50:16 (UTC)
commitf8e027db1d950ec27a3c47fc2a5ea2fe49ae9772 (patch) (side-by-side diff)
tree15edcb7a2b053eae5c5391191f71ba5c5c015211 /korganizer/searchdialog.cpp
parentb76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (diff)
downloadkdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.zip
kdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.tar.gz
kdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.tar.bz2
fixes
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 341a839..db60383 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -56,49 +56,49 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
QHBoxLayout *subLayout = new QHBoxLayout();
layout->addLayout(subLayout);
searchLabel = new QLabel(topFrame);
searchLabel->setText(i18n("Search for:"));
subLayout->addWidget(searchLabel);
searchEdit = new KLineEdit(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);
+ //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("Details"),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,KDialog::spacingHint());
rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
@@ -108,48 +108,91 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
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);
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::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 ");
}
}
void SearchDialog::searchTextChanged( const QString &_text )
{
#if 0
@@ -180,49 +223,49 @@ void SearchDialog::doSearch()
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()
{
-
+ //qDebug("SearchDialog::updateView() %d ", isVisible());
QRegExp re;
re.setWildcard(true); // most people understand these better.
re.setCaseSensitive(false);
re.setPattern(searchEdit->text());
if (re.isValid()) {
search(re);
} else {
mMatchedEvents.clear();
mMatchedTodos.clear();
mMatchedJournals.clear();
}
listView->setStartDate( mStartDate->date() );
listView->showEvents(mMatchedEvents);
listView->addTodos(mMatchedTodos);
listView->addJournals(mMatchedJournals);
}
void SearchDialog::search(const QRegExp &re)
{
QPtrList<Event> events = mCalendar->events( mStartDate->date(),
mEndDate->date(),
false /*mInclusiveCheck->isChecked()*/ );
mMatchedEvents.clear();