summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/categoryeditdialog.cpp4
-rw-r--r--libkdepim/categoryselectdialog.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp
index a19900f..e2325d2 100644
--- a/libkdepim/categoryeditdialog.cpp
+++ b/libkdepim/categoryeditdialog.cpp
@@ -1,137 +1,141 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 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 <qstringlist.h> 24#include <qstringlist.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qlistview.h> 26#include <qlistview.h>
27#include <qheader.h> 27#include <qheader.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include "kpimprefs.h" 31#include "kpimprefs.h"
32 32
33#include "categoryeditdialog.h" 33#include "categoryeditdialog.h"
34 34
35using namespace KPIM; 35using namespace KPIM;
36 36
37CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, 37CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent,
38 const char* name, bool modal, 38 const char* name, bool modal,
39 WFlags fl ) 39 WFlags fl )
40 : CategoryEditDialog_base( parent, name, modal, fl ), 40 : CategoryEditDialog_base( parent, name, modal, fl ),
41 mPrefs( prefs ) 41 mPrefs( prefs )
42{ 42{
43 mCategories->header()->hide(); 43 mCategories->header()->hide();
44 44
45 QStringList::Iterator it; 45 QStringList::Iterator it;
46 bool categoriesExist=false; 46 bool categoriesExist=false;
47 for (it = mPrefs->mCustomCategories.begin(); 47 for (it = mPrefs->mCustomCategories.begin();
48 it != mPrefs->mCustomCategories.end(); ++it ) { 48 it != mPrefs->mCustomCategories.end(); ++it ) {
49 new QListViewItem(mCategories,*it); 49 new QListViewItem(mCategories,*it);
50 categoriesExist=true; 50 categoriesExist=true;
51 } 51 }
52 52
53 connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)), 53 connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)),
54 SLOT(editItem(QListViewItem *))); 54 SLOT(editItem(QListViewItem *)));
55 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); 55 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &)));
56 mButtonRemove->setEnabled(categoriesExist); 56 mButtonRemove->setEnabled(categoriesExist);
57 mButtonModify->setEnabled(categoriesExist); 57 mButtonModify->setEnabled(categoriesExist);
58#ifndef DESKTOP_VERSION
59 mButtonOk->hide();
60 mButtonCancel->hide();
61#endif
58 mButtonAdd->setEnabled(!mEdit->text().isEmpty()); 62 mButtonAdd->setEnabled(!mEdit->text().isEmpty());
59 if ( QApplication::desktop()->width() > 460 ) 63 if ( QApplication::desktop()->width() > 460 )
60 resize( 300, 360 ); 64 resize( 300, 360 );
61 else 65 else
62 showMaximized(); 66 showMaximized();
63} 67}
64 68
65/* 69/*
66 * Destroys the object and frees any allocated resources 70 * Destroys the object and frees any allocated resources
67 */ 71 */
68CategoryEditDialog::~CategoryEditDialog() 72CategoryEditDialog::~CategoryEditDialog()
69{ 73{
70 // no need to delete child widgets, Qt does it all for us 74 // no need to delete child widgets, Qt does it all for us
71} 75}
72 76
73void CategoryEditDialog::slotTextChanged(const QString &text) 77void CategoryEditDialog::slotTextChanged(const QString &text)
74{ 78{
75 mButtonAdd->setEnabled(!text.isEmpty()); 79 mButtonAdd->setEnabled(!text.isEmpty());
76} 80}
77 81
78void CategoryEditDialog::add() 82void CategoryEditDialog::add()
79{ 83{
80 if (!mEdit->text().isEmpty()) { 84 if (!mEdit->text().isEmpty()) {
81 new QListViewItem(mCategories,mEdit->text()); 85 new QListViewItem(mCategories,mEdit->text());
82 mEdit->setText(""); 86 mEdit->setText("");
83 mButtonRemove->setEnabled(mCategories->childCount()>0); 87 mButtonRemove->setEnabled(mCategories->childCount()>0);
84 mButtonModify->setEnabled(mCategories->childCount()>0); 88 mButtonModify->setEnabled(mCategories->childCount()>0);
85 } 89 }
86} 90}
87 91
88void CategoryEditDialog::remove() 92void CategoryEditDialog::remove()
89{ 93{
90 if (mCategories->currentItem()) { 94 if (mCategories->currentItem()) {
91 delete mCategories->currentItem(); 95 delete mCategories->currentItem();
92 mButtonRemove->setEnabled(mCategories->childCount()>0); 96 mButtonRemove->setEnabled(mCategories->childCount()>0);
93 mButtonModify->setEnabled(mCategories->childCount()>0); 97 mButtonModify->setEnabled(mCategories->childCount()>0);
94 } 98 }
95} 99}
96 100
97void CategoryEditDialog::modify() 101void CategoryEditDialog::modify()
98{ 102{
99 if (!mEdit->text().isEmpty()) { 103 if (!mEdit->text().isEmpty()) {
100 if (mCategories->currentItem()) { 104 if (mCategories->currentItem()) {
101 mCategories->currentItem()->setText(0,mEdit->text()); 105 mCategories->currentItem()->setText(0,mEdit->text());
102 } 106 }
103 } 107 }
104} 108}
105void CategoryEditDialog::accept() 109void CategoryEditDialog::accept()
106{ 110{
107 slotOk(); 111 slotOk();
108} 112}
109 113
110void CategoryEditDialog::slotOk() 114void CategoryEditDialog::slotOk()
111{ 115{
112 slotApply(); 116 slotApply();
113 QDialog::accept(); 117 QDialog::accept();
114} 118}
115 119
116void CategoryEditDialog::slotApply() 120void CategoryEditDialog::slotApply()
117{ 121{
118 mPrefs->mCustomCategories.clear(); 122 mPrefs->mCustomCategories.clear();
119 123
120 QListViewItem *item = mCategories->firstChild(); 124 QListViewItem *item = mCategories->firstChild();
121 while(item) { 125 while(item) {
122 mPrefs->mCustomCategories.append(item->text(0)); 126 mPrefs->mCustomCategories.append(item->text(0));
123 item = item->nextSibling(); 127 item = item->nextSibling();
124 } 128 }
125 mPrefs->writeConfig(); 129 mPrefs->writeConfig();
126 130
127 emit categoryConfigChanged(); 131 emit categoryConfigChanged();
128} 132}
129 133
130void CategoryEditDialog::editItem(QListViewItem *item) 134void CategoryEditDialog::editItem(QListViewItem *item)
131{ 135{
132 mEdit->setText(item->text(0)); 136 mEdit->setText(item->text(0));
133 mButtonRemove->setEnabled(true); 137 mButtonRemove->setEnabled(true);
134 mButtonModify->setEnabled(true); 138 mButtonModify->setEnabled(true);
135} 139}
136 140
137//US #include "categoryeditdialog.moc" 141//US #include "categoryeditdialog.moc"
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 974752c..a4e0024 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -1,185 +1,189 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 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 <qlistview.h> 24#include <qlistview.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qheader.h> 26#include <qheader.h>
27#include <qapp.h> 27#include <qapp.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <kmessagebox.h> 29#include <kmessagebox.h>
30 30
31 31
32#include "categoryeditdialog.h" 32#include "categoryeditdialog.h"
33#include "categoryselectdialog.h" 33#include "categoryselectdialog.h"
34 34
35#include "kpimprefs.h" 35#include "kpimprefs.h"
36 36
37using namespace KPIM; 37using namespace KPIM;
38 38
39CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, 39CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
40 const char* name, 40 const char* name,
41 bool modal, WFlags fl ) 41 bool modal, WFlags fl )
42 : CategorySelectDialog_base( parent, name, true, fl ), 42 : CategorySelectDialog_base( parent, name, true, fl ),
43 mPrefs( prefs ) 43 mPrefs( prefs )
44{ 44{
45 mColorItem = 0; 45 mColorItem = 0;
46 mColorEnabled = false; 46 mColorEnabled = false;
47 mCategories->header()->hide(); 47 mCategories->header()->hide();
48 48
49 setCategories(); 49 setCategories();
50 50
51 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); 51 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
52 if ( QApplication::desktop()->width() > 460 ) 52 if ( QApplication::desktop()->width() > 460 )
53 resize( 300, 360 ); 53 resize( 300, 360 );
54 else 54 else
55 showMaximized(); 55 showMaximized();
56 connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); 56 connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) );
57 // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); 57 // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) );
58#ifndef DESKTOP_VERSION
59 mButtonOk->hide();
60 mButtonCancel->hide();
61#endif
58} 62}
59void CategorySelectDialog::editCategoriesDialog() 63void CategorySelectDialog::editCategoriesDialog()
60{ 64{
61 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); 65 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
62 66
63 ced->exec(); 67 ced->exec();
64 delete ced; 68 delete ced;
65 slotApply(); 69 slotApply();
66 QStringList temp = mCategoryList; 70 QStringList temp = mCategoryList;
67 setCategories(); 71 setCategories();
68 setSelected( temp ); 72 setSelected( temp );
69} 73}
70void CategorySelectDialog::setCategories() 74void CategorySelectDialog::setCategories()
71{ 75{
72 mColorItem = 0; 76 mColorItem = 0;
73 mCategories->clear(); 77 mCategories->clear();
74 mCategoryList.clear(); 78 mCategoryList.clear();
75 79
76 QStringList::Iterator it; 80 QStringList::Iterator it;
77 for (it = mPrefs->mCustomCategories.begin(); 81 for (it = mPrefs->mCustomCategories.begin();
78 it != mPrefs->mCustomCategories.end(); ++it ) { 82 it != mPrefs->mCustomCategories.end(); ++it ) {
79 CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); 83 CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox);
80 QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); 84 QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) );
81 85
82 } 86 }
83} 87}
84 88
85CategorySelectDialog::~CategorySelectDialog() 89CategorySelectDialog::~CategorySelectDialog()
86{ 90{
87} 91}
88 92
89void CategorySelectDialog::setSelected(const QStringList &selList) 93void CategorySelectDialog::setSelected(const QStringList &selList)
90{ 94{
91 clear(); 95 clear();
92 96
93 QStringList::ConstIterator it; 97 QStringList::ConstIterator it;
94 QStringList notFound; 98 QStringList notFound;
95 bool found = false; 99 bool found = false;
96 for (it=selList.begin();it!=selList.end();++it) { 100 for (it=selList.begin();it!=selList.end();++it) {
97 //qDebug(" CategorySelectDialog::setSelected("); 101 //qDebug(" CategorySelectDialog::setSelected(");
98 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 102 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
99 while (item) { 103 while (item) {
100 if (item->text() == *it) { 104 if (item->text() == *it) {
101 item->setOn(true); 105 item->setOn(true);
102 if ( ! found ) 106 if ( ! found )
103 setColorItem( item ); 107 setColorItem( item );
104 found = true; 108 found = true;
105 break; 109 break;
106 } 110 }
107 item = (QCheckListItem *)item->nextSibling(); 111 item = (QCheckListItem *)item->nextSibling();
108 } 112 }
109// if ( ! found ) { 113// if ( ! found ) {
110 114
111//emit updateCategoriesGlobal(); 115//emit updateCategoriesGlobal();
112// QMessageBox::information( this, "KO/E: Information!", 116// QMessageBox::information( this, "KO/E: Information!",
113// "Categories found, which were not\n" 117// "Categories found, which were not\n"
114// "in list of categories!\n" 118// "in list of categories!\n"
115// "message", 119// "message",
116// "OK", "", 0, 120// "OK", "", 0,
117// 0, 1 ); 121// 0, 1 );
118// setSelected(selList); 122// setSelected(selList);
119// return; 123// return;
120// } 124// }
121 } 125 }
122} 126}
123 127
124QStringList CategorySelectDialog::selectedCategories() const 128QStringList CategorySelectDialog::selectedCategories() const
125{ 129{
126 return mCategoryList; 130 return mCategoryList;
127} 131}
128void CategorySelectDialog::setColorEnabled() 132void CategorySelectDialog::setColorEnabled()
129{ 133{
130 mColorEnabled = true; 134 mColorEnabled = true;
131 mSetColorCat->show(); 135 mSetColorCat->show();
132} 136}
133void CategorySelectDialog::setColorCat() 137void CategorySelectDialog::setColorCat()
134{ 138{
135 QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); 139 QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem ();
136 if ( !newColorItem ) { 140 if ( !newColorItem ) {
137 KMessageBox::error(this,i18n("There is no current item.")); 141 KMessageBox::error(this,i18n("There is no current item."));
138 return; 142 return;
139 } 143 }
140 if ( !newColorItem->isOn() ) 144 if ( !newColorItem->isOn() )
141 newColorItem->setOn( true ); 145 newColorItem->setOn( true );
142 setColorItem( newColorItem ); 146 setColorItem( newColorItem );
143 147
144} 148}
145void CategorySelectDialog::clicked ( QListViewItem * it ) 149void CategorySelectDialog::clicked ( QListViewItem * it )
146{ 150{
147 if ( ! it ) 151 if ( ! it )
148 return; 152 return;
149 QCheckListItem *i = (QCheckListItem *) it; 153 QCheckListItem *i = (QCheckListItem *) it;
150 if ( !i->isOn() && i==mColorItem) { 154 if ( !i->isOn() && i==mColorItem) {
151 setColorItem( 0); 155 setColorItem( 0);
152 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 156 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
153 while (item) { 157 while (item) {
154 if (item->isOn()) { 158 if (item->isOn()) {
155 setColorItem( item ); 159 setColorItem( item );
156 break; 160 break;
157 } 161 }
158 item = (QCheckListItem *)item->nextSibling(); 162 item = (QCheckListItem *)item->nextSibling();
159 } 163 }
160 } else if ( i->isOn() && !mColorItem) { 164 } else if ( i->isOn() && !mColorItem) {
161 setColorItem( i); 165 setColorItem( i);
162 } 166 }
163} 167}
164void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) 168void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem )
165{ 169{
166 if ( !mColorEnabled ) 170 if ( !mColorEnabled )
167 return; 171 return;
168 if ( mColorItem == newColorItem) 172 if ( mColorItem == newColorItem)
169 return; 173 return;
170 if ( mColorItem ) { 174 if ( mColorItem ) {
171 mColorItem->setPixmap ( 0, QPixmap() ); 175 mColorItem->setPixmap ( 0, QPixmap() );
172 mColorItem = 0; 176 mColorItem = 0;
173 } 177 }
174 if ( newColorItem ) { 178 if ( newColorItem ) {
175 QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); 179 QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 );
176 pix.fill(Qt::red ); 180 pix.fill(Qt::red );
177 newColorItem->setPixmap ( 0, pix ); 181 newColorItem->setPixmap ( 0, pix );
178 mColorItem = newColorItem; 182 mColorItem = newColorItem;
179 } 183 }
180} 184}
181void CategorySelectDialog::slotApply() 185void CategorySelectDialog::slotApply()
182{ 186{
183 QStringList categories; 187 QStringList categories;
184 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 188 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
185 QString colcat; 189 QString colcat;