Diffstat (limited to 'kaddressbook/features/distributionlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/features/distributionlistwidget.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/kaddressbook/features/distributionlistwidget.cpp b/kaddressbook/features/distributionlistwidget.cpp index bfcb121..996177b 100644 --- a/kaddressbook/features/distributionlistwidget.cpp +++ b/kaddressbook/features/distributionlistwidget.cpp @@ -1,202 +1,209 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <qbuttongroup.h> +#include <q3buttongroup.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> -#include <qlistview.h> +#include <q3listview.h> #include <qpushbutton.h> #include <qradiobutton.h> +//Added by qt3to4: +#include <QDragMoveEvent> +#include <QDropEvent> +#include <Q3GridLayout> +#include <Q3Frame> +#include <Q3VBoxLayout> +#include <QDragEnterEvent> #ifndef KAB_EMBEDDED #include <kaccelmanager.h> #endif //KAB_EMBEDDED #include <kdebug.h> #include <klineeditdlg.h> #include <klocale.h> #include <kglobal.h> #include <kmessagebox.h> #include <kabc/addressbook.h> #include <kabc/addresseedialog.h> #include <kabc/distributionlist.h> #include <kabc/vcardconverter.h> #ifndef KAB_EMBEDDED #include <libkdepim/kvcarddrag.h> #endif //KAB_EMBEDDED #include "kabcore.h" #include "distributionlistwidget.h" #ifndef KAB_EMBEDDED class DistributionListFactory : public ExtensionFactory { public: ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) { return new DistributionListWidget( core, parent, name ); } QString identifier() const { return "distribution_list_editor"; } }; extern "C" { void *init_libkaddrbk_distributionlist() { return ( new DistributionListFactory ); } } #endif //KAB_EMBEDDED -class ContactItem : public QListViewItem +class ContactItem : public Q3ListViewItem { public: ContactItem( DistributionListView *parent, const KABC::Addressee &addressee, const QString &email = QString::null ) : - QListViewItem( parent ), + Q3ListViewItem( parent ), mAddressee( addressee ), mEmail( email ) { setText( 0, addressee.realName() ); if( email.isEmpty() ) { setText( 1, addressee.preferredEmail() ); setText( 2, i18n( "Yes" ) ); } else { setText( 1, email ); setText( 2, i18n( "No" ) ); } } KABC::Addressee addressee() const { return mAddressee; } QString email() const { return mEmail; } protected: bool acceptDrop( const QMimeSource* ) { return true; } private: KABC::Addressee mAddressee; QString mEmail; }; DistributionListWidget::DistributionListWidget( KABCore *core, QWidget *parent, const char *name ) : ExtensionWidget( core, parent, name ), mManager( 0 ) { - QGridLayout *topLayout = new QGridLayout( this, 3, 4, KDialog::marginHint(), + Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() ); if (KGlobal::getOrientation() == KGlobal::Portrait) { mCreateListButton = new QPushButton( i18n( "New List" ), this ); mEditListButton = new QPushButton( i18n( "Ren List" ), this ); mRemoveListButton = new QPushButton( i18n( "Del List" ), this ); mAddContactButton = new QPushButton( i18n( "Add Cont." ), this ); mChangeEmailButton = new QPushButton( i18n( "Chge Email" ), this ); mRemoveContactButton = new QPushButton( i18n( "Del Cont." ), this ); } else { mCreateListButton = new QPushButton( i18n( "New List..." ), this ); mEditListButton = new QPushButton( i18n( "Rename List..." ), this ); mRemoveListButton = new QPushButton( i18n( "Remove List" ), this ); mAddContactButton = new QPushButton( i18n( "Add Contact" ), this ); mChangeEmailButton = new QPushButton( i18n( "Change Email..." ), this ); mRemoveContactButton = new QPushButton( i18n( "Remove Contact" ), this ); } mNameCombo = new QComboBox( this ); topLayout->addWidget( mNameCombo, 0, 0 ); connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateContactView() ) ); topLayout->addWidget( mCreateListButton, 0, 1 ); connect( mCreateListButton, SIGNAL( clicked() ), SLOT( createList() ) ); topLayout->addWidget( mEditListButton, 0, 2 ); connect( mEditListButton, SIGNAL( clicked() ), SLOT( editList() ) ); topLayout->addWidget( mRemoveListButton, 0, 3 ); connect( mRemoveListButton, SIGNAL( clicked() ), SLOT( removeList() ) ); mContactView = new DistributionListView( this ); mContactView->addColumn( i18n( "Name" ) ); mContactView->addColumn( i18n( "Email" ) ); mContactView->addColumn( i18n( "Use Preferred" ) ); mContactView->setEnabled( false ); mContactView->setAllColumnsShowFocus( true ); mContactView->setMinimumHeight( 30 ); topLayout->addMultiCellWidget( mContactView, 1, 1, 0, 3 ); connect( mContactView, SIGNAL( selectionChanged() ), SLOT( selectionContactViewChanged() ) ); - connect( mContactView, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ), - SLOT( dropped( QDropEvent*, QListViewItem* ) ) ); + connect( mContactView, SIGNAL( dropped( QDropEvent*, Q3ListViewItem* ) ), + SLOT( dropped( QDropEvent*, Q3ListViewItem* ) ) ); mAddContactButton->setEnabled( false ); topLayout->addWidget( mAddContactButton, 2, 0 ); connect( mAddContactButton, SIGNAL( clicked() ), SLOT( addContact() ) ); topLayout->addWidget( mChangeEmailButton, 2, 2 ); connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); topLayout->addWidget( mRemoveContactButton, 2, 3 ); connect( mRemoveContactButton, SIGNAL( clicked() ), SLOT( removeContact() ) ); mManager = new KABC::DistributionListManager( core->addressBook() ); mManager->load(); updateNameCombo(); #ifdef KAB_EMBEDDED // if (KGlobal::getOrientation() == KGlobal::Portrait) // parent->setMaximumSize( KGlobal::getDesktopWidth() , 150); #endif //KAB_EMBEDDED #ifndef KAB_EMBEDDED KAcceleratorManager::manage( this ); #endif //KAB_EMBEDDED } DistributionListWidget::~DistributionListWidget() { delete mManager; } void DistributionListWidget::save() @@ -381,121 +388,121 @@ void DistributionListWidget::dropEvent( QDropEvent *e ) #endif //KAB_EMBEDDED QStringList list = QStringList::split( "\r\n\r\n", vcards ); QStringList::Iterator it; KABC::VCardConverter converter; for ( it = list.begin(); it != list.end(); ++it ) { KABC::Addressee addr; if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) distributionList->insertEntry( addr ); } changed(); updateContactView(); #ifndef KAB_EMBEDDED } #endif //KAB_EMBEDDED } void DistributionListWidget::contactsSelectionChanged() { mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 ); } QString DistributionListWidget::title() const { return i18n( "Distribution List Editor" ); } QString DistributionListWidget::identifier() const { return "distribution_list_editor"; } -void DistributionListWidget::dropped( QDropEvent *e, QListViewItem* ) +void DistributionListWidget::dropped( QDropEvent *e, Q3ListViewItem* ) { dropEvent( e ); } void DistributionListWidget::changed() { save(); } DistributionListView::DistributionListView( QWidget *parent, const char* name ) : KListView( parent, name ) { setDragEnabled( true ); setAcceptDrops( true ); setAllColumnsShowFocus( true ); } void DistributionListView::dragEnterEvent( QDragEnterEvent* e ) { #ifndef KAB_EMBEDDED - bool canDecode = QTextDrag::canDecode( e ); + bool canDecode = Q3TextDrag::canDecode( e ); e->accept( canDecode ); #endif //KAB_EMBEDDED } void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e ) { #ifndef KAB_EMBEDDED - bool canDecode = QTextDrag::canDecode( e ); + bool canDecode = Q3TextDrag::canDecode( e ); e->accept( canDecode ); #endif //KAB_EMBEDDED } void DistributionListView::viewportDropEvent( QDropEvent *e ) { emit dropped( e, 0 ); } void DistributionListView::dropEvent( QDropEvent *e ) { emit dropped( e, 0 ); } EmailSelector::EmailSelector( const QStringList &emails, const QString ¤t, QWidget *parent ) : KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, parent ) { - QFrame *topFrame = plainPage(); - QBoxLayout *topLayout = new QVBoxLayout( topFrame ); + Q3Frame *topFrame = plainPage(); + Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame ); - mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), + mButtonGroup = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Email Addresses"), topFrame ); topLayout->addWidget( mButtonGroup ); QStringList::ConstIterator it; for( it = emails.begin(); it != emails.end(); ++it ) { QRadioButton *button = new QRadioButton( *it, mButtonGroup ); if ( (*it) == current ) { button->setDown( true ); } } } QString EmailSelector::selected() { - QButton *button = mButtonGroup->selected(); + QAbstractButton *button = mButtonGroup->selected(); if ( button ) return button->text(); return QString::null; } QString EmailSelector::getEmail( const QStringList &emails, const QString ¤t, QWidget *parent ) { EmailSelector dlg( emails, current, parent ); dlg.exec(); return dlg.selected(); } -#ifndef KAB_EMBEDDED -#include "distributionlistwidget.moc" +#ifndef KAB_EMBEDDED_ +#include "moc_distributionlistwidget.cpp" #endif //KAB_EMBEDDED |