-rw-r--r-- | korganizer/searchdialog.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index efe8774..2e32ac2 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -1,219 +1,220 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qgroupbox.h> | 27 | #include <qgroupbox.h> |
28 | #include <qapplication.h> | ||
28 | #include <qlabel.h> | 29 | #include <qlabel.h> |
29 | #include <qlistview.h> | 30 | #include <qlistview.h> |
30 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
31 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
33 | #include <qhbuttongroup.h> | 34 | #include <qhbuttongroup.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | #include <kmessagebox.h> | 36 | #include <kmessagebox.h> |
36 | 37 | ||
37 | #include <libkdepim/kdateedit.h> | 38 | #include <libkdepim/kdateedit.h> |
38 | 39 | ||
39 | #include "koglobals.h" | 40 | #include "koglobals.h" |
40 | #include "koprefs.h" | 41 | #include "koprefs.h" |
41 | #include "klineedit.h" | 42 | #include "klineedit.h" |
42 | 43 | ||
43 | #include "calendarview.h" | 44 | #include "calendarview.h" |
44 | #include "koviewmanager.h" | 45 | #include "koviewmanager.h" |
45 | #include "searchdialog.h" | 46 | #include "searchdialog.h" |
46 | 47 | ||
47 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | 48 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) |
48 | : QVBox( 0 ) | 49 | : QVBox( 0 ) |
49 | 50 | ||
50 | { | 51 | { |
51 | mCalendar = calendar; | 52 | mCalendar = calendar; |
52 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); | 53 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); |
53 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); | 54 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); |
54 | 55 | ||
55 | // Search expression | 56 | // Search expression |
56 | QHBoxLayout *subLayout = new QHBoxLayout(); | 57 | QHBoxLayout *subLayout = new QHBoxLayout(); |
57 | layout->addLayout(subLayout); | 58 | layout->addLayout(subLayout); |
58 | /* | 59 | /* |
59 | searchLabel = new QLabel(topFrame); | 60 | searchLabel = new QLabel(topFrame); |
60 | searchLabel->setText(i18n("Search for:")); | 61 | searchLabel->setText(i18n("Search for:")); |
61 | subLayout->addWidget(searchLabel); | 62 | subLayout->addWidget(searchLabel); |
62 | */ | 63 | */ |
63 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); | 64 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); |
64 | //OkButton->setDefault( true ); | 65 | //OkButton->setDefault( true ); |
65 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); | 66 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); |
66 | subLayout->addWidget(OkButton); | 67 | subLayout->addWidget(OkButton); |
67 | searchEdit = new KLineEdit(topFrame); | 68 | searchEdit = new KLineEdit(topFrame); |
68 | subLayout->addWidget(searchEdit); | 69 | subLayout->addWidget(searchEdit); |
69 | 70 | ||
70 | mAddItems = new QRadioButton( "+ ", topFrame ); | 71 | mAddItems = new QRadioButton( "+ ", topFrame ); |
71 | mSubItems = new QRadioButton( "- ", topFrame ); | 72 | mSubItems = new QRadioButton( "- ", topFrame ); |
72 | mRefineItems = new QRadioButton( "< ", topFrame ); | 73 | mRefineItems = new QRadioButton( "< ", topFrame ); |
73 | subLayout->addWidget( mAddItems ); | 74 | subLayout->addWidget( mAddItems ); |
74 | subLayout->addWidget( mSubItems ); | 75 | subLayout->addWidget( mSubItems ); |
75 | subLayout->addWidget( mRefineItems ); | 76 | subLayout->addWidget( mRefineItems ); |
76 | QFont fo ( mAddItems->font() ); | 77 | QFont fo ( mAddItems->font() ); |
77 | fo.setBold( true ); | 78 | fo.setBold( true ); |
78 | fo.setPointSize( fo.pointSize() + 2 ); | 79 | fo.setPointSize( fo.pointSize() + 2 ); |
79 | mAddItems->setFont( fo ); | 80 | mAddItems->setFont( fo ); |
80 | mSubItems->setFont( fo ); | 81 | mSubItems->setFont( fo ); |
81 | mRefineItems->setFont( fo ); | 82 | mRefineItems->setFont( fo ); |
82 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); | 83 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); |
83 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); | 84 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); |
84 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); | 85 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); |
85 | 86 | ||
86 | QPushButton *togButton = new QPushButton( "", topFrame ); | 87 | QPushButton *togButton = new QPushButton( "", topFrame ); |
87 | subLayout->addWidget(togButton); | 88 | subLayout->addWidget(togButton); |
88 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); | 89 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); |
89 | togButton->setPixmap(SmallIcon("1updownarrow")); | 90 | togButton->setPixmap(SmallIcon("1updownarrow")); |
90 | togButton->setMinimumWidth( togButton->sizeHint().height() ); | 91 | togButton->setMinimumWidth( togButton->sizeHint().height() ); |
91 | 92 | ||
92 | searchEdit->setText("*"); // Find all events by default | 93 | searchEdit->setText("*"); // Find all events by default |
93 | searchEdit->setFocus(); | 94 | searchEdit->setFocus(); |
94 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 95 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
95 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); | 96 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); |
96 | // Subjects to search | 97 | // Subjects to search |
97 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), | 98 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), |
98 | // topFrame); | 99 | // topFrame); |
99 | 100 | ||
100 | incidenceGroup = new QHBox( topFrame ); | 101 | incidenceGroup = new QHBox( topFrame ); |
101 | layout->addWidget(incidenceGroup); | 102 | layout->addWidget(incidenceGroup); |
102 | 103 | ||
103 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); | 104 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); |
104 | //mSearchEvent->setChecked(true); | 105 | //mSearchEvent->setChecked(true); |
105 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); | 106 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); |
106 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); | 107 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); |
107 | 108 | ||
108 | subjectGroup = new QHBox( topFrame ); | 109 | subjectGroup = new QHBox( topFrame ); |
109 | layout->addWidget(subjectGroup); | 110 | layout->addWidget(subjectGroup); |
110 | 111 | ||
111 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); | 112 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); |
112 | mSummaryCheck->setChecked(true); | 113 | mSummaryCheck->setChecked(true); |
113 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); | 114 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); |
114 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); | 115 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); |
115 | 116 | ||
116 | attendeeGroup = new QHBox( topFrame ); | 117 | attendeeGroup = new QHBox( topFrame ); |
117 | layout->addWidget(attendeeGroup ); | 118 | layout->addWidget(attendeeGroup ); |
118 | new QLabel( i18n("Attendee:"),attendeeGroup ); | 119 | new QLabel( i18n("Attendee:"),attendeeGroup ); |
119 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); | 120 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); |
120 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); | 121 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); |
121 | // Date range | 122 | // Date range |
122 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), | 123 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), |
123 | // topFrame); | 124 | // topFrame); |
124 | // layout->addWidget(rangeGroup); | 125 | // layout->addWidget(rangeGroup); |
125 | 126 | ||
126 | QWidget *rangeWidget = new QWidget(topFrame); | 127 | QWidget *rangeWidget = new QWidget(topFrame); |
127 | int space = KDialog::spacingHint(); | 128 | int space = KDialog::spacingHint(); |
128 | if ( QApplication::desktop()->width() <= 240 ) space = 1; | 129 | if ( QApplication::desktop()->width() <= 240 ) space = 1; |
129 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); | 130 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); |
130 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); | 131 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); |
131 | mStartDate = new KDateEdit(rangeWidget); | 132 | mStartDate = new KDateEdit(rangeWidget); |
132 | rangeLayout->addWidget(mStartDate); | 133 | rangeLayout->addWidget(mStartDate); |
133 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); | 134 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); |
134 | mEndDate = new KDateEdit(rangeWidget); | 135 | mEndDate = new KDateEdit(rangeWidget); |
135 | mEndDate->setDate(QDate::currentDate().addDays(365)); | 136 | mEndDate->setDate(QDate::currentDate().addDays(365)); |
136 | rangeLayout->addWidget(mEndDate); | 137 | rangeLayout->addWidget(mEndDate); |
137 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); | 138 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); |
138 | rangeLayout->addWidget( (QWidget*)wt ); | 139 | rangeLayout->addWidget( (QWidget*)wt ); |
139 | layout->addWidget(rangeWidget); | 140 | layout->addWidget(rangeWidget); |
140 | // Results list view | 141 | // Results list view |
141 | listView = new KOListView(mCalendar,topFrame); | 142 | listView = new KOListView(mCalendar,topFrame); |
142 | layout->addWidget(listView); | 143 | layout->addWidget(listView); |
143 | listView->showCompletedTodos(); | 144 | listView->showCompletedTodos(); |
144 | //layout->setStretchFactor( listView, 333 ); | 145 | //layout->setStretchFactor( listView, 333 ); |
145 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); | 146 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); |
146 | //listView->setMaximumHeight( 50 ); | 147 | //listView->setMaximumHeight( 50 ); |
147 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); | 148 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); |
148 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); | 149 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); |
149 | 150 | ||
150 | setCaption( i18n("KO/Pi Find: ")); | 151 | setCaption( i18n("KO/Pi Find: ")); |
151 | #ifdef DESKTOP_VERSION | 152 | #ifdef DESKTOP_VERSION |
152 | OkButton = new QPushButton( i18n("Close"), this ); | 153 | OkButton = new QPushButton( i18n("Close"), this ); |
153 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); | 154 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); |
154 | #endif | 155 | #endif |
155 | } | 156 | } |
156 | 157 | ||
157 | SearchDialog::~SearchDialog() | 158 | SearchDialog::~SearchDialog() |
158 | { | 159 | { |
159 | 160 | ||
160 | } | 161 | } |
161 | void SearchDialog::slot_add( bool b ) | 162 | void SearchDialog::slot_add( bool b ) |
162 | { | 163 | { |
163 | if ( b ) { | 164 | if ( b ) { |
164 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 165 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
165 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 166 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
166 | setCaption( i18n("Matching items will be added to list")); | 167 | setCaption( i18n("Matching items will be added to list")); |
167 | } else | 168 | } else |
168 | setCaption( i18n("List will be cleared before search")); | 169 | setCaption( i18n("List will be cleared before search")); |
169 | } | 170 | } |
170 | void SearchDialog::slot_sub( bool b) | 171 | void SearchDialog::slot_sub( bool b) |
171 | { | 172 | { |
172 | if ( b ) { | 173 | if ( b ) { |
173 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 174 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
174 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 175 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
175 | setCaption( i18n("Matching items will be removed from list")); | 176 | setCaption( i18n("Matching items will be removed from list")); |
176 | } else | 177 | } else |
177 | setCaption( i18n("List will be cleared before search")); | 178 | setCaption( i18n("List will be cleared before search")); |
178 | } | 179 | } |
179 | void SearchDialog::slot_refine( bool b) | 180 | void SearchDialog::slot_refine( bool b) |
180 | { | 181 | { |
181 | if ( b ) { | 182 | if ( b ) { |
182 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 183 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
183 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 184 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
184 | setCaption( i18n("Search on displayed list only")); | 185 | setCaption( i18n("Search on displayed list only")); |
185 | } else | 186 | } else |
186 | setCaption( i18n("List will be cleared before search")); | 187 | setCaption( i18n("List will be cleared before search")); |
187 | } | 188 | } |
188 | void SearchDialog::toggleCheckboxes() | 189 | void SearchDialog::toggleCheckboxes() |
189 | { | 190 | { |
190 | if ( incidenceGroup->isVisible() ) { | 191 | if ( incidenceGroup->isVisible() ) { |
191 | incidenceGroup->hide() ; | 192 | incidenceGroup->hide() ; |
192 | subjectGroup->hide() ; | 193 | subjectGroup->hide() ; |
193 | attendeeGroup->hide() ; | 194 | attendeeGroup->hide() ; |
194 | } else { | 195 | } else { |
195 | incidenceGroup->show() ; | 196 | incidenceGroup->show() ; |
196 | subjectGroup->show() ; | 197 | subjectGroup->show() ; |
197 | attendeeGroup->show() ; | 198 | attendeeGroup->show() ; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | void SearchDialog::raiseAndSelect() | 201 | void SearchDialog::raiseAndSelect() |
201 | { | 202 | { |
202 | 203 | ||
203 | static int currentState = 0; | 204 | static int currentState = 0; |
204 | 205 | ||
205 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) | 206 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) |
206 | currentState = 0; | 207 | currentState = 0; |
207 | int newState = 0; | 208 | int newState = 0; |
208 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 209 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
209 | newState = VIEW_J_VIEW; | 210 | newState = VIEW_J_VIEW; |
210 | } | 211 | } |
211 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 212 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
212 | newState = VIEW_T_VIEW; | 213 | newState = VIEW_T_VIEW; |
213 | } | 214 | } |
214 | else { | 215 | else { |
215 | newState = VIEW_A_VIEW; | 216 | newState = VIEW_A_VIEW; |
216 | } | 217 | } |
217 | if ( newState != currentState ) { | 218 | if ( newState != currentState ) { |
218 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 219 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
219 | if ( ! mSearchJournal->isChecked() ) { | 220 | if ( ! mSearchJournal->isChecked() ) { |