25 #include <tqpopupmenu.h>
27 #include <tdeabc/addressbook.h>
28 #include <tdeabc/distributionlistdialog.h>
29 #include <tdeconfig.h>
31 #include <tdelocale.h>
32 #include <kxmlguifactory.h>
33 #include <kxmlguiclient.h>
36 #include "searchmanager.h"
38 #include "kaddressbookview.h"
40 KAddressBookView::KAddressBookView( KAB::Core *core, TQWidget *parent,
42 : TQWidget( parent, name ), mCore( core ), mFieldList()
46 connect( mCore->searchManager(), TQ_SIGNAL( contactsUpdated() ),
47 TQ_SLOT( updateView() ) );
50 KAddressBookView::~KAddressBookView()
52 kdDebug(5720) <<
"KAddressBookView::~KAddressBookView: destroying - "
58 mFieldList = TDEABC::Field::restoreFields( config,
"KABCFields" );
60 if ( mFieldList.isEmpty() )
61 mFieldList = TDEABC::Field::defaultFields();
63 mDefaultFilterType = (DefaultFilterType)config->readNumEntry(
"DefaultFilterType", 1 );
64 mDefaultFilterName = config->readEntry(
"DefaultFilterName" );
77 TDEABC::Addressee addr;
80 TQStringList::ConstIterator it;
81 for ( it = uidList.begin(); it != uidList.end(); ++it ) {
82 addr = mCore->addressBook()->findByUid( *it );
84 if ( !addr.isEmpty() ) {
85 TQString m = TQString();
87 if ( addr.emails().count() > 1 )
88 m = TDEABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(),
this );
90 email = addr.fullEmail( m );
107 return mCore->searchManager()->contacts();
109 TDEABC::Addressee::List addresseeList;
110 const TDEABC::Addressee::List contacts = mCore->searchManager()->contacts();
112 TDEABC::Addressee::List::ConstIterator it;
113 TDEABC::Addressee::List::ConstIterator contactsEnd( contacts.end() );
114 for ( it = contacts.begin(); it != contactsEnd; ++it ) {
116 addresseeList.append( *it );
119 return addresseeList;
122 void KAddressBookView::initGUI()
125 TQVBoxLayout *layout =
new TQVBoxLayout(
this );
128 mViewWidget =
new TQWidget(
this );
129 layout->addWidget( mViewWidget );
144 return mDefaultFilterType;
149 return mDefaultFilterName;
159 if ( !mCore->guiClient() ) {
160 kdWarning() <<
"No GUI client set!" << endl;
164 TQPopupMenu *menu =
static_cast<TQPopupMenu*
>( mCore->guiClient()->factory()->container(
"RMBPopup",
165 mCore->guiClient() ) );
167 menu->popup( point );
175 void KAddressBookView::updateView()
181 if ( !uidList.isEmpty() ) {
183 TQStringList::ConstIterator it, uidListEnd( uidList.end() );
184 for ( it = uidList.begin(); it != uidListEnd; ++it )
188 const TDEABC::Addressee::List contacts = mCore->searchManager()->contacts();
189 if ( !contacts.isEmpty() )
203 #include "kaddressbookview.moc"
Filter for AddressBook related objects (Addressees)
bool filterAddressee(const TDEABC::Addressee &a) const
Apply the filter to the addressee.
virtual TQStringList selectedUids()=0
Must be overloaded in subclasses.
const TQString & defaultFilterName() const
TQWidget * viewWidget()
This method returns the widget that should be used as the parent for all view components.
void setFilter(const Filter &)
Sets the active filter.
void popup(const TQPoint &point)
Call this slot to popup a rmb menu.
DefaultFilterType defaultFilterType() const
virtual void refresh(const TQString &uid=TQString())=0
Must be overloaded in subclasses to refresh the view.
void selected(const TQString &uid)
This signal should be emitted by a subclass whenever an addressee is selected.
virtual TQString selectedEmails()
Returns a TQString with all the selected email addresses concatenated together with a ',...
virtual void setSelected(const TQString &uid=TQString(), bool selected=true)=0
This method must be overloaded in subclasses.
virtual void writeConfig(TDEConfig *)
Called whenever this view should write the config.
TDEABC::Addressee::List addressees()
Returns a list of the addressees that should be displayed.
virtual void setFirstSelected(bool selected=true)=0
Selects the first contact in the view.
virtual void readConfig(TDEConfig *config)
Called whenever this view should read the config.
TDEABC::Field::List fields() const
Returns a list of the fields that should be displayed.