diff --git a/akonadi/contact/editor/addresseditwidget.cpp b/akonadi/contact/editor/addresseditwidget.cpp deleted file mode 100644 index 8ff067e3e..000000000 --- a/akonadi/contact/editor/addresseditwidget.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ - -#include "addresseditwidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class TabPressEater : public QObject -{ - public: - TabPressEater( QObject *parent ) - : QObject( parent ) - { - setObjectName( "TabPressEater" ); - } - - protected: - bool eventFilter( QObject*, QEvent *event ) - { - if ( event->type() == QEvent::KeyPress ) { - QKeyEvent *keyEvent = (QKeyEvent*)event; - if ( keyEvent->key() == Qt::Key_Tab ) { - QApplication::sendEvent( parent(), event ); - return true; - } else - return false; - } else { - return false; - } - } -}; - -/** - * Dialog for creating a new address types. - * - * @note This dialog is only used by AddressTypeCombo. - */ -class AddressTypeDialog : public KDialog -{ - public: - AddressTypeDialog( KABC::Address::Type type, QWidget *parent ); - ~AddressTypeDialog(); - - KABC::Address::Type type() const; - - private: - QButtonGroup *mGroup; - - KABC::Address::TypeList mTypeList; -}; - - -AddressSelectionWidget::AddressSelectionWidget( QWidget *parent ) - : KComboBox( parent ) -{ - connect( this, SIGNAL( activated( int ) ), SLOT( selected( int ) ) ); -} - -AddressSelectionWidget::~AddressSelectionWidget() -{ -} - -void AddressSelectionWidget::setAddresses( const KABC::Address::List &addresses ) -{ - mAddresses = addresses; - updateView(); -} - -void AddressSelectionWidget::setCurrentAddress( const KABC::Address &address ) -{ - const int index = mAddresses.indexOf( address ); - if ( index != -1 ) - setCurrentIndex( index ); -} - -KABC::Address AddressSelectionWidget::currentAddress() const -{ - if ( currentIndex() != -1 && currentIndex() < mAddresses.count() ) - return mAddresses.at( currentIndex() ); - else - return KABC::Address(); -} - -void AddressSelectionWidget::selected( int index ) -{ - Q_ASSERT( index != -1 && index < mAddresses.count() ); - emit selectionChanged( mAddresses.at( index ) ); -} - -void AddressSelectionWidget::updateView() -{ - clear(); - for ( int i = 0; i < mAddresses.count(); ++i ) - addItem( KABC::Address::typeLabel( mAddresses.at( i ).type() ) ); -} - - - -AddressTypeCombo::AddressTypeCombo( QWidget *parent ) - : KComboBox( parent ), - mType( KABC::Address::Home ), - mLastSelected( 0 ) -{ - for ( int i = 0; i < KABC::Address::typeList().count(); ++i ) - mTypeList.append( KABC::Address::typeList().at( i ) ); - mTypeList.append( -1 ); // Others... - - update(); - - connect( this, SIGNAL( activated( int ) ), - this, SLOT( selected( int ) ) ); -} - -AddressTypeCombo::~AddressTypeCombo() -{ -} - -void AddressTypeCombo::setType( KABC::Address::Type type ) -{ - if ( !mTypeList.contains( (int)type ) ) { - // insert at the end, but before the 'Others...' entry - mTypeList.insert( mTypeList.at( mTypeList.count() - 1 ), (int)type ); - } - - mType = type; - update(); -} - -KABC::Address::Type AddressTypeCombo::type() const -{ - return mType; -} - -void AddressTypeCombo::update() -{ - bool blocked = signalsBlocked(); - blockSignals( true ); - - clear(); - for ( int i = 0; i < mTypeList.count(); ++i ) { - if ( mTypeList.at( i ) == -1 ) // "Other..." entry - addItem( i18nc( "@item:inlistbox Category of contact info field", "Other..." ) ); - else - addItem( KABC::Address::typeLabel( KABC::Address::Type( mTypeList.at( i ) ) ) ); - } - - setCurrentIndex( mLastSelected = mTypeList.indexOf( mType ) ); - - blockSignals( blocked ); -} - -void AddressTypeCombo::selected( int pos ) -{ - if ( mTypeList.at( pos ) == -1 ) - otherSelected(); - else { - mType = KABC::Address::Type( mTypeList.at( pos ) ); - mLastSelected = pos; - } -} - -void AddressTypeCombo::otherSelected() -{ - AddressTypeDialog dlg( mType, this ); - if ( dlg.exec() ) { - mType = dlg.type(); - if ( !mTypeList.contains( mType ) ) - mTypeList.insert( mTypeList.at( mTypeList.count() - 1 ), mType ); - } else { - setType( KABC::Address::Type( mTypeList.at( mLastSelected ) ) ); - } - - update(); -} - - -AddressEditWidget::AddressEditWidget( QWidget *parent ) - : QWidget( parent ), mReadOnly( false ) -{ - QGridLayout *layout = new QGridLayout( this ); - layout->setSpacing( 2 ); - layout->setMargin( 4 ); - layout->setSpacing( KDialog::spacingHint() ); - - mAddressSelectionWidget = new AddressSelectionWidget( this ); - connect( mAddressSelectionWidget, SIGNAL( selectionChanged( const KABC::Address& ) ), - SLOT( updateAddressView() ) ); - layout->addWidget( mAddressSelectionWidget, 0, 0, 1, 3 ); - - mAddressView = new QLabel( this ); - mAddressView->setFrameStyle( QFrame::Panel | QFrame::Sunken ); - mAddressView->setMinimumHeight( 20 ); - mAddressView->setAlignment( Qt::AlignTop ); - mAddressView->setTextFormat( Qt::PlainText ); - mAddressView->setTextInteractionFlags( Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse ); - layout->addWidget( mAddressView, 1, 0, 1, 3 ); - - mCreateButton = new QPushButton( i18nc( "street/postal", "New..." ), this ); - connect( mCreateButton, SIGNAL( clicked() ), this, SLOT( createAddress() ) ); - mEditButton = new QPushButton( i18nc( "street/postal", "Edit..." ), this ); - connect( mEditButton, SIGNAL( clicked() ), this, SLOT( editAddress() ) ); - mDeleteButton = new QPushButton( i18nc( "street/postal", "Delete" ), this ); - connect( mDeleteButton, SIGNAL( clicked() ), this, SLOT( deleteAddress() ) ); - - layout->addWidget( mCreateButton, 2, 0 ); - layout->addWidget( mEditButton, 2, 1 ); - layout->addWidget( mDeleteButton, 2, 2 ); - - updateButtons(); -} - -AddressEditWidget::~AddressEditWidget() -{ -} - -void AddressEditWidget::setReadOnly( bool readOnly ) -{ - mReadOnly = readOnly; - updateButtons(); -} - -void AddressEditWidget::updateName( const QString &name ) -{ - mName = name; - updateAddressView(); -} - -void AddressEditWidget::createAddress() -{ - AddressEditDialog dialog( this ); - if ( dialog.exec() ) { - const KABC::Address address = dialog.address(); - fixPreferredAddress( address ); - mAddressList.append( address ); - mAddressSelectionWidget->setAddresses( mAddressList ); - mAddressSelectionWidget->setCurrentAddress( address ); - - updateAddressView(); - updateButtons(); - } -} - -void AddressEditWidget::editAddress() -{ - AddressEditDialog dialog( this ); - dialog.setAddress( mAddressSelectionWidget->currentAddress() ); - if ( dialog.exec() ) { - const KABC::Address address = dialog.address(); - fixPreferredAddress( address ); - mAddressList[ mAddressSelectionWidget->currentIndex() ] = address; - mAddressSelectionWidget->setAddresses( mAddressList ); - mAddressSelectionWidget->setCurrentAddress( address ); - - updateAddressView(); - } -} - -void AddressEditWidget::deleteAddress() -{ - const int result = KMessageBox::questionYesNo( this, i18n( "Do you really want to delete this address?" ) ); - - if ( result != KMessageBox::Yes ) - return; - - mAddressList.removeAt( mAddressSelectionWidget->currentIndex() ); - mAddressSelectionWidget->setAddresses( mAddressList ); - updateAddressView(); - updateButtons(); -} - -void AddressEditWidget::fixPreferredAddress( const KABC::Address &preferredAddress ) -{ - // as the preferred address is mutual exclusive, we have to - // remove the flag from all other addresses - if ( preferredAddress.type() & KABC::Address::Pref ) { - for ( int i = 0; i < mAddressList.count(); ++i ) { - KABC::Address &address = mAddressList[ i ]; - address.setType( address.type() & ~KABC::Address::Pref ); - } - } -} - -void AddressEditWidget::updateAddressView() -{ - const KABC::Address address = mAddressSelectionWidget->currentAddress(); - - if ( address.isEmpty() ) - mAddressView->setText( QString() ); - else - mAddressView->setText( address.formattedAddress( mName ) ); -} - -void AddressEditWidget::updateButtons() -{ - mCreateButton->setEnabled( !mReadOnly ); - mEditButton->setEnabled( !mReadOnly && (mAddressList.count() > 0) ); - mDeleteButton->setEnabled( !mReadOnly && (mAddressList.count() > 0) ); -} - -void AddressEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mName = contact.realName(); - mAddressList = contact.addresses(); - - mAddressSelectionWidget->setAddresses( mAddressList ); - - // set the preferred address as the visible one - for ( int i = 0; i < mAddressList.count(); ++i ) { - if ( mAddressList.at( i ).type() & KABC::Address::Pref ) { - mAddressSelectionWidget->setCurrentAddress( mAddressList.at( i ) ); - break; - } - } - - updateAddressView(); - updateButtons(); -} - -void AddressEditWidget::storeContact( KABC::Addressee &contact ) const -{ - // delete all previous addresses - const KABC::Address::List oldAddresses = contact.addresses(); - for ( int i = 0; i < oldAddresses.count(); ++i ) - contact.removeAddress( oldAddresses.at( i ) ); - - // insert the new ones - for ( int i = 0; i < mAddressList.count(); ++i ) { - const KABC::Address address( mAddressList.at( i ) ); - if ( !address.isEmpty() ) - contact.insertAddress( address ); - } -} - - -AddressEditDialog::AddressEditDialog( QWidget *parent ) - : KDialog(parent) -{ - setCaption( i18nc( "street/postal", "Edit Address" ) ); - setButtons( Ok | Cancel ); - setDefaultButton( Ok ); - showButtonSeparator( true ); - - QWidget *page = new QWidget( this ); - setMainWidget( page ); - - QGridLayout *topLayout = new QGridLayout( page ); - topLayout->setSpacing( spacingHint() ); - topLayout->setMargin( 0 ); - - mTypeCombo = new AddressTypeCombo( page ); - topLayout->addWidget( mTypeCombo, 0, 0, 1, 2 ); - - QLabel *label = new QLabel( i18nc( ":", "%1:", KABC::Address::streetLabel() ), page ); - label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); - topLayout->addWidget( label, 1, 0 ); - mStreetTextEdit = new KTextEdit( page ); - mStreetTextEdit->setAcceptRichText( false ); - label->setBuddy( mStreetTextEdit ); - topLayout->addWidget( mStreetTextEdit, 1, 1 ); - - TabPressEater *eater = new TabPressEater( this ); - mStreetTextEdit->installEventFilter( eater ); - - label = new QLabel( i18nc( ":", "%1:", KABC::Address::postOfficeBoxLabel() ), page ); - topLayout->addWidget( label, 2 , 0 ); - mPOBoxEdit = new KLineEdit( page ); - label->setBuddy( mPOBoxEdit ); - topLayout->addWidget( mPOBoxEdit, 2, 1 ); - - label = new QLabel( i18nc( ":", "%1:", KABC::Address::localityLabel() ), page ); - topLayout->addWidget( label, 3, 0 ); - mLocalityEdit = new KLineEdit( page ); - label->setBuddy( mLocalityEdit ); - topLayout->addWidget( mLocalityEdit, 3, 1 ); - - label = new QLabel( i18nc( ":", "%1:", KABC::Address::regionLabel() ), page ); - topLayout->addWidget( label, 4, 0 ); - mRegionEdit = new KLineEdit( page ); - label->setBuddy( mRegionEdit ); - topLayout->addWidget( mRegionEdit, 4, 1 ); - - label = new QLabel( i18nc( ":", "%1:", KABC::Address::postalCodeLabel() ), page ); - topLayout->addWidget( label, 5, 0 ); - mPostalCodeEdit = new KLineEdit( page ); - label->setBuddy( mPostalCodeEdit ); - topLayout->addWidget( mPostalCodeEdit, 5, 1 ); - - label = new QLabel( i18nc( ":", "%1:", KABC::Address::countryLabel() ), page ); - topLayout->addWidget( label, 6, 0 ); - mCountryCombo = new KComboBox( page ); - mCountryCombo->setEditable( true ); - mCountryCombo->setDuplicatesEnabled( false ); - - QPushButton *labelButton = new QPushButton( i18n( "Edit Label..." ), page ); - topLayout->addWidget( labelButton, 7, 0, 1, 2 ); - connect( labelButton, SIGNAL( clicked() ), SLOT( editLabel() ) ); - - fillCountryCombo(); - label->setBuddy( mCountryCombo ); - topLayout->addWidget( mCountryCombo, 6, 1 ); - - mPreferredCheckBox = new QCheckBox( i18nc( "street/postal", "This is the preferred address" ), page ); - topLayout->addWidget( mPreferredCheckBox, 8, 0, 1, 2 ); - - KSeparator *sep = new KSeparator( Qt::Horizontal, page ); - topLayout->addWidget( sep, 9, 0, 1, 2 ); - - KHBox *buttonBox = new KHBox( page ); - buttonBox->setSpacing( spacingHint() ); - topLayout->addWidget( buttonBox, 10, 0, 1, 2 ); - - KAcceleratorManager::manage( this ); -} - -AddressEditDialog::~AddressEditDialog() -{ -} - -void AddressEditDialog::editLabel() -{ - bool ok = false; - QString result = KInputDialog::getMultiLineText( KABC::Address::labelLabel(), - KABC::Address::labelLabel(), - mLabel, &ok, this ); - if ( ok ) - mLabel = result; -} - -void AddressEditDialog::setAddress(const KABC::Address &address) -{ - mAddress = address; - - mTypeCombo->setType( mAddress.type() ); - mStreetTextEdit->setPlainText( mAddress.street() ); - mRegionEdit->setText( mAddress.region() ); - mLocalityEdit->setText( mAddress.locality() ); - mPostalCodeEdit->setText( mAddress.postalCode() ); - mPOBoxEdit->setText( mAddress.postOfficeBox() ); - mLabel = mAddress.label(); - mPreferredCheckBox->setChecked( mAddress.type() & KABC::Address::Pref ); - - if ( mAddress.isEmpty() ) - mCountryCombo->setItemText( mCountryCombo->currentIndex(), - KGlobal::locale()->countryCodeToName( KGlobal::locale()->country() ) ); - else - mCountryCombo->setItemText( mCountryCombo->currentIndex(), mAddress.country() ); - - mStreetTextEdit->setFocus(); -} - -KABC::Address AddressEditDialog::address() const -{ - KABC::Address address( mAddress ); - - address.setType( mTypeCombo->type() ); - address.setLocality( mLocalityEdit->text() ); - address.setRegion( mRegionEdit->text() ); - address.setPostalCode( mPostalCodeEdit->text() ); - address.setCountry( mCountryCombo->currentText() ); - address.setPostOfficeBox( mPOBoxEdit->text() ); - address.setStreet( mStreetTextEdit->toPlainText() ); - address.setLabel( mLabel ); - - if ( mPreferredCheckBox->isChecked() ) { - address.setType( address.type() | KABC::Address::Pref ); - } else - address.setType( address.type() & ~(KABC::Address::Pref) ); - - return address; -} - -void AddressEditDialog::fillCountryCombo() -{ - QStringList countries; - - foreach( const QString &cc, KGlobal::locale()->allCountriesList() ) { - countries.append( KGlobal::locale()->countryCodeToName(cc) ); - } - - countries = sortLocaleAware( countries ); - - mCountryCombo->addItems( countries ); - mCountryCombo->completionObject()->setItems( countries ); - mCountryCombo->setAutoCompletion( true ); -} - - -AddressTypeDialog::AddressTypeDialog( KABC::Address::Type type, QWidget *parent ) - : KDialog( parent) -{ - setCaption( i18nc( "street/postal", "Edit Address Type" ) ); - setButtons( Ok | Cancel ); - setDefaultButton( Ok ); - - QWidget *page = new QWidget(this); - setMainWidget( page ); - QVBoxLayout *layout = new QVBoxLayout( page ); - layout->setSpacing( KDialog::spacingHint() ); - layout->setMargin( 0 ); - - QGroupBox *box = new QGroupBox( i18nc( "street/postal", "Address Types" ), page ); - layout->addWidget( box ); - mGroup = new QButtonGroup( box ); - mGroup->setExclusive ( false ); - - QGridLayout *buttonLayout = new QGridLayout( box ); - - mTypeList = KABC::Address::typeList(); - mTypeList.removeAll( KABC::Address::Pref ); - - KABC::Address::TypeList::ConstIterator it; - int i = 0; - int row = 0; - for ( it = mTypeList.constBegin(); it != mTypeList.constEnd(); ++it, ++i ) { - QCheckBox *cb = new QCheckBox( KABC::Address::typeLabel( *it ), box ); - cb->setChecked( type & mTypeList[ i ] ); - buttonLayout->addWidget( cb, row, i%3 ); - - if( i%3 == 2 ) - ++row; - mGroup->addButton( cb ); - } -} - -AddressTypeDialog::~AddressTypeDialog() -{ -} - -KABC::Address::Type AddressTypeDialog::type() const -{ - KABC::Address::Type type; - for ( int i = 0; i < mGroup->buttons().count(); ++i ) { - QCheckBox *box = dynamic_cast( mGroup->buttons().at( i ) ); - if ( box && box->isChecked() ) - type |= mTypeList[ i ]; - } - - return type; -} - -/** - Small helper class, I hope we can remove it as soon as a general solution has - been committed to kdelibs - */ -class LocaleAwareString : public QString -{ - public: - LocaleAwareString() : QString() - {} - - LocaleAwareString( const QString &str ) : QString( str ) - {} -}; - -static bool operator<( const LocaleAwareString &s1, const LocaleAwareString &s2 ) -{ - return ( QString::localeAwareCompare( s1, s2 ) < 0 ); -} - -QStringList AddressEditDialog::sortLocaleAware( const QStringList &list ) -{ - QList sortedList; - - QStringList::ConstIterator it; - for ( it = list.constBegin(); it != list.constEnd(); ++it ) - sortedList.append( LocaleAwareString( *it ) ); - - qSort( sortedList.begin(), sortedList.end() ); - - QStringList retval; - QList::ConstIterator retIt; - for ( retIt = sortedList.constBegin(); retIt != sortedList.constEnd(); ++retIt ) - retval.append( *retIt ); - - return retval; -} - -#include "addresseditwidget.moc" diff --git a/akonadi/contact/editor/addresseditwidget.h b/akonadi/contact/editor/addresseditwidget.h deleted file mode 100644 index d11db865b..000000000 --- a/akonadi/contact/editor/addresseditwidget.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ - -#ifndef ADDRESSEDITWIDGET_H -#define ADDRESSEDITWIDGET_H - -#include - -#include -#include -#include -#include - -class QCheckBox; -class QLabel; - -class KLineEdit; -class KTextEdit; - -/** - * @short A widget that shows a list of addresses for selection. - */ -class AddressSelectionWidget : public KComboBox -{ - Q_OBJECT - - public: - /** - * Creates a new address selection widget. - * - * @param parent The parent widget. - */ - AddressSelectionWidget( QWidget *parent = 0 ); - - /** - * Destroys the address selection widget. - */ - virtual ~AddressSelectionWidget(); - - /** - * Sets the list of @p addresses that can be chosen from. - */ - void setAddresses( const KABC::Address::List &addresses ); - - /** - * Sets the current @p address. - */ - void setCurrentAddress( const KABC::Address &address ); - - /** - * Returns the current selected address. - */ - KABC::Address currentAddress() const; - - Q_SIGNALS: - /** - * This signal is emitted whenever the selection of the - * address has changed. - * - * @param address The new selected address. - */ - void selectionChanged( const KABC::Address &address ); - - private Q_SLOTS: - void selected( int ); - - private: - void updateView(); - - KABC::Address::List mAddresses; -}; - -/** - * @short A widget for selecting the type of an address. - */ -class AddressTypeCombo : public KComboBox -{ - Q_OBJECT - - public: - /** - * Creates a new address type combo. - * - * @param parent The parent widget. - */ - AddressTypeCombo( QWidget *parent = 0 ); - - /** - * Destroys the address type combo. - */ - ~AddressTypeCombo(); - - /** - * Sets the type that shall be selected in the combobox. - */ - void setType( KABC::Address::Type type ); - - /** - * Returns the type that is currently selected. - */ - KABC::Address::Type type() const; - - private Q_SLOTS: - void selected( int ); - void otherSelected(); - - private: - void update(); - - KABC::Address::Type mType; - int mLastSelected; - QList mTypeList; -}; - -/** - * @short An editor widget for addresses. - */ -class AddressEditWidget : public QWidget -{ - Q_OBJECT - - public: - explicit AddressEditWidget( QWidget *parent = 0 ); - ~AddressEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - public Q_SLOTS: - void updateName( const QString &name ); - - private Q_SLOTS: - void updateAddressView(); - void createAddress(); - void editAddress(); - void deleteAddress(); - - private: - void updateButtons(); - void fixPreferredAddress( const KABC::Address &preferredAddress ); - - AddressSelectionWidget *mAddressSelectionWidget; - - QLabel *mAddressView; - QPushButton *mCreateButton; - QPushButton *mEditButton; - QPushButton *mDeleteButton; - - KABC::Address::List mAddressList; - QString mName; - bool mReadOnly; -}; - -/** - Dialog for editing address details. - */ -class AddressEditDialog : public KDialog -{ - Q_OBJECT - - public: - AddressEditDialog( QWidget *parent = 0 ); - ~AddressEditDialog(); - - void setAddress( const KABC::Address &address ); - KABC::Address address() const; - - private Q_SLOTS: - void editLabel(); - - private: - void fillCountryCombo(); - QStringList sortLocaleAware( const QStringList& ); - - AddressTypeCombo *mTypeCombo; - KTextEdit *mStreetTextEdit; - KComboBox *mCountryCombo; - KLineEdit *mRegionEdit; - KLineEdit *mLocalityEdit; - KLineEdit *mPostalCodeEdit; - KLineEdit *mPOBoxEdit; - QCheckBox *mPreferredCheckBox; - - KABC::Address mAddress; - QString mLabel; -}; - -#endif diff --git a/akonadi/contact/editor/contacteditor.cpp b/akonadi/contact/editor/contacteditor.cpp deleted file mode 100644 index b8836737d..000000000 --- a/akonadi/contact/editor/contacteditor.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "contacteditor.h" - -#include "addresseditwidget.h" -#include "contactmetadata.h" -#include "dateeditwidget.h" -#include "displaynameeditwidget.h" -#include "emaileditwidget.h" -#include "freebusyeditwidget.h" -#include "imagewidget.h" -#include "imeditwidget.h" -#include "nameeditwidget.h" -#include "phoneeditwidget.h" -#include "soundeditwidget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -class ContactEditor::Private -{ - public: - Private( ContactEditor *parent ) - : mParent( parent ) - { - } - - void initGui(); - void initGuiContactTab(); - void initGuiLocationTab(); - void initGuiBusinessTab(); - void initGuiPersonalTab(); - - QString loadCustom( const KABC::Addressee &contact, const QString &key ) const; - void storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const; - - ContactEditor *mParent; - KTabWidget *mTabWidget; - - // widgets from name group - NameEditWidget *mNameWidget; - ImageWidget *mPhotoWidget; - DisplayNameEditWidget *mDisplayNameWidget; - KLineEdit *mNickNameWidget; - SoundEditWidget *mPronunciationWidget; - - // widgets from internet group - EmailEditWidget *mEmailWidget; - KLineEdit *mHomepageWidget; - KLineEdit *mBlogWidget; - IMEditWidget *mIMWidget; - - // widgets from phones group - PhoneEditWidget *mPhonesWidget; - - // widgets from addresses group - AddressEditWidget *mAddressesWidget; - - // widgets from coordinates group - QWidget *mCoordinatesWidget; - - // widgets from general group - ImageWidget *mLogoWidget; - KLineEdit *mOrganizationWidget; - KLineEdit *mProfessionWidget; - KLineEdit *mTitleWidget; - KLineEdit *mDepartmentWidget; - KLineEdit *mOfficeWidget; - KLineEdit *mManagerWidget; - KLineEdit *mAssistantWidget; - - // widgets from groupware group - FreeBusyEditWidget *mFreeBusyWidget; - - // widgets from notes group - KTextEdit *mNotesWidget; - - // widgets from dates group - DateEditWidget *mBirthdateWidget; - DateEditWidget *mAnniversaryWidget; - - // widgets from family group - KLineEdit *mPartnerWidget; -}; - -void ContactEditor::Private::initGui() -{ - QVBoxLayout *layout = new QVBoxLayout( mParent ); - layout->setMargin( 0 ); - - mTabWidget = new KTabWidget( mParent ); - layout->addWidget( mTabWidget ); - - initGuiContactTab(); - initGuiLocationTab(); - initGuiBusinessTab(); - initGuiPersonalTab(); -} - -void ContactEditor::Private::initGuiContactTab() -{ - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout( widget ); - - mTabWidget->addTab( widget, i18n( "Contact" ) ); - - QGroupBox *nameGroupBox = new QGroupBox( i18n( "Name" ) ); - QGroupBox *internetGroupBox = new QGroupBox( i18n( "Internet" ) ); - QGroupBox *phonesGroupBox = new QGroupBox( i18n( "Phones" ) ); - - layout->addWidget( nameGroupBox ); - layout->addWidget( internetGroupBox ); - layout->addWidget( phonesGroupBox ); - - QGridLayout *nameLayout = new QGridLayout( nameGroupBox ); - QGridLayout *internetLayout = new QGridLayout( internetGroupBox ); - QGridLayout *phonesLayout = new QGridLayout( phonesGroupBox ); - - QLabel *label = 0; - - // setup name group box - label = new QLabel( i18n( "Name:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - nameLayout->addWidget( label, 0, 0 ); - - mNameWidget = new NameEditWidget; - label->setBuddy( mNameWidget ); - nameLayout->addWidget( mNameWidget, 0, 1 ); - - mPhotoWidget = new ImageWidget( ImageWidget::Photo ); - mPhotoWidget->setMinimumSize( QSize( 100, 140 ) ); - nameLayout->addWidget( mPhotoWidget, 0, 2, 4, 1 ); - - label = new QLabel( i18n( "Display:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - nameLayout->addWidget( label, 1, 0 ); - - mDisplayNameWidget = new DisplayNameEditWidget; - label->setBuddy( mDisplayNameWidget ); - nameLayout->addWidget( mDisplayNameWidget, 1, 1 ); - - label = new QLabel( i18n( "Nickname:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - nameLayout->addWidget( label, 2, 0 ); - - mNickNameWidget = new KLineEdit; - label->setBuddy( mNickNameWidget ); - nameLayout->addWidget( mNickNameWidget, 2, 1 ); - - label = new QLabel( i18n( "Pronunciation:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - nameLayout->addWidget( label, 3, 0 ); - - mPronunciationWidget = new SoundEditWidget; - label->setBuddy( mPronunciationWidget ); - nameLayout->addWidget( mPronunciationWidget, 3, 1 ); - - nameLayout->setRowStretch( 4, 1 ); - - // setup internet group box - label = new QLabel( i18n( "Email:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - internetLayout->addWidget( label, 0, 0 ); - - mEmailWidget = new EmailEditWidget; - label->setBuddy( mEmailWidget ); - internetLayout->addWidget( mEmailWidget, 0, 1 ); - - label = new QLabel( i18n( "Homepage:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - internetLayout->addWidget( label, 1, 0 ); - - mHomepageWidget = new KLineEdit; - label->setBuddy( mHomepageWidget ); - internetLayout->addWidget( mHomepageWidget, 1, 1 ); - - label = new QLabel( i18n( "Blog:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - internetLayout->addWidget( label, 2, 0 ); - - mBlogWidget = new KLineEdit; - label->setBuddy( mBlogWidget ); - internetLayout->addWidget( mBlogWidget, 2, 1 ); - - label = new QLabel( i18n( "Messaging:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - internetLayout->addWidget( label, 3, 0 ); - - mIMWidget = new IMEditWidget; - label->setBuddy( mIMWidget ); - internetLayout->addWidget( mIMWidget, 3, 1 ); - - internetLayout->setRowStretch( 4, 1 ); - - // setup phones group box - mPhonesWidget = new PhoneEditWidget; - phonesLayout->addWidget( mPhonesWidget, 0, 0 ); - - phonesLayout->setRowStretch( 1, 1 ); -} - -void ContactEditor::Private::initGuiLocationTab() -{ - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout( widget ); - - mTabWidget->addTab( widget, i18n( "Location" ) ); - - QGroupBox *addressesGroupBox = new QGroupBox( i18n( "Addresses" ) ); - QGroupBox *coordinatesGroupBox = new QGroupBox( i18n( "Coordinates" ) ); - - layout->addWidget( addressesGroupBox ); - layout->addWidget( coordinatesGroupBox ); - - QGridLayout *addressesLayout = new QGridLayout( addressesGroupBox ); - QGridLayout *coordinatesLayout = new QGridLayout( coordinatesGroupBox ); - - // setup addresses group box - mAddressesWidget = new AddressEditWidget( addressesGroupBox ); - mAddressesWidget->setMinimumHeight( 200 ); - addressesLayout->addWidget( mAddressesWidget, 0, 0 ); - addressesLayout->setRowStretch( 1, 1 ); - - // setup coordinates group box - mCoordinatesWidget = new QWidget; - coordinatesLayout->addWidget( mCoordinatesWidget, 0, 0 ); - coordinatesLayout->setRowStretch( 1, 1 ); -} - -void ContactEditor::Private::initGuiBusinessTab() -{ - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout( widget ); - - mTabWidget->addTab( widget, i18n( "Business" ) ); - - QGroupBox *generalGroupBox = new QGroupBox( i18n( "General" ) ); - QGroupBox *groupwareGroupBox = new QGroupBox( i18n( "Groupware" ) ); - QGroupBox *notesGroupBox = new QGroupBox( i18n( "Notes" ) ); - - layout->addWidget( generalGroupBox ); - layout->addWidget( groupwareGroupBox ); - layout->addWidget( notesGroupBox ); - - QGridLayout *generalLayout = new QGridLayout( generalGroupBox ); - QGridLayout *groupwareLayout = new QGridLayout( groupwareGroupBox ); - QGridLayout *notesLayout = new QGridLayout( notesGroupBox ); - - QLabel *label = 0; - - // setup general group box - mLogoWidget = new ImageWidget( ImageWidget::Logo ); - generalLayout->addWidget( mLogoWidget, 0, 2, 6, 1, Qt::AlignTop ); - - label = new QLabel( i18n( "Organization:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 0, 0 ); - - mOrganizationWidget = new KLineEdit; - label->setBuddy( mOrganizationWidget ); - generalLayout->addWidget( mOrganizationWidget, 0, 1 ); - - label = new QLabel( i18n( "Profession:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 1, 0 ); - - mProfessionWidget = new KLineEdit; - label->setBuddy( mProfessionWidget ); - generalLayout->addWidget( mProfessionWidget, 1, 1 ); - - label = new QLabel( i18n( "Title:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 2, 0 ); - - mTitleWidget = new KLineEdit; - label->setBuddy( mTitleWidget ); - generalLayout->addWidget( mTitleWidget , 2, 1 ); - - label = new QLabel( i18n( "Department:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 3, 0 ); - - mDepartmentWidget = new KLineEdit; - label->setBuddy( mDepartmentWidget ); - generalLayout->addWidget( mDepartmentWidget, 3, 1 ); - - label = new QLabel( i18n( "Office:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 4, 0 ); - - mOfficeWidget = new KLineEdit; - label->setBuddy( mOfficeWidget ); - generalLayout->addWidget( mOfficeWidget, 4, 1 ); - - label = new QLabel( i18n( "Manager's name:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 5, 0 ); - - mManagerWidget = new KLineEdit; - label->setBuddy( mManagerWidget ); - generalLayout->addWidget( mManagerWidget, 5, 1 ); - - label = new QLabel( i18n( "Assistant's name:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - generalLayout->addWidget( label, 6, 0 ); - - mAssistantWidget = new KLineEdit; - label->setBuddy( mAssistantWidget ); - generalLayout->addWidget( mAssistantWidget, 6, 1 ); - - generalLayout->setRowStretch( 7, 1 ); - - // setup groupware group box - label = new QLabel( i18n( "Free/Busy:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - groupwareLayout->addWidget( label, 0, 0 ); - - mFreeBusyWidget = new FreeBusyEditWidget; - label->setBuddy( mFreeBusyWidget ); - groupwareLayout->addWidget( mFreeBusyWidget, 0, 1 ); - - groupwareLayout->setRowStretch( 1, 1 ); - - // setup notes group box - mNotesWidget = new KTextEdit; - notesLayout->addWidget( mNotesWidget, 0, 0 ); -} - -void ContactEditor::Private::initGuiPersonalTab() -{ - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout( widget ); - - mTabWidget->addTab( widget, i18n( "Personal" ) ); - - QGroupBox *datesGroupBox = new QGroupBox( i18n( "Dates" ) ); - QGroupBox *familyGroupBox = new QGroupBox( i18n( "Family" ) ); - - layout->addWidget( datesGroupBox ); - layout->addWidget( familyGroupBox ); - - QGridLayout *datesLayout = new QGridLayout( datesGroupBox ); - QGridLayout *familyLayout = new QGridLayout( familyGroupBox ); - - QLabel *label = 0; - - // setup dates group box - label = new QLabel( i18n( "Birthdate:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - datesLayout->addWidget( label, 0, 0 ); - - mBirthdateWidget = new DateEditWidget; - label->setBuddy( mBirthdateWidget ); - datesLayout->addWidget( mBirthdateWidget, 0, 1 ); - - label = new QLabel( i18n( "Anniversary:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - datesLayout->addWidget( label, 1, 0 ); - - mAnniversaryWidget = new DateEditWidget; - label->setBuddy( mAnniversaryWidget ); - datesLayout->addWidget( mAnniversaryWidget, 1, 1 ); - - datesLayout->setRowStretch( 2, 1 ); - datesLayout->setColumnStretch( 1, 1 ); - - // widgets from family group - label = new QLabel( i18n( "Partner's name:" ) ); - label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - familyLayout->addWidget( label, 0, 0 ); - - mPartnerWidget = new KLineEdit; - label->setBuddy( mPartnerWidget ); - familyLayout->addWidget( mPartnerWidget, 0, 1 ); - - familyLayout->setRowStretch( 1, 1 ); -} - -QString ContactEditor::Private::loadCustom( const KABC::Addressee &contact, const QString &key ) const -{ - return contact.custom( "KADDRESSBOOK", key ); -} - -void ContactEditor::Private::storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const -{ - if ( value.isEmpty() ) - contact.removeCustom( "KADDRESSBOOK", key ); - else - contact.insertCustom( "KADDRESSBOOK", key, value ); -} - -ContactEditor::ContactEditor( QWidget* ) - : d( new Private( this ) ) -{ - d->initGui(); - - connect( d->mNameWidget, SIGNAL( nameChanged( const KABC::Addressee& ) ), - d->mDisplayNameWidget, SLOT( changeName( const KABC::Addressee& ) ) ); - connect( d->mOrganizationWidget, SIGNAL( textChanged( const QString& ) ), - d->mDisplayNameWidget, SLOT( changeOrganization( const QString& ) ) ); -} - -ContactEditor::~ContactEditor() -{ - delete d; -} - -void ContactEditor::loadContact( const KABC::Addressee &contact ) -{ - // name group - d->mPhotoWidget->loadContact( contact ); - d->mNameWidget->loadContact( contact ); - d->mDisplayNameWidget->loadContact( contact ); - d->mNickNameWidget->setText( contact.nickName() ); - d->mPronunciationWidget->loadContact( contact ); - - // internet group - d->mEmailWidget->loadContact( contact ); - d->mHomepageWidget->setUrl( contact.url() ); - d->mBlogWidget->setText( d->loadCustom( contact, "BlogFeed" ) ); - d->mIMWidget->loadContact( contact ); - - // phones group - d->mPhonesWidget->loadContact( contact ); - - // address group - d->mAddressesWidget->loadContact( contact ); - - // coordinates group - - // general group - d->mLogoWidget->loadContact( contact ); - d->mOrganizationWidget->setText( contact.organization() ); - d->mProfessionWidget->setText( d->loadCustom( contact, "X-Profession" ) ); - d->mTitleWidget->setText( contact.title() ); - d->mDepartmentWidget->setText( contact.department() ); - d->mOfficeWidget->setText( d->loadCustom( contact, "X-Office" ) ); - d->mManagerWidget->setText( d->loadCustom( contact, "X-ManagersName" ) ); - d->mAssistantWidget->setText( d->loadCustom( contact, "X-AssistantsName" ) ); - - // groupware group - d->mFreeBusyWidget->loadContact( contact ); - - // notes group - d->mNotesWidget->setPlainText( contact.note() ); - - // dates group - d->mBirthdateWidget->setDate( contact.birthday().date() ); - d->mAnniversaryWidget->setDate( QDate::fromString( d->loadCustom( contact, "X-Anniversary" ), Qt::ISODate ) ); - - // family group - d->mPartnerWidget->setText( d->loadCustom( contact, "X-SpousesName" ) ); - - const ContactMetaData metaData( contact ); - d->mDisplayNameWidget->setDisplayType( (DisplayNameEditWidget::DisplayType)metaData.displayNameMode() ); -} - -void ContactEditor::storeContact( KABC::Addressee &contact ) const -{ - // name group - d->mPhotoWidget->storeContact( contact ); - d->mNameWidget->storeContact( contact ); - d->mDisplayNameWidget->storeContact( contact ); - contact.setNickName( d->mNickNameWidget->text().trimmed() ); - d->mPronunciationWidget->storeContact( contact ); - - // internet group - d->mEmailWidget->storeContact( contact ); - contact.setUrl( KUrl( d->mHomepageWidget->text().trimmed() ) ); - d->storeCustom( contact, "BlogFeed", d->mBlogWidget->text().trimmed() ); - d->mIMWidget->storeContact( contact ); - - // phones group - d->mPhonesWidget->storeContact( contact ); - - // address group - d->mAddressesWidget->storeContact( contact ); - - // coordinates group - - // general group - d->mLogoWidget->storeContact( contact ); - contact.setOrganization( d->mOrganizationWidget->text() ); - d->storeCustom( contact, "X-Profession", d->mProfessionWidget->text().trimmed() ); - contact.setTitle( d->mTitleWidget->text().trimmed() ); - contact.setDepartment( d->mDepartmentWidget->text().trimmed() ); - d->storeCustom( contact, "X-Office", d->mOfficeWidget->text().trimmed() ); - d->storeCustom( contact, "X-ManagersName", d->mManagerWidget->text().trimmed() ); - d->storeCustom( contact, "X-AssistantsName", d->mAssistantWidget->text().trimmed() ); - - // groupware group - d->mFreeBusyWidget->storeContact( contact ); - - // notes group - contact.setNote( d->mNotesWidget->toPlainText() ); - - // dates group - contact.setBirthday( QDateTime( d->mBirthdateWidget->date(), QTime() ) ); - d->storeCustom( contact, "X-Anniversary", d->mAnniversaryWidget->date().toString( Qt::ISODate ) ); - - // family group - d->storeCustom( contact, "X-SpousesName", d->mPartnerWidget->text().trimmed() ); - - ContactMetaData metaData( contact ); - metaData.setDisplayNameMode( d->mDisplayNameWidget->displayType() ); -} diff --git a/akonadi/contact/editor/contacteditor.h b/akonadi/contact/editor/contacteditor.h deleted file mode 100644 index 0766ea4a8..000000000 --- a/akonadi/contact/editor/contacteditor.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef CONTACTEDITOR_H -#define CONTACTEDITOR_H - -#include "abstractcontacteditorwidget.h" - -namespace KABC -{ -class Addressee; -} - -/** - * @short A widget for editing a contact. - * - * @author Tobias Koenig - */ -class ContactEditor : public AbstractContactEditorWidget -{ - public: - /** - * Creates a new contact editor. - * - * @param parent The parent widget. - */ - ContactEditor( QWidget *parent = 0 ); - - /** - * Destroys the contact editor. - */ - ~ContactEditor(); - - /** - * Initializes the fields of the contact editor - * with the values from a @p contact. - */ - void loadContact( const KABC::Addressee &contact ); - - /** - * Stores back the fields of the contact editor - * into the given @p contact. - */ - void storeContact( KABC::Addressee &contact ) const; - - private: - class Private; - Private* const d; -}; - -#endif diff --git a/akonadi/contact/editor/dateeditwidget.cpp b/akonadi/contact/editor/dateeditwidget.cpp deleted file mode 100644 index 2ecfc039b..000000000 --- a/akonadi/contact/editor/dateeditwidget.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "dateeditwidget.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -DateLineEdit::DateLineEdit( QWidget *parent ) - : KLineEdit( parent ) -{ - setReadOnly( true ); -} - -void DateLineEdit::contextMenuEvent( QContextMenuEvent *event ) -{ - QMenu menu; - menu.addAction( i18n( "Remove" ), this, SLOT( emitSignal() ) ); - - menu.exec( event->globalPos() ); -} - -void DateLineEdit::emitSignal() -{ - emit resetDate(); -} - -DateEditWidget::DateEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - - mView = new DateLineEdit; - layout->addWidget( mView ); - - mButton = new QToolButton; - mButton->setPopupMode(QToolButton::InstantPopup); - mButton->setIcon( KIcon( "view-calendar-day" ) ); - layout->addWidget( mButton ); - - mMenu = new KPIM::KDatePickerPopup( KPIM::KDatePickerPopup::DatePicker, QDate(), this ); - mButton->setMenu( mMenu ); - - connect( mMenu, SIGNAL( dateChanged( const QDate& ) ), SLOT( dateSelected( const QDate& ) ) ); - connect( mView, SIGNAL( resetDate() ), SLOT( resetDate() ) ); - - updateView(); -} - -DateEditWidget::~DateEditWidget() -{ -} - -void DateEditWidget::setDate( const QDate &date ) -{ - mDate = date; - mMenu->setDate( mDate ); - updateView(); -} - -QDate DateEditWidget::date() const -{ - return mDate; -} - -void DateEditWidget::setReadOnly( bool readOnly ) -{ - mButton->setEnabled( !readOnly ); -} - -void DateEditWidget::dateSelected(const QDate &date) -{ - mDate = date; - updateView(); -} - -void DateEditWidget::resetDate() -{ - mDate = QDate(); - updateView(); -} - -void DateEditWidget::updateView() -{ - if ( mDate.isValid() ) - mView->setText( KGlobal::locale()->formatDate( mDate ) ); - else - mView->setText( QString() ); -} - -#include "dateeditwidget.moc" diff --git a/akonadi/contact/editor/dateeditwidget.h b/akonadi/contact/editor/dateeditwidget.h deleted file mode 100644 index 6cbe5b6a6..000000000 --- a/akonadi/contact/editor/dateeditwidget.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef DATEEDITWIDGET_H -#define DATEEDITWIDGET_H - -#include -#include - -#include - -namespace KPIM -{ -class KDatePickerPopup; -} - -class QContextMenuEvent; -class QToolButton; - -class DateLineEdit : public KLineEdit -{ - Q_OBJECT - - public: - DateLineEdit( QWidget *parent = 0 ); - - Q_SIGNALS: - void resetDate(); - - protected: - virtual void contextMenuEvent( QContextMenuEvent* ); - - private Q_SLOTS: - void emitSignal(); -}; - -class DateEditWidget : public QWidget -{ - Q_OBJECT - - public: - DateEditWidget( QWidget *parent = 0 ); - ~DateEditWidget(); - - void setDate( const QDate &date ); - QDate date() const; - - void setReadOnly( bool readOnly ); - - private Q_SLOTS: - void dateSelected( const QDate& ); - void resetDate(); - void updateView(); - - private: - QDate mDate; - DateLineEdit *mView; - QToolButton *mButton; - KPIM::KDatePickerPopup *mMenu; -}; - -#endif diff --git a/akonadi/contact/editor/displaynameeditwidget.cpp b/akonadi/contact/editor/displaynameeditwidget.cpp deleted file mode 100644 index 50621c7b1..000000000 --- a/akonadi/contact/editor/displaynameeditwidget.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "displaynameeditwidget.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -class DisplayNameEditWidget::LineEdit : public KLineEdit -{ - public: - LineEdit( DisplayNameEditWidget *parent ) - : KLineEdit( parent ), mParent( parent ) - { - } - - protected: - // context menu handling - virtual void contextMenuEvent( QContextMenuEvent *event ) - { - mParent->contextMenuEvent( event ); - } - - private: - DisplayNameEditWidget *mParent; -}; - -DisplayNameEditWidget::DisplayNameEditWidget( QWidget *parent ) - : QWidget( parent ), - mDisplayType( FullName ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - layout->setSpacing( KDialog::spacingHint() ); - - mView = new LineEdit( this ); - layout->addWidget( mView ); -} - -DisplayNameEditWidget::~DisplayNameEditWidget() -{ -} - -void DisplayNameEditWidget::setReadOnly( bool readOnly ) -{ - mView->setReadOnly( readOnly && (mDisplayType != CustomName) ); -} - -void DisplayNameEditWidget::setDisplayType( DisplayType type ) -{ - mDisplayType = type; - updateView(); -} - -DisplayNameEditWidget::DisplayType DisplayNameEditWidget::displayType() const -{ - return mDisplayType; -} - -void DisplayNameEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mView->setText( contact.formattedName() ); - mContact = contact; - - updateView(); -} - -void DisplayNameEditWidget::storeContact( KABC::Addressee &contact ) const -{ - contact.setFormattedName( mView->text() ); -} - -void DisplayNameEditWidget::changeName( const KABC::Addressee &contact ) -{ - const QString organization = mContact.organization(); - mContact = contact; - mContact.setOrganization( organization ); - mContact.setFormattedName( mView->text() ); - - updateView(); -} - -void DisplayNameEditWidget::changeOrganization( const QString &organization ) -{ - mContact.setOrganization( organization ); - - updateView(); -} - -void DisplayNameEditWidget::contextMenuEvent( QContextMenuEvent *event ) -{ - QMenu menu; - - QActionGroup *group = new QActionGroup( this ); - - KToggleAction *simpleNameAction = new KToggleAction( i18n( "Simple Name" ), group ); - KToggleAction *fullNameAction = new KToggleAction( i18n( "Full Name" ), group ); - KToggleAction *reverseNameWithCommaAction = new KToggleAction( i18n( "Reverse Name with Comma" ), group ); - KToggleAction *reverseNameAction = new KToggleAction( i18n( "Reverse Name" ), group ); - KToggleAction *organizationNameAction = new KToggleAction( i18n( "Organization Name" ), group ); - KToggleAction *customNameAction = new KToggleAction( i18n( "Custom" ), group ); - - group->setExclusive( true ); - - menu.addAction( simpleNameAction ); - menu.addAction( fullNameAction ); - menu.addAction( reverseNameWithCommaAction ); - menu.addAction( reverseNameAction ); - menu.addAction( organizationNameAction ); - menu.addAction( customNameAction ); - - if ( mDisplayType == SimpleName ) - simpleNameAction->setChecked( true ); - if ( mDisplayType == FullName ) - fullNameAction->setChecked( true ); - if ( mDisplayType == ReverseNameWithComma ) - reverseNameWithCommaAction->setChecked( true ); - if ( mDisplayType == ReverseName ) - reverseNameAction->setChecked( true ); - if ( mDisplayType == Organization ) - organizationNameAction->setChecked( true ); - if ( mDisplayType == CustomName ) - customNameAction->setChecked( true ); - - QAction *result = menu.exec( event->globalPos() ); - if ( result == simpleNameAction ) - mDisplayType = SimpleName; - else if ( result == fullNameAction ) - mDisplayType = FullName; - else if ( result == reverseNameWithCommaAction ) - mDisplayType = ReverseNameWithComma; - else if ( result == reverseNameAction ) - mDisplayType = ReverseName; - else if ( result == organizationNameAction ) - mDisplayType = Organization; - else if ( result == customNameAction ) - mDisplayType = CustomName; - - delete group; - - updateView(); -} - -void DisplayNameEditWidget::updateView() -{ - QString text; - - switch ( mDisplayType ) { - case SimpleName: - text = mContact.givenName() + ' ' + mContact.familyName(); - break; - case FullName: - text = mContact.assembledName(); - break; - case ReverseNameWithComma: - text = mContact.familyName() + ", " + mContact.givenName(); - break; - case ReverseName: - text = mContact.familyName() + ' ' + mContact.givenName(); - break; - case Organization: - text = mContact.organization(); - break; - case CustomName: - text = mContact.formattedName(); - default: - break; - } - - mView->setText( text ); - mView->setReadOnly( mDisplayType != CustomName ); -} - -#include "displaynameeditwidget.moc" diff --git a/akonadi/contact/editor/displaynameeditwidget.h b/akonadi/contact/editor/displaynameeditwidget.h deleted file mode 100644 index f004871b3..000000000 --- a/akonadi/contact/editor/displaynameeditwidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef DISPLAYNAMEEDITWIDGET_H -#define DISPLAYNAMEEDITWIDGET_H - -#include - -#include - -/** - * @short A widget for editing the display name of a contact. - * - * The widget will either use a predefined schema for formatting - * the name or a custom one. - */ -class DisplayNameEditWidget : public QWidget -{ - Q_OBJECT - - public: - /** - * Describes what the display name should look like. - */ - enum DisplayType - { - CustomName, ///< Let the user input a display name - SimpleName, ///< A name of the form: givenName familyName - FullName, ///< A name of the form: prefix givenName additionalName familyName suffix - ReverseNameWithComma, ///< A name of the form: familyName, givenName - ReverseName, ///< A name of the form: familyName givenName - Organization ///< The organization name - }; - - explicit DisplayNameEditWidget( QWidget *parent = 0 ); - ~DisplayNameEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - void setDisplayType( DisplayType type ); - DisplayType displayType() const; - - public Q_SLOTS: - void changeName( const KABC::Addressee &contact ); - void changeOrganization( const QString &organization ); - - protected: - // context menu handling - virtual void contextMenuEvent( QContextMenuEvent* ); - - private: - void updateView(); - - class LineEdit; - LineEdit *mView; - - DisplayType mDisplayType; - KABC::Addressee mContact; -}; - -#endif diff --git a/akonadi/contact/editor/emaileditwidget.cpp b/akonadi/contact/editor/emaileditwidget.cpp deleted file mode 100644 index 491b76243..000000000 --- a/akonadi/contact/editor/emaileditwidget.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "emaileditwidget.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -class EmailValidator : public QRegExpValidator -{ - public: - EmailValidator() : QRegExpValidator( 0 ) - { - setObjectName( "EmailValidator" ); - QRegExp rx( ".*@.*\\.[A-Za-z]+" ); - setRegExp( rx ); - } -}; - -class EmailItem : public QListWidgetItem -{ - public: - EmailItem( const QString &text, QListWidget *parent, bool preferred ) - : QListWidgetItem( text, parent ), mPreferred( preferred ) - { - format(); - } - - void setPreferred( bool preferred ) { mPreferred = preferred; format(); } - bool preferred() const { return mPreferred; } - - private: - void format() - { - QFont f = font(); - f.setBold( mPreferred ); - setFont( f ); - } - - private: - bool mPreferred; -}; - -EmailEditWidget::EmailEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - layout->setSpacing( KDialog::spacingHint() ); - - mEmailEdit = new KLineEdit; - mEmailEdit->setValidator( new EmailValidator ); - connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), - SLOT( textChanged( const QString& ) ) ); - layout->addWidget( mEmailEdit ); - - mEditButton = new QToolButton; - mEditButton->setText( "..." ); - connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); - layout->addWidget( mEditButton ); -} - -EmailEditWidget::~EmailEditWidget() -{ -} - -void EmailEditWidget::setReadOnly( bool readOnly ) -{ - mEmailEdit->setReadOnly( readOnly ); - mEditButton->setEnabled( !readOnly ); -} - -void EmailEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mEmailList = contact.emails(); - - if ( !mEmailList.isEmpty() ) - mEmailEdit->setText( mEmailList.first() ); - else - mEmailEdit->setText( QString() ); -} - -void EmailEditWidget::storeContact( KABC::Addressee &contact ) const -{ - QStringList emails( mEmailList ); - - // the preferred address is always the first one, remove it... - if ( !emails.isEmpty() ) - emails.removeFirst(); - - // ... and prepend the one from the line edit - if ( !mEmailEdit->text().isEmpty() ) - emails.prepend( mEmailEdit->text() ); - - contact.setEmails( emails ); -} - -void EmailEditWidget::edit() -{ - EmailEditDialog dlg( mEmailList, this ); - - if ( dlg.exec() ) { - if ( dlg.changed() ) { - mEmailList = dlg.emails(); - if ( !mEmailList.isEmpty() ) - mEmailEdit->setText( mEmailList.first() ); - else - mEmailEdit->setText( QString() ); - } - } -} - -void EmailEditWidget::textChanged( const QString &text ) -{ - if ( !mEmailList.isEmpty() ) - mEmailList.removeFirst(); - - mEmailList.prepend( text ); -} - - -EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent ) - : KDialog( parent ) -{ - setCaption( i18n( "Edit Email Addresses" ) ); - setButtons( KDialog::Ok | KDialog::Cancel ); - setDefaultButton( KDialog::Help ); - - QWidget *page = new QWidget( this); - setMainWidget( page ); - - QGridLayout *topLayout = new QGridLayout( page ); - topLayout->setSpacing( spacingHint() ); - topLayout->setMargin( 0 ); - - mEmailListBox = new KListWidget( page ); - mEmailListBox->setSelectionMode( QAbstractItemView::SingleSelection ); - - // Make sure there is room for the scrollbar - mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 ); - connect( mEmailListBox, SIGNAL( currentItemChanged( QListWidgetItem *, QListWidgetItem * ) ), - SLOT( selectionChanged() ) ); - connect( mEmailListBox, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ), - SLOT( edit() ) ); - topLayout->addWidget( mEmailListBox, 0, 0, 5, 2 ); - - mAddButton = new QPushButton( i18n( "Add..." ), page ); - connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); - topLayout->addWidget( mAddButton, 0, 2 ); - - mEditButton = new QPushButton( i18n( "Edit..." ), page ); - mEditButton->setEnabled( false ); - connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); - topLayout->addWidget( mEditButton, 1, 2 ); - - mRemoveButton = new QPushButton( i18n( "Remove" ), page ); - mRemoveButton->setEnabled( false ); - connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); - topLayout->addWidget( mRemoveButton, 2, 2 ); - - mStandardButton = new QPushButton( i18n( "Set Standard" ), page ); - mStandardButton->setEnabled( false ); - connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) ); - topLayout->addWidget( mStandardButton, 3, 2 ); - - topLayout->setRowStretch( 4, 1 ); - - QStringList items = list; - if ( items.removeAll( "" ) > 0 ) - mChanged = true; - else - mChanged = false; - - QStringList::ConstIterator it; - bool preferred = true; - for ( it = items.constBegin(); it != items.constEnd(); ++it ) { - new EmailItem( *it, mEmailListBox, preferred ); - preferred = false; - } - - // set default state - KAcceleratorManager::manage( this ); - - setInitialSize( QSize( 400, 200 ) ); -} - -EmailEditDialog::~EmailEditDialog() -{ -} - -QStringList EmailEditDialog::emails() const -{ - QStringList emails; - - for ( int i = 0; i < mEmailListBox->count(); ++i ) { - EmailItem *item = static_cast( mEmailListBox->item( i ) ); - if ( item->preferred() ) - emails.prepend( item->text() ); - else - emails.append( item->text() ); - } - - return emails; -} - -void EmailEditDialog::add() -{ - EmailValidator *validator = new EmailValidator; - bool ok = false; - - QString email = KInputDialog::getText( i18n( "Add Email" ), i18n( "New Email:" ), - QString(), &ok, this, validator ); - - if ( !ok ) - return; - - // check if item already available, ignore if so... - for ( int i = 0; i < mEmailListBox->count(); ++i ) { - if ( mEmailListBox->item( i )->text() == email ) - return; - } - - new EmailItem( email, mEmailListBox, (mEmailListBox->count() == 0) ); - - mChanged = true; -} - -void EmailEditDialog::edit() -{ - EmailValidator *validator = new EmailValidator; - bool ok = false; - - QListWidgetItem *item = mEmailListBox->currentItem(); - - QString email = KInputDialog::getText( i18n( "Edit Email" ), - i18nc( "@label:textbox Inputfield for an email address", "Email:" ), - item->text(), &ok, this, - validator ); - - if ( !ok ) - return; - - // check if item already available, ignore if so... - for ( int i = 0; i < mEmailListBox->count(); ++i ) { - if ( mEmailListBox->item( i )->text() == email ) - return; - } - - EmailItem *eitem = static_cast( item ); - eitem->setText( email ); - - mChanged = true; -} - -void EmailEditDialog::remove() -{ - QString address = mEmailListBox->currentItem()->text(); - - QString text = i18n( "Are you sure that you want to remove the email address %1?", address ); - QString caption = i18n( "Confirm Remove" ); - - if ( KMessageBox::warningContinueCancel( this, text, caption, KGuiItem( i18n( "&Delete" ), "edit-delete" ) ) == KMessageBox::Continue ) { - EmailItem *item = static_cast( mEmailListBox->currentItem() ); - - bool preferred = item->preferred(); - mEmailListBox->takeItem( mEmailListBox->currentRow() ); - if ( preferred ) { - item = dynamic_cast( mEmailListBox->item( 0 ) ); - if ( item ) - item->setPreferred( true ); - } - - mChanged = true; - } -} - -bool EmailEditDialog::changed() const -{ - return mChanged; -} - -void EmailEditDialog::standard() -{ - for ( int i = 0; i < mEmailListBox->count(); ++i ) { - EmailItem *item = static_cast( mEmailListBox->item( i ) ); - if ( i == mEmailListBox->currentRow() ) - item->setPreferred( true ); - else - item->setPreferred( false ); - } - - mChanged = true; -} - -void EmailEditDialog::selectionChanged() -{ - int index = mEmailListBox->currentRow(); - bool value = ( index >= 0 ); // An item is selected - - mRemoveButton->setEnabled( value ); - mEditButton->setEnabled( value ); - mStandardButton->setEnabled( value ); -} - -#include "emaileditwidget.moc" diff --git a/akonadi/contact/editor/emaileditwidget.h b/akonadi/contact/editor/emaileditwidget.h deleted file mode 100644 index 820464aa1..000000000 --- a/akonadi/contact/editor/emaileditwidget.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef EMAILEDITWIDGET_H -#define EMAILEDITWIDGET_H - -#include - -namespace KABC -{ -class Addressee; -} - -class KLineEdit; -class KListWidget; -class QToolButton; - -/** - * @short A widget for editing email addresses. - * - * The widget will show the preferred email address in a lineedit - * and provides a button to open a dialog for further editing. - */ -class EmailEditWidget : public QWidget -{ - Q_OBJECT - - public: - explicit EmailEditWidget( QWidget *parent = 0 ); - ~EmailEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - private Q_SLOTS: - void edit(); - void textChanged( const QString& ); - - private: - KLineEdit *mEmailEdit; - QToolButton *mEditButton; - QStringList mEmailList; -}; - -class EmailEditDialog : public KDialog -{ - Q_OBJECT - - public: - EmailEditDialog( const QStringList &list, QWidget *parent = 0 ); - ~EmailEditDialog(); - - QStringList emails() const; - bool changed() const; - - protected Q_SLOTS: - void add(); - void edit(); - void remove(); - void standard(); - void selectionChanged(); - - private: - KListWidget *mEmailListBox; - QPushButton *mAddButton; - QPushButton *mRemoveButton; - QPushButton *mEditButton; - QPushButton *mStandardButton; - - bool mChanged; -}; - -#endif diff --git a/akonadi/contact/editor/freebusyeditwidget.cpp b/akonadi/contact/editor/freebusyeditwidget.cpp deleted file mode 100644 index 083562cb9..000000000 --- a/akonadi/contact/editor/freebusyeditwidget.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "freebusyeditwidget.h" - -#include - -#include -#include -#include - -FreeBusyEditWidget::FreeBusyEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - - mURL = new KUrlRequester; - layout->addWidget( mURL ); -} - -FreeBusyEditWidget::~FreeBusyEditWidget() -{ -} - -void FreeBusyEditWidget::loadContact( const KABC::Addressee &contact ) -{ - if ( contact.preferredEmail().isEmpty() ) - return; - - mURL->setUrl( KCal::FreeBusyUrlStore::self()->readUrl( contact.preferredEmail() ) ); -} - -void FreeBusyEditWidget::storeContact( KABC::Addressee &contact ) const -{ - if ( contact.preferredEmail().isEmpty() ) - return; - - KCal::FreeBusyUrlStore::self()->writeUrl( contact.preferredEmail(), mURL->url().url() ); - KCal::FreeBusyUrlStore::self()->sync(); -} - -void FreeBusyEditWidget::setReadOnly( bool readOnly ) -{ - mURL->setEnabled( !readOnly ); -} - -#include "freebusyeditwidget.moc" diff --git a/akonadi/contact/editor/freebusyeditwidget.h b/akonadi/contact/editor/freebusyeditwidget.h deleted file mode 100644 index d43635b77..000000000 --- a/akonadi/contact/editor/freebusyeditwidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef FREEBUSYEDITWIDGET_H -#define FREEBUSYEDITWIDGET_H - -#include - -namespace KABC -{ -class Addressee; -} - -class KUrlRequester; - -class FreeBusyEditWidget : public QWidget -{ - Q_OBJECT - - public: - FreeBusyEditWidget( QWidget *parent = 0 ); - ~FreeBusyEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - private: - KUrlRequester *mURL; - bool mReadOnly; -}; - -#endif diff --git a/akonadi/contact/editor/imagewidget.cpp b/akonadi/contact/editor/imagewidget.cpp deleted file mode 100644 index 2e01bc4b6..000000000 --- a/akonadi/contact/editor/imagewidget.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "imagewidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/** - * @short Small helper class to load image from network - */ -class ImageLoader -{ - public: - ImageLoader( QWidget *parent = 0 ); - - QImage loadImage( const KUrl &url, bool *ok ); - - private: - QImage mImage; - QWidget *mParent; -}; - - -ImageLoader::ImageLoader( QWidget *parent ) - : mParent( parent ) -{ -} - -QImage ImageLoader::loadImage( const KUrl &url, bool *ok ) -{ - QImage image; - QString tempFile; - - if ( url.isEmpty() ) - return image; - - (*ok) = false; - - if ( url.isLocalFile() ) { - if ( image.load( url.path() ) ) { - (*ok) = true; - } - } else if ( KIO::NetAccess::download( url, tempFile, mParent ) ) { - if ( image.load( tempFile ) ) { - (*ok) = true; - } - KIO::NetAccess::removeTempFile( tempFile ); - } - - if ( !(*ok) ) { - // image does not exist (any more) - KMessageBox::sorry( mParent, i18n( "This contact's image cannot be found." ) ); - return image; - } - - QPixmap pixmap = QPixmap::fromImage( image ); - - image = KPixmapRegionSelectorDialog::getSelectedImage( pixmap, 100, 140, mParent ); - if ( image.isNull() ) { - (*ok) = false; - return image; - } - - if ( image.height() != 140 || image.width() != 100 ) { - if ( image.height() > image.width() ) - image = image.scaledToHeight( 140 ); - else - image = image.scaledToWidth( 100 ); - } - - (*ok) = true; - - return image; -} - - - - -ImageWidget::ImageWidget( Type type, QWidget *parent ) - : QPushButton( parent ), - mType( type ), - mHasImage( false ), - mReadOnly( false ), - mImageLoader( 0 ) -{ - setAcceptDrops( true ); - - setIconSize( QSize( 100, 130 ) ); - setFixedSize( QSize( 120, 160 ) ); - - connect( this, SIGNAL( clicked() ), SLOT( changeImage() ) ); - - updateView(); -} - -ImageWidget::~ImageWidget() -{ - delete mImageLoader; -} - -void ImageWidget::loadContact( const KABC::Addressee &contact ) -{ - const KABC::Picture picture = (mType == Photo ? contact.photo() : contact.logo()); - if ( picture.isIntern() && !picture.data().isNull() ) { - mHasImage = true; - mImage = picture.data(); - } - - updateView(); -} - -void ImageWidget::storeContact( KABC::Addressee &contact ) const -{ - if ( mType == Photo ) - contact.setPhoto( mImage ); - else - contact.setLogo( mImage ); -} - -void ImageWidget::setReadOnly( bool readOnly ) -{ - mReadOnly = readOnly; -} - -void ImageWidget::updateView() -{ - if ( mHasImage ) { - setIcon( QPixmap::fromImage( mImage ) ); - } else { - setIcon( KIcon( "user-identity" ) ); - } -} - -void ImageWidget::dragEnterEvent( QDragEnterEvent *event ) -{ - const QMimeData *mimeData = event->mimeData(); - event->setAccepted( mimeData->hasImage() || mimeData->hasUrls() ); -} - -void ImageWidget::dropEvent( QDropEvent *event ) -{ - if ( mReadOnly ) - return; - - const QMimeData *mimeData = event->mimeData(); - if ( mimeData->hasImage() ) { - mImage = qvariant_cast(mimeData->imageData()); - mHasImage = true; - updateView(); - } - - const KUrl::List urls = KUrl::List::fromMimeData( mimeData ); - if ( urls.isEmpty() ) { // oops, no data - event->setAccepted( false ); - } else { - bool ok = false; - const QImage image = imageLoader()->loadImage( urls.first(), &ok ); - if ( ok ) { - mImage = image; - mHasImage = true; - updateView(); - } - } -} - -void ImageWidget::mousePressEvent( QMouseEvent *event ) -{ - mDragStartPos = event->pos(); - QPushButton::mousePressEvent( event ); -} - -void ImageWidget::mouseMoveEvent( QMouseEvent *event ) -{ - if ( (event->buttons() & Qt::LeftButton) && - (event->pos() - mDragStartPos).manhattanLength() > KGlobalSettings::dndEventDelay() ) { - - if ( mHasImage ) { - QDrag *drag = new QDrag( this ); - drag->setMimeData( new QMimeData() ); - drag->mimeData()->setImageData( mImage ); - drag->start(); - } - } -} - -void ImageWidget::contextMenuEvent( QContextMenuEvent *event ) -{ - QMenu menu; - - if ( mType == Photo ) { - if ( !mReadOnly ) - menu.addAction( i18n( "Change photo..." ), this, SLOT( changeImage() ) ); - - if ( mHasImage ) { - menu.addAction( i18n( "Save photo..." ), this, SLOT( saveImage() ) ); - - if ( !mReadOnly ) - menu.addAction( i18n( "Remove photo" ), this, SLOT( deleteImage() ) ); - } - } else { - if ( !mReadOnly ) - menu.addAction( i18n( "Change logo..." ), this, SLOT( changeImage() ) ); - - if ( mHasImage ) { - menu.addAction( i18n( "Save logo..." ), this, SLOT( saveImage() ) ); - - if ( !mReadOnly ) - menu.addAction( i18n( "Remove logo" ), this, SLOT( deleteImage() ) ); - } - } - - menu.exec( event->globalPos() ); -} - -void ImageWidget::changeImage() -{ - const KUrl url = KFileDialog::getOpenUrl( QString(), KImageIO::pattern(), this ); - if ( url.isValid() ) { - bool ok = false; - const QImage image = imageLoader()->loadImage( url, &ok ); - if ( ok ) { - mImage = image; - mHasImage = true; - updateView(); - } - } -} - -void ImageWidget::saveImage() -{ - const QString fileName = KFileDialog::getSaveFileName( KUrl(), KImageIO::pattern(), this ); - if ( !fileName.isEmpty() ) - mImage.save( fileName ); -} - -void ImageWidget::deleteImage() -{ - mHasImage = false; - mImage = QImage(); - updateView(); -} - -ImageLoader* ImageWidget::imageLoader() -{ - if ( !mImageLoader ) - mImageLoader = new ImageLoader; - - return mImageLoader; -} diff --git a/akonadi/contact/editor/imagewidget.h b/akonadi/contact/editor/imagewidget.h deleted file mode 100644 index 92c1419fa..000000000 --- a/akonadi/contact/editor/imagewidget.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef IMAGEWIDGET_H -#define IMAGEWIDGET_H - -#include -#include - -namespace KABC -{ -class Addressee; -} - -class ImageLoader; - -class ImageWidget : public QPushButton -{ - Q_OBJECT - - public: - enum Type { - Photo, - Logo - }; - - ImageWidget( Type type, QWidget *parent = 0 ); - ~ImageWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - protected: - // image drop handling - virtual void dragEnterEvent( QDragEnterEvent* ); - virtual void dropEvent( QDropEvent* ); - - // image drag handling - virtual void mousePressEvent( QMouseEvent* ); - virtual void mouseMoveEvent( QMouseEvent* ); - - // context menu handling - virtual void contextMenuEvent( QContextMenuEvent* ); - - private Q_SLOTS: - void updateView(); - - void changeImage(); - void saveImage(); - void deleteImage(); - - private: - ImageLoader *imageLoader(); - - Type mType; - QImage mImage; - bool mHasImage; - bool mReadOnly; - - QPoint mDragStartPos; - ImageLoader *mImageLoader; -}; - -#endif diff --git a/akonadi/contact/editor/imeditwidget.cpp b/akonadi/contact/editor/imeditwidget.cpp deleted file mode 100644 index b4c97400c..000000000 --- a/akonadi/contact/editor/imeditwidget.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "imeditwidget.h" - -#include - -#include -#include - -IMEditWidget::IMEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - - mIMEdit = new KLineEdit; - layout->addWidget( mIMEdit ); -} - -IMEditWidget::~IMEditWidget() -{ -} - -void IMEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mIMEdit->setText( contact.custom( "KADDRESSBOOK", "X-IMAddress" ) ); -} - -void IMEditWidget::storeContact( KABC::Addressee &contact ) const -{ - if ( !mIMEdit->text().isEmpty() ) - contact.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMEdit->text() ); - else - contact.removeCustom( "KADDRESSBOOK", "X-IMAddress" ); -} - -void IMEditWidget::setReadOnly( bool readOnly ) -{ - mIMEdit->setReadOnly( readOnly ); -} - -#include "imeditwidget.moc" diff --git a/akonadi/contact/editor/imeditwidget.h b/akonadi/contact/editor/imeditwidget.h deleted file mode 100644 index a82e92f65..000000000 --- a/akonadi/contact/editor/imeditwidget.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef IMEDITWIDGET_H -#define IMEDITWIDGET_H - -#include - -namespace KABC -{ -class Addressee; -} - -class KLineEdit; - -/** - * This widget displays an input field for changing - * the instant messaging id of a contact. - */ -class IMEditWidget : public QWidget -{ - Q_OBJECT - - public: - IMEditWidget( QWidget *parent = 0 ); - ~IMEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - private: - KLineEdit *mIMEdit; -}; - -#endif diff --git a/akonadi/contact/editor/nameeditwidget.cpp b/akonadi/contact/editor/nameeditwidget.cpp deleted file mode 100644 index d008e54ee..000000000 --- a/akonadi/contact/editor/nameeditwidget.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "nameeditwidget.h" - -#include -#include - -#include -#include -#include - -NameEditWidget::NameEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 0 ); - layout->setSpacing( KDialog::spacingHint() ); - - mNameEdit = new KLineEdit; - layout->addWidget( mNameEdit ); - - connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); -} - -NameEditWidget::~NameEditWidget() -{ -} - -void NameEditWidget::setReadOnly( bool readOnly ) -{ - mNameEdit->setReadOnly( readOnly ); -} - -void NameEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mNameEdit->setText( contact.assembledName() ); -} - -void NameEditWidget::storeContact( KABC::Addressee &contact ) const -{ - contact.setNameFromString( mNameEdit->text() ); -} - -void NameEditWidget::textChanged( const QString &text ) -{ - KABC::Addressee contact; - contact.setNameFromString( text ); - - emit nameChanged( contact ); -} - -#include "nameeditwidget.moc" diff --git a/akonadi/contact/editor/nameeditwidget.h b/akonadi/contact/editor/nameeditwidget.h deleted file mode 100644 index 1bcce72cc..000000000 --- a/akonadi/contact/editor/nameeditwidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef NAMEEDITWIDGET_H -#define NAMEEDITWIDGET_H - -#include - -#include - -class KLineEdit; - -/** - * @short A widget for editing the name of a contact. - * - * The widget will show the name in a lineedit - * and provides a button to open a dialog for editing of - * the single name components. - */ -class NameEditWidget : public QWidget -{ - Q_OBJECT - - public: - explicit NameEditWidget( QWidget *parent = 0 ); - ~NameEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - Q_SIGNALS: - /** - * This signal is emitted whenever the name has been changed. - * - * @param contact A dummy contact that contains only the name components. - */ - void nameChanged( const KABC::Addressee &contact ); - - private Q_SLOTS: - void textChanged( const QString& ); - - private: - KLineEdit *mNameEdit; - KABC::Addressee mContact; -}; - -#endif diff --git a/akonadi/contact/editor/phoneeditwidget.cpp b/akonadi/contact/editor/phoneeditwidget.cpp deleted file mode 100644 index 3c42c1c58..000000000 --- a/akonadi/contact/editor/phoneeditwidget.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ - -#include "phoneeditwidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -PhoneTypeCombo::PhoneTypeCombo( QWidget *parent ) - : KComboBox( parent ), - mType( KABC::PhoneNumber::Home ), - mLastSelected( 0 ) -{ - for ( int i = 0; i < KABC::PhoneNumber::typeList().count(); ++i ) - mTypeList.append( KABC::PhoneNumber::typeList().at( i ) ); - - mTypeList.append( -1 ); // Others... - - update(); - - connect( this, SIGNAL( activated( int ) ), - this, SLOT( selected( int ) ) ); -} - -PhoneTypeCombo::~PhoneTypeCombo() -{ -} - -void PhoneTypeCombo::setType( KABC::PhoneNumber::Type type ) -{ - if ( !mTypeList.contains( type ) ) - mTypeList.insert( mTypeList.at( mTypeList.count() - 1 ), type ); - - mType = type; - update(); -} - -KABC::PhoneNumber::Type PhoneTypeCombo::type() const -{ - return mType; -} - -void PhoneTypeCombo::update() -{ - clear(); - - for ( int i = 0; i < mTypeList.count(); ++i ) { - if ( mTypeList.at( i ) == -1 ) // "Other..." entry - addItem( i18nc( "@item:inlistbox Category of contact info field", "Other..." ) ); - else - addItem( KABC::PhoneNumber::typeLabel( KABC::PhoneNumber::Type( mTypeList.at( i ) ) ) ); - } - - setCurrentIndex( mLastSelected = mTypeList.indexOf( mType ) ); -} - -void PhoneTypeCombo::selected( int pos ) -{ - if ( mTypeList.at( pos ) == -1 ) - otherSelected(); - else { - mType = KABC::PhoneNumber::Type( mTypeList.at( pos ) ); - mLastSelected = pos; - } -} - -void PhoneTypeCombo::otherSelected() -{ - PhoneTypeDialog dlg( mType, this ); - if ( dlg.exec() ) { - mType = dlg.type(); - if ( !mTypeList.contains( mType ) ) - mTypeList.insert( mTypeList.at( mTypeList.count() - 1 ), mType ); - } else { - setType( KABC::PhoneNumber::Type( mTypeList.at( mLastSelected ) ) ); - } - - update(); -} - -PhoneNumberWidget::PhoneNumberWidget( QWidget *parent ) - : QWidget( parent ) -{ - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setSpacing( 11 ); - layout->setMargin( 0 ); - - mTypeCombo = new PhoneTypeCombo( this ); - mNumberEdit = new KLineEdit( this ); - - layout->addWidget( mTypeCombo ); - layout->addWidget( mNumberEdit ); - - connect( mNumberEdit, SIGNAL( textChanged( const QString& ) ), SIGNAL( modified() ) ); -} - -void PhoneNumberWidget::setNumber( const KABC::PhoneNumber &number ) -{ - mNumber = number; - - mTypeCombo->setType( number.type() ); - mNumberEdit->setText( number.number() ); -} - -KABC::PhoneNumber PhoneNumberWidget::number() const -{ - KABC::PhoneNumber number( mNumber ); - - number.setType( mTypeCombo->type() ); - number.setNumber( mNumberEdit->text() ); - - return number; -} - -void PhoneNumberWidget::setReadOnly( bool readOnly ) -{ - mTypeCombo->setEnabled( !readOnly ); - mNumberEdit->setReadOnly( readOnly ); -} - -PhoneNumberListWidget::PhoneNumberListWidget( QWidget *parent ) - : QWidget( parent ), mReadOnly( false ) -{ - mWidgetLayout = new QVBoxLayout( this ); - - mMapper = new QSignalMapper( this ); - connect( mMapper, SIGNAL( mapped( int ) ), SLOT( changed( int ) ) ); - - setPhoneNumbers( KABC::PhoneNumber::List() ); -} - -PhoneNumberListWidget::~PhoneNumberListWidget() -{ -} - -void PhoneNumberListWidget::setReadOnly( bool readOnly ) -{ - mReadOnly = readOnly; - - foreach ( PhoneNumberWidget *const widget, mWidgets ) - widget->setReadOnly( readOnly ); -} - -int PhoneNumberListWidget::phoneNumberCount() const -{ - return mPhoneNumberList.count(); -} - -void PhoneNumberListWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) -{ - mPhoneNumberList = list; - - KABC::PhoneNumber::TypeList types; - types << KABC::PhoneNumber::Home; - types << KABC::PhoneNumber::Work; - types << KABC::PhoneNumber::Cell; - - // add an empty entry per default - if ( mPhoneNumberList.count() < 3 ) - for ( int i = mPhoneNumberList.count(); i < 3; ++i ) - mPhoneNumberList.append( KABC::PhoneNumber( QString(), types[ i ] ) ); - - recreateNumberWidgets(); -} - -KABC::PhoneNumber::List PhoneNumberListWidget::phoneNumbers() const -{ - KABC::PhoneNumber::List list; - - KABC::PhoneNumber::List::ConstIterator it; - for ( it = mPhoneNumberList.constBegin(); it != mPhoneNumberList.constEnd(); ++it ) - if ( !(*it).number().isEmpty() ) - list.append( *it ); - - return list; -} - -void PhoneNumberListWidget::add() -{ - mPhoneNumberList.append( KABC::PhoneNumber() ); - - recreateNumberWidgets(); -} - -void PhoneNumberListWidget::remove() -{ - mPhoneNumberList.removeLast(); - - recreateNumberWidgets(); -} - -void PhoneNumberListWidget::recreateNumberWidgets() -{ - foreach ( QWidget *const widget, mWidgets ) { - mWidgetLayout->removeWidget( widget ); - delete widget; - } - mWidgets.clear(); - - KABC::PhoneNumber::List::ConstIterator it; - int counter = 0; - for ( it = mPhoneNumberList.constBegin(); it != mPhoneNumberList.constEnd(); ++it ) { - PhoneNumberWidget *wdg = new PhoneNumberWidget( this ); - wdg->setNumber( *it ); - - mMapper->setMapping( wdg, counter ); - connect( wdg, SIGNAL( modified() ), mMapper, SLOT( map() ) ); - - mWidgetLayout->addWidget( wdg ); - mWidgets.append( wdg ); - wdg->show(); - - ++counter; - } - - setReadOnly( mReadOnly ); -} - -void PhoneNumberListWidget::changed( int pos ) -{ - mPhoneNumberList[ pos ] = mWidgets.at( pos )->number(); -} - -PhoneEditWidget::PhoneEditWidget( QWidget *parent ) - : QWidget( parent ), mReadOnly( false ) -{ - QGridLayout *layout = new QGridLayout( this ); - layout->setSpacing( KDialog::spacingHint() ); - - mListScrollArea = new QScrollArea( this ); - mPhoneNumberListWidget = new PhoneNumberListWidget; - mListScrollArea->setWidget( mPhoneNumberListWidget ); - mListScrollArea->setWidgetResizable( true ); - - // ugly but size policies seem to be messed up dialog (parent) wide - const int scrollAreaMinHeight = mPhoneNumberListWidget->sizeHint().height() + - mListScrollArea->horizontalScrollBar()->sizeHint().height(); - mListScrollArea->setMinimumHeight( scrollAreaMinHeight ); - layout->addWidget( mListScrollArea, 0, 0, 1, 2 ); - - mAddButton = new QPushButton( i18n( "Add" ), this ); - mAddButton->setMaximumSize( mAddButton->sizeHint() ); - layout->addWidget( mAddButton, 1, 0, Qt::AlignRight ); - - mRemoveButton = new QPushButton( i18n( "Remove" ), this ); - mRemoveButton->setMaximumSize( mRemoveButton->sizeHint() ); - layout->addWidget( mRemoveButton, 1, 1 ); - - connect( mAddButton, SIGNAL( clicked() ), mPhoneNumberListWidget, SLOT( add() ) ); - connect( mRemoveButton, SIGNAL( clicked() ), mPhoneNumberListWidget, SLOT( remove() ) ); - connect( mAddButton, SIGNAL( clicked() ), SLOT( changed() ) ); - connect( mRemoveButton, SIGNAL( clicked() ), SLOT( changed() ) ); -} - -PhoneEditWidget::~PhoneEditWidget() -{ -} - -void PhoneEditWidget::setReadOnly( bool readOnly ) -{ - mReadOnly = readOnly; - mAddButton->setEnabled( !readOnly ); - mRemoveButton->setEnabled( !readOnly && mPhoneNumberListWidget->phoneNumberCount() > 3 ); - - mPhoneNumberListWidget->setReadOnly( readOnly ); -} - -void PhoneEditWidget::changed() -{ - mRemoveButton->setEnabled( !mReadOnly && mPhoneNumberListWidget->phoneNumberCount() > 3 ); -} - -void PhoneEditWidget::loadContact( const KABC::Addressee &contact ) -{ - mPhoneNumberListWidget->setPhoneNumbers( contact.phoneNumbers() ); - changed(); -} - -void PhoneEditWidget::storeContact( KABC::Addressee &contact ) const -{ - const KABC::PhoneNumber::List oldNumbers = contact.phoneNumbers(); - for ( int i = 0; i < oldNumbers.count(); ++i ) - contact.removePhoneNumber( oldNumbers.at( i ) ); - - const KABC::PhoneNumber::List newNumbers = mPhoneNumberListWidget->phoneNumbers(); - for ( int i = 0; i < newNumbers.count(); ++i ) - contact.insertPhoneNumber( newNumbers.at( i ) ); -} - -/////////////////////////////////////////// -// PhoneTypeDialog -PhoneTypeDialog::PhoneTypeDialog( KABC::PhoneNumber::Type type, QWidget *parent ) - : KDialog( parent), - mType( type ) -{ - setCaption( i18n( "Edit Phone Number" ) ); - setButtons( Ok | Cancel ); - setDefaultButton( Ok ); - showButtonSeparator( true ); - - QWidget *page = new QWidget( this ); - setMainWidget( page ); - - QVBoxLayout *layout = new QVBoxLayout( page ); - layout->setSpacing( spacingHint() ); - layout->setMargin( 0 ); - - mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); - layout->addWidget( mPreferredBox ); - - QGroupBox *box = new QGroupBox( i18n( "Types" ), page ); - layout->addWidget( box ); - - QGridLayout *buttonLayout = new QGridLayout( box ); - - // fill widgets - mTypeList = KABC::PhoneNumber::typeList(); - mTypeList.removeAll( KABC::PhoneNumber::Pref ); - - KABC::PhoneNumber::TypeList::ConstIterator it; - mGroup = new QButtonGroup( box ); - mGroup->setExclusive( false ); - int row, column, counter; - row = column = counter = 0; - for ( it = mTypeList.constBegin(); it != mTypeList.constEnd(); ++it, ++counter ) { - QCheckBox *cb = new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), box ); - cb->setChecked( type & mTypeList[ counter ] ); - buttonLayout->addWidget( cb, row, column ); - mGroup->addButton( cb ); - - column++; - if ( column == 5 ) { - column = 0; - ++row; - } - } - - mPreferredBox->setChecked( mType & KABC::PhoneNumber::Pref ); -} - -KABC::PhoneNumber::Type PhoneTypeDialog::type() const -{ - KABC::PhoneNumber::Type type = 0; - - for ( int i = 0; i < mGroup->buttons().count(); ++i ) { - QCheckBox *box = dynamic_cast( mGroup->buttons().at( i ) ) ; - if ( box && box->isChecked() ) - type |= mTypeList[ i ]; - } - - if ( mPreferredBox->isChecked() ) - type = type | KABC::PhoneNumber::Pref; - else - type = type & ~KABC::PhoneNumber::Pref; - - return type; -} - -#include "phoneeditwidget.moc" diff --git a/akonadi/contact/editor/phoneeditwidget.h b/akonadi/contact/editor/phoneeditwidget.h deleted file mode 100644 index ce8f18479..000000000 --- a/akonadi/contact/editor/phoneeditwidget.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ - - -#ifndef PHONEEDITWIDGET_H -#define PHONEEDITWIDGET_H - -#include - -#include -#include -#include - -class KLineEdit; - -class QButtonGroup; -class QCheckBox; -class QScrollArea; -class QSignalMapper; -class QVBoxLayout; - -/** - * @short A combobox to select a phone number type. - */ -class PhoneTypeCombo : public KComboBox -{ - Q_OBJECT - - public: - /** - * Creates a phone type combo. - * - * @param parent The parent widget. - */ - PhoneTypeCombo( QWidget *parent = 0 ); - - /** - * Destroys the phone type combo. - */ - ~PhoneTypeCombo(); - - /** - * Sets the phone number @p type that shall be selected. - */ - void setType( KABC::PhoneNumber::Type type ); - - /** - * Returns the selected phone number type. - */ - KABC::PhoneNumber::Type type() const; - - private Q_SLOTS: - void selected( int ); - void otherSelected(); - - private: - void update(); - - KABC::PhoneNumber::Type mType; - int mLastSelected; - QList mTypeList; -}; - -/** - * A widget that provides selectors for the type - * and number of a phone number entry. - */ -class PhoneNumberWidget : public QWidget -{ - Q_OBJECT - - public: - /** - * Creates a new phone number widget. - * - * @param parent The parent widget. - */ - PhoneNumberWidget( QWidget *parent = 0 ); - - /** - * Sets the phone @p number of the widget. - */ - void setNumber( const KABC::PhoneNumber &number ); - - /** - * Returns the phone number of the widget. - */ - KABC::PhoneNumber number() const; - - /** - * Sets the widget to @p readOnly mode. - */ - void setReadOnly( bool readOnly ); - - Q_SIGNALS: - void modified(); - - private: - PhoneTypeCombo *mTypeCombo; - KLineEdit *mNumberEdit; - KABC::PhoneNumber mNumber; -}; - -/** - * A widgets that groups together a list of PhoneNumberWidgets - */ -class PhoneNumberListWidget : public QWidget -{ - Q_OBJECT - - public: - /** - * Creates a new phone number list widget. - * - * @param parent The parent widget. - */ - PhoneNumberListWidget( QWidget *parent = 0 ); - - /** - * Destroys the phone number list widget. - */ - ~PhoneNumberListWidget(); - - /** - * Sets the @p list of phone numbers the widget shall show. - */ - void setPhoneNumbers( const KABC::PhoneNumber::List &list ); - - /** - * Returns the list of phone numbers. - */ - KABC::PhoneNumber::List phoneNumbers() const; - - /** - * Sets the widget to @p readOnly mode. - */ - void setReadOnly( bool readOnly ); - - /** - * Returns the number of phone numbers available. - */ - int phoneNumberCount() const; - - public Q_SLOTS: - /** - * Adds a new phone number widget to this widget. - */ - void add(); - - /** - * Removes the last phone number widget from this widget. - */ - void remove(); - - private Q_SLOTS: - void changed( int ); - - private: - void recreateNumberWidgets(); - - KABC::PhoneNumber::List mPhoneNumberList; - QList mWidgets; - - QVBoxLayout *mWidgetLayout; - - bool mReadOnly; - QSignalMapper *mMapper; -}; - -/** - * @short A widget for editing phone numbers of a contact. - */ -class PhoneEditWidget : public QWidget -{ - Q_OBJECT - - public: - /** - * Creates a new phone edit widget. - * - * @param parent The parent widget. - */ - explicit PhoneEditWidget( QWidget *parent = 0 ); - - /** - * Destroys the phone edit widget. - */ - ~PhoneEditWidget(); - - /** - * Loads the data from @p contact to the widget. - */ - void loadContact( const KABC::Addressee &contact ); - - /** - * Stores the data from the widget to the @p contact. - */ - void storeContact( KABC::Addressee &contact ) const; - - /** - * Sets the widget to @p readOnly mode. - */ - void setReadOnly( bool readOnly ); - - private Q_SLOTS: - void changed(); - - private: - QPushButton *mAddButton; - QPushButton *mRemoveButton; - - bool mReadOnly; - - QScrollArea *mListScrollArea; - PhoneNumberListWidget *mPhoneNumberListWidget; -}; - -/** - * A dialog for editing phone number types. - */ -class PhoneTypeDialog : public KDialog -{ - public: - /** - * Creates a new phone type dialog. - * - * @param type The initial type of the phone number. - * @param parent The parent widget. - */ - PhoneTypeDialog( KABC::PhoneNumber::Type type, QWidget *parent = 0 ); - - /** - * Returns the selected type. - */ - KABC::PhoneNumber::Type type() const; - - private: - KABC::PhoneNumber::Type mType; - KABC::PhoneNumber::TypeList mTypeList; - - QButtonGroup *mGroup; - QCheckBox *mPreferredBox; -}; - -#endif diff --git a/akonadi/contact/editor/secrecyeditwidget.cpp b/akonadi/contact/editor/secrecyeditwidget.cpp deleted file mode 100644 index f90a1554f..000000000 --- a/akonadi/contact/editor/secrecyeditwidget.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "secrecyeditwidget.h" - -#include - -#include -#include -#include - -SecrecyEditWidget::SecrecyEditWidget( QWidget *parent ) - : QWidget( parent ) -{ - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setMargin( 0 ); - - mSecrecyCombo = new KComboBox( this ); - layout->addWidget( mSecrecyCombo ); - - const KABC::Secrecy::TypeList list = KABC::Secrecy::typeList(); - KABC::Secrecy::TypeList::ConstIterator it; - - // (*it) is the type enum, which is also used as the index in the combo - for ( it = list.begin(); it != list.end(); ++it ) - mSecrecyCombo->insertItem( *it, KABC::Secrecy::typeLabel( *it ) ); -} - -SecrecyEditWidget::~SecrecyEditWidget() -{ -} - -void SecrecyEditWidget::setReadOnly( bool readOnly ) -{ - mSecrecyCombo->setEnabled( !readOnly ); -} - -void SecrecyEditWidget::loadContact( const KABC::Addressee &contact ) -{ - if ( contact.secrecy().type() != KABC::Secrecy::Invalid ) - mSecrecyCombo->setCurrentIndex( contact.secrecy().type() ); -} - -void SecrecyEditWidget::storeContact( KABC::Addressee &contact ) const -{ - KABC::Secrecy secrecy; - secrecy.setType( (KABC::Secrecy::Type)mSecrecyCombo->currentIndex() ); - - contact.setSecrecy( secrecy ); -} - -#include "secrecyeditwidget.moc" diff --git a/akonadi/contact/editor/secrecyeditwidget.h b/akonadi/contact/editor/secrecyeditwidget.h deleted file mode 100644 index 78d1eef9f..000000000 --- a/akonadi/contact/editor/secrecyeditwidget.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef SECRECYEDITWIDGET_H -#define SECRECYEDITWIDGET_H - -#include - -namespace KABC -{ -class Addressee; -} - -class KComboBox; - -class SecrecyEditWidget : public QWidget -{ - Q_OBJECT - - public: - explicit SecrecyEditWidget( QWidget *parent = 0 ); - ~SecrecyEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - private: - KComboBox *mSecrecyCombo; -}; - -#endif diff --git a/akonadi/contact/editor/soundeditwidget.cpp b/akonadi/contact/editor/soundeditwidget.cpp deleted file mode 100644 index cbc90c44f..000000000 --- a/akonadi/contact/editor/soundeditwidget.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "soundeditwidget.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/** - * @short Small helper class to load sound from network - */ -class SoundLoader -{ - public: - SoundLoader( QWidget *parent = 0 ); - - QByteArray loadSound( const KUrl &url, bool *ok ); - - private: - QByteArray mSound; - QWidget *mParent; -}; - - -SoundLoader::SoundLoader( QWidget *parent ) - : mParent( parent ) -{ -} - -QByteArray SoundLoader::loadSound( const KUrl &url, bool *ok ) -{ - QByteArray sound; - QString tempFile; - - if ( url.isEmpty() ) - return sound; - - (*ok) = false; - - if ( url.isLocalFile() ) { - QFile file( url.path() ); - if ( file.open( QIODevice::ReadOnly ) ) { - sound = file.readAll(); - file.close(); - (*ok) = true; - } - } else if ( KIO::NetAccess::download( url, tempFile, mParent ) ) { - QFile file( tempFile ); - if ( file.open( QIODevice::ReadOnly ) ) { - sound = file.readAll(); - file.close(); - (*ok) = true; - } - KIO::NetAccess::removeTempFile( tempFile ); - } - - if ( !(*ok) ) { - KMessageBox::sorry( mParent, i18n( "This contact's sound cannot be found." ) ); - return sound; - } - - (*ok) = true; - - return sound; -} - - - - -SoundEditWidget::SoundEditWidget( QWidget *parent ) - : QToolButton( parent ), - mHasSound( false ), - mReadOnly( false ), - mSoundLoader( 0 ) -{ - connect( this, SIGNAL( clicked() ), SLOT( playSound() ) ); - - updateView(); -} - -SoundEditWidget::~SoundEditWidget() -{ - delete mSoundLoader; -} - -void SoundEditWidget::loadContact( const KABC::Addressee &contact ) -{ - const KABC::Sound sound = contact.sound(); - if ( sound.isIntern() && !sound.data().isEmpty() ) { - mHasSound = true; - mSound = sound.data(); - } - - updateView(); -} - -void SoundEditWidget::storeContact( KABC::Addressee &contact ) const -{ - KABC::Sound sound( contact.sound() ); - sound.setData( mSound ); - contact.setSound( sound ); -} - -void SoundEditWidget::setReadOnly( bool readOnly ) -{ - mReadOnly = readOnly; -} - -void SoundEditWidget::updateView() -{ - if ( mHasSound ) { - setIcon( KIcon( "audio-volume-medium" ) ); - setToolTip( i18n( "Click to play pronunciation" ) ); - } else { - setIcon( KIcon( "audio-volume-muted" ) ); - setToolTip( i18n( "No pronunciation available" ) ); - } -} - -void SoundEditWidget::contextMenuEvent( QContextMenuEvent *event ) -{ - QMenu menu; - - if ( mHasSound ) - menu.addAction( i18n( "Play" ), this, SLOT( playSound() ) ); - - if ( !mReadOnly ) - menu.addAction( i18n( "Change..." ), this, SLOT( changeSound() ) ); - - if ( mHasSound ) { - menu.addAction( i18n( "Save..." ), this, SLOT( saveSound() ) ); - - if ( !mReadOnly ) - menu.addAction( i18n( "Remove" ), this, SLOT( deleteSound() ) ); - } - - menu.exec( event->globalPos() ); -} - -void SoundEditWidget::playSound() -{ - if ( !mHasSound ) - return; - - Phonon::MediaObject* player = Phonon::createPlayer( Phonon::NotificationCategory ); - QBuffer* soundData = new QBuffer( player ); - soundData->setData( mSound ); - player->setCurrentSource( soundData ); - player->setParent( this ); - connect( player, SIGNAL( finished() ), player, SLOT( deleteLater() ) ); - player->play(); -} - -void SoundEditWidget::changeSound() -{ - const KUrl url = KFileDialog::getOpenUrl( QString(), "*.wav", this ); - if ( url.isValid() ) { - bool ok = false; - const QByteArray sound = soundLoader()->loadSound( url, &ok ); - if ( ok ) { - mSound = sound; - mHasSound = true; - updateView(); - } - } -} - -void SoundEditWidget::saveSound() -{ - const QString fileName = KFileDialog::getSaveFileName( KUrl(), "*.wav", this ); - if ( !fileName.isEmpty() ) { - QFile file( fileName ); - if ( file.open( QIODevice::WriteOnly ) ) { - file.write( mSound ); - file.close(); - } - } -} - -void SoundEditWidget::deleteSound() -{ - mHasSound = false; - mSound = QByteArray(); - updateView(); -} - -SoundLoader* SoundEditWidget::soundLoader() -{ - if ( !mSoundLoader ) - mSoundLoader = new SoundLoader; - - return mSoundLoader; -} diff --git a/akonadi/contact/editor/soundeditwidget.h b/akonadi/contact/editor/soundeditwidget.h deleted file mode 100644 index f5e082db5..000000000 --- a/akonadi/contact/editor/soundeditwidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of KContactManager. - - Copyright (c) 2009 Tobias Koenig - - 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. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef SOUNDEDITWIDGET_H -#define SOUNDEDITWIDGET_H - -#include -#include - -namespace KABC -{ -class Addressee; -} - -class SoundLoader; - -class SoundEditWidget : public QToolButton -{ - Q_OBJECT - - public: - SoundEditWidget( QWidget *parent = 0 ); - ~SoundEditWidget(); - - void loadContact( const KABC::Addressee &contact ); - void storeContact( KABC::Addressee &contact ) const; - - void setReadOnly( bool readOnly ); - - protected: - // context menu handling - virtual void contextMenuEvent( QContextMenuEvent* ); - - private Q_SLOTS: - void playSound(); - void updateView(); - - void changeSound(); - void saveSound(); - void deleteSound(); - - private: - SoundLoader *soundLoader(); - - QByteArray mSound; - bool mHasSound; - bool mReadOnly; - - SoundLoader *mSoundLoader; -}; - -#endif diff --git a/kmbox/CMakeLists.txt b/kmbox/CMakeLists.txt deleted file mode 100644 index 799935f26..000000000 --- a/kmbox/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(mbox_LIB_SRCS mbox.cpp) - -add_subdirectory(tests) - -kde4_add_library(mbox SHARED ${mbox_LIB_SRCS}) - -target_link_libraries(mbox ${KDE4_KDECORE_LIBS} ${KDEPIMLIBS_KPIMUTILS_LIBS} ) - -set_target_properties(mbox PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) -install(TARGETS mbox ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/kmbox/mbox.cpp b/kmbox/mbox.cpp deleted file mode 100644 index c52f4da0d..000000000 --- a/kmbox/mbox.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - Copyright (c) 1996-1998 Stefan Taferner - Copyright (c) 2009 Bertjan Broeksema - - 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. - - NOTE: Most of the code inside here is an slightly adjusted version of - kdepim/kmail/kmfoldermbox.cpp. This is why I added a copyright line - for Stefan Taferner. - - Bertjan Broeksema, april 2009 -*/ - -#include "mbox.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -class MBox::Private -{ - public: - Private(const QString &mboxFileName, bool readOnly) - : mLock(mboxFileName) - , mMboxFile(mboxFileName) - , mReadOnly(readOnly) - { } - - ~Private() - { - if (mMboxFile.isOpen()) - mMboxFile.close(); - } - - bool mFileLocked; - KLockFile mLock; - LockType mLockType; - QFile mMboxFile; - QString mProcmailLockFileName; - bool mReadOnly; -}; - -/// private static methods. - -QByteArray quoteAndEncode(const QString &str) -{ - return QFile::encodeName(KShell::quoteArg(str)); -} - -/// public methods. - -MBox::MBox(const QString &mboxFile, bool readOnly) - : d(new Private(mboxFile, readOnly)) -{ - // Set some sane defaults - d->mFileLocked = false; - d->mLockType = KDELockFile; -} - -MBox::~MBox() -{ - close(); - - delete d; -} - -void MBox::close() -{ - if (d->mFileLocked) - unlock(); - - if (d->mMboxFile.isOpen()) - d->mMboxFile.close(); - - d->mFileLocked = false; -} - -QList MBox::entryList(const QSet &deletedItems) const -{ - Q_ASSERT(d->mMboxFile.isOpen()); - - QRegExp regexp("^From .*[0-9][0-9]:[0-9][0-9]"); - QByteArray line; - quint64 offs = 0; // The offset of the next message to read. - - QList result; - - while (!d->mMboxFile.atEnd()) { - quint64 pos = d->mMboxFile.pos(); - - line = d->mMboxFile.readLine(); - - if (regexp.indexIn(line) >= 0 || d->mMboxFile.atEnd()) { - // Found the separator or at end of file, the message starts at offs - quint64 msgSize = pos - offs; - if(pos > 0 && !deletedItems.contains(offs)) { - // This is not the separator of the first mail in the file. If pos == 0 - // than we matched the separator of the first mail in the file. - MsgInfo info; - info.first = offs; - info.second = msgSize; - - result << info; - offs += msgSize; // Mark the beginning of the next message. - } - } - } - - return result; -} - -bool MBox::isValid() const -{ - QString msg; - return isValid(msg); -} - -bool MBox::isValid(QString &errorMsg) const -{ - QFileInfo info(d->mMboxFile); - - if (!info.isFile()) { - errorMsg = i18n("%1 is not a file.").arg(info.absoluteFilePath()); - return false; - } - - if (!info.exists()) { - errorMsg = i18n("%1 does not exist").arg(info.absoluteFilePath()); - return false; - } - - switch (d->mLockType) { - case ProcmailLockfile: - if (KStandardDirs::findExe("lockfile").isEmpty()) { - errorMsg = i18n("Could not find the lockfile executable"); - return false; - } - break; - case MuttDotlock: // fall through - case MuttDotlockPrivileged: - if (KStandardDirs::findExe("mutt_dotlock").isEmpty()) { - errorMsg = i18n("Could not find the mutt_dotlock executable"); - return false; - } - break; - default: - break; // We assume fcntl available and lock_none doesn't need a check. - } - - // TODO: Add some heuristics to see if the file actually is a mbox file. - - return true; -} - -int MBox::open(OpenMode openMode) -{ - if (d->mMboxFile.isOpen() && openMode == Normal) { - return 0; // already open - } else if (d->mMboxFile.isOpen()) { - close(); // ReloadMode, so close the file first. - } - - d->mFileLocked = false; - - if (int rc = lock()) { - kDebug() << "Locking of the mbox file failed."; - return rc; - } - - if (!d->mMboxFile.open(QIODevice::ReadOnly)) { // messages file - kDebug() << "Cannot open mbox file `" << d->mMboxFile.fileName() << "' FileError:" - << d->mMboxFile.error(); - return d->mMboxFile.error(); - } - - return 0; -} - -QByteArray MBox::readEntry(quint64 offset) const -{ - Q_ASSERT(d->mMboxFile.isOpen()); - Q_ASSERT(d->mMboxFile.size() > offset); - - d->mMboxFile.seek(offset); - - QByteArray line = d->mMboxFile.readLine(); - QRegExp regexp("^From .*[0-9][0-9]:[0-9][0-9]"); - if (regexp.indexIn(line) < 0) - return QByteArray(); // The file is messed up or the index is incorrect. - - QByteArray message; - message += line; - line = d->mMboxFile.readLine(); - - while (regexp.indexIn(line) < 0) { - message += line; - line = d->mMboxFile.readLine(); - } - - unescapeFrom(message.data(), message.size()); - - return message; -} - -QByteArray MBox::readEntryHeaders(quint64 offset) -{ - Q_ASSERT(d->mMboxFile.isOpen()); - Q_ASSERT(d->mMboxFile.size() > offset); - - d->mMboxFile.seek(offset); - QByteArray headers; - QByteArray line = d->mMboxFile.readLine(); - - while (!line[0] == '\n') { - headers += line; - line = d->mMboxFile.readLine(); - } - - return headers; -} - -void MBox::setLockType(LockType ltype) -{ - if (d->mFileLocked) - return; // Don't change the method if the file is currently locked. - - d->mLockType = ltype; -} - -void MBox::setProcmailLockFile(const QString &lockFile) -{ - d->mProcmailLockFileName = lockFile; -} - -/// private methods - -int MBox::lock() -{ - if (d->mLockType == None) - return 0; - - d->mFileLocked = false; - - QStringList args; - int rc = 0; - - switch(d->mLockType) - { - case KDELockFile: - /* FIXME: Don't use the mbox file itself as lock file. - if ((rc = d->mLock.lock(KLockFile::ForceFlag))) { - kDebug() << "KLockFile lock failed: (" << rc - << ") switching to read only mode"; - d->mReadOnly = true; - } - */ - return 0; - break; // We only need to lock the file using the QReadWriteLock - - case ProcmailLockfile: - args << "-l20" << "-r5"; - if (!d->mProcmailLockFileName.isEmpty()) - args << quoteAndEncode(d->mProcmailLockFileName); - else - args << quoteAndEncode(d->mMboxFile.fileName() + ".lock"); - - rc = QProcess::execute("lockfile", args); - if(rc != 0) { - kDebug() << "lockfile -l20 -r5 " << d->mMboxFile.fileName() - << ": Failed ("<< rc << ") switching to read only mode"; - d->mReadOnly = true; // In case the MBox object was created read/write we - // set it to read only when locking failed. - return rc; - } - break; - - case MuttDotlock: - args << quoteAndEncode(d->mMboxFile.fileName()); - rc = QProcess::execute("mutt_dotlock", args); - - if(rc != 0) { - kDebug() << "mutt_dotlock " << d->mMboxFile.fileName() - << ": Failed (" << rc << ") switching to read only mode"; - d->mReadOnly = true; // In case the MBox object was created read/write we - // set it to read only when locking failed. - return rc; - } - break; - - case MuttDotlockPrivileged: - args << "-p" << quoteAndEncode(d->mMboxFile.fileName()); - rc = QProcess::execute("mutt_dotlock", args); - - if(rc != 0) { - kDebug() << "mutt_dotlock -p " << d->mMboxFile.fileName() << ":" - << ": Failed (" << rc << ") switching to read only mode"; - d->mReadOnly = true; - return rc; - } - break; - - case None: // This is never reached because of the check at the - return 0; // beginning of the function. - default: - break; - } - - d->mFileLocked = true; - return 0; -} - -int MBox::unlock() -{ - int rc = 0; - QStringList args; - - switch(d->mLockType) - { - case KDELockFile: - // FIXME - //d->mLock.unlock(); - break; - - case ProcmailLockfile: - // QFile::remove returns true on succes so negate the result. - if (!d->mProcmailLockFileName.isEmpty()) - rc = !QFile(d->mProcmailLockFileName).remove(); - else - rc = !QFile(d->mMboxFile.fileName() + ".lock").remove(); - break; - - case MuttDotlock: - args << "-u" << quoteAndEncode(d->mMboxFile.fileName()); - rc = QProcess::execute("mutt_dotlock", args); - break; - - case MuttDotlockPrivileged: - args << "-u" << "-p" << quoteAndEncode(d->mMboxFile.fileName()); - rc = QProcess::execute("mutt_dotlock", args); - break; - - case None: // Fall through. - default: - break; - } - - if (!rc) // Unlocking succeeded - d->mFileLocked = false; - - return rc; -} - -#define STRDIM(x) (sizeof(x)/sizeof(*x)-1) -// performs (\n|^)>{n}From_ -> \1>{n-1}From_ conversion -void MBox::unescapeFrom(char* str, size_t strLen) -{ - if (!str) - return; - if ( strLen <= STRDIM(">From ") ) - return; - - // yes, *d++ = *s++ is a no-op as long as d == s (until after the - // first >From_), but writes are cheap compared to reads and the - // data is already in the cache from the read, so special-casing - // might even be slower... - const char * s = str; - char * d = str; - const char * const e = str + strLen - STRDIM(">From "); - - while ( s < e ) { - if ( *s == '\n' && *(s+1) == '>' ) { // we can do the lookahead, since e is 6 chars from the end! - *d++ = *s++; // == '\n' - *d++ = *s++; // == '>' - while ( s < e && *s == '>' ) - *d++ = *s++; - if ( qstrncmp( s, "From ", STRDIM("From ") ) == 0 ) - --d; - } - *d++ = *s++; // yes, s might be e here, but e is not the end :-) - } - // copy the rest: - while ( s < str + strLen ) - *d++ = *s++; - if ( d < s ) // only NUL-terminate if it's shorter - *d = 0; -} -#undef STRDIM diff --git a/kmbox/mbox.h b/kmbox/mbox.h deleted file mode 100644 index aca05441d..000000000 --- a/kmbox/mbox.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - Copyright (c) 2009 Bertjan Broeksema - - 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 MBOX_H -#define MBOX_H - -#include -#include - -#include "mbox_export.h" - -typedef QPair MsgInfo; // QPair - -class MBOX_EXPORT MBox -{ - public: - enum OpenMode { - Normal, - Reload - }; - - enum LockType { - KDELockFile, // Uses KLockFile - ProcmailLockfile, - MuttDotlock, - MuttDotlockPrivileged, - None - }; - - public: - explicit MBox(const QString &mboxFile = QString(), bool readOnly = false); - - /** - * Closes the file if it is still open. - */ - ~MBox(); - - /** - * Closes the file and releases the lock. - */ - void close(); - - /** - * Retrieve MsgInfo objects for all emails from the file except the - * @param deleteItems. The @param deletedItems should be a list of file - * offsets of messages which are deleted. - * - * Each MsgInfo object contains the offset and the size of the messages in - * the file which are not marked as deleted. - * - * Note: One must call open() before calling this method. - */ - QList entryList(const QSet &deletedItems = QSet()) const; - - /** - * Checks if the file exists and if it can be opened for read/write. Also - * checks if the selected lock method is available when it is set to - * procmail_lockfile or one of the mutt_dotlock variants. - */ - bool isValid() const; - - /** - * @see isValid() - * @param errorMsg can be used to find out what kind of error occurred and - * passed onto the user. - */ - bool isValid(QString &errorMsg) const; - - /** - * Open folder for access. Does nothing if the folder is already opened - * and openMode equals Normal (default behavior). When Reload is given as - * open mode the file will be closed first if it is open. - * - * Returns zero on success and an error code equal to the c-library fopen - * call otherwise (errno). - */ - int open(OpenMode openMode = Normal); - - - /** - * Reads the entire message from the file at given @param offset. - */ - QByteArray readEntry(quint64 offset) const; - - /** - * Reads the headers of the message at given @param offset. - */ - QByteArray readEntryHeaders(quint64 offset); - - /** - * Sets the locktype that should be used for locking the mbox file. The - * isValid method will check if the lock method is available when the - * procmail_lockfile or one of the mutt_dotlock variants is set. - * - * This method will not do anything if the mbox obeject is currently locked - * to make sure that it doesn't leave a locked file for one of the lockfile - * / mutt_dotlock methods. - */ - void setLockType(LockType ltype); - - /** - * Sets the lockfile that should be used by the procmail lock file method. - * If this method is not called and procfile is used the name of the lock - * file will be equal to MBOXFILENAME.lock. - */ - void setProcmailLockFile(const QString &lockFile); - - private: - /** - * Locks the mbox file. Called by open(). Returns 0 on success and an errno - * error code on failure. - * - * NOTE: This method will set the MBox object to ReadOnly mode when locking - * failed to prevent data corruption, even when the MBox was originally - * opened ReadWrite. - */ - int lock(); - - /** - * Unlock the mbox file. Called by close() or ~MBox(). Returns 0 on success - * and an errno error code on failure. - */ - int unlock(); - - /** - * Unescapes the raw message read from the file. - */ - static void unescapeFrom(char *msg, size_t size); - - private: - class Private; - Private *d; -}; - -#endif // MBOX_H diff --git a/kmbox/mbox_export.h b/kmbox/mbox_export.h deleted file mode 100644 index 13ec34753..000000000 --- a/kmbox/mbox_export.h +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 David Faure - - 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 MBOX_EXPORT_H -#define MBOX_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef MBOX_EXPORT -# if defined(MAKE_MAILDIR_LIB) - /* We are building this library */ -# define MBOX_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define MBOX_EXPORT KDE_IMPORT -# endif -#endif - -# ifndef MBOX_EXPORT_DEPRECATED -# define MBOX_EXPORT_DEPRECATED KDE_DEPRECATED MBOX_EXPORT -# endif - -#endif diff --git a/kmbox/tests/CMakeLists.txt b/kmbox/tests/CMakeLists.txt deleted file mode 100644 index 59be32490..000000000 --- a/kmbox/tests/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) - -########### next target ############### - -set(testmbox_SRCS mboxtest.cpp ) - -kde4_add_unit_test(testmbox TESTNAME mbox-testmbox ${testmbox_SRCS}) - -target_link_libraries(testmbox ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} mbox ) - diff --git a/kmbox/tests/mboxtest.cpp b/kmbox/tests/mboxtest.cpp deleted file mode 100644 index 27b3d8732..000000000 --- a/kmbox/tests/mboxtest.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2009 Bertjan Broeksema - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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. -*/ - - -#include "mboxtest.h" -#include "mboxtest.moc" - -#include -#include - -#include -#include -#include - -QTEST_KDEMAIN_CORE(MboxTest) - -#include "../mbox.h" - -static const char * testDir = "libmbox-unit-test"; -static const char * testFile = "test-mbox-file"; - -QString MboxTest::fileName() -{ - return mTempDir->name() + testFile; -} - -void MboxTest::initTestCase() -{ - mTempDir = new KTempDir( KStandardDirs::locateLocal("tmp", testDir ) ); - - QDir temp(mTempDir->name()); - QVERIFY(temp.exists()); - - QFile mboxfile(fileName()); - mboxfile.open(QFile::ReadWrite); - - // Put some testdata in the file. - QTextStream out(&mboxfile); - out << "From: me@me.me" << endl; - - mboxfile.close(); - QVERIFY(mboxfile.exists()); -} - -void MboxTest::testClose() -{ - MBox mbox1(fileName(), true); // ReadOnly - mbox1.open(); - mbox1.close(); - - QFile mboxfile(fileName()); - QVERIFY(mboxfile.exists()); // It should not get deleted on close. - - MBox mbox2(fileName(), false); - mbox2.open(); - mbox2.close(); - - QVERIFY(mboxfile.exists()); // It should not get deleted on close. -} - -void MboxTest::testIsValid() -{ - MBox mbox1(fileName(), true); // ReadOnly - QVERIFY(mbox1.isValid()); // FCNTL is the default lock method. - - if (!KStandardDirs::findExe("lockfile").isEmpty()) { - mbox1.setLockType(MBox::ProcmailLockfile); - QVERIFY(mbox1.isValid()); - } else { - mbox1.setLockType(MBox::ProcmailLockfile); - QVERIFY(!mbox1.isValid()); - } - - if (!KStandardDirs::findExe("mutt_dotlock").isEmpty()) { - mbox1.setLockType(MBox::MuttDotlock); - QVERIFY(mbox1.isValid()); - mbox1.setLockType(MBox::MuttDotlockPrivileged); - QVERIFY(mbox1.isValid()); - } else { - mbox1.setLockType(MBox::MuttDotlock); - QVERIFY(!mbox1.isValid()); - mbox1.setLockType(MBox::MuttDotlockPrivileged); - QVERIFY(!mbox1.isValid()); - } - - mbox1.setLockType(MBox::None); - QVERIFY(mbox1.isValid()); - - MBox mbox2(fileName(), false); - QVERIFY(mbox2.isValid()); - - MBox mbox3("2_Non-ExistingFile", true); - QVERIFY(!mbox3.isValid()); - - MBox mbox4("2_Non-ExistingFile", false); - QVERIFY(!mbox4.isValid()); -} - -void MboxTest::testProcMailLock() -{ - // It really only makes sense to test this if the lockfile executable can be - // found. - MBox mbox(fileName(), true); - mbox.setLockType(MBox::ProcmailLockfile); - if (!KStandardDirs::findExe("lockfile").isEmpty()) { - QVERIFY(!QFile(fileName() + ".lock").exists()); - QCOMPARE(mbox.open(), 0); - QVERIFY(QFile(fileName() + ".lock").exists()); - mbox.close(); - QVERIFY(!QFile(fileName() + ".lock").exists()); - } else { - QVERIFY(!QFile(fileName() + ".lock").exists()); - QVERIFY(mbox.open() != 0); - QEXPECT_FAIL("", "This only works when procmail is installed.", Continue); - QVERIFY(QFile(fileName() + ".lock").exists()); - mbox.close(); - QVERIFY(!QFile(fileName() + ".lock").exists()); - } -} - -void MboxTest::cleanupTestCase() -{ - mTempDir->unlink(); -} diff --git a/kmbox/tests/mboxtest.h b/kmbox/tests/mboxtest.h deleted file mode 100644 index f51ec1e20..000000000 --- a/kmbox/tests/mboxtest.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (c) 2009 Bertjan Broeksema - - 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 MBOXTEST_H -#define MBOXTEST_H - -#include - -class KTempDir; - -class MboxTest : public QObject -{ - Q_OBJECT - private Q_SLOTS: - void initTestCase(); - void testClose(); - void testIsValid(); - void testProcMailLock(); - void cleanupTestCase(); - - private: - QString fileName(); - - private: - KTempDir *mTempDir; -}; - -#endif // MBOXTEST_H diff --git a/kontactinterface/.krazy b/kontactinterface/.krazy deleted file mode 100644 index cc3b3c429..000000000 --- a/kontactinterface/.krazy +++ /dev/null @@ -1 +0,0 @@ -EXTRA style,kdebug diff --git a/kontactinterface/CMakeLists.txt b/kontactinterface/CMakeLists.txt deleted file mode 100644 index cd49f1d7e..000000000 --- a/kontactinterface/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -project(kontactinterfaces) - -add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5601) - -set(kontactinterfaces_LIB_SRCS - core.cpp - plugin.cpp - summary.cpp - uniqueapphandler.cpp) - -kde4_add_library(kontactinterfaces SHARED ${kontactinterfaces_LIB_SRCS}) - -target_link_libraries(kontactinterfaces kdepim ${KDE4_KPARTS_LIBS}) - -set_target_properties(kontactinterfaces PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION}) - -########### install files ############### - -install(TARGETS kontactinterfaces ${INSTALL_TARGETS_DEFAULT_ARGS}) - -install(FILES kontactplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) diff --git a/kontactinterface/Mainpage.dox b/kontactinterface/Mainpage.dox deleted file mode 100644 index cefc7579f..000000000 --- a/kontactinterface/Mainpage.dox +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * @mainpage Kontact Plugin Interface Library - * - * @section purpose Purpose - * - * This library provides the glue necessary for application "Parts" - * to be embedded as a Kontact component (or plugin). - * - * @authors - * The major authors of this library are (in alphabetical order):\n - * David Faure \\n - * Matthias Hoelzer-Kluepfel \\n - * Daniel Molkentin \\n - * Cornelius Schumacher \ - * - * @maintainers - * Allen Winter \ - * - * @licenses - * @lgpl - */ - -// DOXYGEN_PROJECTNAME = Kontact Plugin Interface Library -// DOXYGEN_REFERENCES = kdecore kdeui diff --git a/kontactinterface/Messages.sh b/kontactinterface/Messages.sh deleted file mode 100644 index 7f90eb1cd..000000000 --- a/kontactinterface/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -$XGETTEXT *.cpp -o $podir/kontactinterfaces.pot diff --git a/kontactinterface/core.cpp b/kontactinterface/core.cpp deleted file mode 100644 index fe1a9d11a..000000000 --- a/kontactinterface/core.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2001 Matthias Hoelzer-Kluepfel - Copyright (c) 2002-2003 Daniel Molkentin - Copyright (c) 2003 Cornelius Schumacher - - 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. -*/ - -#include "core.h" - -#include -#include -#include - -#include -#include - -using namespace Kontact; - -//@cond PRIVATE -class Kontact::Core::Private -{ - Core *const q; - - public: - explicit Private( Core *qq ); - - void slotPartDestroyed( QObject * ); - void checkNewDay(); - - QString lastErrorMessage; - QDate mLastDate; - QMap mParts; -}; - -Core::Private::Private( Core *qq ) - : q( qq ), mLastDate( QDate::currentDate() ) -{ -} -//@endcond - -Core::Core( QWidget *parent, Qt::WindowFlags f ) - : KParts::MainWindow( parent, f ), d( new Private( this ) ) -{ - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), SLOT(checkNewDay()) ); - timer->start( 1000 * 60 ); -} - -Core::~Core() -{ - delete d; -} - -KParts::ReadOnlyPart *Core::createPart( const char *libname ) -{ - kDebug() << libname; - - QMap::ConstIterator it; - it = d->mParts.constFind( libname ); - if ( it != d->mParts.constEnd() ) { - return it.value(); - } - - kDebug() << "Creating new KPart"; - - KPluginLoader loader( libname ); - kDebug() << loader.fileName(); - KPluginFactory *factory = loader.factory(); - KParts::ReadOnlyPart *part = 0; - if ( factory ) { - part = factory->create( this ); - } - - if (part) { - d->mParts.insert( libname, part ); - QObject::connect( part, SIGNAL(destroyed(QObject *)), - SLOT(slotPartDestroyed(QObject *)) ); - } else { - d->lastErrorMessage = loader.errorString(); - kWarning() << d->lastErrorMessage; - } - - return part; -} - -//@cond PRIVATE -void Core::Private::slotPartDestroyed( QObject *obj ) -{ - // the part was deleted, we need to remove it from the part map to not return - // a dangling pointer in createPart - QMap::Iterator end = mParts.end(); - QMap::Iterator it = mParts.begin(); - for ( ; it != end; ++it ) { - if ( it.value() == obj ) { - mParts.erase( it ); - return; - } - } -} - -void Core::Private::checkNewDay() -{ - if ( mLastDate != QDate::currentDate() ) { - emit q->dayChanged( QDate::currentDate() ); - } - - mLastDate = QDate::currentDate(); -} -//@endcond - -QString Core::lastErrorMessage() const -{ - return d->lastErrorMessage; -} - -#include "core.moc" -// vim: sw=2 sts=2 et tw=80 diff --git a/kontactinterface/core.h b/kontactinterface/core.h deleted file mode 100644 index e39c7a2b3..000000000 --- a/kontactinterface/core.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2001 Matthias Hoelzer-Kluepfel - Copyright (c) 2002-2003 Daniel Molkentin - - 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 KONTACTINTERFACES_CORE_H -#define KONTACTINTERFACES_CORE_H - -#include "kontactinterfaces_export.h" -#include -#include - -namespace Kontact -{ - -class Plugin; - -/** - This class provides the interface to the Kontact core for the plugins. -*/ -class KONTACTINTERFACES_EXPORT Core : public KParts::MainWindow -{ - Q_OBJECT - public: - virtual ~Core(); - - /** - Selects the given plugin and raises the associated part. - @see selectPlugin(const QString &) - - @param plugin is a pointer to the Kontact Plugin to select. - */ - virtual void selectPlugin( Kontact::Plugin *plugin ) = 0; - - /** - This is an overloaded member function - @see selectPlugin(Kontact::Plugin *) - - @param plugin is the name of the Kontact Plugin select. - */ - virtual void selectPlugin( const QString &plugin ) = 0; - - /** - Returns the pointer list of available plugins. - */ - virtual QList pluginList() const = 0; - - /** - @internal (for Plugin) - */ - KParts::ReadOnlyPart *createPart( const char *libname ); - - /** - @internal (for Plugin) - Tell kontact that a part was loaded - */ - virtual void partLoaded( Plugin *plugin, KParts::ReadOnlyPart *part ) = 0; - - Q_SIGNALS: - /** - Emitted when a new day starts - */ - void dayChanged( const QDate & ); - - protected: - explicit Core( QWidget *parentWidget = 0, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS ); - - QString lastErrorMessage() const; - - private: - class Private; - Private *const d; - Q_PRIVATE_SLOT( d, void slotPartDestroyed( QObject * ) ) - Q_PRIVATE_SLOT( d, void checkNewDay() ) -}; - -} - -#endif - -// vim: sw=2 sts=2 et tw=80 diff --git a/kontactinterface/kontactinterfaces_export.h b/kontactinterface/kontactinterfaces_export.h deleted file mode 100644 index 98e208925..000000000 --- a/kontactinterface/kontactinterfaces_export.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (C) 2007 David Faure - - 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 KONTACTINTERFACES_EXPORT_H -#define KONTACTINTERFACES_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef KONTACTINTERFACES_EXPORT -# if defined(MAKE_KONTACTINTERFACES_LIB) - /* We are building this library */ -# define KONTACTINTERFACES_EXPORT KDE_EXPORT -# else - /* We are using this library */ -# define KONTACTINTERFACES_EXPORT KDE_IMPORT -# endif -#endif - -#endif diff --git a/kontactinterface/kontactplugin.desktop b/kontactinterface/kontactplugin.desktop deleted file mode 100644 index c006f6511..000000000 --- a/kontactinterface/kontactplugin.desktop +++ /dev/null @@ -1,70 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Kontact/Plugin -Name=Kontact Plugin -Name[af]=Kontact inprop module -Name[be]=Утулка Kontact -Name[bg]=Приставка на Kontact -Name[br]=Lugent Kontact -Name[ca]=Connector Kontact -Name[cs]=Modul aplikace Kontact -Name[cy]=Ategyn Kontact -Name[da]=Kontact-plugin -Name[de]=Kontact-Modul -Name[el]=Πρόσθετο Kontact -Name[es]=Complemento de Kontact -Name[et]=Kontacti plugin -Name[eu]=Kontact plugin-a -Name[fa]=وصلۀ Kontact -Name[fi]=Kontact-liitännäinen -Name[fr]=Module Kontact -Name[ga]=Breiseán Kontact -Name[gl]=Engadido do Kontact -Name[he]=תוסף Kontact -Name[hu]=Kontact-bővítőmodul -Name[is]=Kontact íforrit -Name[it]=Estensione Kontact -Name[ja]=Kontact プラグイン -Name[ka]=Kontact მოდული -Name[kk]=Kontact модулі -Name[km]=កម្មវិធី​ជំនួយ Kontact -Name[ko]=Kontact 플러그인 -Name[lt]=Kontact įskiepis -Name[lv]=Kontact spraudnis -Name[mk]=Приклучок за Контакт -Name[ms]=Plugin Kontact -Name[nb]=Kontact-programtillegg -Name[nds]=Kontact-Moduul -Name[ne]=सम्पर्क प्लगइन -Name[nn]=Kontakt-programtillegg -Name[pa]=ਕੇ-ਸੰਪਰਕ ਪਲੱਗਇਨ -Name[pl]=Wtyczka Kontact -Name[pt]='Plugin' do Kontact -Name[pt_BR]=Plug-in do Kontact -Name[ro]=Modul Kontact -Name[ru]=Модуль Kontact -Name[se]=Kontact-lassemoduvla -Name[sl]=Vstavek za Kontact -Name[sv]=Kontact-insticksprogram -Name[ta]=சொருகுப்பொருளை தொடர்புக்கொள் -Name[tg]=Модули Kontact -Name[tr]=Kontact Eklentisi -Name[uk]=Втулок Kontact -Name[uz]=Kontact uchun plagin -Name[uz@cyrillic]=Kontact учун плагин -Name[x-test]=xxKontact Pluginxx -Name[zh_CN]=Kontact 插件 -Name[zh_TW]=Kontact 外掛程式 - -[PropertyDef::X-KDE-KontactPluginVersion] -Type=int -[PropertyDef::X-KDE-KontactPartLibraryName] -Type=QString -[PropertyDef::X-KDE-KontactPartExecutableName] -Type=QString -[PropertyDef::X-KDE-KontactPartLoadOnStart] -Type=bool -[PropertyDef::X-KDE-KontactPluginHasSummary] -Type=bool -[PropertyDef::X-KDE-KontactPluginHasPart] -Type=bool diff --git a/kontactinterface/plugin.cpp b/kontactinterface/plugin.cpp deleted file mode 100644 index 1fbaee4de..000000000 --- a/kontactinterface/plugin.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2001 Matthias Hoelzer-Kluepfel - Copyright (c) 2002-2003 Daniel Molkentin - - 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. -*/ - -#include "plugin.h" -#include "core.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -using namespace Kontact; - -/** - Private class that helps to provide binary compatibility between releases. - @internal -*/ -//@cond PRIVATE -class Plugin::Private -{ - public: - - void partDestroyed(); - - Core *core; - QList *newActions; - QList *syncActions; - QString identifier; - QString title; - QString icon; - QString executableName; - QString serviceName; - QByteArray partLibraryName; - bool hasPart; - KParts::ReadOnlyPart *part; - bool disabled; -}; -//@endcond - -Plugin::Plugin( Core *core, QObject *parent, const char *name ) - : KXMLGUIClient( core ), QObject( parent ), d( new Private ) -{ - setObjectName( name ); - core->factory()->addClient( this ); - KGlobal::locale()->insertCatalog( name ); - - d->core = core; - d->newActions = new QList; - d->syncActions = new QList; - d->hasPart = true; - d->part = 0; - d->disabled = false; -} - -Plugin::~Plugin() -{ - delete d->part; - delete d; -} - -void Plugin::setIdentifier( const QString &identifier ) -{ - d->identifier = identifier; -} - -QString Plugin::identifier() const -{ - return d->identifier; -} - -void Plugin::setTitle( const QString &title ) -{ - d->title = title; -} - -QString Plugin::title() const -{ - return d->title; -} - -void Plugin::setIcon( const QString &icon ) -{ - d->icon = icon; -} - -QString Plugin::icon() const -{ - return d->icon; -} - -void Plugin::setExecutableName( const QString &bin ) -{ - d->executableName = bin; -} - -QString Plugin::executableName() const -{ - return d->executableName; -} - -void Plugin::setPartLibraryName( const QByteArray &libName ) -{ - d->partLibraryName = libName; -} - -bool Plugin::createDBUSInterface( const QString &serviceType ) -{ - Q_UNUSED( serviceType ); - return false; -} - -bool Plugin::isRunningStandalone() -{ - return false; -} - -KParts::ReadOnlyPart *Plugin::loadPart() -{ - return core()->createPart( d->partLibraryName ); -} - -const KAboutData *Plugin::aboutData() -{ - KPluginLoader loader( d->partLibraryName ); - KPluginFactory *factory = loader.factory(); - kDebug() << "filename:" << loader.fileName(); - kDebug() << "libname:" << d->partLibraryName; - - if ( factory ) { - if ( factory->componentData().isValid() ) { - kDebug() << "returning factory component aboutdata"; - return factory->componentData().aboutData(); - } else { - // If the componentData of the factory is invalid, the likely cause is that - // the part has not been ported to use K_PLUGIN_FACTORY/K_EXPORT_PLUGIN yet. - // In that case, fallback to the old method of loading component data, which - // does only work for old-style parts. - - kDebug() << "Unable to load component data for" << loader.fileName() - << "trying to use the old style plugin system now."; - const KComponentData instance = - KParts::Factory::partComponentDataFromLibrary( d->partLibraryName ); - if ( instance.isValid() ) { - return instance.aboutData(); - } else { - kDebug() << "Invalid instance, unable to get about information!"; - } - } - } - - kError() << "Cannot load instance for" << title(); - return 0; -} - -KParts::ReadOnlyPart *Plugin::part() -{ - if ( !d->part ) { - d->part = createPart(); - if ( d->part ) { - connect( d->part, SIGNAL(destroyed()), SLOT(partDestroyed()) ); - core()->partLoaded( this, d->part ); - } - } - return d->part; -} - -QString Plugin::tipFile() const -{ - return QString(); -} - -QString Plugin::registerClient() -{ - if ( d->serviceName.isEmpty() ) { - d->serviceName = "org.kde." + objectName().toLatin1(); -#ifdef Q_WS_WIN - const QString pid = QString::number( getpid() ); - d->serviceName.append( ".unique-" + pid ); -#endif - QDBusConnection::sessionBus().registerService( d->serviceName ); - } - return d->serviceName; -} - -int Plugin::weight() const -{ - return 0; -} - -void Plugin::insertNewAction( KAction *action ) -{ - d->newActions->append( action ); -} - -void Plugin::insertSyncAction( KAction *action ) -{ - d->syncActions->append( action ); -} - -QList *Plugin::newActions() const -{ - return d->newActions; -} - -QList *Plugin::syncActions() const -{ - return d->syncActions; -} - -QStringList Plugin::invisibleToolbarActions() const -{ - return QStringList(); -} - -bool Plugin::canDecodeMimeData( const QMimeData *data ) -{ - Q_UNUSED( data ); - return false; -} - -Core *Plugin::core() const -{ - return d->core; -} - -void Plugin::select() -{ -} - -void Plugin::configUpdated() -{ -} - -//@cond PRIVATE -void Plugin::Private::partDestroyed() -{ - part = 0; -} -//@endcond - -void Plugin::slotConfigUpdated() -{ - configUpdated(); -} - -void Plugin::bringToForeground() -{ - if ( d->executableName.isEmpty() ) { - return; - } -#ifdef Q_WS_WIN - KPIM::Utils::activateWindowForProcess( d->executableName ); -#else - KRun::runCommand( d->executableName, 0 ); -#endif -} - -Summary *Plugin::createSummaryWidget( QWidget *parent ) -{ - Q_UNUSED( parent ); - return 0; -} - -bool Plugin::showInSideBar() const -{ - return d->hasPart; -} - -void Plugin::setShowInSideBar( bool hasPart ) -{ - d->hasPart = hasPart; -} - -bool Plugin::queryClose() const -{ - return true; -} - -void Plugin::setDisabled( bool disabled ) -{ - d->disabled = disabled; -} - -bool Plugin::disabled() const -{ - return d->disabled; -} - -void Plugin::virtual_hook( int, void * ) -{ - //BASE::virtual_hook( id, data ); -} - -#include "plugin.moc" - -// vim: sw=2 et sts=2 tw=80 diff --git a/kontactinterface/plugin.h b/kontactinterface/plugin.h deleted file mode 100644 index 4f94e027f..000000000 --- a/kontactinterface/plugin.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2001 Matthias Hoelzer-Kluepfel - Copyright (c) 2002-2003 Daniel Molkentin - Copyright (c) 2003 Cornelius Schumacher - - 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 KONTACTINTERFACES_PLUGIN_H -#define KONTACTINTERFACES_PLUGIN_H - -#include "kontactinterfaces_export.h" - -#include -#include - -#include -#include - -class KAboutData; -class KAction; -class KConfig; -class KConfigGroup; -class QDropEvent; -class QMimeData; -class QStringList; -class QWidget; -namespace KParts { - class ReadOnlyPart; -} - -/** - Exports Kontact plugin. - */ -#define EXPORT_KONTACT_PLUGIN( pluginclass, pluginname ) \ -class Instance \ -{ \ - public: \ - static QObject *createInstance( QWidget *, QObject *parent, const QVariantList &list ) \ - { return new pluginclass( static_cast( parent ), list ); } \ -}; \ -K_PLUGIN_FACTORY( KontactPluginFactory, registerPlugin< pluginclass > \ - ( QString(), Instance::createInstance ); ) \ -K_EXPORT_PLUGIN( KontactPluginFactory( "kontact_" #pluginname "plugin" ) ) - -/** - Increase this version number whenever you make a change in the API. - */ -#define KONTACT_PLUGIN_VERSION 7 - -namespace Kontact -{ - -class Core; -class Summary; - -/** - Base class for all Plugins in Kontact. Inherit from it - to get a plugin. It can insert an icon into the sidepane, - add widgets to the widgetstack and add menu items via XMLGUI. - */ -class KONTACTINTERFACES_EXPORT Plugin : public QObject, virtual public KXMLGUIClient -{ - Q_OBJECT - - public: - /** - Creates a new Plugin, note that name parameter name is required if - you want your plugin to do dcop via it's own instance of - DCOPClient by calling dcopClient. - @note name MUST be the name of the application that - provides the part! This is the name used for DCOP registration. - It's ok to have several plugins using the same application name. - */ - Plugin( Core *core, QObject *parent, const char *name ); - - virtual ~Plugin(); - - /** - Sets the identifier. - */ - void setIdentifier( const QString &identifier ); - - /** - Returns the identifier. It is used as argument for several - methods of Kontacts core. - */ - QString identifier() const; - - /** - Sets the localized title. - */ - void setTitle( const QString &title ); - - /** - Returns the localized title. - */ - QString title() const; - - /** - Sets the icon name. - */ - void setIcon( const QString &icon ); - - /** - Returns the icon name. - */ - QString icon() const; - - /** - Sets the name of executable (if existent). - */ - void setExecutableName( const QString &bin ); - - /** - Returns the name of the binary (if existent). - */ - QString executableName() const; - - /** - Set name of library which contains the KPart used by this plugin. - */ - void setPartLibraryName( const QByteArray & ); - - /** - Create the D-Bus interface for the given @p serviceType, if this - plugin provides it. Return false otherwise. - */ - virtual bool createDBUSInterface( const QString &serviceType ); - - /** - Reimplement this method and return whether a standalone application - is still running. This is only required if your part is also available - as standalone application. - */ - virtual bool isRunningStandalone(); - - /** - Reimplement this method if your application needs a different approach to be brought - in the foreground. The default behaviour is calling the binary. - This is only required if your part is also available as standalone application. - */ - virtual void bringToForeground(); - - /** - Reimplement this method if you want to add your credits to the Kontact - about dialog. - */ - virtual const KAboutData *aboutData(); - - /** - You can use this method if you need to access the current part. You can be - sure that you always get the same pointer as long as the part has not been - deleted. - */ - KParts::ReadOnlyPart *part(); - - /** - Reimplement this method and return the a path relative to "data" to the tips file. - The tips file contains hints/tips that are displayed at the beginning of the program - as "tip of the day". It has nothing to do with tooltips. - */ - virtual QString tipFile() const; - - /** - This function is called when the plugin is selected by the user before the - widget of the KPart belonging to the plugin is raised. - */ - virtual void select(); - - /** - This function is called whenever the config dialog has been closed - successfully. - */ - virtual void configUpdated(); - - /** - Reimplement this method if you want to add a widget for your application - to Kontact's summary page. - */ - virtual Summary *createSummaryWidget( QWidget *parent ); - - /** - Returns whether the plugin provides a part that should be shown in the sidebar. - */ - virtual bool showInSideBar() const; - - /** - Set if the plugin provides a part that should be shown in the sidebar. - */ - void setShowInSideBar( bool hasPart ); - - /** - Reimplement this method if you want to add checks before closing the - main kontact window. Return true if it's OK to close the window. - If any loaded plugin returns false from this method, then the - main kontact window will not close. - */ - virtual bool queryClose() const; - - QString registerClient(); - - /** - Return the weight of the plugin. The higher the weight the lower it will - be displayed in the sidebar. The default implementation returns 0. - */ - virtual int weight() const; - - /** - Insert "New" action. - */ - void insertNewAction( KAction *action ); - - /** - Insert "Sync" action. - */ - void insertSyncAction( KAction *action ); - - /** - FIXME: write API doc for Plugin::newActions(). - */ - QList* newActions() const; - - /** - FIXME: write API doc for Plugin::syncActions(). - */ - QList* syncActions() const; - - /** - Returns a list of action name which shall be hidden in the main toolbar. - */ - virtual QStringList invisibleToolbarActions() const; - - /** - Return, if the plugin can handle the drag object of the given mime type. - */ - virtual bool canDecodeMimeData( const QMimeData *data ); - - /** - Process drop event. - */ - virtual void processDropEvent( QDropEvent * ) {} - - /** - * Session management: read properties - */ - virtual void readProperties( const KConfigGroup & ) {} - - /** - * Session management: save properties - */ - virtual void saveProperties( KConfigGroup & ) {} - - Core *core() const; - - bool disabled() const; - void setDisabled( bool v ); - - public Q_SLOTS: - /** - internal usage - */ - void slotConfigUpdated(); - - protected: - /** - Reimplement and return the part here. Reimplementing createPart() is - mandatory! - */ - virtual KParts::ReadOnlyPart *createPart() = 0; - - KParts::ReadOnlyPart *loadPart(); - - virtual void virtual_hook( int id, void *data ); - - private: - class Private; - Private *const d; - Q_PRIVATE_SLOT( d, void partDestroyed() ) -}; - -} - -#endif diff --git a/kontactinterface/summary.cpp b/kontactinterface/summary.cpp deleted file mode 100644 index 02b3af725..000000000 --- a/kontactinterface/summary.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Daniel Molkentin - - 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. -*/ - -#include "summary.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Kontact; - -//@cond PRIVATE -namespace Kontact { -class SummaryMimeData : public QMimeData -{ - public: - virtual bool hasFormat( const QString &format ) const - { - if ( format == "application/x-kontact-summary" ) { - return true; - } - return false; - } -}; -} -//@endcond - -//@cond PRIVATE -class Summary::Private -{ - public: - KStatusBar *mStatusBar; - QPoint mDragStartPoint; -}; -//@endcond - -Summary::Summary( QWidget *parent ) - : QWidget( parent ), d( new Private ) -{ - setFont( KGlobalSettings::generalFont() ); - setAcceptDrops( true ); -} - -Summary::~Summary() -{ - delete d; -} - -int Summary::summaryHeight() const -{ - return 1; -} - -QWidget *Summary::createHeader( QWidget *parent, const QString &iconname, const QString &heading ) -{ - setStyleSheet( "KHBox {" - "border: 1px solid palette(window);" - "border-top: 0px solid white;" - "border-left: 0px solid white;" - "border-right: 0px solid white;" - "font: bold large;" - "padding: 2px;" - "}" - "KHBox > QLabel { font: bold larger; } " ); - - KHBox *hbox = new KHBox( parent ); - //hbox->setMargin( 2 ); - //hbox->setAutoFillBackground( true ); - - QLabel *label = new QLabel( hbox ); - label->setPixmap( KIconLoader::global()->loadIcon( iconname, KIconLoader::Toolbar ) ); - - label->setFixedSize( label->sizeHint() ); - label->setAcceptDrops( true ); - - label = new QLabel( heading, hbox ); - label->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - label->setIndent( KDialog::spacingHint() ); - - hbox->setMaximumHeight( hbox->minimumSizeHint().height() ); - - return hbox; -} - -QStringList Summary::configModules() const -{ - return QStringList(); -} - -void Summary::updateSummary( bool force ) -{ - Q_UNUSED( force ); -} - -void Summary::mousePressEvent( QMouseEvent *event ) -{ - d->mDragStartPoint = event->pos(); - - QWidget::mousePressEvent( event ); -} - -void Summary::mouseMoveEvent( QMouseEvent *event ) -{ - if ( ( event->buttons() & Qt::LeftButton ) && - ( event->pos() - d->mDragStartPoint ).manhattanLength() > 4 ) { - - QDrag *drag = new QDrag( this ); - drag->setMimeData( new SummaryMimeData() ); - drag->setObjectName( "SummaryWidgetDrag" ); - - QPixmap pm = QPixmap::grabWidget( this ); - if ( pm.width() > 300 ) { - pm = QPixmap::fromImage( - pm.toImage().scaled( 300, 300, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); - } - - QPainter painter; - painter.begin( &pm ); - painter.setPen( QPalette::AlternateBase ); - painter.drawRect( 0, 0, pm.width(), pm.height() ); - painter.end(); - drag->setPixmap( pm ); - drag->start( Qt::MoveAction ); - } else { - QWidget::mouseMoveEvent( event ); - } -} - -void Summary::dragEnterEvent( QDragEnterEvent *event ) -{ - if ( event->mimeData()->hasFormat( "application/x-kontact-summary" ) ) { - event->acceptProposedAction(); - } -} - -void Summary::dropEvent( QDropEvent *event ) -{ - int alignment = ( event->pos().y() < ( height() / 2 ) ? Qt::AlignTop : Qt::AlignBottom ); - emit summaryWidgetDropped( this, event->source(), alignment ); -} - -#include "summary.moc" diff --git a/kontactinterface/summary.h b/kontactinterface/summary.h deleted file mode 100644 index 21deb9300..000000000 --- a/kontactinterface/summary.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2003 Cornelius Schumacher - - 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 KONTACTINTERFACES_SUMMARY_H -#define KONTACTINTERFACES_SUMMARY_H - -#include "kontactinterfaces_export.h" - -#include - -class KStatusBar; -class QMouseEvent; -class QDragEnterEvent; -class QDropEvent; - -namespace Kontact -{ - -/** - Summary widget for display in the Summary View plugin. - */ -class KONTACTINTERFACES_EXPORT Summary : public QWidget -{ - Q_OBJECT - public: - explicit Summary( QWidget *parent ); - - virtual ~Summary(); - - /** - Return logical height of summary widget. This is used to calculate how - much vertical space relative to other summary widgets this widget will - use in the summary view. - */ - virtual int summaryHeight() const; - - /** - Creates a heading for a typical summary view with an icon and a heading. - */ - QWidget *createHeader( QWidget *parent, const QString &iconname, const QString &heading ); - - /** - Return list of strings identifying configuration modules for this summary - part. The string has to be suitable for being passed to - KCMultiDialog::addModule(). - */ - virtual QStringList configModules() const; - - public Q_SLOTS: - virtual void configChanged() {} - - /** - This is called if the displayed information should be updated. - @param force true if the update was requested by the user - */ - virtual void updateSummary( bool force = false ); - - Q_SIGNALS: - void message( const QString &message ); - void summaryWidgetDropped( QWidget *target, QWidget *widget, int alignment ); - - protected: - virtual void mousePressEvent( QMouseEvent * ); - virtual void mouseMoveEvent( QMouseEvent * ); - virtual void dragEnterEvent( QDragEnterEvent * ); - virtual void dropEvent( QDropEvent * ); - - private: - class Private; - Private *const d; -}; - -} - -#endif diff --git a/kontactinterface/uniqueapphandler.cpp b/kontactinterface/uniqueapphandler.cpp deleted file mode 100644 index 9ee2c5d1c..000000000 --- a/kontactinterface/uniqueapphandler.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2003,2008 David Faure - - 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. -*/ - -#include "uniqueapphandler.h" -#include -#include "core.h" -#include "libkdepim/utils.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef Q_WS_WIN -# include -#endif - -/* - Test plan for the various cases of interaction between standalone apps and kontact: - - 1) start kontact, select "Mail". - 1a) type "korganizer" -> it switches to korganizer - 1b) type "kmail" -> it switches to kmail - 1c) type "kaddressbook" -> it switches to kaddressbook - 1d) type "kmail foo@kde.org" -> it opens a kmail composer, without switching - 1e) type "knode" -> it switches to knode [unless configured to be external] - 1f) type "kaddressbook --new-contact" -> it opens a kaddressbook contact window - 1g) type "knode news://foobar/group" -> it pops up "can't resolve hostname" - - 2) close kontact. Launch kmail. Launch kontact again. - 2a) click "Mail" icon -> kontact doesn't load a part, but activates the kmail window - 2b) type "kmail foo@kde.org" -> standalone kmail opens composer. - 2c) close kmail, click "Mail" icon -> kontact loads the kmail part. - 2d) type "kmail" -> kontact is brought to front - - 3) close kontact. Launch korganizer, then kontact. - 3a) both Todo and Calendar activate the running korganizer. - 3b) type "korganizer" -> standalone korganizer is brought to front - 3c) close korganizer, click Calendar or Todo -> kontact loads part. - 3d) type "korganizer" -> kontact is brought to front - - 4) close kontact. Launch kaddressbook, then kontact. - 4a) "Contacts" icon activate the running kaddressbook. - 4b) type "kaddressbook" -> standalone kaddressbook is brought to front - 4c) close kaddressbook, type "kaddressbook -a foo@kde.org" -> kontact loads part and opens editor - 4d) type "kaddressbook" -> kontact is brought to front - - 5) close kontact. Launch knode, then kontact. - 5a) "News" icon activate the running knode. - 5b) type "knode" -> standalone knode is brought to front - 5c) close knode, type "knode news://foobar/group" -> kontact loads knode and pops up msgbox - 5d) type "knode" -> kontact is brought to front - - 6) start "kontact --module summaryplugin" - 6a) type "qdbus org.kde.kmail /kmail_PimApplication newInstance '' ''" -> - kontact switches to kmail (#103775) - 6b) type "kmail" -> kontact is brought to front - 6c) type "kontact" -> kontact is brought to front - 6d) type "kontact --module summaryplugin" -> kontact switches to summary - -*/ - -using namespace Kontact; - -//@cond PRIVATE -class UniqueAppHandler::Private -{ - public: - Plugin *mPlugin; -}; -//@endcond - -UniqueAppHandler::UniqueAppHandler( Plugin *plugin ) - : d( new Private ) -{ - //kDebug() << "plugin->objectName():" << plugin->objectName(); - - d->mPlugin = plugin; - QDBusConnection session = QDBusConnection::sessionBus(); - const QString appName = plugin->objectName(); - session.registerService( "org.kde." + appName ); - const QString objectName = QString( '/' ) + appName + "_PimApplication"; - session.registerObject( objectName, this, QDBusConnection::ExportAllSlots ); -} - -UniqueAppHandler::~UniqueAppHandler() -{ - delete d; -} - -// DBUS call -int UniqueAppHandler::newInstance( const QByteArray &asn_id, const QByteArray &args ) -{ - if ( !asn_id.isEmpty() ) { - kapp->setStartupId( asn_id ); - } - - KCmdLineArgs::reset(); // forget options defined by other "applications" - loadCommandLineOptions(); // implemented by plugin - - // This bit is duplicated from KUniqueApplicationAdaptor::newInstance() - QDataStream ds( args ); - KCmdLineArgs::loadAppArgs( ds ); - - return newInstance(); -} - -static QWidget *s_mainWidget = 0; - -// Plugin-specific newInstance implementation, called by above method -int Kontact::UniqueAppHandler::newInstance() -{ - if ( s_mainWidget ) { - s_mainWidget->show(); - KWindowSystem::forceActiveWindow( s_mainWidget->winId() ); - KStartupInfo::appStarted(); - } - - // Then ensure the part appears in kontact - d->mPlugin->core()->selectPlugin( d->mPlugin ); - return 0; -} - -Plugin *UniqueAppHandler::plugin() const -{ - return d->mPlugin; -} - -bool Kontact::UniqueAppHandler::load() -{ - (void)d->mPlugin->part(); // load the part without bringing it to front - return true; -} - -//@cond PRIVATE -class UniqueAppWatcher::Private -{ - public: - UniqueAppHandlerFactoryBase *mFactory; - Plugin *mPlugin; - bool mRunningStandalone; -}; -//@endcond - -UniqueAppWatcher::UniqueAppWatcher( UniqueAppHandlerFactoryBase *factory, Plugin *plugin ) - : QObject( plugin ), d( new Private ) -{ - d->mFactory = factory; - d->mPlugin = plugin; - - // The app is running standalone if 1) that name is known to D-Bus - const QString serviceName = "org.kde." + plugin->objectName(); - d->mRunningStandalone = - QDBusConnection::sessionBus().interface()->isServiceRegistered( serviceName ); -#ifdef Q_WS_WIN - if ( d->mRunningStandalone ) { - QList pids; - KPIM::Utils::getProcessesIdForName( plugin->objectName(), pids ); - const int mypid = getpid(); - bool processExits = false; - foreach ( int pid, pids ) { - if ( mypid != pid ) { - processExits = true; - break; - } - } - if ( !processExits ) { - d->mRunningStandalone = false; - } - } -#endif - - QString owner = QDBusConnection::sessionBus().interface()->serviceOwner( serviceName ); - if ( d->mRunningStandalone && ( owner == QDBusConnection::sessionBus().baseService() ) ) { - d->mRunningStandalone = false; - } - //kDebug() << " plugin->objectName()=" << plugin->objectName() - // << " running standalone:" << d->mRunningStandalone; - - if ( d->mRunningStandalone ) { - QObject::connect( QDBusConnection::sessionBus().interface(), - SIGNAL(serviceOwnerChanged(QString,QString,QString)), - this, SLOT(slotApplicationRemoved(QString,QString,QString)) ); - } else { - d->mFactory->createHandler( d->mPlugin ); - } -} - -UniqueAppWatcher::~UniqueAppWatcher() -{ - delete d->mFactory; - delete d; -} - -bool UniqueAppWatcher::isRunningStandalone() const -{ - return d->mRunningStandalone; -} - -void Kontact::UniqueAppWatcher::slotApplicationRemoved( const QString &name, - const QString &oldOwner, - const QString &newOwner ) -{ - if ( oldOwner.isEmpty() || !newOwner.isEmpty() ) { - return; - } - - const QString serviceName = "org.kde." + d->mPlugin->objectName(); - if ( name == serviceName && d->mRunningStandalone ) { - d->mFactory->createHandler( d->mPlugin ); - d->mRunningStandalone = false; - } -} - -void Kontact::UniqueAppHandler::setMainWidget( QWidget *widget ) -{ - s_mainWidget = widget; -} - -#include "uniqueapphandler.moc" diff --git a/kontactinterface/uniqueapphandler.h b/kontactinterface/uniqueapphandler.h deleted file mode 100644 index a28f20e33..000000000 --- a/kontactinterface/uniqueapphandler.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - This file is part of the KDE Kontact Plugin Interface Library. - - Copyright (c) 2003,2008 David Faure - - 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 KONTACTINTERFACES_UNIQUEAPPHANDLER_H -#define KONTACTINTERFACES_UNIQUEAPPHANDLER_H - -#include "kontactinterfaces_export.h" -#include "plugin.h" - -namespace Kontact -{ - -/** - * D-Bus Object that has the name of the standalone application (e.g. "kmail") - * and implements newInstance() so that running the separate application does - * the right thing when kontact is running. - * By default this means simply bringing the main window to the front, - * but newInstance can be reimplemented. - */ -class KONTACTINTERFACES_EXPORT UniqueAppHandler : public QObject -{ - Q_OBJECT - // We implement the KUniqueApplication interface - Q_CLASSINFO( "D-Bus Interface", "org.kde.KUniqueApplication" ) - - public: - UniqueAppHandler( Plugin *plugin ); - virtual ~UniqueAppHandler(); - - /// This must be reimplemented so that app-specific command line options can be parsed - virtual void loadCommandLineOptions() = 0; - - Plugin *plugin() const; - - // for kontact - static void setMainWidget( QWidget *widget ); - - public Q_SLOTS: // DBUS methods - int newInstance( const QByteArray &asn_id, const QByteArray &args ); - bool load(); - - protected: - virtual int newInstance(); - - private: - class Private; - Private *const d; -}; - -/// Base class for UniqueAppHandler -class UniqueAppHandlerFactoryBase -{ - public: - virtual ~UniqueAppHandlerFactoryBase(){} - virtual UniqueAppHandler *createHandler( Plugin * ) = 0; -}; - -/** - * Used by UniqueAppWatcher below, to create the above UniqueAppHandler object - * when necessary. - * The template argument is the UniqueAppHandler-derived class. - * This allows to remove the need to subclass UniqueAppWatcher. - */ -template class UniqueAppHandlerFactory : public UniqueAppHandlerFactoryBase -{ - public: - virtual UniqueAppHandler *createHandler( Plugin *plugin ) { - plugin->registerClient(); - return new T( plugin ); - } -}; - -/** - * If the standalone application is running by itself, we need to watch - * for when the user closes it, and activate the uniqueapphandler then. - * This prevents, on purpose, that the standalone app can be restarted. - * Kontact takes over from there. - * - */ -class KONTACTINTERFACES_EXPORT UniqueAppWatcher : public QObject -{ - Q_OBJECT - - public: - /** - * Create an instance of UniqueAppWatcher, which does everything necessary - * for the "unique application" behavior: create the UniqueAppHandler as soon - * as possible, i.e. either right now or when the standalone app is closed. - * - * @param factory templatized factory to create the handler. Example: - * ... Note that the watcher takes ownership of the factory. - * @param plugin is the plugin application - */ - UniqueAppWatcher( UniqueAppHandlerFactoryBase *factory, Plugin *plugin ); - - virtual ~UniqueAppWatcher(); - - bool isRunningStandalone() const; - - private Q_SLOTS: - void slotApplicationRemoved( const QString &name, const QString &oldOwner, - const QString &newOwner ); - - private: - class Private; - Private *const d; -}; - -} // namespace - -#endif - diff --git a/mailtransport/tests/unittestenv/config.xml b/mailtransport/tests/unittestenv/config.xml deleted file mode 100644 index 47d7cb0b8..000000000 --- a/mailtransport/tests/unittestenv/config.xml +++ /dev/null @@ -1,5 +0,0 @@ - - kdehome - xdgconfig - xdglocal - diff --git a/mailtransport/tests/unittestenv/kdehome/share/config/akonadi-firstrunrc b/mailtransport/tests/unittestenv/kdehome/share/config/akonadi-firstrunrc deleted file mode 100644 index 1cac492a3..000000000 --- a/mailtransport/tests/unittestenv/kdehome/share/config/akonadi-firstrunrc +++ /dev/null @@ -1,3 +0,0 @@ -[ProcessedDefaults] -defaultaddressbook=done -defaultcalendar=done diff --git a/mailtransport/tests/unittestenv/kdehome/share/config/kdebugrc b/mailtransport/tests/unittestenv/kdehome/share/config/kdebugrc deleted file mode 100644 index 32317f745..000000000 --- a/mailtransport/tests/unittestenv/kdehome/share/config/kdebugrc +++ /dev/null @@ -1,110 +0,0 @@ -[0] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[5250] -InfoOutput=2 - -[5251] -InfoOutput=2 - -[5252] -InfoOutput=2 - -[5253] -InfoOutput=2 - -[5254] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[5255] -InfoOutput=2 - -[5256] -InfoOutput=2 - -[5257] -InfoOutput=2 - -[5258] -InfoOutput=2 - -[5259] -InfoOutput=2 - -[5260] -InfoOutput=2 - -[5261] -InfoOutput=2 - -[5262] -InfoOutput=2 - -[5263] -InfoOutput=2 - -[5264] -InfoOutput=2 - -[5265] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[5266] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[5295] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[5324] -AbortFatal=true -ErrorFilename[$e]=kdebug.dbg -ErrorOutput=2 -FatalFilename[$e]=kdebug.dbg -FatalOutput=2 -InfoFilename[$e]=kdebug.dbg -InfoOutput=2 -WarnFilename[$e]=kdebug.dbg -WarnOutput=2 - -[7129] -InfoOutput=2 diff --git a/mailtransport/tests/unittestenv/kdehome/share/config/kwalletrc b/mailtransport/tests/unittestenv/kdehome/share/config/kwalletrc deleted file mode 100644 index 8ba29ca12..000000000 --- a/mailtransport/tests/unittestenv/kdehome/share/config/kwalletrc +++ /dev/null @@ -1,2 +0,0 @@ -[Wallet] -Enabled=false diff --git a/mailtransport/tests/unittestenv/kdehome/share/config/mailtransports b/mailtransport/tests/unittestenv/kdehome/share/config/mailtransports deleted file mode 100644 index bc9c63f07..000000000 --- a/mailtransport/tests/unittestenv/kdehome/share/config/mailtransports +++ /dev/null @@ -1,17 +0,0 @@ -[$Version] -update_info=mailtransports.upd:initial-kmail-migration,mailtransports.upd:initial-knode-migration - -[General] -default-transport=549190884 - -[Transport 549190884] -auth=true -encryption=SSL -host=smtp.gmail.com -id=549190884 -name=idanoka2-stored -password=ᄒᄡᄚᄆᄒᄏᄊᆱᄎᆲᆱ -port=465 -storepass=true -user=idanoka2@gmail.com - diff --git a/mailtransport/tests/unittestenv/kdehome/share/config/qttestrc b/mailtransport/tests/unittestenv/kdehome/share/config/qttestrc deleted file mode 100644 index 2e2f28ea1..000000000 --- a/mailtransport/tests/unittestenv/kdehome/share/config/qttestrc +++ /dev/null @@ -1,2 +0,0 @@ -[Notification Messages] -WalletMigrate=false diff --git a/mailtransport/tests/unittestenv/xdgconfig/akonadi/akonadiserverrc b/mailtransport/tests/unittestenv/xdgconfig/akonadi/akonadiserverrc deleted file mode 100644 index 7f738ce21..000000000 --- a/mailtransport/tests/unittestenv/xdgconfig/akonadi/akonadiserverrc +++ /dev/null @@ -1,4 +0,0 @@ -[%General] - -[Search] -Manager=Dummy