summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/categoryeditdialog.cpp2
-rw-r--r--libkdepim/categoryselectdialog.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp
index f719c31..a19900f 100644
--- a/libkdepim/categoryeditdialog.cpp
+++ b/libkdepim/categoryeditdialog.cpp
@@ -1,135 +1,137 @@
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 mButtonAdd->setEnabled(!mEdit->text().isEmpty()); 58 mButtonAdd->setEnabled(!mEdit->text().isEmpty());
59 if ( QApplication::desktop()->width() > 460 ) 59 if ( QApplication::desktop()->width() > 460 )
60 resize( 300, 360 ); 60 resize( 300, 360 );
61 else
62 showMaximized();
61} 63}
62 64
63/* 65/*
64 * Destroys the object and frees any allocated resources 66 * Destroys the object and frees any allocated resources
65 */ 67 */
66CategoryEditDialog::~CategoryEditDialog() 68CategoryEditDialog::~CategoryEditDialog()
67{ 69{
68 // no need to delete child widgets, Qt does it all for us 70 // no need to delete child widgets, Qt does it all for us
69} 71}
70 72
71void CategoryEditDialog::slotTextChanged(const QString &text) 73void CategoryEditDialog::slotTextChanged(const QString &text)
72{ 74{
73 mButtonAdd->setEnabled(!text.isEmpty()); 75 mButtonAdd->setEnabled(!text.isEmpty());
74} 76}
75 77
76void CategoryEditDialog::add() 78void CategoryEditDialog::add()
77{ 79{
78 if (!mEdit->text().isEmpty()) { 80 if (!mEdit->text().isEmpty()) {
79 new QListViewItem(mCategories,mEdit->text()); 81 new QListViewItem(mCategories,mEdit->text());
80 mEdit->setText(""); 82 mEdit->setText("");
81 mButtonRemove->setEnabled(mCategories->childCount()>0); 83 mButtonRemove->setEnabled(mCategories->childCount()>0);
82 mButtonModify->setEnabled(mCategories->childCount()>0); 84 mButtonModify->setEnabled(mCategories->childCount()>0);
83 } 85 }
84} 86}
85 87
86void CategoryEditDialog::remove() 88void CategoryEditDialog::remove()
87{ 89{
88 if (mCategories->currentItem()) { 90 if (mCategories->currentItem()) {
89 delete mCategories->currentItem(); 91 delete mCategories->currentItem();
90 mButtonRemove->setEnabled(mCategories->childCount()>0); 92 mButtonRemove->setEnabled(mCategories->childCount()>0);
91 mButtonModify->setEnabled(mCategories->childCount()>0); 93 mButtonModify->setEnabled(mCategories->childCount()>0);
92 } 94 }
93} 95}
94 96
95void CategoryEditDialog::modify() 97void CategoryEditDialog::modify()
96{ 98{
97 if (!mEdit->text().isEmpty()) { 99 if (!mEdit->text().isEmpty()) {
98 if (mCategories->currentItem()) { 100 if (mCategories->currentItem()) {
99 mCategories->currentItem()->setText(0,mEdit->text()); 101 mCategories->currentItem()->setText(0,mEdit->text());
100 } 102 }
101 } 103 }
102} 104}
103void CategoryEditDialog::accept() 105void CategoryEditDialog::accept()
104{ 106{
105 slotOk(); 107 slotOk();
106} 108}
107 109
108void CategoryEditDialog::slotOk() 110void CategoryEditDialog::slotOk()
109{ 111{
110 slotApply(); 112 slotApply();
111 QDialog::accept(); 113 QDialog::accept();
112} 114}
113 115
114void CategoryEditDialog::slotApply() 116void CategoryEditDialog::slotApply()
115{ 117{
116 mPrefs->mCustomCategories.clear(); 118 mPrefs->mCustomCategories.clear();
117 119
118 QListViewItem *item = mCategories->firstChild(); 120 QListViewItem *item = mCategories->firstChild();
119 while(item) { 121 while(item) {
120 mPrefs->mCustomCategories.append(item->text(0)); 122 mPrefs->mCustomCategories.append(item->text(0));
121 item = item->nextSibling(); 123 item = item->nextSibling();
122 } 124 }
123 mPrefs->writeConfig(); 125 mPrefs->writeConfig();
124 126
125 emit categoryConfigChanged(); 127 emit categoryConfigChanged();
126} 128}
127 129
128void CategoryEditDialog::editItem(QListViewItem *item) 130void CategoryEditDialog::editItem(QListViewItem *item)
129{ 131{
130 mEdit->setText(item->text(0)); 132 mEdit->setText(item->text(0));
131 mButtonRemove->setEnabled(true); 133 mButtonRemove->setEnabled(true);
132 mButtonModify->setEnabled(true); 134 mButtonModify->setEnabled(true);
133} 135}
134 136
135//US #include "categoryeditdialog.moc" 137//US #include "categoryeditdialog.moc"
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 40b46cf..7df9154 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -1,173 +1,171 @@
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 29
30 30
31#include "categoryeditdialog.h" 31#include "categoryeditdialog.h"
32#include "categoryselectdialog.h" 32#include "categoryselectdialog.h"
33 33
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35 35
36using namespace KPIM; 36using namespace KPIM;
37 37
38CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, 38CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
39 const char* name, 39 const char* name,
40 bool modal, WFlags fl ) 40 bool modal, WFlags fl )
41 : CategorySelectDialog_base( parent, name, true, fl ), 41 : CategorySelectDialog_base( parent, name, true, fl ),
42 mPrefs( prefs ) 42 mPrefs( prefs )
43{ 43{
44 mCategories->header()->hide(); 44 mCategories->header()->hide();
45 45
46 setCategories(); 46 setCategories();
47 47
48 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); 48 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
49 if ( qApp->desktop()->height() < 321 )
50 setMaximumHeight( QApplication::desktop()->height() - 50 );
51 else
52 setMaximumHeight( QApplication::desktop()->height() - 80 );
53 if ( QApplication::desktop()->width() > 460 ) 49 if ( QApplication::desktop()->width() > 460 )
54 resize( 260, 360 ); 50 resize( 300, 360 );
51 else
52 showMaximized();
55} 53}
56void CategorySelectDialog::editCategoriesDialog() 54void CategorySelectDialog::editCategoriesDialog()
57{ 55{
58 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); 56 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
59 57
60 ced->exec(); 58 ced->exec();
61 delete ced; 59 delete ced;
62 setCategories(); 60 setCategories();
63} 61}
64void CategorySelectDialog::setCategories() 62void CategorySelectDialog::setCategories()
65{ 63{
66 mCategories->clear(); 64 mCategories->clear();
67 mCategoryList.clear(); 65 mCategoryList.clear();
68 66
69 QStringList::Iterator it; 67 QStringList::Iterator it;
70 68
71 for (it = mPrefs->mCustomCategories.begin(); 69 for (it = mPrefs->mCustomCategories.begin();
72 it != mPrefs->mCustomCategories.end(); ++it ) { 70 it != mPrefs->mCustomCategories.end(); ++it ) {
73 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox); 71 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
74 } 72 }
75} 73}
76 74
77CategorySelectDialog::~CategorySelectDialog() 75CategorySelectDialog::~CategorySelectDialog()
78{ 76{
79} 77}
80 78
81void CategorySelectDialog::setSelected(const QStringList &selList) 79void CategorySelectDialog::setSelected(const QStringList &selList)
82{ 80{
83 clear(); 81 clear();
84 82
85 QStringList::ConstIterator it; 83 QStringList::ConstIterator it;
86 QStringList notFound; 84 QStringList notFound;
87 bool found = false; 85 bool found = false;
88 for (it=selList.begin();it!=selList.end();++it) { 86 for (it=selList.begin();it!=selList.end();++it) {
89 //qDebug(" CategorySelectDialog::setSelected("); 87 //qDebug(" CategorySelectDialog::setSelected(");
90 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 88 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
91 while (item) { 89 while (item) {
92 if (item->text() == *it) { 90 if (item->text() == *it) {
93 item->setOn(true); 91 item->setOn(true);
94 found = true; 92 found = true;
95 break; 93 break;
96 } 94 }
97 item = (QCheckListItem *)item->nextSibling(); 95 item = (QCheckListItem *)item->nextSibling();
98 } 96 }
99// if ( ! found ) { 97// if ( ! found ) {
100 98
101//emit updateCategoriesGlobal(); 99//emit updateCategoriesGlobal();
102// QMessageBox::information( this, "KO/E: Information!", 100// QMessageBox::information( this, "KO/E: Information!",
103// "Categories found, which were not\n" 101// "Categories found, which were not\n"
104// "in list of categories!\n" 102// "in list of categories!\n"
105// "message", 103// "message",
106// "OK", "", 0, 104// "OK", "", 0,
107// 0, 1 ); 105// 0, 1 );
108// setSelected(selList); 106// setSelected(selList);
109// return; 107// return;
110// } 108// }
111 } 109 }
112} 110}
113 111
114QStringList CategorySelectDialog::selectedCategories() const 112QStringList CategorySelectDialog::selectedCategories() const
115{ 113{
116 return mCategoryList; 114 return mCategoryList;
117} 115}
118 116
119void CategorySelectDialog::slotApply() 117void CategorySelectDialog::slotApply()
120{ 118{
121 QStringList categories; 119 QStringList categories;
122 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 120 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
123 while (item) { 121 while (item) {
124 if (item->isOn()) { 122 if (item->isOn()) {
125 categories.append(item->text()); 123 categories.append(item->text());
126 } 124 }
127 item = (QCheckListItem *)item->nextSibling(); 125 item = (QCheckListItem *)item->nextSibling();
128 } 126 }
129 127
130 QString categoriesStr = categories.join(","); 128 QString categoriesStr = categories.join(",");
131 129
132 mCategoryList = categories; 130 mCategoryList = categories;
133 131
134 emit categoriesSelected(categories); 132 emit categoriesSelected(categories);
135 emit categoriesSelected(categoriesStr); 133 emit categoriesSelected(categoriesStr);
136} 134}
137void CategorySelectDialog::accept() 135void CategorySelectDialog::accept()
138{ 136{
139 slotOk(); 137 slotOk();
140} 138}
141 139
142void CategorySelectDialog::slotOk() 140void CategorySelectDialog::slotOk()
143{ 141{
144 slotApply(); 142 slotApply();
145 QDialog::accept(); 143 QDialog::accept();
146} 144}
147 145
148void CategorySelectDialog::clear() 146void CategorySelectDialog::clear()
149{ 147{
150 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 148 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
151 while (item) { 149 while (item) {
152 item->setOn(false); 150 item->setOn(false);
153 item = (QCheckListItem *)item->nextSibling(); 151 item = (QCheckListItem *)item->nextSibling();
154 } 152 }
155} 153}
156 154
157void CategorySelectDialog::updateCategoryConfig() 155void CategorySelectDialog::updateCategoryConfig()
158{ 156{
159 QStringList selected; 157 QStringList selected;
160 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 158 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
161 while (item) { 159 while (item) {
162 if (item->isOn()) { 160 if (item->isOn()) {
163 selected.append(item->text()); 161 selected.append(item->text());
164 } 162 }
165 item = (QCheckListItem *)item->nextSibling(); 163 item = (QCheckListItem *)item->nextSibling();
166 } 164 }
167 165
168 setCategories(); 166 setCategories();
169 167
170 setSelected(selected); 168 setSelected(selected);
171} 169}
172 170
173//#include "categoryselectdialog.moc" 171//#include "categoryselectdialog.moc"