summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseeeditordialog.cpp
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kaddressbook/addresseeeditordialog.cpp
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'kaddressbook/addresseeeditordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditordialog.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
new file mode 100644
index 0000000..102138e
--- a/dev/null
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -0,0 +1,129 @@
1/*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
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
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25
26#include <kdebug.h>
27#include <klocale.h>
28#include <kglobal.h>
29
30#include "addresseeeditorwidget.h"
31#include "kabcore.h"
32
33#include "addresseeeditordialog.h"
34
35AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent,
36 const char *name )
37 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
38 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
39 KDialogBase::Ok, parent, name, false )
40{
41#ifdef KAB_EMBEDDED
42 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
43#endif //KAB_EMBEDDED
44
45 kdDebug(5720) << "AddresseeEditorDialog()" << endl;
46
47 QWidget *page = plainPage();
48
49 QVBoxLayout *layout = new QVBoxLayout( page );
50
51 mEditorWidget = new AddresseeEditorWidget( core, false, page );
52 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
53 SLOT( widgetModified() ) );
54 layout->addWidget( mEditorWidget );
55
56 enableButton( KDialogBase::Apply, false );
57}
58
59AddresseeEditorDialog::~AddresseeEditorDialog()
60{
61 kdDebug(5720) << "~AddresseeEditorDialog()" << endl;
62
63 emit editorDestroyed( mEditorWidget->addressee().uid() );
64}
65
66void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
67{
68 enableButton( KDialogBase::Apply, false );
69
70 mEditorWidget->setAddressee( addr );
71}
72
73KABC::Addressee AddresseeEditorDialog::addressee()
74{
75 return mEditorWidget->addressee();
76}
77
78bool AddresseeEditorDialog::dirty()
79{
80 return mEditorWidget->dirty();
81}
82
83void AddresseeEditorDialog::slotApply()
84{
85 if ( mEditorWidget->dirty() ) {
86 mEditorWidget->save();
87 emit contactModified( mEditorWidget->addressee() );
88 }
89
90 enableButton( KDialogBase::Apply, false );
91
92 KDialogBase::slotApply();
93}
94
95void AddresseeEditorDialog::slotOk()
96{
97 slotApply();
98
99 KDialogBase::slotOk();
100
101 // Destroy this dialog
102#ifndef KAB_EMBEDDED
103 delayedDestruct();
104#else //KAB_EMBEDDED
105 delete this;
106#endif //KAB_EMBEDDED
107}
108
109void AddresseeEditorDialog::widgetModified()
110{
111 enableButton( KDialogBase::Apply, true );
112}
113
114void AddresseeEditorDialog::slotCancel()
115{
116 KDialogBase::slotCancel();
117
118 // Destroy this dialog
119#ifndef KAB_EMBEDDED
120 delayedDestruct();
121#else //KAB_EMBEDDED
122 delete this;
123#endif //KAB_EMBEDDED
124
125}
126
127#ifndef KAB_EMBEDDED
128#include "addresseeeditordialog.moc"
129#endif //KAB_EMBEDDED