summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditordialog.cpp2
-rw-r--r--kaddressbook/undocmds.cpp9
2 files changed, 6 insertions, 5 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
index 790f148..6bc4129 100644
--- a/kaddressbook/addresseeeditordialog.cpp
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -13,97 +13,97 @@
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 <qlayout.h> 24#include <qlayout.h>
25#include <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <klocale.h> 28#include <klocale.h>
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31#include "addresseeeditorwidget.h" 31#include "addresseeeditorwidget.h"
32#include "kabcore.h" 32#include "kabcore.h"
33 33
34#include "addresseeeditordialog.h" 34#include "addresseeeditordialog.h"
35 35
36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, 36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent,
37 const char *name ) 37 const char *name )
38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, 39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
40 KDialogBase::Ok, parent, name, true ) 40 KDialogBase::Ok, parent, name, true )
41{ 41{
42 42
43 43
44 QWidget *page = plainPage(); 44 QWidget *page = plainPage();
45 45
46 QVBoxLayout *layout = new QVBoxLayout( page ); 46 QVBoxLayout *layout = new QVBoxLayout( page );
47 47
48 mEditorWidget = new AddresseeEditorWidget( core, false, page ); 48 mEditorWidget = new AddresseeEditorWidget( core, false, page );
49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), 49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
50 SLOT( widgetModified() ) ); 50 SLOT( widgetModified() ) );
51 layout->addWidget( mEditorWidget ); 51 layout->addWidget( mEditorWidget );
52 52
53 enableButton( KDialogBase::Apply, false ); 53 enableButton( KDialogBase::Apply, false );
54 if ( QApplication::desktop()->width() < 480 ) { 54 if ( QApplication::desktop()->width() < 480 ) {
55 hideButtons(); 55 hideButtons();
56 } 56 }
57} 57}
58 58
59AddresseeEditorDialog::~AddresseeEditorDialog() 59AddresseeEditorDialog::~AddresseeEditorDialog()
60{ 60{
61 qDebug("----------------------------------------------- "); 61 qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()");
62 //emit editorDestroyed( mEditorWidget->addressee().uid() ); 62 //emit editorDestroyed( mEditorWidget->addressee().uid() );
63} 63}
64 64
65void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) 65void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
66{ 66{
67 enableButton( KDialogBase::Apply, false ); 67 enableButton( KDialogBase::Apply, false );
68 68
69 mEditorWidget->setAddressee( addr ); 69 mEditorWidget->setAddressee( addr );
70} 70}
71 71
72KABC::Addressee AddresseeEditorDialog::addressee() 72KABC::Addressee AddresseeEditorDialog::addressee()
73{ 73{
74 return mEditorWidget->addressee(); 74 return mEditorWidget->addressee();
75} 75}
76 76
77bool AddresseeEditorDialog::dirty() 77bool AddresseeEditorDialog::dirty()
78{ 78{
79 return mEditorWidget->dirty(); 79 return mEditorWidget->dirty();
80} 80}
81 81
82void AddresseeEditorDialog::slotApply() 82void AddresseeEditorDialog::slotApply()
83{ 83{
84 if ( mEditorWidget->dirty() ) { 84 if ( mEditorWidget->dirty() ) {
85 mEditorWidget->save(); 85 mEditorWidget->save();
86 emit contactModified( mEditorWidget->addressee() ); 86 emit contactModified( mEditorWidget->addressee() );
87 } 87 }
88 88
89 enableButton( KDialogBase::Apply, false ); 89 enableButton( KDialogBase::Apply, false );
90 90
91 KDialogBase::slotApply(); 91 KDialogBase::slotApply();
92} 92}
93 93
94void AddresseeEditorDialog:: accept () 94void AddresseeEditorDialog:: accept ()
95{ 95{
96 slotOk(); 96 slotOk();
97 97
98} 98}
99void AddresseeEditorDialog::slotOk() 99void AddresseeEditorDialog::slotOk()
100{ 100{
101 slotApply(); 101 slotApply();
102 102
103 KDialogBase::slotOk(); 103 KDialogBase::slotOk();
104 104
105} 105}
106 106
107void AddresseeEditorDialog::widgetModified() 107void AddresseeEditorDialog::widgetModified()
108{ 108{
109 enableButton( KDialogBase::Apply, true ); 109 enableButton( KDialogBase::Apply, true );
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp
index db773be..5fbeec3 100644
--- a/kaddressbook/undocmds.cpp
+++ b/kaddressbook/undocmds.cpp
@@ -71,100 +71,101 @@ void PwDeleteCommand::undo()
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 (*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
128PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) 129PwNewCommand::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
134PwNewCommand::~PwNewCommand() 135PwNewCommand::~PwNewCommand()
135{ 136{
136} 137}
137 138
138QString PwNewCommand::name() 139QString PwNewCommand::name()
139{ 140{
140 return i18n( "New Contact" ); 141 return i18n( "New Contact" );
141} 142}
142 143
143void PwNewCommand::undo() 144void PwNewCommand::undo()
144{ 145{
145 mDocument->removeAddressee( mA ); 146 mDocument->removeAddressee( mA );
146} 147}
147 148
148void PwNewCommand::redo() 149void 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
156PwEditCommand::PwEditCommand(KABC::AddressBook *doc, 157PwEditCommand::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
164PwEditCommand::~PwEditCommand() 165PwEditCommand::~PwEditCommand()
165{ 166{
166} 167}
167 168
168QString PwEditCommand::name() 169QString PwEditCommand::name()
169{ 170{
170 return i18n( "Entry Edit" ); 171 return i18n( "Entry Edit" );