summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Unidiff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index d0865c3..efe8774 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -31,193 +31,195 @@
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qhbuttongroup.h> 33#include <qhbuttongroup.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 /* 58 /*
59 searchLabel = new QLabel(topFrame); 59 searchLabel = new QLabel(topFrame);
60 searchLabel->setText(i18n("Search for:")); 60 searchLabel->setText(i18n("Search for:"));
61 subLayout->addWidget(searchLabel); 61 subLayout->addWidget(searchLabel);
62 */ 62 */
63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); 63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
64 //OkButton->setDefault( true ); 64 //OkButton->setDefault( true );
65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
66 subLayout->addWidget(OkButton); 66 subLayout->addWidget(OkButton);
67 searchEdit = new KLineEdit(topFrame); 67 searchEdit = new KLineEdit(topFrame);
68 subLayout->addWidget(searchEdit); 68 subLayout->addWidget(searchEdit);
69 69
70 mAddItems = new QRadioButton( "+ ", topFrame ); 70 mAddItems = new QRadioButton( "+ ", topFrame );
71 mSubItems = new QRadioButton( "- ", topFrame ); 71 mSubItems = new QRadioButton( "- ", topFrame );
72 mRefineItems = new QRadioButton( "< ", topFrame ); 72 mRefineItems = new QRadioButton( "< ", topFrame );
73 subLayout->addWidget( mAddItems ); 73 subLayout->addWidget( mAddItems );
74 subLayout->addWidget( mSubItems ); 74 subLayout->addWidget( mSubItems );
75 subLayout->addWidget( mRefineItems ); 75 subLayout->addWidget( mRefineItems );
76 QFont fo ( mAddItems->font() ); 76 QFont fo ( mAddItems->font() );
77 fo.setBold( true ); 77 fo.setBold( true );
78 fo.setPointSize( fo.pointSize() + 2 ); 78 fo.setPointSize( fo.pointSize() + 2 );
79 mAddItems->setFont( fo ); 79 mAddItems->setFont( fo );
80 mSubItems->setFont( fo ); 80 mSubItems->setFont( fo );
81 mRefineItems->setFont( fo ); 81 mRefineItems->setFont( fo );
82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); 82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool )));
83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); 83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool )));
84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); 84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool )));
85 85
86 QPushButton *togButton = new QPushButton( "", topFrame ); 86 QPushButton *togButton = new QPushButton( "", topFrame );
87 subLayout->addWidget(togButton); 87 subLayout->addWidget(togButton);
88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); 88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes()));
89 togButton->setPixmap(SmallIcon("1updownarrow")); 89 togButton->setPixmap(SmallIcon("1updownarrow"));
90 togButton->setMinimumWidth( togButton->sizeHint().height() ); 90 togButton->setMinimumWidth( togButton->sizeHint().height() );
91 91
92 searchEdit->setText("*"); // Find all events by default 92 searchEdit->setText("*"); // Find all events by default
93 searchEdit->setFocus(); 93 searchEdit->setFocus();
94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
96 // Subjects to search 96 // Subjects to search
97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
98 // topFrame); 98 // topFrame);
99 99
100 incidenceGroup = new QHBox( topFrame ); 100 incidenceGroup = new QHBox( topFrame );
101 layout->addWidget(incidenceGroup); 101 layout->addWidget(incidenceGroup);
102 102
103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
104 //mSearchEvent->setChecked(true); 104 //mSearchEvent->setChecked(true);
105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
107 107
108 subjectGroup = new QHBox( topFrame ); 108 subjectGroup = new QHBox( topFrame );
109 layout->addWidget(subjectGroup); 109 layout->addWidget(subjectGroup);
110 110
111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
112 mSummaryCheck->setChecked(true); 112 mSummaryCheck->setChecked(true);
113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
115 115
116 attendeeGroup = new QHBox( topFrame ); 116 attendeeGroup = new QHBox( topFrame );
117 layout->addWidget(attendeeGroup ); 117 layout->addWidget(attendeeGroup );
118 new QLabel( i18n("Attendee:"),attendeeGroup ); 118 new QLabel( i18n("Attendee:"),attendeeGroup );
119 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 119 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
120 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 120 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
121 // Date range 121 // Date range
122 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 122 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
123 // topFrame); 123 // topFrame);
124 // layout->addWidget(rangeGroup); 124 // layout->addWidget(rangeGroup);
125 125
126 QWidget *rangeWidget = new QWidget(topFrame); 126 QWidget *rangeWidget = new QWidget(topFrame);
127 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()-3); 127 int space = KDialog::spacingHint();
128 if ( QApplication::desktop()->width() <= 240 ) space = 1;
129 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space);
128 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 130 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
129 mStartDate = new KDateEdit(rangeWidget); 131 mStartDate = new KDateEdit(rangeWidget);
130 rangeLayout->addWidget(mStartDate); 132 rangeLayout->addWidget(mStartDate);
131 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 133 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
132 mEndDate = new KDateEdit(rangeWidget); 134 mEndDate = new KDateEdit(rangeWidget);
133 mEndDate->setDate(QDate::currentDate().addDays(365)); 135 mEndDate->setDate(QDate::currentDate().addDays(365));
134 rangeLayout->addWidget(mEndDate); 136 rangeLayout->addWidget(mEndDate);
135 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 137 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
136 rangeLayout->addWidget( (QWidget*)wt ); 138 rangeLayout->addWidget( (QWidget*)wt );
137 layout->addWidget(rangeWidget); 139 layout->addWidget(rangeWidget);
138 // Results list view 140 // Results list view
139 listView = new KOListView(mCalendar,topFrame); 141 listView = new KOListView(mCalendar,topFrame);
140 layout->addWidget(listView); 142 layout->addWidget(listView);
141 listView->showCompletedTodos(); 143 listView->showCompletedTodos();
142 //layout->setStretchFactor( listView, 333 ); 144 //layout->setStretchFactor( listView, 333 );
143 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 145 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
144 //listView->setMaximumHeight( 50 ); 146 //listView->setMaximumHeight( 50 );
145 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 147 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
146 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 148 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
147 149
148 setCaption( i18n("KO/Pi Find: ")); 150 setCaption( i18n("KO/Pi Find: "));
149#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
150 OkButton = new QPushButton( i18n("Close"), this ); 152 OkButton = new QPushButton( i18n("Close"), this );
151 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 153 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
152#endif 154#endif
153} 155}
154 156
155SearchDialog::~SearchDialog() 157SearchDialog::~SearchDialog()
156{ 158{
157 159
158} 160}
159void SearchDialog::slot_add( bool b ) 161void SearchDialog::slot_add( bool b )
160{ 162{
161 if ( b ) { 163 if ( b ) {
162 if ( mSubItems->isOn() ) mSubItems->toggle(); 164 if ( mSubItems->isOn() ) mSubItems->toggle();
163 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 165 if ( mRefineItems->isOn() ) mRefineItems->toggle();
164 setCaption( i18n("Matching items will be added to list")); 166 setCaption( i18n("Matching items will be added to list"));
165 } else 167 } else
166 setCaption( i18n("List will be cleared before search")); 168 setCaption( i18n("List will be cleared before search"));
167} 169}
168void SearchDialog::slot_sub( bool b) 170void SearchDialog::slot_sub( bool b)
169{ 171{
170 if ( b ) { 172 if ( b ) {
171 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 173 if ( mRefineItems->isOn() ) mRefineItems->toggle();
172 if ( mAddItems->isOn() ) mAddItems->toggle(); 174 if ( mAddItems->isOn() ) mAddItems->toggle();
173 setCaption( i18n("Matching items will be removed from list")); 175 setCaption( i18n("Matching items will be removed from list"));
174 } else 176 } else
175 setCaption( i18n("List will be cleared before search")); 177 setCaption( i18n("List will be cleared before search"));
176} 178}
177void SearchDialog::slot_refine( bool b) 179void SearchDialog::slot_refine( bool b)
178{ 180{
179 if ( b ) { 181 if ( b ) {
180 if ( mSubItems->isOn() ) mSubItems->toggle(); 182 if ( mSubItems->isOn() ) mSubItems->toggle();
181 if ( mAddItems->isOn() ) mAddItems->toggle(); 183 if ( mAddItems->isOn() ) mAddItems->toggle();
182 setCaption( i18n("Search on displayed list only")); 184 setCaption( i18n("Search on displayed list only"));
183 } else 185 } else
184 setCaption( i18n("List will be cleared before search")); 186 setCaption( i18n("List will be cleared before search"));
185} 187}
186void SearchDialog::toggleCheckboxes() 188void SearchDialog::toggleCheckboxes()
187{ 189{
188 if ( incidenceGroup->isVisible() ) { 190 if ( incidenceGroup->isVisible() ) {
189 incidenceGroup->hide() ; 191 incidenceGroup->hide() ;
190 subjectGroup->hide() ; 192 subjectGroup->hide() ;
191 attendeeGroup->hide() ; 193 attendeeGroup->hide() ;
192 } else { 194 } else {
193 incidenceGroup->show() ; 195 incidenceGroup->show() ;
194 subjectGroup->show() ; 196 subjectGroup->show() ;
195 attendeeGroup->show() ; 197 attendeeGroup->show() ;
196 } 198 }
197} 199}
198void SearchDialog::raiseAndSelect() 200void SearchDialog::raiseAndSelect()
199{ 201{
200 202
201 static int currentState = 0; 203 static int currentState = 0;
202 204
203 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 205 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
204 currentState = 0; 206 currentState = 0;
205 int newState = 0; 207 int newState = 0;
206 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 208 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
207 newState = VIEW_J_VIEW; 209 newState = VIEW_J_VIEW;
208 } 210 }
209 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 211 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
210 newState = VIEW_T_VIEW; 212 newState = VIEW_T_VIEW;
211 } 213 }
212 else { 214 else {
213 newState = VIEW_A_VIEW; 215 newState = VIEW_A_VIEW;
214 } 216 }
215 if ( newState != currentState ) { 217 if ( newState != currentState ) {
216 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 218 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
217 if ( ! mSearchJournal->isChecked() ) { 219 if ( ! mSearchJournal->isChecked() ) {
218 mSearchJournal->setChecked( true ); 220 mSearchJournal->setChecked( true );
219 mSearchTodo->setChecked( false ); 221 mSearchTodo->setChecked( false );
220 mSearchEvent->setChecked( false ); 222 mSearchEvent->setChecked( false );
221 mSummaryCheck->setChecked( true ); 223 mSummaryCheck->setChecked( true );
222 mDescriptionCheck->setChecked( true ); 224 mDescriptionCheck->setChecked( true );
223 225