author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/publishdialog.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'korganizer/publishdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/publishdialog.cpp | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/korganizer/publishdialog.cpp b/korganizer/publishdialog.cpp new file mode 100644 index 0000000..176595a --- a/dev/null +++ b/korganizer/publishdialog.cpp | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qlineedit.h> | ||
25 | #include <kdebug.h> | ||
26 | |||
27 | #include <kglobal.h> | ||
28 | #include <klocale.h> | ||
29 | #ifndef KORG_NOKABC | ||
30 | #include <kabc/addresseedialog.h> | ||
31 | #endif | ||
32 | |||
33 | #include "koprefs.h" | ||
34 | #include "publishdialog.h" | ||
35 | |||
36 | PublishDialog::PublishDialog(QWidget* parent, const char* name, | ||
37 | bool modal, WFlags fl) | ||
38 | : PublishDialog_base(parent,name,modal,fl) | ||
39 | { | ||
40 | setCaption(i18n("Select Addresses")); | ||
41 | mNameLineEdit->setEnabled(false); | ||
42 | mEmailLineEdit->setEnabled(false); | ||
43 | connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)), | ||
44 | SLOT(updateInput())); | ||
45 | } | ||
46 | |||
47 | PublishDialog::~PublishDialog() | ||
48 | { | ||
49 | } | ||
50 | |||
51 | void PublishDialog::addAttendee(Attendee *attendee) | ||
52 | { | ||
53 | mNameLineEdit->setEnabled(true); | ||
54 | mEmailLineEdit->setEnabled(true); | ||
55 | QListViewItem *item = new QListViewItem(mAddressListView); | ||
56 | item->setText(0,attendee->name()); | ||
57 | item->setText(1,attendee->email()); | ||
58 | mAddressListView->insertItem(item); | ||
59 | } | ||
60 | |||
61 | QString PublishDialog::addresses() | ||
62 | { | ||
63 | QString to = ""; | ||
64 | QListViewItem *item; | ||
65 | int i, count; | ||
66 | count = mAddressListView->childCount(); | ||
67 | for (i=0;i<count;i++) { | ||
68 | item = mAddressListView->firstChild(); | ||
69 | mAddressListView->takeItem(item); | ||
70 | to += item->text(1); | ||
71 | if (i<count-1) { | ||
72 | to += ", "; | ||
73 | } | ||
74 | } | ||
75 | return to; | ||
76 | } | ||
77 | |||
78 | void PublishDialog::addItem() | ||
79 | { | ||
80 | mNameLineEdit->setEnabled(true); | ||
81 | mEmailLineEdit->setEnabled(true); | ||
82 | QListViewItem *item = new QListViewItem(mAddressListView); | ||
83 | mAddressListView->insertItem(item); | ||
84 | mAddressListView->setSelected(item,true); | ||
85 | mNameLineEdit->setText(i18n("(EmptyName)")); | ||
86 | mEmailLineEdit->setText(i18n("(EmptyEmail)")); | ||
87 | } | ||
88 | |||
89 | void PublishDialog::removeItem() | ||
90 | { | ||
91 | QListViewItem *item; | ||
92 | item = mAddressListView->selectedItem(); | ||
93 | if (!item) return; | ||
94 | mAddressListView->takeItem(item); | ||
95 | item = mAddressListView->selectedItem(); | ||
96 | if (!item) { | ||
97 | mNameLineEdit->setText(""); | ||
98 | mEmailLineEdit->setText(""); | ||
99 | mNameLineEdit->setEnabled(false); | ||
100 | mEmailLineEdit->setEnabled(false); | ||
101 | } | ||
102 | if (mAddressListView->childCount() == 0) { | ||
103 | mNameLineEdit->setEnabled(false); | ||
104 | mEmailLineEdit->setEnabled(false); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void PublishDialog::openAddressbook() | ||
109 | { | ||
110 | #ifndef KORG_NOKABC | ||
111 | KABC::Addressee::List addressList; | ||
112 | addressList = KABC::AddresseeDialog::getAddressees(this); | ||
113 | //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | ||
114 | KABC::Addressee a = addressList.first(); | ||
115 | if (!a.isEmpty()) { | ||
116 | uint i; | ||
117 | for (i=0;i<addressList.count();i++) { | ||
118 | a = addressList[i]; | ||
119 | mNameLineEdit->setEnabled(true); | ||
120 | mEmailLineEdit->setEnabled(true); | ||
121 | QListViewItem *item = new QListViewItem(mAddressListView); | ||
122 | mAddressListView->setSelected(item,true); | ||
123 | mNameLineEdit->setText(a.realName()); | ||
124 | mEmailLineEdit->setText(a.preferredEmail()); | ||
125 | mAddressListView->insertItem(item); | ||
126 | } | ||
127 | } | ||
128 | #endif | ||
129 | } | ||
130 | |||
131 | void PublishDialog::updateItem() | ||
132 | { | ||
133 | QListViewItem *item; | ||
134 | item = mAddressListView->selectedItem(); | ||
135 | if (!item) return; | ||
136 | item->setText(0,mNameLineEdit->text()); | ||
137 | item->setText(1,mEmailLineEdit->text()); | ||
138 | } | ||
139 | |||
140 | void PublishDialog::updateInput() | ||
141 | { | ||
142 | QListViewItem *item; | ||
143 | item = mAddressListView->selectedItem(); | ||
144 | if (!item) return; | ||
145 | mNameLineEdit->setEnabled(true); | ||
146 | mEmailLineEdit->setEnabled(true); | ||
147 | QString mail = item->text(1); | ||
148 | mNameLineEdit->setText(item->text(0)); | ||
149 | mEmailLineEdit->setText(mail); | ||
150 | } | ||
151 | |||
152 | #include "publishdialog.moc" | ||