You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
6.3 KiB
235 lines
6.3 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
|
||
|
Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef KPIM_ADDRESSEESELECTOR_H
|
||
|
#define KPIM_ADDRESSEESELECTOR_H
|
||
|
|
||
|
#include <kabc/addressee.h>
|
||
|
#include <kabc/distributionlist.h>
|
||
|
#include <kabc/resource.h>
|
||
|
#include <kdialogbase.h>
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqbitarray.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqwidget.h>
|
||
15 years ago
|
|
||
|
class KComboBox;
|
||
|
class KLineEdit;
|
||
|
class KListView;
|
||
15 years ago
|
class TQSignalMapper;
|
||
15 years ago
|
|
||
|
namespace KPIM {
|
||
|
|
||
|
class AddresseeSelector;
|
||
|
|
||
|
class KDE_EXPORT Selection
|
||
|
{
|
||
|
friend class AddresseeSelector;
|
||
|
|
||
|
public:
|
||
|
virtual ~Selection() {}
|
||
|
|
||
|
/**
|
||
|
Returns the number of fields the selection offers.
|
||
|
*/
|
||
|
virtual uint fieldCount() const = 0;
|
||
|
|
||
|
/**
|
||
|
Returns the title for the field specified by index.
|
||
|
*/
|
||
15 years ago
|
virtual TQString fieldTitle( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the number of items for the given addressee.
|
||
|
*/
|
||
|
virtual uint itemCount( const KABC::Addressee &addresse ) const = 0;
|
||
|
|
||
|
/**
|
||
|
Returns the text that's used for the item specified by index.
|
||
|
*/
|
||
15 years ago
|
virtual TQString itemText( const KABC::Addressee &addresse, uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the icon that's used for the item specified by index.
|
||
|
*/
|
||
15 years ago
|
virtual TQPixmap itemIcon( const KABC::Addressee &addresse, uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns whether the item specified by index is enabled.
|
||
|
*/
|
||
|
virtual bool itemEnabled( const KABC::Addressee &addresse, uint index ) const = 0;
|
||
|
|
||
|
/**
|
||
|
Returns whether the item specified by index matches the passed pattern.
|
||
|
*/
|
||
15 years ago
|
virtual bool itemMatches( const KABC::Addressee &addresse, uint index, const TQString &pattern ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns whether the item specified by index equals the passed pattern.
|
||
|
*/
|
||
15 years ago
|
virtual bool itemEquals( const KABC::Addressee &addresse, uint index, const TQString &pattern ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the text that's used for the given distribution list.
|
||
|
*/
|
||
15 years ago
|
virtual TQString distributionListText( const KABC::DistributionList *distributionList ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the icon that's used for the given distribution list.
|
||
|
*/
|
||
15 years ago
|
virtual TQPixmap distributionListIcon( const KABC::DistributionList *distributionList ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns whether the given distribution list is enabled.
|
||
|
*/
|
||
|
virtual bool distributionListEnabled( const KABC::DistributionList *distributionList ) const = 0;
|
||
|
|
||
|
/**
|
||
|
Returns whether the given distribution list matches the passed pattern.
|
||
|
*/
|
||
|
virtual bool distributionListMatches( const KABC::DistributionList *distributionList,
|
||
15 years ago
|
const TQString &pattern ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the number of additional address books.
|
||
|
*/
|
||
|
virtual uint addressBookCount() const = 0;
|
||
|
|
||
|
/**
|
||
|
Returns the title for an additional address book.
|
||
|
*/
|
||
15 years ago
|
virtual TQString addressBookTitle( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
Returns the content for an additional address book.
|
||
|
*/
|
||
|
virtual KABC::Addressee::List addressBookContent( uint index ) const = 0;
|
||
|
|
||
|
protected:
|
||
|
AddresseeSelector* selector() { return mSelector; }
|
||
|
|
||
|
private:
|
||
|
virtual void addSelectedAddressees( uint fieldIndex, const KABC::Addressee&, uint itemIndex ) = 0;
|
||
|
virtual void addSelectedDistributionList( uint fieldIndex, const KABC::DistributionList* ) = 0;
|
||
|
|
||
|
void setSelector( AddresseeSelector *selector ) { mSelector = selector; }
|
||
|
|
||
|
AddresseeSelector *mSelector;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
Internal helper class
|
||
|
*/
|
||
|
class SelectionItem
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
typedef TQValueList<SelectionItem> List;
|
||
15 years ago
|
|
||
|
SelectionItem( const KABC::Addressee &addressee, uint index );
|
||
|
SelectionItem( KABC::DistributionList *list, uint index );
|
||
|
SelectionItem();
|
||
|
|
||
|
void addToField( int index );
|
||
|
void removeFromField( int index );
|
||
|
bool isInField( int index );
|
||
|
|
||
|
KABC::Addressee addressee() const;
|
||
|
KABC::DistributionList* distributionList() const;
|
||
|
uint index() const;
|
||
|
|
||
|
private:
|
||
|
KABC::Addressee mAddressee;
|
||
|
KABC::DistributionList *mDistributionList;
|
||
|
uint mIndex;
|
||
15 years ago
|
TQBitArray mField;
|
||
15 years ago
|
};
|
||
|
|
||
14 years ago
|
class KDE_EXPORT AddresseeSelector : public TQWidget
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
14 years ago
|
TQ_OBJECT
|
||
15 years ago
|
|
||
|
public:
|
||
|
AddresseeSelector( Selection *selection,
|
||
13 years ago
|
TQWidget *parent, const char *name = 0 );
|
||
15 years ago
|
~AddresseeSelector();
|
||
|
|
||
|
/**
|
||
|
Writes back the selected items to the selection.
|
||
|
*/
|
||
|
void finish();
|
||
|
|
||
|
void setItemSelected( uint fieldIndex, const KABC::Addressee&, uint itemIndex );
|
||
|
void setItemSelected( uint fieldIndex, const KABC::Addressee&,
|
||
15 years ago
|
uint itemIndex, const TQString& );
|
||
15 years ago
|
|
||
|
private slots:
|
||
|
void move( int index );
|
||
|
void remove( int index );
|
||
|
|
||
|
void updateAddresseeView();
|
||
|
void reloadAddressBook();
|
||
|
|
||
|
private:
|
||
|
void init();
|
||
|
void initGUI();
|
||
|
|
||
|
void updateSelectionView( int index );
|
||
|
void updateSelectionViews();
|
||
|
|
||
|
Selection *mSelection;
|
||
|
|
||
|
KComboBox *mAddressBookCombo;
|
||
|
KLineEdit *mAddresseeFilter;
|
||
|
KListView *mAddresseeView;
|
||
|
SelectionItem::List mSelectionItems;
|
||
|
|
||
15 years ago
|
TQValueList<KListView*> mSelectionViews;
|
||
|
TQSignalMapper *mMoveMapper;
|
||
|
TQSignalMapper *mRemoveMapper;
|
||
15 years ago
|
|
||
|
KABC::DistributionListManager *mManager;
|
||
|
|
||
|
class AddressBookManager;
|
||
|
AddressBookManager *mAddressBookManager;
|
||
|
};
|
||
|
|
||
|
class KDE_EXPORT AddresseeSelectorDialog : public KDialogBase
|
||
|
{
|
||
|
Q_OBJECT
|
||
14 years ago
|
TQ_OBJECT
|
||
15 years ago
|
|
||
|
public:
|
||
|
AddresseeSelectorDialog( Selection *selection,
|
||
13 years ago
|
TQWidget *parent = 0, const char *name = 0 );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
|
void accept();
|
||
|
|
||
|
private:
|
||
|
AddresseeSelector *mSelector;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|