author | zautrix <zautrix> | 2004-07-05 14:16:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-05 14:16:54 (UTC) |
commit | 9a90061115ee2cac8adc5b2d21e607b6c5c9b890 (patch) (side-by-side diff) | |
tree | 87efb03b00559f3a7fbb5c693d6d7b734f0d1eb7 | |
parent | af75333f69c6b7284a7fbe7ab63c08e10ae4541b (diff) | |
download | kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.zip kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.tar.gz kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.tar.bz2 |
Improved pasting of many items
-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/undocmds.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index 790f148..6bc4129 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -1,121 +1,121 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 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 <qlayout.h> #include <qapplication.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include "addresseeeditorwidget.h" #include "kabcore.h" #include "addresseeeditordialog.h" AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, const char *name ) : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, KDialogBase::Ok, parent, name, true ) { QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page ); mEditorWidget = new AddresseeEditorWidget( core, false, page ); connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), SLOT( widgetModified() ) ); layout->addWidget( mEditorWidget ); enableButton( KDialogBase::Apply, false ); if ( QApplication::desktop()->width() < 480 ) { hideButtons(); } } AddresseeEditorDialog::~AddresseeEditorDialog() { - qDebug("----------------------------------------------- "); + qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()"); //emit editorDestroyed( mEditorWidget->addressee().uid() ); } void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) { enableButton( KDialogBase::Apply, false ); mEditorWidget->setAddressee( addr ); } KABC::Addressee AddresseeEditorDialog::addressee() { return mEditorWidget->addressee(); } bool AddresseeEditorDialog::dirty() { return mEditorWidget->dirty(); } void AddresseeEditorDialog::slotApply() { if ( mEditorWidget->dirty() ) { mEditorWidget->save(); emit contactModified( mEditorWidget->addressee() ); } enableButton( KDialogBase::Apply, false ); KDialogBase::slotApply(); } void AddresseeEditorDialog:: accept () { slotOk(); } void AddresseeEditorDialog::slotOk() { slotApply(); KDialogBase::slotOk(); } void AddresseeEditorDialog::widgetModified() { enableButton( KDialogBase::Apply, true ); } void AddresseeEditorDialog::slotCancel() { KDialogBase::slotCancel(); } #ifndef KAB_EMBEDDED #include "addresseeeditordialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp index db773be..5fbeec3 100644 --- a/kaddressbook/undocmds.cpp +++ b/kaddressbook/undocmds.cpp @@ -1,240 +1,241 @@ /* This file is part of KAddressBook. Copyright (C) 1999 Don Sanders <sanders@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 <qtextstream.h> #include <qapplication.h> #include <qclipboard.h> #include <klocale.h> #include <kdebug.h> #include <kapplication.h> #include <kabc/addressbook.h> #include "addresseeutil.h" #include "addresseeconfig.h" #include "kabcore.h" #include "undocmds.h" ///////////////////////////////// // PwDelete Methods PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, const QStringList &uidList) : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) { redo(); } PwDeleteCommand::~PwDeleteCommand() { } QString PwDeleteCommand::name() { return i18n( "Delete" ); } void PwDeleteCommand::undo() { // Put it back in the document KABC::Addressee::List::Iterator iter; for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) { mDocument->insertAddressee(*iter); } mAddresseeList.clear(); } void PwDeleteCommand::redo() { // Just remove it from the document. This is enough to make the user // Think the item has been deleted KABC::Addressee a; QStringList::Iterator iter; for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) { a = mDocument->findByUid(*iter); mDocument->removeAddressee(a); mAddresseeList.append(a); AddresseeConfig::instance()->remove(a.uid()); } } ///////////////////////////////// // PwPaste Methods PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) : Command(), mCore( core ), mAddresseeList( list ) { redo(); } QString PwPasteCommand::name() { return i18n( "Paste" ); } void PwPasteCommand::undo() { KABC::Addressee::List::Iterator it; for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) mCore->addressBook()->removeAddressee( *it ); } void PwPasteCommand::redo() { QStringList uids; KABC::Addressee::List::Iterator it; for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { /* we have to set a new uid for the contact, otherwise insertAddressee() ignore it. */ (*it).setUid( KApplication::randomString( 10 ) ); uids.append( (*it).uid() ); mCore->addressBook()->insertAddressee( *it ); } - + if ( uids.count() < 4 ) { QStringList::Iterator uidIt; for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) mCore->editContact( *uidIt ); } +} ///////////////////////////////// // PwNew Methods PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) : Command(), mDocument( doc ), mA( a ) { mDocument->insertAddressee(mA); } PwNewCommand::~PwNewCommand() { } QString PwNewCommand::name() { return i18n( "New Contact" ); } void PwNewCommand::undo() { mDocument->removeAddressee( mA ); } void PwNewCommand::redo() { mDocument->insertAddressee( mA ); } ///////////////////////////////// // PwEdit Methods PwEditCommand::PwEditCommand(KABC::AddressBook *doc, const KABC::Addressee &oldA, const KABC::Addressee &newA ) : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) { redo(); } PwEditCommand::~PwEditCommand() { } QString PwEditCommand::name() { return i18n( "Entry Edit" ); } void PwEditCommand::undo() { mDocument->insertAddressee(mOldA); } void PwEditCommand::redo() { mDocument->insertAddressee(mNewA); } ///////////////////////////////// // PwCut Methods PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList), mClipText(), mOldText() { redo(); } QString PwCutCommand::name() { return i18n( "Cut" ); } void PwCutCommand::undo() { KABC::Addressee::List::Iterator iter; for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) { mDocument->insertAddressee(*iter); } mAddresseeList.clear(); QClipboard *cb = QApplication::clipboard(); //US #ifndef KAB_EMBEDDED kapp->processEvents(); #else //KAB_EMBEDDED qApp->processEvents(); #endif //KAB_EMBEDDED cb->setText( mOldText ); } void PwCutCommand::redo() { KABC::Addressee a; QStringList::Iterator iter; for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) { a = mDocument->findByUid(*iter); mDocument->removeAddressee(a); mAddresseeList.append(a); } // Convert to clipboard mClipText = AddresseeUtil::addresseesToClipboard(mAddresseeList); QClipboard *cb = QApplication::clipboard(); mOldText = cb->text(); //US #ifndef KAB_EMBEDDED kapp->processEvents(); #else //KAB_EMBEDDED qApp->processEvents(); #endif //KAB_EMBEDDED cb->setText( mClipText ); } |