summaryrefslogtreecommitdiffabout
path: root/kaddressbook/undocmds.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/undocmds.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/undocmds.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/undocmds.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp
index 5807dc0..e900b00 100644
--- a/kaddressbook/undocmds.cpp
+++ b/kaddressbook/undocmds.cpp
@@ -1,120 +1,120 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (C) 1999 Don Sanders <sanders@kde.org> 3 Copyright (C) 1999 Don Sanders <sanders@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtextstream.h> 24#include <q3textstream.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kapplication.h> 31#include <kapplication.h>
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33 33
34#include "addresseeutil.h" 34#include "addresseeutil.h"
35#include "addresseeconfig.h" 35#include "addresseeconfig.h"
36#include "kabcore.h" 36#include "kabcore.h"
37 37
38#include "undocmds.h" 38#include "undocmds.h"
39extern bool pasteWithNewUid; 39extern bool pasteWithNewUid;
40///////////////////////////////// 40/////////////////////////////////
41// PwDelete Methods 41// PwDelete Methods
42 42
43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, 43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc,
44 const QStringList &uidList) 44 const QStringList &uidList)
45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) 45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList)
46{ 46{
47 redo(); 47 redo();
48} 48}
49 49
50PwDeleteCommand::~PwDeleteCommand() 50PwDeleteCommand::~PwDeleteCommand()
51{ 51{
52} 52}
53 53
54QString PwDeleteCommand::name() 54QString PwDeleteCommand::name()
55{ 55{
56 return i18n( "Delete" ); 56 return i18n( "Delete" );
57} 57}
58 58
59void PwDeleteCommand::undo() 59void PwDeleteCommand::undo()
60{ 60{
61 // Put it back in the document 61 // Put it back in the document
62 KABC::Addressee::List::Iterator iter; 62 KABC::Addressee::List::Iterator iter;
63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) 63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter)
64 { 64 {
65 mDocument->insertAddressee(*iter); 65 mDocument->insertAddressee(*iter);
66 } 66 }
67 67
68 mAddresseeList.clear(); 68 mAddresseeList.clear();
69} 69}
70 70
71void PwDeleteCommand::redo() 71void PwDeleteCommand::redo()
72{ 72{
73 // Just remove it from the document. This is enough to make the user 73 // Just remove it from the document. This is enough to make the user
74 // Think the item has been deleted 74 // Think the item has been deleted
75 KABC::Addressee a; 75 KABC::Addressee a;
76 QStringList::Iterator iter; 76 QStringList::Iterator iter;
77 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) 77 for (iter = mUidList.begin(); iter != mUidList.end(); ++iter)
78 { 78 {
79 a = mDocument->findByUid(*iter); 79 a = mDocument->findByUid(*iter);
80 mDocument->removeAddressee(a); 80 mDocument->removeAddressee(a);
81 mAddresseeList.append(a); 81 mAddresseeList.append(a);
82 AddresseeConfig::instance()->remove(a.uid()); 82 AddresseeConfig::instance()->remove(a.uid());
83 } 83 }
84} 84}
85 85
86///////////////////////////////// 86/////////////////////////////////
87// PwPaste Methods 87// PwPaste Methods
88 88
89PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) 89PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list )
90 : Command(), mCore( core ), mAddresseeList( list ) 90 : Command(), mCore( core ), mAddresseeList( list )
91{ 91{
92 redo(); 92 redo();
93} 93}
94 94
95QString PwPasteCommand::name() 95QString PwPasteCommand::name()
96{ 96{
97 return i18n( "Paste" ); 97 return i18n( "Paste" );
98} 98}
99 99
100void PwPasteCommand::undo() 100void PwPasteCommand::undo()
101{ 101{
102 KABC::Addressee::List::Iterator it; 102 KABC::Addressee::List::Iterator it;
103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) 103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it )
104 mCore->addressBook()->removeAddressee( *it ); 104 mCore->addressBook()->removeAddressee( *it );
105} 105}
106 106
107void PwPasteCommand::redo() 107void PwPasteCommand::redo()
108{ 108{
109 QStringList uids; 109 QStringList uids;
110 KABC::Addressee::List::Iterator it; 110 KABC::Addressee::List::Iterator it;
111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { 111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) {
112 /* we have to set a new uid for the contact, otherwise insertAddressee() 112 /* we have to set a new uid for the contact, otherwise insertAddressee()
113 ignore it. 113 ignore it.
114 */ 114 */
115 if ( pasteWithNewUid ) 115 if ( pasteWithNewUid )
116 (*it).setUid( KApplication::randomString( 10 ) ); 116 (*it).setUid( KApplication::randomString( 10 ) );
117 uids.append( (*it).uid() ); 117 uids.append( (*it).uid() );
118 mCore->addressBook()->insertAddressee( *it ); 118 mCore->addressBook()->insertAddressee( *it );
119 } 119 }
120 if ( uids.count() < 4 ) { 120 if ( uids.count() < 4 ) {