author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkdepim/categoryeditdialog.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'libkdepim/categoryeditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/categoryeditdialog.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp index e2325d2..92a1737 100644 --- a/libkdepim/categoryeditdialog.cpp +++ b/libkdepim/categoryeditdialog.cpp | |||
@@ -1,141 +1,142 @@ | |||
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 <q3listview.h> |
27 | #include <qheader.h> | 27 | #include <q3header.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #include <QDesktopWidget> | ||
30 | 31 | ||
31 | #include "kpimprefs.h" | 32 | #include "kpimprefs.h" |
32 | 33 | ||
33 | #include "categoryeditdialog.h" | 34 | #include "categoryeditdialog.h" |
34 | 35 | ||
35 | using namespace KPIM; | 36 | using namespace KPIM; |
36 | 37 | ||
37 | CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, | 38 | CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, |
38 | const char* name, bool modal, | 39 | const char* name, bool modal, |
39 | WFlags fl ) | 40 | Qt::WFlags fl ) |
40 | : CategoryEditDialog_base( parent, name, modal, fl ), | 41 | : CategoryEditDialog_base( parent, name, modal, fl ), |
41 | mPrefs( prefs ) | 42 | mPrefs( prefs ) |
42 | { | 43 | { |
43 | mCategories->header()->hide(); | 44 | mCategories->header()->hide(); |
44 | 45 | ||
45 | QStringList::Iterator it; | 46 | QStringList::Iterator it; |
46 | bool categoriesExist=false; | 47 | bool categoriesExist=false; |
47 | for (it = mPrefs->mCustomCategories.begin(); | 48 | for (it = mPrefs->mCustomCategories.begin(); |
48 | it != mPrefs->mCustomCategories.end(); ++it ) { | 49 | it != mPrefs->mCustomCategories.end(); ++it ) { |
49 | new QListViewItem(mCategories,*it); | 50 | new Q3ListViewItem(mCategories,*it); |
50 | categoriesExist=true; | 51 | categoriesExist=true; |
51 | } | 52 | } |
52 | 53 | ||
53 | connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)), | 54 | connect(mCategories,SIGNAL(selectionChanged(Q3ListViewItem *)), |
54 | SLOT(editItem(QListViewItem *))); | 55 | SLOT(editItem(Q3ListViewItem *))); |
55 | connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); | 56 | connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); |
56 | mButtonRemove->setEnabled(categoriesExist); | 57 | mButtonRemove->setEnabled(categoriesExist); |
57 | mButtonModify->setEnabled(categoriesExist); | 58 | mButtonModify->setEnabled(categoriesExist); |
58 | #ifndef DESKTOP_VERSION | 59 | #ifndef DESKTOP_VERSION |
59 | mButtonOk->hide(); | 60 | mButtonOk->hide(); |
60 | mButtonCancel->hide(); | 61 | mButtonCancel->hide(); |
61 | #endif | 62 | #endif |
62 | mButtonAdd->setEnabled(!mEdit->text().isEmpty()); | 63 | mButtonAdd->setEnabled(!mEdit->text().isEmpty()); |
63 | if ( QApplication::desktop()->width() > 460 ) | 64 | if ( QApplication::desktop()->width() > 460 ) |
64 | resize( 300, 360 ); | 65 | resize( 300, 360 ); |
65 | else | 66 | else |
66 | showMaximized(); | 67 | showMaximized(); |
67 | } | 68 | } |
68 | 69 | ||
69 | /* | 70 | /* |
70 | * Destroys the object and frees any allocated resources | 71 | * Destroys the object and frees any allocated resources |
71 | */ | 72 | */ |
72 | CategoryEditDialog::~CategoryEditDialog() | 73 | CategoryEditDialog::~CategoryEditDialog() |
73 | { | 74 | { |
74 | // no need to delete child widgets, Qt does it all for us | 75 | // no need to delete child widgets, Qt does it all for us |
75 | } | 76 | } |
76 | 77 | ||
77 | void CategoryEditDialog::slotTextChanged(const QString &text) | 78 | void CategoryEditDialog::slotTextChanged(const QString &text) |
78 | { | 79 | { |
79 | mButtonAdd->setEnabled(!text.isEmpty()); | 80 | mButtonAdd->setEnabled(!text.isEmpty()); |
80 | } | 81 | } |
81 | 82 | ||
82 | void CategoryEditDialog::add() | 83 | void CategoryEditDialog::add() |
83 | { | 84 | { |
84 | if (!mEdit->text().isEmpty()) { | 85 | if (!mEdit->text().isEmpty()) { |
85 | new QListViewItem(mCategories,mEdit->text()); | 86 | new Q3ListViewItem(mCategories,mEdit->text()); |
86 | mEdit->setText(""); | 87 | mEdit->setText(""); |
87 | mButtonRemove->setEnabled(mCategories->childCount()>0); | 88 | mButtonRemove->setEnabled(mCategories->childCount()>0); |
88 | mButtonModify->setEnabled(mCategories->childCount()>0); | 89 | mButtonModify->setEnabled(mCategories->childCount()>0); |
89 | } | 90 | } |
90 | } | 91 | } |
91 | 92 | ||
92 | void CategoryEditDialog::remove() | 93 | void CategoryEditDialog::remove() |
93 | { | 94 | { |
94 | if (mCategories->currentItem()) { | 95 | if (mCategories->currentItem()) { |
95 | delete mCategories->currentItem(); | 96 | delete mCategories->currentItem(); |
96 | mButtonRemove->setEnabled(mCategories->childCount()>0); | 97 | mButtonRemove->setEnabled(mCategories->childCount()>0); |
97 | mButtonModify->setEnabled(mCategories->childCount()>0); | 98 | mButtonModify->setEnabled(mCategories->childCount()>0); |
98 | } | 99 | } |
99 | } | 100 | } |
100 | 101 | ||
101 | void CategoryEditDialog::modify() | 102 | void CategoryEditDialog::modify() |
102 | { | 103 | { |
103 | if (!mEdit->text().isEmpty()) { | 104 | if (!mEdit->text().isEmpty()) { |
104 | if (mCategories->currentItem()) { | 105 | if (mCategories->currentItem()) { |
105 | mCategories->currentItem()->setText(0,mEdit->text()); | 106 | mCategories->currentItem()->setText(0,mEdit->text()); |
106 | } | 107 | } |
107 | } | 108 | } |
108 | } | 109 | } |
109 | void CategoryEditDialog::accept() | 110 | void CategoryEditDialog::accept() |
110 | { | 111 | { |
111 | slotOk(); | 112 | slotOk(); |
112 | } | 113 | } |
113 | 114 | ||
114 | void CategoryEditDialog::slotOk() | 115 | void CategoryEditDialog::slotOk() |
115 | { | 116 | { |
116 | slotApply(); | 117 | slotApply(); |
117 | QDialog::accept(); | 118 | QDialog::accept(); |
118 | } | 119 | } |
119 | 120 | ||
120 | void CategoryEditDialog::slotApply() | 121 | void CategoryEditDialog::slotApply() |
121 | { | 122 | { |
122 | mPrefs->mCustomCategories.clear(); | 123 | mPrefs->mCustomCategories.clear(); |
123 | 124 | ||
124 | QListViewItem *item = mCategories->firstChild(); | 125 | Q3ListViewItem *item = mCategories->firstChild(); |
125 | while(item) { | 126 | while(item) { |
126 | mPrefs->mCustomCategories.append(item->text(0)); | 127 | mPrefs->mCustomCategories.append(item->text(0)); |
127 | item = item->nextSibling(); | 128 | item = item->nextSibling(); |
128 | } | 129 | } |
129 | mPrefs->writeConfig(); | 130 | mPrefs->writeConfig(); |
130 | 131 | ||
131 | emit categoryConfigChanged(); | 132 | emit categoryConfigChanged(); |
132 | } | 133 | } |
133 | 134 | ||
134 | void CategoryEditDialog::editItem(QListViewItem *item) | 135 | void CategoryEditDialog::editItem(Q3ListViewItem *item) |
135 | { | 136 | { |
136 | mEdit->setText(item->text(0)); | 137 | mEdit->setText(item->text(0)); |
137 | mButtonRemove->setEnabled(true); | 138 | mButtonRemove->setEnabled(true); |
138 | mButtonModify->setEnabled(true); | 139 | mButtonModify->setEnabled(true); |
139 | } | 140 | } |
140 | 141 | ||
141 | //US #include "categoryeditdialog.moc" | 142 | //US #include "categoryeditdialog.moc" |