author | zautrix <zautrix> | 2005-06-16 06:30:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-16 06:30:09 (UTC) |
commit | 9f60da2b6768e94d2aeb2f94a4479b6678f2aa76 (patch) (unidiff) | |
tree | eea4e7ee02afc86a543c142efa7b5c8c83e0f1f8 /korganizer | |
parent | b8b1547f1f4ae54ace16e5faf55aad1274ec2e57 (diff) | |
download | kdepimpi-9f60da2b6768e94d2aeb2f94a4479b6678f2aa76.zip kdepimpi-9f60da2b6768e94d2aeb2f94a4479b6678f2aa76.tar.gz kdepimpi-9f60da2b6768e94d2aeb2f94a4479b6678f2aa76.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/kofilterview.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 36ee2eb..e4dc751 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,423 +1,424 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kcolorbutton.h> | 40 | #include <kcolorbutton.h> |
41 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
48 | const char* name,WFlags fl ) | 48 | const char* name,WFlags fl ) |
49 | : KOFilterView_base(parent,name,fl) | 49 | : KOFilterView_base(parent,name,fl) |
50 | { | 50 | { |
51 | mFilters = filterList; | 51 | mFilters = filterList; |
52 | 52 | ||
53 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 53 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
54 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 54 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
55 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 55 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
56 | } | 56 | } |
57 | 57 | ||
58 | KOFilterView::~KOFilterView() | 58 | KOFilterView::~KOFilterView() |
59 | { | 59 | { |
60 | // no need to delete child widgets, Qt does it all for us | 60 | // no need to delete child widgets, Qt does it all for us |
61 | } | 61 | } |
62 | 62 | ||
63 | bool KOFilterView::filtersEnabled() | 63 | bool KOFilterView::filtersEnabled() |
64 | { | 64 | { |
65 | return mEnabledCheck->isChecked(); | 65 | return mEnabledCheck->isChecked(); |
66 | } | 66 | } |
67 | 67 | ||
68 | void KOFilterView::setFiltersEnabled(bool set) | 68 | void KOFilterView::setFiltersEnabled(bool set) |
69 | { | 69 | { |
70 | mEnabledCheck->setChecked(set); | 70 | mEnabledCheck->setChecked(set); |
71 | emit filterChanged(); | 71 | emit filterChanged(); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void KOFilterView::updateFilters() | 75 | void KOFilterView::updateFilters() |
76 | { | 76 | { |
77 | mSelectionCombo->clear(); | 77 | mSelectionCombo->clear(); |
78 | 78 | ||
79 | CalFilter *filter = mFilters->first(); | 79 | CalFilter *filter = mFilters->first(); |
80 | while(filter) { | 80 | while(filter) { |
81 | mSelectionCombo->insertItem(filter->name()); | 81 | mSelectionCombo->insertItem(filter->name()); |
82 | filter = mFilters->next(); | 82 | filter = mFilters->next(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | CalFilter *KOFilterView::selectedFilter() | 86 | CalFilter *KOFilterView::selectedFilter() |
87 | { | 87 | { |
88 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 88 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
89 | return f; | 89 | return f; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KOFilterView::setSelectedFilter(QString filterName) | 92 | void KOFilterView::setSelectedFilter(QString filterName) |
93 | { | 93 | { |
94 | int filter_num = mSelectionCombo->count(); | 94 | int filter_num = mSelectionCombo->count(); |
95 | int i; | 95 | int i; |
96 | for (i=0;i<filter_num;i++) { | 96 | for (i=0;i<filter_num;i++) { |
97 | if (mSelectionCombo->text(i)==filterName) | 97 | if (mSelectionCombo->text(i)==filterName) |
98 | mSelectionCombo->setCurrentItem(i); | 98 | mSelectionCombo->setCurrentItem(i); |
99 | } | 99 | } |
100 | emit filterChanged(); | 100 | emit filterChanged(); |
101 | } | 101 | } |
102 | void KOFilterView::setSelectedFilter( int fil ) | 102 | void KOFilterView::setSelectedFilter( int fil ) |
103 | { | 103 | { |
104 | if ( fil >= mSelectionCombo->count() ) | 104 | if ( fil >= mSelectionCombo->count() ) |
105 | return; | 105 | return; |
106 | mSelectionCombo->setCurrentItem( fil ); | 106 | mSelectionCombo->setCurrentItem( fil ); |
107 | emit filterChanged(); | 107 | emit filterChanged(); |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | KOCalEditView::KOCalEditView(QWidget* parent, | 112 | KOCalEditView::KOCalEditView(QWidget* parent, |
113 | const char* name ) | 113 | const char* name ) |
114 | : QScrollView(parent,name) | 114 | : QScrollView(parent,name) |
115 | { | 115 | { |
116 | mw = 0; | 116 | mw = 0; |
117 | setResizePolicy( AutoOneFit ); | 117 | setResizePolicy( AutoOneFit ); |
118 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); | 118 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); |
119 | setLineWidth ( 1 ); | 119 | setLineWidth ( 1 ); |
120 | setMidLineWidth ( 1 ); | 120 | setMidLineWidth ( 1 ); |
121 | setFocusPolicy(NoFocus); | 121 | setFocusPolicy(NoFocus); |
122 | } | 122 | } |
123 | 123 | ||
124 | KOCalEditView::~KOCalEditView() | 124 | KOCalEditView::~KOCalEditView() |
125 | { | 125 | { |
126 | // no need to delete child widgets, Qt does it all for us | 126 | // no need to delete child widgets, Qt does it all for us |
127 | } | 127 | } |
128 | void KOCalEditView::selectCal(int id ,bool b) | 128 | void KOCalEditView::selectCal(int id ,bool b) |
129 | { | 129 | { |
130 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 130 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
131 | emit calendarEnabled ( id, b ); | 131 | emit calendarEnabled ( id, b ); |
132 | emit needsUpdate(); | 132 | emit needsUpdate(); |
133 | 133 | ||
134 | } | 134 | } |
135 | void KOCalEditView::selectStdCal( int id, bool b ) | 135 | void KOCalEditView::selectStdCal( int id, bool b ) |
136 | { | 136 | { |
137 | 137 | ||
138 | if ( !b ) { | 138 | if ( !b ) { |
139 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); | 139 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); |
140 | if ( it ) { | 140 | if ( it ) { |
141 | it->blockSignals( true ); | 141 | it->blockSignals( true ); |
142 | it->setChecked( true ); | 142 | it->setChecked( true ); |
143 | it->blockSignals( false ); | 143 | it->blockSignals( false ); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | return; | 146 | return; |
147 | } | 147 | } |
148 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); | 148 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); |
149 | KOCalCheckButton* it = mStdandardB.first(); | 149 | KOCalCheckButton* it = mStdandardB.first(); |
150 | while ( it ) { | 150 | while ( it ) { |
151 | if ( it->isChecked() ) { | 151 | if ( it->isChecked() ) { |
152 | if ( it != sen ) { | 152 | if ( it != sen ) { |
153 | it->blockSignals( true ); | 153 | it->blockSignals( true ); |
154 | it->setChecked( false ); | 154 | it->setChecked( false ); |
155 | it->blockSignals( false ); | 155 | it->blockSignals( false ); |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | it = mStdandardB.next(); | 159 | it = mStdandardB.next(); |
160 | } | 160 | } |
161 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 161 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
162 | while ( kkf ) { | 162 | while ( kkf ) { |
163 | kkf->isStandard = false; | 163 | kkf->isStandard = false; |
164 | kkf = KOPrefs::instance()->mCalendars.next(); | 164 | kkf = KOPrefs::instance()->mCalendars.next(); |
165 | } | 165 | } |
166 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | 166 | KOPrefs::instance()->getCalendar( id )->isStandard = true; |
167 | emit setCalendarDefault ( id ); | 167 | emit setCalendarDefault ( id ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 170 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
171 | { | 171 | { |
172 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 172 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
173 | emit alarmEnabled ( id , b ); | 173 | emit alarmEnabled ( id , b ); |
174 | emit needsUpdate(); | 174 | emit needsUpdate(); |
175 | } | 175 | } |
176 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 176 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
177 | { | 177 | { |
178 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 178 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
179 | emit calendarReadonly ( id , b ); | 179 | emit calendarReadonly ( id , b ); |
180 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { | 180 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { |
181 | KOPrefs::instance()->getCalendar( id )->isStandard = false; | 181 | KOPrefs::instance()->getCalendar( id )->isStandard = false; |
182 | KOPrefs::instance()->getCalendar( 1 )->isStandard = true; | 182 | KOPrefs::instance()->getCalendar( 1 )->isStandard = true; |
183 | emit setCalendarDefault ( 1 ); | 183 | emit setCalendarDefault ( 1 ); |
184 | } | 184 | } |
185 | emit needsUpdate(); | 185 | emit needsUpdate(); |
186 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 186 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
187 | 187 | ||
188 | } | 188 | } |
189 | void KOCalEditView::setColor( const QColor& c, int id ) | 189 | void KOCalEditView::setColor( const QColor& c, int id ) |
190 | { | 190 | { |
191 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 191 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
192 | emit needsUpdate(); | 192 | emit needsUpdate(); |
193 | } | 193 | } |
194 | void KOCalEditView::deleteCal( int id ) | 194 | void KOCalEditView::deleteCal( int id ) |
195 | { | 195 | { |
196 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 196 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
197 | QString name = kkf->mName; | 197 | QString name = kkf->mName; |
198 | QString file = kkf->mFileName; | 198 | QString file = kkf->mFileName; |
199 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar<tr><b>%1</b><tr>is displaying file<tr><b>%2</b><tr>Do you want to remove<tr>this calendar from KO/Pi?<tr>(The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 199 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
200 | if ( kkf->isStandard ) | 200 | if ( kkf->isStandard ) |
201 | selectStdCal( 1, true ); | 201 | selectStdCal( 1, true ); |
202 | emit removeCalendar ( id ); | 202 | emit removeCalendar ( id ); |
203 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 203 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
204 | emit needsUpdate(); | 204 | emit needsUpdate(); |
205 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 205 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
206 | } | 206 | } |
207 | void KOCalEditView::infoCal( int id ) | 207 | void KOCalEditView::infoCal( int id ) |
208 | { | 208 | { |
209 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 209 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
210 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; | 210 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; |
211 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { | 211 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
212 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <tr><b>%1</b><tr> is not loaded! Loading of file <tr><b>%2</b><tr>failed!<tr><b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | 212 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { |
213 | emit calendarAdded( id ); | 213 | emit calendarAdded( id ); |
214 | emit needsUpdate(); | 214 | emit needsUpdate(); |
215 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 215 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | else | 218 | else |
219 | KMessageBox::information( this, i18n("The calendar <tr><b>%1</b><tr>is displaying file<tr><b>%2</b>").arg(name).arg(file) ); | 219 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
220 | } | 220 | } |
221 | void KOCalEditView::readConfig() | 221 | void KOCalEditView::readConfig() |
222 | { | 222 | { |
223 | 223 | ||
224 | mStdandardB.clear(); | 224 | mStdandardB.clear(); |
225 | mEnabledB.clear(); | 225 | mEnabledB.clear(); |
226 | mAlarmB.clear(); | 226 | mAlarmB.clear(); |
227 | mROB.clear(); | 227 | mROB.clear(); |
228 | 228 | ||
229 | if ( mw ) delete mw; | 229 | if ( mw ) delete mw; |
230 | mw = new QWidget ( viewport() ); | 230 | mw = new QWidget ( viewport() ); |
231 | addChild(mw); | 231 | addChild(mw); |
232 | 232 | ||
233 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 233 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
234 | mainLayout->setMargin( 3); | 234 | mainLayout->setMargin( 3); |
235 | mainLayout->setSpacing( 2); | 235 | mainLayout->setSpacing( 2); |
236 | QPushButton * addBut = new QPushButton ( mw ); | 236 | QPushButton * addBut = new QPushButton ( mw ); |
237 | addBut->setFocusPolicy(NoFocus); | 237 | addBut->setFocusPolicy(NoFocus); |
238 | mainLayout->addWidget( addBut,0,0 ); | 238 | mainLayout->addWidget( addBut,0,0 ); |
239 | addBut->setPixmap ( SmallIcon("plus")); | 239 | addBut->setPixmap ( SmallIcon("plus")); |
240 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 240 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
241 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 241 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
242 | 242 | ||
243 | addBut = new QPushButton ( mw ); | 243 | addBut = new QPushButton ( mw ); |
244 | addBut->setFocusPolicy(NoFocus); | 244 | addBut->setFocusPolicy(NoFocus); |
245 | mainLayout->addWidget( addBut,0,1 ); | 245 | mainLayout->addWidget( addBut,0,1 ); |
246 | addBut->setPixmap ( SmallIcon("eye")); | 246 | addBut->setPixmap ( SmallIcon("eye")); |
247 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 247 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
248 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 248 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
249 | 249 | ||
250 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); | 250 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); |
251 | mainLayout->addWidget( lab,0,2 ); | 251 | mainLayout->addWidget( lab,0,2 ); |
252 | lab = new QLabel ( i18n(" "), mw ); | 252 | lab = new QLabel ( i18n(" "), mw ); |
253 | mainLayout->addWidget( lab,0,3 ); | 253 | mainLayout->addWidget( lab,0,3 ); |
254 | lab->setFixedWidth( 6 ); | 254 | lab->setFixedWidth( 6 ); |
255 | addBut = new QPushButton ( mw ); | 255 | addBut = new QPushButton ( mw ); |
256 | addBut->setFocusPolicy(NoFocus); | 256 | addBut->setFocusPolicy(NoFocus); |
257 | mainLayout->addWidget( addBut,0,4 ); | 257 | mainLayout->addWidget( addBut,0,4 ); |
258 | addBut->setPixmap ( SmallIcon("bell")); | 258 | addBut->setPixmap ( SmallIcon("bell")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
261 | 261 | ||
262 | addBut = new QPushButton ( mw ); | 262 | addBut = new QPushButton ( mw ); |
263 | addBut->setFocusPolicy(NoFocus); | 263 | addBut->setFocusPolicy(NoFocus); |
264 | mainLayout->addWidget( addBut,0,5 ); | 264 | mainLayout->addWidget( addBut,0,5 ); |
265 | addBut->setPixmap ( SmallIcon("pencil")); | 265 | addBut->setPixmap ( SmallIcon("pencil")); |
266 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 266 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
267 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 267 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
268 | 268 | ||
269 | lab = new QLabel ( i18n(" Color "), mw ); | 269 | lab = new QLabel ( i18n(" Color "), mw ); |
270 | mainLayout->addWidget( lab,0,6 ); | 270 | mainLayout->addWidget( lab,0,6 ); |
271 | #if 0 | 271 | #if 0 |
272 | addBut = new QPushButton ( mw ); | 272 | addBut = new QPushButton ( mw ); |
273 | mainLayout->addWidget( addBut,0,6 ); | 273 | mainLayout->addWidget( addBut,0,6 ); |
274 | addBut->setPixmap ( SmallIcon("minus")); | 274 | addBut->setPixmap ( SmallIcon("minus")); |
275 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); | 275 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); |
276 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 276 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | 279 | ||
280 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 280 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
281 | int row = 1; | 281 | int row = 1; |
282 | while ( kkf ) { | 282 | while ( kkf ) { |
283 | int iii = 0; | 283 | int iii = 0; |
284 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 284 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
285 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); | 285 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); |
286 | cb->setChecked( kkf->isStandard ); | 286 | cb->setChecked( kkf->isStandard ); |
287 | cb->setNum( kkf->mCalNumber ); | 287 | cb->setNum( kkf->mCalNumber ); |
288 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); | 288 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); |
289 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 289 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
290 | cb->setEnabled( false ); | 290 | cb->setEnabled( false ); |
291 | cb = new KOCalCheckButton( mw ); | 291 | cb = new KOCalCheckButton( mw ); |
292 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); | 292 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); |
293 | cb->setChecked( kkf->isEnabled ); | 293 | cb->setChecked( kkf->isEnabled ); |
294 | cb->setNum( kkf->mCalNumber ); | 294 | cb->setNum( kkf->mCalNumber ); |
295 | if ( kkf->mErrorOnLoad ) | 295 | if ( kkf->mErrorOnLoad ) |
296 | cb->setEnabled( false ); | 296 | cb->setEnabled( false ); |
297 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 297 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
298 | KOCalButton* name = new KOCalButton( mw ); | 298 | KOCalButton* name = new KOCalButton( mw ); |
299 | name->setNum( kkf->mCalNumber ); | 299 | name->setNum( kkf->mCalNumber ); |
300 | name->setText( kkf->mName ); | 300 | name->setText( kkf->mName ); |
301 | mainLayout->addWidget( name,row,++iii ); | 301 | mainLayout->addWidget( name,row,++iii ); |
302 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 302 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
303 | lab = new QLabel ( i18n(" "), mw ); | 303 | lab = new QLabel ( i18n(" "), mw ); |
304 | mainLayout->addWidget( lab,row,++iii ); | 304 | mainLayout->addWidget( lab,row,++iii ); |
305 | cb = new KOCalCheckButton( mw ); | 305 | cb = new KOCalCheckButton( mw ); |
306 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 306 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
307 | cb->setChecked( kkf->isAlarmEnabled ); | 307 | cb->setChecked( kkf->isAlarmEnabled ); |
308 | cb->setNum( kkf->mCalNumber ); | 308 | cb->setNum( kkf->mCalNumber ); |
309 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 309 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
310 | if ( kkf->mErrorOnLoad ) | 310 | if ( kkf->mErrorOnLoad ) |
311 | cb->setEnabled( false ); | 311 | cb->setEnabled( false ); |
312 | cb = new KOCalCheckButton( mw ); | 312 | cb = new KOCalCheckButton( mw ); |
313 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 313 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
314 | cb->setChecked( kkf->isReadOnly ); | 314 | cb->setChecked( kkf->isReadOnly ); |
315 | cb->setNum( kkf->mCalNumber ); | 315 | cb->setNum( kkf->mCalNumber ); |
316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
317 | if ( kkf->mErrorOnLoad ) | 317 | if ( kkf->mErrorOnLoad ) |
318 | cb->setEnabled( false ); | 318 | cb->setEnabled( false ); |
319 | if ( row > 1) { | 319 | if ( row > 1) { |
320 | KColorButton *colb = new KColorButton( mw ); | 320 | KColorButton *colb = new KColorButton( mw ); |
321 | mainLayout->addWidget( colb,row,++iii ); | 321 | mainLayout->addWidget( colb,row,++iii ); |
322 | colb->setID( kkf->mCalNumber ); | 322 | colb->setID( kkf->mCalNumber ); |
323 | colb->setColor( kkf->mDefaultColor ); | 323 | colb->setColor( kkf->mDefaultColor ); |
324 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 324 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
325 | KOCalButton* calb = new KOCalButton( mw ); | 325 | KOCalButton* calb = new KOCalButton( mw ); |
326 | mainLayout->addWidget( calb,row,++iii ); | 326 | mainLayout->addWidget( calb,row,++iii ); |
327 | calb->setNum( kkf->mCalNumber ); | 327 | calb->setNum( kkf->mCalNumber ); |
328 | calb->setPixmap ( SmallIcon("minus")); | 328 | calb->setPixmap ( SmallIcon("minus")); |
329 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 329 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
330 | int hei = calb->sizeHint().height(); | 330 | int hei = calb->sizeHint().height(); |
331 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 331 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
332 | } | 332 | } |
333 | ++row; | 333 | ++row; |
334 | kkf = KOPrefs::instance()->mCalendars.next(); | 334 | kkf = KOPrefs::instance()->mCalendars.next(); |
335 | } | 335 | } |
336 | lab = new QLabel ( "", mw ); | 336 | lab = new QLabel ( "", mw ); |
337 | mainLayout->addWidget( lab,row,0 ); | 337 | mainLayout->addWidget( lab,row,0 ); |
338 | mw->show(); | 338 | mw->show(); |
339 | 339 | ||
340 | } | 340 | } |
341 | void KOCalEditView::addCal() | 341 | void KOCalEditView::addCal() |
342 | { | 342 | { |
343 | bool tryagain = true; | 343 | bool tryagain = true; |
344 | QString name, file; | 344 | QString name, file; |
345 | while ( tryagain ) { | 345 | while ( tryagain ) { |
346 | KONewCalPrefs prefs ( this ); | 346 | KONewCalPrefs prefs ( this ); |
347 | if ( !name.isEmpty() ) prefs.nameE->setText( name ); | 347 | prefs.nameE->setText( name ); |
348 | if ( !file.isEmpty() ) prefs.url->setURL( file ); | 348 | prefs.url->setURL( file ); |
349 | if ( ! prefs.exec() ) | 349 | if ( ! prefs.exec() ) |
350 | return; | 350 | return; |
351 | name = prefs.calName(); | 351 | name = prefs.calName(); |
352 | file = prefs.calFileName(); | 352 | file = prefs.calFileName(); |
353 | tryagain = false; | 353 | tryagain = false; |
354 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 354 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
355 | while ( kkf ) { | 355 | while ( kkf ) { |
356 | if ( kkf->mName == name ) { | 356 | if ( kkf->mName == name ) { |
357 | KMessageBox::information( this, i18n("Sorry, the calendar name already exists!\nPlease choose another name!") ); | 357 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
358 | name = ""; | 358 | name = ""; |
359 | tryagain = true; | ||
359 | break; | 360 | break; |
360 | tryagain = true; | ||
361 | } | 361 | } |
362 | if ( kkf->mFileName == file ) { | 362 | if ( kkf->mFileName == file ) { |
363 | 363 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( file) ); | |
364 | break; | ||
365 | tryagain = true; | 364 | tryagain = true; |
365 | file = ""; | ||
366 | break; | ||
366 | } | 367 | } |
367 | kkf = KOPrefs::instance()->mCalendars.next(); | 368 | kkf = KOPrefs::instance()->mCalendars.next(); |
368 | } | 369 | } |
369 | } | 370 | } |
370 | QFileInfo fi ( file ); | 371 | QFileInfo fi ( file ); |
371 | if (!fi.exists() ) { | 372 | if (!fi.exists() ) { |
372 | if ( KMessageBox::questionYesNo(this, i18n("The file does not exist!\nShall I create it for you?")) == KMessageBox::No ) | 373 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) |
373 | return; | 374 | return; |
374 | QFile fileIn( file ); | 375 | QFile fileIn( file ); |
375 | if (!fileIn.open( IO_WriteOnly ) ) { | 376 | if (!fileIn.open( IO_WriteOnly ) ) { |
376 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file!\nNo calendar added!") ); | 377 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
377 | return; | 378 | return; |
378 | } | 379 | } |
379 | QTextStream tsIn( &fileIn ); | 380 | QTextStream tsIn( &fileIn ); |
380 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 381 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
381 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 382 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
382 | fileIn.close(); | 383 | fileIn.close(); |
383 | } | 384 | } |
384 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 385 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
385 | kkf->mName = name; | 386 | kkf->mName = name; |
386 | kkf->mFileName = file; | 387 | kkf->mFileName = file; |
387 | emit calendarAdded( kkf->mCalNumber ); | 388 | emit calendarAdded( kkf->mCalNumber ); |
388 | emit needsUpdate(); | 389 | emit needsUpdate(); |
389 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 390 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
390 | } | 391 | } |
391 | void KOCalEditView::enableAll() | 392 | void KOCalEditView::enableAll() |
392 | { | 393 | { |
393 | toggleList( mEnabledB ); | 394 | toggleList( mEnabledB ); |
394 | } | 395 | } |
395 | void KOCalEditView::enableAlarm() | 396 | void KOCalEditView::enableAlarm() |
396 | { | 397 | { |
397 | toggleList( mAlarmB ); | 398 | toggleList( mAlarmB ); |
398 | } | 399 | } |
399 | void KOCalEditView::disableRO() | 400 | void KOCalEditView::disableRO() |
400 | { | 401 | { |
401 | toggleList( mROB ); | 402 | toggleList( mROB ); |
402 | } | 403 | } |
403 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | 404 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) |
404 | { | 405 | { |
405 | bool dis = false; | 406 | bool dis = false; |
406 | KOCalCheckButton* it = list.first(); | 407 | KOCalCheckButton* it = list.first(); |
407 | while ( it ) { | 408 | while ( it ) { |
408 | if ( !it->isChecked() ) { | 409 | if ( !it->isChecked() ) { |
409 | dis = true; | 410 | dis = true; |
410 | break; | 411 | break; |
411 | } | 412 | } |
412 | it = list.next(); | 413 | it = list.next(); |
413 | } | 414 | } |
414 | it = list.first(); | 415 | it = list.first(); |
415 | while ( it ) { | 416 | while ( it ) { |
416 | it->setChecked(dis); | 417 | it->setChecked(dis); |
417 | it = list.next(); | 418 | it = list.next(); |
418 | } | 419 | } |
419 | } | 420 | } |
420 | void KOCalEditView::deleteAll() | 421 | void KOCalEditView::deleteAll() |
421 | { | 422 | { |
422 | qDebug("delteAll"); | 423 | qDebug("delteAll"); |
423 | } | 424 | } |