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.
659 lines
19 KiB
659 lines
19 KiB
15 years ago
|
/****************************************************************************
|
||
|
** ui.h extension file, included from the uic-generated form implementation.
|
||
|
**
|
||
14 years ago
|
** If you wish to add, delete or rename slots use TQt Designer which will
|
||
15 years ago
|
** update this file, preserving your code. Create an init() slot in place of
|
||
|
** a constructor, and a destroy() slot in place of a destructor.
|
||
|
*****************************************************************************/
|
||
|
|
||
15 years ago
|
#include <tqfiledialog.h>
|
||
15 years ago
|
#include <kinputdialog.h>
|
||
15 years ago
|
#include <tqmessagebox.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
|
||
12 years ago
|
#include <tdeabc/stdaddressbook.h>
|
||
15 years ago
|
|
||
12 years ago
|
using namespace TDEABC;
|
||
15 years ago
|
|
||
14 years ago
|
class AddresseeItem : public TQListViewItem
|
||
15 years ago
|
{
|
||
|
public:
|
||
13 years ago
|
AddresseeItem( TQListView *parent, const Addressee &a ) :
|
||
|
TQListViewItem( parent, a.realName(), a.uid() ), mAddressee( a ) {}
|
||
15 years ago
|
|
||
|
void setAddressee( const Addressee &a ) { mAddressee = a; }
|
||
|
Addressee &addressee() { return mAddressee; }
|
||
|
|
||
|
private:
|
||
|
Addressee mAddressee;
|
||
|
};
|
||
|
|
||
|
void MainWindow::init()
|
||
|
{
|
||
12 years ago
|
mAddressBook = TDEABC::StdAddressBook::self( true );
|
||
15 years ago
|
|
||
|
mCurrentItem = 0;
|
||
|
|
||
|
mEmailListView->header()->hide();
|
||
|
mCategoryListView->header()->hide();
|
||
|
|
||
15 years ago
|
connect( mAddressBook, TQT_SIGNAL( addressBookChanged( AddressBook * ) ),
|
||
|
TQT_SLOT( addressBookChanged() ) );
|
||
|
connect( mAddressBook, TQT_SIGNAL( addressBookLocked( AddressBook * ) ),
|
||
|
TQT_SLOT( addressBookLocked() ) );
|
||
|
connect( mAddressBook, TQT_SIGNAL( addressBookUnlocked( AddressBook * ) ),
|
||
|
TQT_SLOT( addressBookUnlocked() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void MainWindow::destroy()
|
||
|
{
|
||
|
delete mAddressBook;
|
||
|
}
|
||
|
|
||
|
void MainWindow::fileSave()
|
||
|
{
|
||
|
updateAddressee( mAddresseeList->selectedItem() );
|
||
|
|
||
|
StdAddressBook::save();
|
||
|
}
|
||
|
|
||
|
void MainWindow::fileOpen()
|
||
|
{
|
||
15 years ago
|
TQString fileName = TQFileDialog::getOpenFileName();
|
||
15 years ago
|
|
||
|
loadAddressBook( fileName );
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::loadAddressBook( const TQString &fileName )
|
||
15 years ago
|
{
|
||
|
kdDebug() << "loadAddressBook(): '" << fileName << "'" << endl;
|
||
|
|
||
|
mAddresseeList->clear();
|
||
|
mCurrentItem = 0;
|
||
14 years ago
|
mCurrentAddress = TQString();
|
||
15 years ago
|
readAddressee( Addressee() );
|
||
|
|
||
12 years ago
|
TDEABC::AddressBook::Iterator it;
|
||
15 years ago
|
for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
|
||
|
new AddresseeItem( mAddresseeList, (*it) );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::updateAddressee( TQListViewItem *item )
|
||
15 years ago
|
{
|
||
|
AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( item );
|
||
|
if ( !addresseeItem ) return;
|
||
|
|
||
|
if (mCurrentItem ) {
|
||
|
writeAddress( mCurrentAddress );
|
||
|
writePhone( mCurrentPhone );
|
||
|
Addressee a = writeAddressee( mCurrentItem->addressee() );
|
||
|
mCurrentItem->setAddressee( a );
|
||
|
mAddressBook->insertAddressee( a );
|
||
|
}
|
||
|
mCurrentItem = addresseeItem;
|
||
|
|
||
|
readAddressee( addresseeItem->addressee() );
|
||
|
updateAddress( mAddressIdCombo->currentItem() );
|
||
|
updatePhone( mPhoneIdCombo->currentItem() );
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void MainWindow::readAddressee( const TDEABC::Addressee &a )
|
||
15 years ago
|
{
|
||
|
kdDebug() << "MainWindow::readAddressee(): " << a.name() << endl;
|
||
|
|
||
|
mNameEdit->setText( a.name() );
|
||
|
mUrlEdit->setText( a.url().url() );
|
||
|
mAdditionalNameEdit->setText( a.additionalName() );
|
||
|
mSuffixEdit->setText( a.suffix() );
|
||
|
mGivenNameEdit->setText( a.givenName() );
|
||
|
mPrefixEdit->setText( a.prefix() );
|
||
|
mFamilyNameEdit->setText( a.familyName() );
|
||
|
mFormattedNameEdit->setText( a.formattedName() );
|
||
|
mNickNameEdit->setText( a.nickName() );
|
||
|
mSortStringEdit->setText( a.sortString() );
|
||
|
mTitleEdit->setText( a.title() );
|
||
|
mRoleEdit->setText( a.role() );
|
||
|
mOrganizationEdit->setText( a.organization() );
|
||
|
mNoteEdit->setText( a.note() );
|
||
|
// mLabelEdit->setText( a.label() );
|
||
|
|
||
|
mEmailListView->clear();
|
||
15 years ago
|
TQStringList emails = a.emails();
|
||
|
TQStringList::ConstIterator it3;
|
||
15 years ago
|
for( it3 = emails.begin(); it3 != emails.end(); ++it3 ) {
|
||
15 years ago
|
new TQListViewItem( mEmailListView, *it3 );
|
||
15 years ago
|
}
|
||
|
|
||
|
mCategoryListView->clear();
|
||
15 years ago
|
TQStringList categories = a.categories();
|
||
|
TQStringList::ConstIterator it4;
|
||
15 years ago
|
for( it4 = categories.begin(); it4 != categories.end(); ++it4 ) {
|
||
15 years ago
|
new TQListViewItem( mCategoryListView, *it4 );
|
||
15 years ago
|
}
|
||
|
|
||
|
mCustomListView->clear();
|
||
15 years ago
|
TQStringList customs = a.customs();
|
||
|
TQStringList::ConstIterator it5;
|
||
15 years ago
|
for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
|
||
14 years ago
|
int posDash = (*it5).find( "-" );
|
||
|
int posColon = (*it5).find( ":" );
|
||
15 years ago
|
|
||
15 years ago
|
TQString app = (*it5).left( posDash );
|
||
|
TQString cname = (*it5).mid( posDash + 1, posColon - posDash - 1 );
|
||
|
TQString value = (*it5).mid( posColon + 1 );
|
||
15 years ago
|
|
||
15 years ago
|
new TQListViewItem( mCustomListView, app, cname, value );
|
||
15 years ago
|
}
|
||
|
|
||
|
Address::List addresses = a.addresses();
|
||
|
mAddressIdCombo->clear();
|
||
|
Address::List::ConstIterator it;
|
||
|
for( it = addresses.begin(); it != addresses.end(); ++it ) {
|
||
|
mAddressIdCombo->insertItem( (*it).id() );
|
||
|
}
|
||
|
if ( mAddressIdCombo->count() > 0 ) mCurrentAddress = mAddressIdCombo->currentText();
|
||
14 years ago
|
else mCurrentAddress = TQString();
|
||
15 years ago
|
readAddress( mCurrentAddress );
|
||
|
|
||
|
mPhoneIdCombo->clear();
|
||
|
PhoneNumber::List pl = a.phoneNumbers();
|
||
|
PhoneNumber::List::ConstIterator it2;
|
||
|
for( it2 = pl.begin(); it2 != pl.end(); ++it2) {
|
||
|
mPhoneIdCombo->insertItem( (*it2).id() );
|
||
|
}
|
||
|
if ( mPhoneIdCombo->count() > 0 ) mCurrentPhone = mPhoneIdCombo->currentText();
|
||
|
readPhone( mCurrentPhone );
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEABC::Addressee MainWindow::writeAddressee( const TDEABC::Addressee &addressee )
|
||
15 years ago
|
{
|
||
|
Addressee a( addressee );
|
||
|
a.setName( mNameEdit->text() );
|
||
|
if ( !mUrlEdit->text().isEmpty() ) {
|
||
|
a.setUrl( KURL( mUrlEdit->text() ) );
|
||
|
}
|
||
|
|
||
|
a.setAdditionalName( mAdditionalNameEdit->text() );
|
||
|
a.setSuffix( mSuffixEdit->text() );
|
||
|
a.setGivenName( mGivenNameEdit->text() );
|
||
|
a.setPrefix( mPrefixEdit->text() );
|
||
|
a.setFamilyName( mFamilyNameEdit->text() );
|
||
|
a.setFormattedName( mFormattedNameEdit->text() );
|
||
|
a.setNickName( mNickNameEdit->text() );
|
||
|
a.setSortString( mSortStringEdit->text() );
|
||
|
a.setTitle( mTitleEdit->text() );
|
||
|
a.setRole( mRoleEdit->text() );
|
||
|
a.setOrganization( mOrganizationEdit->text() );
|
||
|
a.setNote( mNoteEdit->text() );
|
||
|
// a.setLabel( mLabelEdit->text() );
|
||
|
|
||
|
kdDebug() << "MainWindow::writeAddressee()" << endl;
|
||
|
a.dump();
|
||
|
|
||
|
return a;
|
||
|
}
|
||
|
|
||
|
void MainWindow::newEntry()
|
||
|
{
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("New Address Book Entry"),
|
||
15 years ago
|
i18n("Please enter name:"),
|
||
14 years ago
|
TQString(), &ok,
|
||
15 years ago
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
|
Addressee a;
|
||
|
a.setName( name );
|
||
|
mAddressBook->insertAddressee( a );
|
||
|
|
||
|
new AddresseeItem( mAddresseeList, a );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removeEntry()
|
||
|
{
|
||
|
AddresseeItem *item = dynamic_cast<AddresseeItem *>(mAddresseeList->selectedItem());
|
||
|
if ( item ) {
|
||
|
mAddressBook->removeAddressee( item->addressee() );
|
||
|
delete item;
|
||
|
mCurrentItem = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::updateAddress( int id )
|
||
|
{
|
||
|
if( !mCurrentItem ) return;
|
||
|
|
||
|
writeAddress( mCurrentAddress );
|
||
|
if ( mAddressIdCombo->count() > 0 ) {
|
||
|
mCurrentAddress = mAddressIdCombo->text( id );
|
||
|
} else {
|
||
14 years ago
|
mCurrentAddress = TQString();
|
||
15 years ago
|
}
|
||
|
readAddress( mCurrentAddress );
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEABC::Address MainWindow::writeAddress( const TDEABC::Address &address )
|
||
15 years ago
|
{
|
||
|
Address a( address );
|
||
|
|
||
|
a.setPostOfficeBox( mAddressPostOfficeBoxEdit->text() );
|
||
|
a.setExtended( mAddressExtendedEdit->text() );
|
||
|
a.setStreet( mAddressStreetEdit->text() );
|
||
|
a.setLocality( mAddressLocalityEdit->text() );
|
||
|
a.setRegion( mAddressRegionEdit->text() );
|
||
|
a.setLabel( mAddressLabelEdit->text() );
|
||
|
a.setPostalCode( mAddressPostalCodeEdit->text() );
|
||
|
a.setCountry( mAddressCountryEdit->text() );
|
||
|
|
||
|
int type = 0;
|
||
|
if ( mAddressDomCheck->isChecked() ) type |= Address::Dom;
|
||
|
if ( mAddressIntlCheck->isChecked() ) type |= Address::Intl;
|
||
|
if ( mAddressParcelCheck->isChecked() ) type |= Address::Parcel;
|
||
|
if ( mAddressPostalCheck->isChecked() ) type |= Address::Postal;
|
||
|
if ( mAddressHomeCheck->isChecked() ) type |= Address::Home;
|
||
|
if ( mAddressPrefCheck->isChecked() ) type |= Address::Pref;
|
||
|
if ( mAddressWorkCheck->isChecked() ) type |= Address::Work;
|
||
|
a.setType( type );
|
||
|
|
||
|
return a;
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::writeAddress( const TQString &id )
|
||
15 years ago
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
if ( id.isEmpty() ) return;
|
||
|
|
||
|
Address address;
|
||
|
address.setId( id );
|
||
|
address = writeAddress( address );
|
||
|
|
||
|
mCurrentItem->addressee().insertAddress( address );
|
||
|
}
|
||
|
|
||
12 years ago
|
void MainWindow::readAddress( const TDEABC::Address &a )
|
||
15 years ago
|
{
|
||
|
mAddressPostOfficeBoxEdit->setText( a.postOfficeBox() );
|
||
|
mAddressExtendedEdit->setText( a.extended() );
|
||
|
mAddressStreetEdit->setText( a.street() );
|
||
|
mAddressLocalityEdit->setText( a.locality() );
|
||
|
mAddressRegionEdit->setText( a.region() );
|
||
|
mAddressLabelEdit->setText( a.label() );
|
||
|
mAddressPostalCodeEdit->setText( a.postalCode() );
|
||
|
mAddressCountryEdit->setText( a.country() );
|
||
|
|
||
|
int type = a.type();
|
||
|
if ( type & Address::Dom ) mAddressDomCheck->setChecked( true );
|
||
|
else mAddressDomCheck->setChecked( false );
|
||
|
if ( type & Address::Intl ) mAddressIntlCheck->setChecked( true );
|
||
|
else mAddressIntlCheck->setChecked( false );
|
||
|
if ( type & Address::Parcel ) mAddressParcelCheck->setChecked( true );
|
||
|
else mAddressParcelCheck->setChecked( false );
|
||
|
if ( type & Address::Postal ) mAddressPostalCheck->setChecked( true );
|
||
|
else mAddressPostalCheck->setChecked( false );
|
||
|
if ( type & Address::Home ) mAddressHomeCheck->setChecked( true );
|
||
|
else mAddressHomeCheck->setChecked( false );
|
||
|
if ( type & Address::Pref ) mAddressPrefCheck->setChecked( true );
|
||
|
else mAddressPrefCheck->setChecked( false );
|
||
|
if ( type & Address::Work ) mAddressWorkCheck->setChecked( true );
|
||
|
else mAddressWorkCheck->setChecked( false );
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::readAddress( const TQString &id )
|
||
15 years ago
|
{
|
||
|
if ( !mCurrentItem || id.isEmpty() ) {
|
||
|
readAddress( Address() );
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Address address = mCurrentItem->addressee().findAddress( id );
|
||
|
readAddress( address );
|
||
|
}
|
||
|
|
||
|
void MainWindow::updatePhone( int id )
|
||
|
{
|
||
|
if( !mCurrentItem ) return;
|
||
|
|
||
|
writePhone( mCurrentPhone );
|
||
|
if ( mPhoneIdCombo->count() > 0 ) {
|
||
|
mCurrentPhone = mPhoneIdCombo->text( id );
|
||
|
} else {
|
||
14 years ago
|
mCurrentPhone = TQString();
|
||
15 years ago
|
}
|
||
|
readPhone( mCurrentPhone );
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEABC::PhoneNumber MainWindow::writePhone( const TDEABC::PhoneNumber &phoneNumber )
|
||
15 years ago
|
{
|
||
|
PhoneNumber p( phoneNumber );
|
||
|
|
||
|
p.setNumber( mPhoneNumberEdit->text() );
|
||
|
|
||
|
int type = 0;
|
||
|
if ( mPhoneMsgCheck->isChecked() ) type |= PhoneNumber::Msg;
|
||
|
if ( mPhoneVoiceCheck->isChecked() ) type |= PhoneNumber::Voice;
|
||
|
if ( mPhoneFaxCheck->isChecked() ) type |= PhoneNumber::Fax;
|
||
|
if ( mPhoneCellCheck->isChecked() ) type |= PhoneNumber::Cell;
|
||
|
if ( mPhoneHomeCheck->isChecked() ) type |= PhoneNumber::Home;
|
||
|
if ( mPhonePrefCheck->isChecked() ) type |= PhoneNumber::Pref;
|
||
|
if ( mPhoneWorkCheck->isChecked() ) type |= PhoneNumber::Work;
|
||
|
if ( mPhoneVideoCheck->isChecked() ) type |= PhoneNumber::Video;
|
||
|
if ( mPhoneBbsCheck->isChecked() ) type |= PhoneNumber::Bbs;
|
||
|
if ( mPhoneModemCheck->isChecked() ) type |= PhoneNumber::Modem;
|
||
|
if ( mPhoneCarCheck->isChecked() ) type |= PhoneNumber::Car;
|
||
|
if ( mPhoneIsdnCheck->isChecked() ) type |= PhoneNumber::Isdn;
|
||
|
if ( mPhonePcsCheck->isChecked() ) type |= PhoneNumber::Pcs;
|
||
|
if ( mPhonePagerCheck->isChecked() ) type |= PhoneNumber::Pager;
|
||
|
p.setType( type );
|
||
|
|
||
|
return p;
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::writePhone( const TQString &id )
|
||
15 years ago
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
if ( id.isEmpty() ) return;
|
||
|
|
||
|
PhoneNumber p;
|
||
|
p.setId( id );
|
||
|
p = writePhone( p );
|
||
|
|
||
|
mCurrentItem->addressee().insertPhoneNumber( p );
|
||
|
}
|
||
|
|
||
12 years ago
|
void MainWindow::readPhone( const TDEABC::PhoneNumber &p )
|
||
15 years ago
|
{
|
||
|
mPhoneNumberEdit->setText( p.number() );
|
||
|
|
||
|
int type = p.type();
|
||
|
if ( type & PhoneNumber::Msg ) mPhoneMsgCheck->setChecked( true );
|
||
|
else mPhoneMsgCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Voice ) mPhoneVoiceCheck->setChecked( true );
|
||
|
else mPhoneVoiceCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Fax ) mPhoneFaxCheck->setChecked( true );
|
||
|
else mPhoneFaxCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Cell ) mPhoneCellCheck->setChecked( true );
|
||
|
else mPhoneCellCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Home ) mPhoneHomeCheck->setChecked( true );
|
||
|
else mPhoneHomeCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Pref ) mPhonePrefCheck->setChecked( true );
|
||
|
else mPhonePrefCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Work ) mPhoneWorkCheck->setChecked( true );
|
||
|
else mPhoneWorkCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Video ) mPhoneVideoCheck->setChecked( true );
|
||
|
else mPhoneVideoCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Bbs ) mPhoneBbsCheck->setChecked( true );
|
||
|
else mPhoneBbsCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Modem ) mPhoneModemCheck->setChecked( true );
|
||
|
else mPhoneModemCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Car ) mPhoneCarCheck->setChecked( true );
|
||
|
else mPhoneCarCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Isdn ) mPhoneIsdnCheck->setChecked( true );
|
||
|
else mPhoneIsdnCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Pcs ) mPhonePcsCheck->setChecked( true );
|
||
|
else mPhonePcsCheck->setChecked( false );
|
||
|
if ( type & PhoneNumber::Pager ) mPhonePagerCheck->setChecked( true );
|
||
|
else mPhonePagerCheck->setChecked( false );
|
||
|
}
|
||
|
|
||
15 years ago
|
void MainWindow::readPhone( const TQString &id )
|
||
15 years ago
|
{
|
||
|
if ( !mCurrentItem || id.isEmpty() ) {
|
||
|
readPhone( PhoneNumber() );
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
PhoneNumber p = mCurrentItem->addressee().findPhoneNumber( id );
|
||
|
readPhone( p );
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::newAddress()
|
||
|
{
|
||
|
if( !mCurrentItem ) return;
|
||
|
|
||
|
Address address;
|
||
|
mCurrentItem->addressee().insertAddress( address );
|
||
|
|
||
|
mAddressIdCombo->insertItem( address.id() );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removeAddress()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQString id = mAddressIdCombo->currentText();
|
||
15 years ago
|
if ( id.isEmpty() ) return;
|
||
|
|
||
|
Address address;
|
||
|
address.setId( id );
|
||
|
mCurrentItem->addressee().removeAddress( address );
|
||
|
|
||
|
readAddressee( mCurrentItem->addressee() );
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::dumpAddressBook()
|
||
|
{
|
||
|
mAddressBook->dump();
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::newEmail()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("New Email Address"),
|
||
15 years ago
|
i18n("Please enter email address:"),
|
||
14 years ago
|
TQString(), &ok,
|
||
15 years ago
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
15 years ago
|
new TQListViewItem( mEmailListView, name );
|
||
15 years ago
|
mCurrentItem->addressee().insertEmail( name );
|
||
|
}
|
||
|
|
||
|
void MainWindow::editEmail()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mEmailListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
15 years ago
|
TQString oldName = item->text( 0 );
|
||
15 years ago
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("Edit Email Address"),
|
||
15 years ago
|
i18n("Please enter new email address:"),
|
||
|
oldName, &ok,
|
||
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
|
item->setText( 0, name );
|
||
|
mCurrentItem->addressee().removeEmail( oldName );
|
||
|
mCurrentItem->addressee().insertEmail( name );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removeEmail()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mEmailListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
|
mCurrentItem->addressee().removeEmail( item->text( 0 ) );
|
||
|
delete item;
|
||
|
}
|
||
|
|
||
|
void MainWindow::newPhoneNumber()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
PhoneNumber p;
|
||
|
mCurrentItem->addressee().insertPhoneNumber( p );
|
||
|
|
||
|
mPhoneIdCombo->insertItem( p.id() );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removePhoneNumber()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQString id = mPhoneIdCombo->currentText();
|
||
15 years ago
|
if ( id.isEmpty() ) return;
|
||
|
|
||
|
PhoneNumber p;
|
||
|
p.setId( id );
|
||
|
mCurrentItem->addressee().removePhoneNumber( p );
|
||
|
|
||
|
readAddressee( mCurrentItem->addressee() );
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::newCategory()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("New Category"),
|
||
15 years ago
|
i18n("Please enter category name:"),
|
||
14 years ago
|
TQString(), &ok,
|
||
15 years ago
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
15 years ago
|
new TQListViewItem( mCategoryListView, name );
|
||
15 years ago
|
mCurrentItem->addressee().insertCategory( name );
|
||
|
}
|
||
|
|
||
|
void MainWindow::editCategory()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mCategoryListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
15 years ago
|
TQString oldName = item->text( 0 );
|
||
15 years ago
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("Edit Category"),
|
||
15 years ago
|
i18n("Please enter new category name:"),
|
||
|
oldName, &ok,
|
||
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
|
item->setText( 0, name );
|
||
|
mCurrentItem->addressee().removeCategory( oldName );
|
||
|
mCurrentItem->addressee().insertCategory( name );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removeCategory()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mCategoryListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
|
mCurrentItem->addressee().removeCategory( item->text( 0 ) );
|
||
|
delete item;
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::editCustom()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mCustomListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
15 years ago
|
TQString oldName = item->text( 0 ) + "-" + item->text( 1 ) + ":" +
|
||
15 years ago
|
item->text( 2 );
|
||
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("New Custom Entry"),
|
||
15 years ago
|
i18n("Please enter custom entry.\n"
|
||
|
"Format: APP-NAME:VALUE"),
|
||
|
oldName, &ok,
|
||
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
14 years ago
|
int posDash = name.find( "-" );
|
||
|
int posColon = name.find( ":" );
|
||
15 years ago
|
|
||
15 years ago
|
TQString app = name.left( posDash );
|
||
|
TQString cname = name.mid( posDash + 1, posColon - posDash - 1 );
|
||
|
TQString value = name.mid( posColon + 1 );
|
||
15 years ago
|
|
||
|
item->setText( 0, app );
|
||
|
item->setText( 1, cname );
|
||
|
item->setText( 2, value );
|
||
|
|
||
|
mCurrentItem->addressee().removeCustom( app, cname );
|
||
|
mCurrentItem->addressee().insertCustom( app, cname, value );
|
||
|
}
|
||
|
|
||
|
void MainWindow::newCustom()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
|
bool ok = false;
|
||
15 years ago
|
TQString name = KInputDialog::getText( i18n("New Custom Entry"),
|
||
15 years ago
|
i18n("Please enter custom entry.\n"
|
||
|
"Format: APP-NAME:VALUE"),
|
||
14 years ago
|
TQString(), &ok,
|
||
15 years ago
|
this );
|
||
|
if ( !ok || name.isEmpty() ) return;
|
||
|
|
||
14 years ago
|
int posDash = name.find( "-" );
|
||
|
int posColon = name.find( ":" );
|
||
15 years ago
|
|
||
15 years ago
|
TQString app = name.left( posDash );
|
||
|
TQString cname = name.mid( posDash + 1, posColon - posDash - 1 );
|
||
|
TQString value = name.mid( posColon + 1 );
|
||
15 years ago
|
|
||
15 years ago
|
new TQListViewItem( mCustomListView, app, cname, value );
|
||
15 years ago
|
|
||
|
mCurrentItem->addressee().insertCustom( app, cname, value );
|
||
|
}
|
||
|
|
||
|
void MainWindow::removeCustom()
|
||
|
{
|
||
|
if ( !mCurrentItem ) return;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = mCustomListView->selectedItem();
|
||
15 years ago
|
if( !item ) return;
|
||
|
|
||
|
mCurrentItem->addressee().removeCustom( item->text( 0 ), item->text( 1 ) );
|
||
|
delete item;
|
||
|
}
|
||
|
|
||
|
void MainWindow::addressBookChanged()
|
||
|
{
|
||
15 years ago
|
TQMessageBox::warning( this, i18n("Address Book Changed"),
|
||
15 years ago
|
i18n("The address book has changed on disk."),
|
||
|
i18n("Reload") );
|
||
|
loadAddressBook( "dummy" );
|
||
|
}
|
||
|
|
||
|
void MainWindow::addressBookLocked()
|
||
|
{
|
||
|
kdDebug() << "AddressBook locked()" << endl;
|
||
|
}
|
||
|
|
||
|
void MainWindow::addressBookUnlocked()
|
||
|
{
|
||
|
kdDebug() << "AddressBook unlocked()" << endl;
|
||
|
}
|
||
|
|
||
|
|
||
|
void MainWindow::fileOpenStd()
|
||
|
{
|
||
|
loadAddressBook( StdAddressBook::fileName() );
|
||
|
}
|