summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-07-07 11:56:39 (UTC)
committer zautrix <zautrix>2004-07-07 11:56:39 (UTC)
commit56721aac86c9ae5253abac8962474c8d1a7e648a (patch) (unidiff)
treec12f41eba0d5724ee800cdb92727ffd6d3c1cf6c /kaddressbook
parent13d88c91f2916090bd45e23b504d0b665c68126f (diff)
downloadkdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.zip
kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.gz
kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.bz2
Changes for compiling on desktop
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp1
-rw-r--r--kaddressbook/mainembedded.cpp7
2 files changed, 5 insertions, 3 deletions
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index f84b2ba..eb5bdd9 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,242 +1,243 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h>
29 30
30#include <kbuttonbox.h> 31#include <kbuttonbox.h>
31#include <kcombobox.h> 32#include <kcombobox.h>
32#include <kconfig.h> 33#include <kconfig.h>
33#include <kdialog.h> 34#include <kdialog.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kglobal.h> 36#include <kglobal.h>
36#include <klineedit.h> 37#include <klineedit.h>
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38 39
39#include "addresseewidget.h" 40#include "addresseewidget.h"
40 41
41NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
42 const char *name ) 43 const char *name )
43 : QWidget( parent, name ) 44 : QWidget( parent, name )
44{ 45{
45 if (KGlobal::getOrientation() == KGlobal::Portrait) 46 if (KGlobal::getOrientation() == KGlobal::Portrait)
46 { 47 {
47 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(),
48 KDialog::spacingHintSmall() ); 49 KDialog::spacingHintSmall() );
49 50
50 QLabel *label = new QLabel( i18n( title ), this ); 51 QLabel *label = new QLabel( i18n( title ), this );
51 layout->addWidget( label, 0, 1 ); 52 layout->addWidget( label, 0, 1 );
52 53
53 mBox = new QListBox( this ); 54 mBox = new QListBox( this );
54 mBox->setMaximumSize(70, 70); 55 mBox->setMaximumSize(70, 70);
55 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
56 57
57 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
58 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
59 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
60 bbox->layout(); 61 bbox->layout();
61 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 62 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
62 63
63 mEdit = new KLineEdit( this ); 64 mEdit = new KLineEdit( this );
64 layout->addWidget( mEdit, 1, 1 ); 65 layout->addWidget( mEdit, 1, 1 );
65 //mEdit->setMinimumWidth(50); 66 //mEdit->setMinimumWidth(50);
66 67
67// layout->addWidget( group ); 68// layout->addWidget( group );
68 69
69 } 70 }
70 else 71 else
71 { 72 {
72 QHBoxLayout *layout = new QHBoxLayout( this ); 73 QHBoxLayout *layout = new QHBoxLayout( this );
73 74
74 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this );
75 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2,
76 KDialog::spacingHint() ); 77 KDialog::spacingHint() );
77 78
78 mBox = new QListBox( group ); 79 mBox = new QListBox( group );
79 80
80 groupLayout->addWidget( mBox, 0, 0 ); 81 groupLayout->addWidget( mBox, 0, 0 );
81 82
82 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
83 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
84 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
85 bbox->layout(); 86 bbox->layout();
86 groupLayout->addWidget( bbox, 0, 1 ); 87 groupLayout->addWidget( bbox, 0, 1 );
87 88
88 mEdit = new KLineEdit( group ); 89 mEdit = new KLineEdit( group );
89 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
90 91
91 layout->addWidget( group ); 92 layout->addWidget( group );
92 93
93 } 94 }
94 95
95 mAddButton->setEnabled( false ); 96 mAddButton->setEnabled( false );
96 mRemoveButton->setEnabled( false ); 97 mRemoveButton->setEnabled( false );
97 98
98 99
99 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ),
100 SLOT( selectionChanged( QListBoxItem* ) ) ); 101 SLOT( selectionChanged( QListBoxItem* ) ) );
101 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 102 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
102 SLOT( textChanged( const QString& ) ) ); 103 SLOT( textChanged( const QString& ) ) );
103 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
104 105
105} 106}
106 107
107NamePartWidget::~NamePartWidget() 108NamePartWidget::~NamePartWidget()
108{ 109{
109} 110}
110 111
111void NamePartWidget::setNameParts( const QStringList &list ) 112void NamePartWidget::setNameParts( const QStringList &list )
112{ 113{
113 mBox->clear(); 114 mBox->clear();
114 mBox->insertStringList( list ); 115 mBox->insertStringList( list );
115} 116}
116 117
117QStringList NamePartWidget::nameParts() const 118QStringList NamePartWidget::nameParts() const
118{ 119{
119 QStringList parts; 120 QStringList parts;
120 for ( uint i = 0; i < mBox->count(); ++i ) 121 for ( uint i = 0; i < mBox->count(); ++i )
121 parts.append( mBox->text( i ) ); 122 parts.append( mBox->text( i ) );
122 123
123 return parts; 124 return parts;
124} 125}
125 126
126void NamePartWidget::add() 127void NamePartWidget::add()
127{ 128{
128 if ( !mEdit->text().isEmpty() ) { 129 if ( !mEdit->text().isEmpty() ) {
129 mBox->insertItem( mEdit->text() ); 130 mBox->insertItem( mEdit->text() );
130 emit modified(); 131 emit modified();
131 } 132 }
132 133
133 mEdit->setText( "" ); 134 mEdit->setText( "" );
134} 135}
135 136
136void NamePartWidget::remove() 137void NamePartWidget::remove()
137{ 138{
138 mBox->removeItem( mBox->currentItem() ); 139 mBox->removeItem( mBox->currentItem() );
139 if ( mBox->count() == 0 ) 140 if ( mBox->count() == 0 )
140 selectionChanged( 0 ); 141 selectionChanged( 0 );
141 142
142 emit modified(); 143 emit modified();
143} 144}
144 145
145void NamePartWidget::selectionChanged( QListBoxItem *item ) 146void NamePartWidget::selectionChanged( QListBoxItem *item )
146{ 147{
147 mRemoveButton->setEnabled( item != 0 ); 148 mRemoveButton->setEnabled( item != 0 );
148} 149}
149 150
150void NamePartWidget::textChanged( const QString& text ) 151void NamePartWidget::textChanged( const QString& text )
151{ 152{
152 mAddButton->setEnabled( !text.isEmpty() ); 153 mAddButton->setEnabled( !text.isEmpty() );
153} 154}
154 155
155 156
156AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
157 : QWidget( parent, name ) 158 : QWidget( parent, name )
158{ 159{
159 QGridLayout *layout; 160 QGridLayout *layout;
160 161
161 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
162 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
163 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
164 QString dfn; 165 QString dfn;
165 if (QApplication::desktop()->width() > 320 ) 166 if (QApplication::desktop()->width() > 320 )
166 dfn = i18n( "Default formatted name:" ); 167 dfn = i18n( "Default formatted name:" );
167 else 168 else
168 dfn = i18n( "Def. formatted name:" ); 169 dfn = i18n( "Def. formatted name:" );
169 170
170 QLabel *label = new QLabel( dfn, this ); 171 QLabel *label = new QLabel( dfn, this );
171 172
172 mFormattedNameCombo = new KComboBox( this ); 173 mFormattedNameCombo = new KComboBox( this );
173 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 174 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
174 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
175 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
177 178
178 if (KGlobal::getOrientation() == KGlobal::Portrait) 179 if (KGlobal::getOrientation() == KGlobal::Portrait)
179 { 180 {
180 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(),
181 KDialog::spacingHintSmall() ); 182 KDialog::spacingHintSmall() );
182 183
183 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
184 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
185 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
186 layout->addWidget( label, 3, 0 ); 187 layout->addWidget( label, 3, 0 );
187 layout->addWidget( mFormattedNameCombo, 3, 1 ); 188 layout->addWidget( mFormattedNameCombo, 3, 1 );
188 189
189 } 190 }
190 else 191 else
191 { 192 {
192 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
193 KDialog::spacingHint() ); 194 KDialog::spacingHint() );
194 195
195 layout->addWidget( mPrefix, 0, 0 ); 196 layout->addWidget( mPrefix, 0, 0 );
196 layout->addWidget( mInclusion, 0, 1 ); 197 layout->addWidget( mInclusion, 0, 1 );
197 layout->addWidget( mSuffix, 0, 2 ); 198 layout->addWidget( mSuffix, 0, 2 );
198 layout->addWidget( label, 1, 0 ); 199 layout->addWidget( label, 1, 0 );
199 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
200 } 201 }
201 202
202 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
203 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
206} 207}
207 208
208AddresseeWidget::~AddresseeWidget() 209AddresseeWidget::~AddresseeWidget()
209{ 210{
210} 211}
211 212
212void AddresseeWidget::restoreSettings() 213void AddresseeWidget::restoreSettings()
213{ 214{
214 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
215 config.setGroup( "General" ); 216 config.setGroup( "General" );
216 217
217 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
218 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
219 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
220 221
221 KConfig cfg( locateLocal("config","kaddressbookrc") ); 222 KConfig cfg( locateLocal("config","kaddressbookrc") );
222 cfg.setGroup( "General" ); 223 cfg.setGroup( "General" );
223 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) ); 224 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) );
224} 225}
225 226
226void AddresseeWidget::saveSettings() 227void AddresseeWidget::saveSettings()
227{ 228{
228 KConfig config( locateLocal("config","kabcrc") ); 229 KConfig config( locateLocal("config","kabcrc") );
229 config.setGroup( "General" ); 230 config.setGroup( "General" );
230 231
231 config.writeEntry( "Prefixes", mPrefix->nameParts() ); 232 config.writeEntry( "Prefixes", mPrefix->nameParts() );
232 config.writeEntry( "Inclusions", mInclusion->nameParts() ); 233 config.writeEntry( "Inclusions", mInclusion->nameParts() );
233 config.writeEntry( "Suffixes", mSuffix->nameParts() ); 234 config.writeEntry( "Suffixes", mSuffix->nameParts() );
234 235
235 KConfig cfg( locateLocal("config","kaddressbookrc") ); 236 KConfig cfg( locateLocal("config","kaddressbookrc") );
236 cfg.setGroup( "General" ); 237 cfg.setGroup( "General" );
237 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); 238 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
238} 239}
239 240
240#ifndef KAB_EMBEDDED 241#ifndef KAB_EMBEDDED
241#include "addresseewidget.moc" 242#include "addresseewidget.moc"
242#endif //KAB_EMBEDDED 243#endif //KAB_EMBEDDED
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index dce6a88..cf1fd3e 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,189 +1,190 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#else 4#else
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qwindowsstyle.h> 6#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 7#include <qplatinumstyle.h>
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#endif 9#endif
10 10
11#include <kstandarddirs.h> 11#include <kstandarddirs.h>
12#include <kglobal.h> 12#include <kglobal.h>
13#include <stdio.h> 13#include <stdio.h>
14#include <qdir.h> 14#include <qdir.h>
15#include "kaddressbookmain.h" 15#include "kaddressbookmain.h"
16 16
17int main( int argc, char **argv ) 17int main( int argc, char **argv )
18{ 18{
19#ifndef DESKTOP_VERSION 19#ifndef DESKTOP_VERSION
20 QPEApplication a( argc, argv ); 20 QPEApplication a( argc, argv );
21 a.setKeepRunning (); 21 a.setKeepRunning ();
22#else 22#else
23 QApplication a( argc, argv ); 23 QApplication a( argc, argv );
24 QApplication::setStyle( new QPlatinumStyle ()); 24 QApplication::setStyle( new QPlatinumStyle ());
25#endif 25#endif
26 26
27 bool exitHelp = false; 27 bool exitHelp = false;
28 if ( argc > 1 ) { 28 if ( argc > 1 ) {
29 QString command = argv[1]; 29 QString command = argv[1];
30 if ( command == "-help" ){ 30 if ( command == "-help" ){
31 printf("KA/E command line commands:\n"); 31 printf("KA/E command line commands:\n");
32 printf(" no command: Start KA/E in usual way\n"); 32 printf(" no command: Start KA/E in usual way\n");
33 printf(" -help: This output\n"); 33 printf(" -help: This output\n");
34 printf(" KA/E is exiting now. Bye!\n"); 34 printf(" KA/E is exiting now. Bye!\n");
35 exitHelp = true; 35 exitHelp = true;
36 } 36 }
37 } 37 }
38 if ( ! exitHelp ) { 38 if ( ! exitHelp ) {
39 39
40 KGlobal::setAppName( "kaddressbook" ); 40 KGlobal::setAppName( "kaddressbook" );
41#ifndef DESKTOP_VERSION 41#ifndef DESKTOP_VERSION
42 if ( QApplication::desktop()->width() > 320 ) 42 if ( QApplication::desktop()->width() > 320 )
43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
44 else 44 else
45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
46#else 46#else
47 QString fileName ; 47 QString fileName ;
48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; 48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
50 QApplication::addLibraryPath ( qApp->applicationDirPath () );
50 51
51#endif 52#endif
52 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
53 KAddressBookMain m ; 54 KAddressBookMain m ;
54//US MainWindow m; 55//US MainWindow m;
55//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 56//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
56 57
57#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
58 a.showMainWidget( &m ); 59 a.showMainWidget( &m );
59#else 60#else
60 a.setMainWidget(m ); 61 a.setMainWidget( &m );
61 m->show(); 62 m.show();
62#endif 63#endif
63 a.exec(); 64 a.exec();
64 65
65 } 66 }
66 qDebug("KA: Bye! "); 67 qDebug("KA: Bye! ");
67} 68}
68 69
69/* 70/*
70#include <stdlib.h> 71#include <stdlib.h>
71 72
72#include <qstring.h> 73#include <qstring.h>
73 74
74#include <kabc/stdaddressbook.h> 75#include <kabc/stdaddressbook.h>
75#include <kaboutdata.h> 76#include <kaboutdata.h>
76#include <kcmdlineargs.h> 77#include <kcmdlineargs.h>
77#include <kcrash.h> 78#include <kcrash.h>
78#include <kdebug.h> 79#include <kdebug.h>
79#include <klocale.h> 80#include <klocale.h>
80#include <kstartupinfo.h> 81#include <kstartupinfo.h>
81#include <kuniqueapplication.h> 82#include <kuniqueapplication.h>
82#include <kwin.h> 83#include <kwin.h>
83 84
84#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
85#include "kabcore.h" 86#include "kabcore.h"
86 87
87extern "C" { 88extern "C" {
88 89
89void crashHandler( int ) 90void crashHandler( int )
90{ 91{
91 KABC::StdAddressBook::handleCrash(); 92 KABC::StdAddressBook::handleCrash();
92 ::exit( 0 ); 93 ::exit( 0 );
93} 94}
94 95
95} 96}
96 97
97class KAddressBookApp : public KUniqueApplication { 98class KAddressBookApp : public KUniqueApplication {
98 public: 99 public:
99 KAddressBookApp() : mMainWin( 0 ) {} 100 KAddressBookApp() : mMainWin( 0 ) {}
100 ~KAddressBookApp() {} 101 ~KAddressBookApp() {}
101 102
102 int newInstance(); 103 int newInstance();
103 104
104 private: 105 private:
105 KAddressBookMain *mMainWin; 106 KAddressBookMain *mMainWin;
106}; 107};
107 108
108int KAddressBookApp::newInstance() 109int KAddressBookApp::newInstance()
109{ 110{
110 if ( isRestored() ) { 111 if ( isRestored() ) {
111 // There can only be one main window 112 // There can only be one main window
112 if ( KMainWindow::canBeRestored( 1 ) ) { 113 if ( KMainWindow::canBeRestored( 1 ) ) {
113 mMainWin = new KAddressBookMain; 114 mMainWin = new KAddressBookMain;
114 mMainWin->show(); 115 mMainWin->show();
115 mMainWin->restore( 1 ); 116 mMainWin->restore( 1 );
116 } 117 }
117 } else { 118 } else {
118 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 119 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
119 120
120 QCString addrStr = args->getOption( "addr" ); 121 QCString addrStr = args->getOption( "addr" );
121 QCString uidStr = args->getOption( "uid" ); 122 QCString uidStr = args->getOption( "uid" );
122 QString addr; 123 QString addr;
123 QString uid; 124 QString uid;
124 if ( !addrStr.isEmpty() ) 125 if ( !addrStr.isEmpty() )
125 addr = QString::fromLocal8Bit( addrStr ); 126 addr = QString::fromLocal8Bit( addrStr );
126 if ( !uidStr.isEmpty() ) 127 if ( !uidStr.isEmpty() )
127 uid = QString::fromLocal8Bit( uidStr ); 128 uid = QString::fromLocal8Bit( uidStr );
128 129
129 130
130 if ( args->isSet( "editor-only" ) ) { 131 if ( args->isSet( "editor-only" ) ) {
131 if ( !mMainWin ) 132 if ( !mMainWin )
132 mMainWin = new KAddressBookMain; 133 mMainWin = new KAddressBookMain;
133 KStartupInfo::appStarted(); 134 KStartupInfo::appStarted();
134 mMainWin->hide(); 135 mMainWin->hide();
135 } else { 136 } else {
136 if ( mMainWin ) { 137 if ( mMainWin ) {
137 mMainWin->show(); 138 mMainWin->show();
138 KWin::setActiveWindow( mMainWin->winId() ); 139 KWin::setActiveWindow( mMainWin->winId() );
139 } else { 140 } else {
140 mMainWin = new KAddressBookMain; 141 mMainWin = new KAddressBookMain;
141 mMainWin->show(); 142 mMainWin->show();
142 } 143 }
143 } 144 }
144 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 145 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
145 if ( !addr.isEmpty() ) 146 if ( !addr.isEmpty() )
146 mMainWin->addEmail( addr ); 147 mMainWin->addEmail( addr );
147 148
148 if ( !uid.isEmpty() ) 149 if ( !uid.isEmpty() )
149 mMainWin->showContactEditor( uid ); 150 mMainWin->showContactEditor( uid );
150 if ( args->isSet( "new-contact" ) ) { 151 if ( args->isSet( "new-contact" ) ) {
151 mMainWin->newContact(); 152 mMainWin->newContact();
152 } 153 }
153 } 154 }
154 155
155 KCrash::setEmergencySaveFunction( crashHandler ); 156 KCrash::setEmergencySaveFunction( crashHandler );
156 157
157 return 0; 158 return 0;
158} 159}
159 160
160// the dummy argument is required, because KMail apparently sends an empty 161// the dummy argument is required, because KMail apparently sends an empty
161// argument. 162// argument.
162static KCmdLineOptions kmoptions[] = 163static KCmdLineOptions kmoptions[] =
163{ 164{
164 { "a", 0 , 0 }, 165 { "a", 0 , 0 },
165 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 166 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
166 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 167 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
167 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 168 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
168 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 169 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
169 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 170 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
170 { 0, 0, 0} 171 { 0, 0, 0}
171}; 172};
172 173
173int main( int argc, char *argv[] ) 174int main( int argc, char *argv[] )
174{ 175{
175 KLocale::setMainCatalogue( "kaddressbook" ); 176 KLocale::setMainCatalogue( "kaddressbook" );
176 177
177 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 178 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
178 KCmdLineArgs::addCmdLineOptions( kmoptions ); 179 KCmdLineArgs::addCmdLineOptions( kmoptions );
179 KUniqueApplication::addCmdLineOptions(); 180 KUniqueApplication::addCmdLineOptions();
180 181
181 if ( !KAddressBookApp::start() ) 182 if ( !KAddressBookApp::start() )
182 exit( 0 ); 183 exit( 0 );
183 184
184 KAddressBookApp app; 185 KAddressBookApp app;
185 KGlobal::locale()->insertCatalogue( "libkdepim" ); 186 KGlobal::locale()->insertCatalogue( "libkdepim" );
186 187
187 return app.exec(); 188 return app.exec();
188} 189}
189*/ 190*/