author | zautrix <zautrix> | 2004-07-05 14:16:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-05 14:16:54 (UTC) |
commit | 9a90061115ee2cac8adc5b2d21e607b6c5c9b890 (patch) (unidiff) | |
tree | 87efb03b00559f3a7fbb5c693d6d7b734f0d1eb7 /kaddressbook/undocmds.cpp | |
parent | af75333f69c6b7284a7fbe7ab63c08e10ae4541b (diff) | |
download | kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.zip kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.tar.gz kdepimpi-9a90061115ee2cac8adc5b2d21e607b6c5c9b890.tar.bz2 |
Improved pasting of many items
-rw-r--r-- | kaddressbook/undocmds.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp index db773be..5fbeec3 100644 --- a/kaddressbook/undocmds.cpp +++ b/kaddressbook/undocmds.cpp | |||
@@ -55,132 +55,133 @@ QString PwDeleteCommand::name() | |||
55 | { | 55 | { |
56 | return i18n( "Delete" ); | 56 | return i18n( "Delete" ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void PwDeleteCommand::undo() | 59 | void 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 | ||
71 | void PwDeleteCommand::redo() | 71 | void 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 | ||
89 | PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) | 89 | PwPasteCommand::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 | ||
95 | QString PwPasteCommand::name() | 95 | QString PwPasteCommand::name() |
96 | { | 96 | { |
97 | return i18n( "Paste" ); | 97 | return i18n( "Paste" ); |
98 | } | 98 | } |
99 | 99 | ||
100 | void PwPasteCommand::undo() | 100 | void 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 | ||
107 | void PwPasteCommand::redo() | 107 | void 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 | (*it).setUid( KApplication::randomString( 10 ) ); | 115 | (*it).setUid( KApplication::randomString( 10 ) ); |
116 | uids.append( (*it).uid() ); | 116 | uids.append( (*it).uid() ); |
117 | mCore->addressBook()->insertAddressee( *it ); | 117 | mCore->addressBook()->insertAddressee( *it ); |
118 | } | 118 | } |
119 | 119 | if ( uids.count() < 4 ) { | |
120 | QStringList::Iterator uidIt; | 120 | QStringList::Iterator uidIt; |
121 | for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) | 121 | for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) |
122 | mCore->editContact( *uidIt ); | 122 | mCore->editContact( *uidIt ); |
123 | } | ||
123 | } | 124 | } |
124 | 125 | ||
125 | ///////////////////////////////// | 126 | ///////////////////////////////// |
126 | // PwNew Methods | 127 | // PwNew Methods |
127 | 128 | ||
128 | PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) | 129 | PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) |
129 | : Command(), mDocument( doc ), mA( a ) | 130 | : Command(), mDocument( doc ), mA( a ) |
130 | { | 131 | { |
131 | mDocument->insertAddressee(mA); | 132 | mDocument->insertAddressee(mA); |
132 | } | 133 | } |
133 | 134 | ||
134 | PwNewCommand::~PwNewCommand() | 135 | PwNewCommand::~PwNewCommand() |
135 | { | 136 | { |
136 | } | 137 | } |
137 | 138 | ||
138 | QString PwNewCommand::name() | 139 | QString PwNewCommand::name() |
139 | { | 140 | { |
140 | return i18n( "New Contact" ); | 141 | return i18n( "New Contact" ); |
141 | } | 142 | } |
142 | 143 | ||
143 | void PwNewCommand::undo() | 144 | void PwNewCommand::undo() |
144 | { | 145 | { |
145 | mDocument->removeAddressee( mA ); | 146 | mDocument->removeAddressee( mA ); |
146 | } | 147 | } |
147 | 148 | ||
148 | void PwNewCommand::redo() | 149 | void PwNewCommand::redo() |
149 | { | 150 | { |
150 | mDocument->insertAddressee( mA ); | 151 | mDocument->insertAddressee( mA ); |
151 | } | 152 | } |
152 | 153 | ||
153 | ///////////////////////////////// | 154 | ///////////////////////////////// |
154 | // PwEdit Methods | 155 | // PwEdit Methods |
155 | 156 | ||
156 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, | 157 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, |
157 | const KABC::Addressee &oldA, | 158 | const KABC::Addressee &oldA, |
158 | const KABC::Addressee &newA ) | 159 | const KABC::Addressee &newA ) |
159 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) | 160 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) |
160 | { | 161 | { |
161 | redo(); | 162 | redo(); |
162 | } | 163 | } |
163 | 164 | ||
164 | PwEditCommand::~PwEditCommand() | 165 | PwEditCommand::~PwEditCommand() |
165 | { | 166 | { |
166 | } | 167 | } |
167 | 168 | ||
168 | QString PwEditCommand::name() | 169 | QString PwEditCommand::name() |
169 | { | 170 | { |
170 | return i18n( "Entry Edit" ); | 171 | return i18n( "Entry Edit" ); |
171 | } | 172 | } |
172 | 173 | ||
173 | void PwEditCommand::undo() | 174 | void PwEditCommand::undo() |
174 | { | 175 | { |
175 | mDocument->insertAddressee(mOldA); | 176 | mDocument->insertAddressee(mOldA); |
176 | } | 177 | } |
177 | 178 | ||
178 | void PwEditCommand::redo() | 179 | void PwEditCommand::redo() |
179 | { | 180 | { |
180 | mDocument->insertAddressee(mNewA); | 181 | mDocument->insertAddressee(mNewA); |
181 | } | 182 | } |
182 | 183 | ||
183 | ///////////////////////////////// | 184 | ///////////////////////////////// |
184 | // PwCut Methods | 185 | // PwCut Methods |
185 | 186 | ||
186 | PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) | 187 | PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) |