summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (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
@@ -29,65 +29,65 @@
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
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp
index db773be..5fbeec3 100644
--- a/kaddressbook/undocmds.cpp
+++ b/kaddressbook/undocmds.cpp
@@ -87,68 +87,69 @@ void PwDeleteCommand::redo()
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