24 #include <tqlineedit.h>
25 #include <tqpushbutton.h>
27 #include <tqlistview.h>
29 #include <tdeglobal.h>
30 #include <tdelocale.h>
32 #include <tdeabc/addresseedialog.h>
34 #include <libkcal/attendee.h>
37 #include "publishdialog.h"
38 #include "publishdialog_base.h"
40 PublishDialog::PublishDialog( TQWidget* parent,
const char* name,
42 : KDialogBase( parent, name, modal,
43 i18n(
"Select Addresses"), Ok|Cancel|Help, Ok, true )
45 mWidget =
new PublishDialog_base(
this,
"PublishFreeBusy" );
46 setMainWidget( mWidget );
47 mWidget->mNameLineEdit->setEnabled(
false );
48 mWidget->mEmailLineEdit->setEnabled(
false );
49 connect( mWidget->mAddressListView, TQ_SIGNAL( selectionChanged(TQListViewItem *) ),
50 TQ_SLOT(updateInput()));
51 connect( mWidget->mNew, TQ_SIGNAL( clicked() ),
52 TQ_SLOT( addItem() ) );
53 connect( mWidget->mRemove, TQ_SIGNAL( clicked() ),
54 TQ_SLOT( removeItem() ) );
55 connect( mWidget->mSelectAddressee, TQ_SIGNAL( clicked() ),
56 TQ_SLOT( openAddressbook() ) );
57 connect( mWidget->mNameLineEdit, TQ_SIGNAL( textChanged(
const TQString&) ),
58 TQ_SLOT( updateItem() ) );
59 connect( mWidget->mEmailLineEdit, TQ_SIGNAL( textChanged(
const TQString&) ),
60 TQ_SLOT( updateItem() ) );
63 PublishDialog::~PublishDialog()
67 void PublishDialog::addAttendee(
Attendee *attendee )
69 mWidget->mNameLineEdit->setEnabled(
true );
70 mWidget->mEmailLineEdit->setEnabled(
true );
71 TQListViewItem *item =
new TQListViewItem( mWidget->mAddressListView );
72 item->setText( 0, attendee->name() );
73 item->setText( 1, attendee->email() );
74 mWidget->mAddressListView->insertItem( item );
77 TQString PublishDialog::addresses()
82 count = mWidget->mAddressListView->childCount();
83 for ( i=0; i<count; i++ ) {
84 item = mWidget->mAddressListView->firstChild();
85 mWidget->mAddressListView->takeItem( item );
86 to += item->text( 1 );
94 void PublishDialog::addItem()
96 mWidget->mNameLineEdit->setEnabled(
true );
97 mWidget->mEmailLineEdit->setEnabled(
true );
98 TQListViewItem *item =
new TQListViewItem( mWidget->mAddressListView );
99 mWidget->mAddressListView->insertItem( item );
100 mWidget->mAddressListView->setSelected( item,
true );
101 mWidget->mNameLineEdit->setText( i18n(
"(EmptyName)") );
102 mWidget->mEmailLineEdit->setText( i18n(
"(EmptyEmail)") );
105 void PublishDialog::removeItem()
107 TQListViewItem *item;
108 item = mWidget->mAddressListView->selectedItem();
110 mWidget->mAddressListView->takeItem( item );
111 item = mWidget->mAddressListView->selectedItem();
113 mWidget->mNameLineEdit->setText(
"" );
114 mWidget->mEmailLineEdit->setText(
"" );
115 mWidget->mNameLineEdit->setEnabled(
false );
116 mWidget->mEmailLineEdit->setEnabled(
false );
118 if ( mWidget->mAddressListView->childCount() == 0 ) {
119 mWidget->mNameLineEdit->setEnabled(
false );
120 mWidget->mEmailLineEdit->setEnabled(
false );
124 void PublishDialog::openAddressbook()
127 TDEABC::Addressee::List addressList;
128 addressList = TDEABC::AddresseeDialog::getAddressees(
this );
130 TDEABC::Addressee a = addressList.first();
131 if ( !a.isEmpty() ) {
133 for ( i=0; i<addressList.size(); i++ ) {
135 mWidget->mNameLineEdit->setEnabled(
true );
136 mWidget->mEmailLineEdit->setEnabled(
true );
137 TQListViewItem *item =
new TQListViewItem( mWidget->mAddressListView );
138 mWidget->mAddressListView->setSelected( item,
true );
139 mWidget->mNameLineEdit->setText( a.realName() );
140 mWidget->mEmailLineEdit->setText( a.preferredEmail() );
141 mWidget->mAddressListView->insertItem( item );
147 void PublishDialog::updateItem()
149 TQListViewItem *item;
150 item = mWidget->mAddressListView->selectedItem();
152 item->setText( 0, mWidget->mNameLineEdit->text() );
153 item->setText( 1, mWidget->mEmailLineEdit->text() );
156 void PublishDialog::updateInput()
158 TQListViewItem *item;
159 item = mWidget->mAddressListView->selectedItem();
161 mWidget->mNameLineEdit->setEnabled(
true );
162 mWidget->mEmailLineEdit->setEnabled(
true );
163 mWidget->mNameLineEdit->setText( item->text( 0 ) );
164 mWidget->mEmailLineEdit->setText( item->text( 1 ) );
167 #include "publishdialog.moc"