summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/ui/addressbookselectordialog.cpp
blob: 7d2e17ff3a81a6c5a8ae2a81d23888f9b9026d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
    AddressBookSelectorDialog
    Nice Dialog to select a KDE AddressBook contact

    Copyright (c) 2005 by Duncan Mac-Vicar Prett <duncan@kde.org>

    Kopete    (c) 2002-2005 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "addressbookselectordialog.h"
#include "addressbookselectorwidget.h"
#include <kdialogbase.h>
#include <qdialog.h>
#include <qlistview.h>
#include <qvbox.h>
#include <klocale.h>
#include <kdialog.h>

namespace Kopete
{
namespace UI
{

AddressBookSelectorDialog::AddressBookSelectorDialog(const QString &title, const QString &message, const QString &preSelectUid, QWidget *parent, const char *name, bool modal ) : KDialogBase(parent, name, modal, title, Help|Ok|Cancel, Ok, true )
{
	QVBox *vbox=new QVBox(this);
	m_addressBookSelectorWidget= new AddressBookSelectorWidget(vbox);
	m_addressBookSelectorWidget->setLabelMessage(message);	

	vbox->setSpacing( KDialog::spacingHint() );
	
	setMainWidget(vbox);
	enableButtonOK(false);
	//setHelp("linkaddressbook");

	connect(m_addressBookSelectorWidget, SIGNAL(addresseeListClicked( QListViewItem * )), SLOT(slotWidgetAddresseeListClicked( QListViewItem * )));

	if ( !preSelectUid.isEmpty() )
		m_addressBookSelectorWidget->selectAddressee(preSelectUid);
}

AddressBookSelectorDialog::~AddressBookSelectorDialog()
{
}

KABC::Addressee AddressBookSelectorDialog::getAddressee( const QString &title, const QString &message, const QString &preSelectUid, QWidget *parent)
{
	AddressBookSelectorDialog dialog(title, message, preSelectUid, parent);
	int result = dialog.exec();

	KABC::Addressee adr;
	if ( result == QDialog::Accepted )
		adr = dialog.addressBookSelectorWidget()->addressee();

	return adr;
}

void AddressBookSelectorDialog::slotWidgetAddresseeListClicked( QListViewItem *addressee )
{
	// enable ok if a valid addressee is selected
	enableButtonOK( addressee ? addressee->isSelected() : false);
}

void AddressBookSelectorDialog::accept()
{
	QDialog::accept();
}

void AddressBookSelectorDialog::reject()
{
	QDialog::reject();
}

} // namespace UI
} // namespace Kopete

#include "addressbookselectordialog.moc"

// vim: set noet ts=4 sts=4 sw=4: