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.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 9cfdc35..105b844 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -3,160 +3,167 @@
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 <q3groupbox.h>
#include <qapplication.h>
+#include <QDesktopWidget>
#include <qlabel.h>
-#include <qlistview.h>
-#include <qwhatsthis.h>
+#include <q3listview.h>
+#include <q3whatsthis.h>
#include <qlineedit.h>
#include <qpushbutton.h>
-#include <qhbuttongroup.h>
+//#include <qhbuttongroup.h>
+//Added by qt3to4:
+#include <Q3HBoxLayout>
+#include <Q3Frame>
+#include <Q3PtrList>
+#include <QKeyEvent>
+#include <Q3VBoxLayout>
#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 )
+ : Q3VBox( 0 )
{
mCalendar = calendar;
- QFrame *topFrame = new QFrame( this ) ;//plainPage();
- QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
+ Q3Frame *topFrame = new Q3Frame( this ) ;//plainPage();
+ Q3VBoxLayout *layout = new Q3VBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
// Search expression
- QHBoxLayout *subLayout = new QHBoxLayout();
+ Q3HBoxLayout *subLayout = new Q3HBoxLayout();
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 QRadioButton( "+ ", topFrame );
mSubItems = new QRadioButton( "- ", topFrame );
mRefineItems = new QRadioButton( "< ", topFrame );
subLayout->addWidget( mAddItems );
subLayout->addWidget( mSubItems );
subLayout->addWidget( mRefineItems );
QFont fo ( mAddItems->font() );
fo.setBold( true );
fo.setPointSize( fo.pointSize() + 2 );
mAddItems->setFont( fo );
mSubItems->setFont( fo );
mRefineItems->setFont( fo );
connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool )));
connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool )));
connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool )));
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);
- incidenceGroup = new QHBox( topFrame );
+ incidenceGroup = new Q3HBox( 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);
- subjectGroup = new QHBox( topFrame );
+ subjectGroup = new Q3HBox( 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);
- attendeeGroup = new QHBox( topFrame );
+ attendeeGroup = new Q3HBox( 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);
int space = KDialog::spacingHint();
if ( QApplication::desktop()->width() <= 240 ) space = 1;
- QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space);
+ Q3HBoxLayout *rangeLayout = new Q3HBoxLayout(rangeWidget,0,space);
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 );
+ QToolButton *wt = Q3WhatsThis::whatsThisButton ( rangeWidget );
rangeLayout->addWidget( (QWidget*)wt );
layout->addWidget(rangeWidget);
// Results list view
listView = new KOListView(mCalendar,topFrame);
layout->addWidget(listView);
listView->showCompletedTodos();
//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::slot_add( bool b )
@@ -320,49 +327,49 @@ void SearchDialog::updateConfig()
void SearchDialog::updateView()
{
//qDebug("SearchDialog::updateView() %d ", isVisible());
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);
mMatchedEvents.clear();
mMatchedTodos.clear();
mMatchedJournals.clear();
if (re.isValid()) {
search(re);
}
listView->setStartDate( mStartDate->date() );
listView->showEvents(mMatchedEvents);
listView->addTodos(mMatchedTodos);
listView->addJournals(mMatchedJournals);
}
void SearchDialog::search(const QRegExp &re)
{
- QPtrList<Event> events;
+ Q3PtrList<Event> events;
if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
if ( mRefineItems->isChecked() ) events = mMatchedEvents;
mMatchedEvents.clear();
}
if ( mSearchEvent->isChecked() ) {
if ( !mRefineItems->isChecked() )
events = mCalendar->events( mStartDate->date(),
mEndDate->date(),
false /*mInclusiveCheck->isChecked()*/ );
Event *ev;
for(ev=events.first();ev;ev=events.next()) {
if (mSummaryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(ev->summary()) != -1)
#else
if (re.match(ev->summary()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedEvents.remove(ev);
else {
if ( !mMatchedEvents.contains( ev ) )
@@ -398,88 +405,88 @@ void SearchDialog::search(const QRegExp &re)
if ( !mMatchedEvents.contains( ev ) )
mMatchedEvents.append(ev);
}
continue;
}
}
if (mCategoryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(ev->categoriesStr()) != -1)
#else
if (re.match(ev->categoriesStr()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedEvents.remove(ev);
else{
if ( !mMatchedEvents.contains( ev ) )
mMatchedEvents.append(ev);
}
continue;
}
}
if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
- QPtrList<Attendee> tmpAList = ev->attendees();
+ Q3PtrList<Attendee> tmpAList = ev->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() )
mMatchedEvents.remove(ev);
else{
if ( !mMatchedEvents.contains( ev ) )
mMatchedEvents.append(ev);
}
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() )
mMatchedEvents.remove(ev);
else{
if ( !mMatchedEvents.contains( ev ) )
mMatchedEvents.append(ev);
}
break;
}
}
}
}
}
}
- QPtrList<Todo> todos;
+ Q3PtrList<Todo> todos;
if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
if ( mRefineItems->isChecked() ) todos = mMatchedTodos ;
mMatchedTodos.clear();
}
if ( mSearchTodo->isChecked() ) {
if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( );
Todo *tod;
for(tod=todos.first();tod;tod=todos.next()) {
if (mSummaryCheck->isChecked()) {
#if QT_VERSION >= 0x030000
if (re.search(tod->summary()) != -1)
#else
if (re.match(tod->summary()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedTodos.remove(tod);
else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
continue;
}
}
@@ -491,85 +498,85 @@ void SearchDialog::search(const QRegExp &re)
#endif
{
if ( mSubItems->isChecked() )
mMatchedTodos.remove(tod);
else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
continue;
}
}
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();
+ Q3PtrList<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;
+ Q3PtrList<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)
#else
if (re.match(journ->description()) != -1)
#endif
{
if ( mSubItems->isChecked() )
mMatchedJournals.remove(journ);
else if (!mMatchedJournals.contains( journ ))
mMatchedJournals.append(journ);
continue;
}