summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kresources
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kresources') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp17
-rw-r--r--microkde/kresources/configpage.cpp38
-rw-r--r--microkde/kresources/configpage.h10
-rw-r--r--microkde/kresources/factory.cpp6
-rw-r--r--microkde/kresources/factory.h4
-rw-r--r--microkde/kresources/kcmkresources.cpp7
-rw-r--r--microkde/kresources/manager.h8
-rw-r--r--microkde/kresources/managerimpl.cpp10
-rw-r--r--microkde/kresources/managerimpl.h8
-rw-r--r--microkde/kresources/resource.h4
-rw-r--r--microkde/kresources/selectdialog.cpp22
-rw-r--r--microkde/kresources/selectdialog.h10
12 files changed, 82 insertions, 62 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 55253c0..4820faf 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -1,179 +1,182 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <q3groupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvbox.h> 32#include <q3vbox.h>
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h> 35#include <q3scrollview.h>
36//Added by qt3to4:
37#include <Q3VBoxLayout>
38#include <Q3Frame>
36 39
37#include <kbuttonbox.h> 40#include <kbuttonbox.h>
38#include <kdialog.h> 41#include <kdialog.h>
39#include <klineedit.h> 42#include <klineedit.h>
40 43
41#include "factory.h" 44#include "factory.h"
42#include "configwidget.h" 45#include "configwidget.h"
43#include "configdialog.h" 46#include "configdialog.h"
44 47
45using namespace KRES; 48using namespace KRES;
46 49
47ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 50ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
48 Resource* resource, const char *name ) 51 Resource* resource, const char *name )
49 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), 52 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
50 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) 53 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
51{ 54{
52 55
53 Factory *factory = Factory::self( resourceFamily ); 56 Factory *factory = Factory::self( resourceFamily );
54 57
55//US resize( 250, 240 ); 58//US resize( 250, 240 );
56 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 59 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
57 60
58 QFrame *main; 61 Q3Frame *main;
59 62
60 main = plainPage(); 63 main = plainPage();
61 64
62 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 65 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main, 0, spacingHint() );
63 66
64 67
65 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 68 Q3GroupBox *generalGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
66 generalGroupBox->layout()->setSpacing( spacingHint() ); 69 generalGroupBox->layout()->setSpacing( spacingHint() );
67 generalGroupBox->setTitle( i18n( "General Settings" ) ); 70 generalGroupBox->setTitle( i18n( "General Settings" ) );
68 71
69 new QLabel( i18n( "Name:" ), generalGroupBox ); 72 new QLabel( i18n( "Name:" ), generalGroupBox );
70 73
71 mName = new KLineEdit( generalGroupBox ); 74 mName = new KLineEdit( generalGroupBox );
72 75
73 new QLabel("", generalGroupBox ); 76 new QLabel("", generalGroupBox );
74 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 77 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
75 mReadOnly->setChecked( mResource->readOnly() ); 78 mReadOnly->setChecked( mResource->readOnly() );
76 79
77 new QLabel("", generalGroupBox ); 80 new QLabel("", generalGroupBox );
78 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); 81 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox );
79 mIncludeInSync->setChecked( mResource->includeInSync() ); 82 mIncludeInSync->setChecked( mResource->includeInSync() );
80 83
81 mName->setText( mResource->resourceName() ); 84 mName->setText( mResource->resourceName() );
82 85
83 mainLayout->addWidget( generalGroupBox ); 86 mainLayout->addWidget( generalGroupBox );
84 87
85 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 88 Q3GroupBox *resourceGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
86 resourceGroupBox->layout()->setSpacing( spacingHint()); 89 resourceGroupBox->layout()->setSpacing( spacingHint());
87 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 90 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
88 .arg( factory->typeName( resource->type() ) ) ); 91 .arg( factory->typeName( resource->type() ) ) );
89 mainLayout->addWidget( resourceGroupBox ); 92 mainLayout->addWidget( resourceGroupBox );
90 93
91 mainLayout->addStretch(); 94 mainLayout->addStretch();
92 95
93 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 96 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
94 if ( mConfigWidget ) { 97 if ( mConfigWidget ) {
95 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 98 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
96 SLOT( setReadOnly( bool ) ) ); 99 SLOT( setReadOnly( bool ) ) );
97 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ), 100 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ),
98 SLOT( setIncludeInSync( bool ) ) ); 101 SLOT( setIncludeInSync( bool ) ) );
99 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 102 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
100 SLOT( setPersistentReadOnly( bool ) ) ); 103 SLOT( setPersistentReadOnly( bool ) ) );
101 mConfigWidget->setInEditMode( false ); 104 mConfigWidget->setInEditMode( false );
102 mConfigWidget->loadSettings( mResource ); 105 mConfigWidget->loadSettings( mResource );
103 mConfigWidget->show(); 106 mConfigWidget->show();
104 107
105 } 108 }
106 109
107 110
108 connect( mName, SIGNAL( textChanged(const QString &)), 111 connect( mName, SIGNAL( textChanged(const QString &)),
109 SLOT( slotNameChanged(const QString &))); 112 SLOT( slotNameChanged(const QString &)));
110 113
111 slotNameChanged( mName->text() ); 114 slotNameChanged( mName->text() );
112 115
113//US setMinimumSize( 400, 250 ); 116//US setMinimumSize( 400, 250 );
114 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 117 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
115 118
116} 119}
117 120
118void ConfigDialog::setInEditMode( bool value ) 121void ConfigDialog::setInEditMode( bool value )
119{ 122{
120 if ( mConfigWidget ) 123 if ( mConfigWidget )
121 mConfigWidget->setInEditMode( value ); 124 mConfigWidget->setInEditMode( value );
122} 125}
123 126
124void ConfigDialog::slotNameChanged( const QString &text) 127void ConfigDialog::slotNameChanged( const QString &text)
125{ 128{
126 enableButtonOK( !text.isEmpty() ); 129 enableButtonOK( !text.isEmpty() );
127} 130}
128 131
129void ConfigDialog::setReadOnly( bool value ) 132void ConfigDialog::setReadOnly( bool value )
130{ 133{
131 if (mPersistentReadOnly == false) 134 if (mPersistentReadOnly == false)
132 mReadOnly->setChecked( value ); 135 mReadOnly->setChecked( value );
133 else 136 else
134 mReadOnly->setChecked( true ); 137 mReadOnly->setChecked( true );
135} 138}
136 139
137void ConfigDialog::setIncludeInSync( bool value ) 140void ConfigDialog::setIncludeInSync( bool value )
138{ 141{
139 if (mPersistentReadOnly == false) 142 if (mPersistentReadOnly == false)
140 mIncludeInSync->setChecked( value ); 143 mIncludeInSync->setChecked( value );
141 else 144 else
142 mIncludeInSync->setChecked( false ); 145 mIncludeInSync->setChecked( false );
143} 146}
144 147
145void ConfigDialog::setPersistentReadOnly( bool value ) 148void ConfigDialog::setPersistentReadOnly( bool value )
146{ 149{
147 mPersistentReadOnly = value; 150 mPersistentReadOnly = value;
148 151
149 if (value == true) { 152 if (value == true) {
150 setReadOnly( true ); 153 setReadOnly( true );
151 setIncludeInSync( false ); 154 setIncludeInSync( false );
152 } 155 }
153 156
154 mReadOnly->setEnabled( !value ); 157 mReadOnly->setEnabled( !value );
155 mIncludeInSync->setEnabled (!value ); 158 mIncludeInSync->setEnabled (!value );
156} 159}
157 160
158 161
159void ConfigDialog::accept() 162void ConfigDialog::accept()
160{ 163{
161 if ( mName->text().isEmpty() ) { 164 if ( mName->text().isEmpty() ) {
162 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); 165 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
163 return; 166 return;
164 } 167 }
165 168
166 mResource->setResourceName( mName->text() ); 169 mResource->setResourceName( mName->text() );
167 mResource->setReadOnly( mReadOnly->isChecked() ); 170 mResource->setReadOnly( mReadOnly->isChecked() );
168 mResource->setIncludeInSync( mIncludeInSync->isChecked() ); 171 mResource->setIncludeInSync( mIncludeInSync->isChecked() );
169 172
170 if ( mConfigWidget ) { 173 if ( mConfigWidget ) {
171 // First save generic information 174 // First save generic information
172 // Also save setting of specific resource type 175 // Also save setting of specific resource type
173 mConfigWidget->saveSettings( mResource ); 176 mConfigWidget->saveSettings( mResource );
174 } 177 }
175 178
176 KDialog::accept(); 179 KDialog::accept();
177} 180}
178 181
179//US #include "configdialog.moc" 182//US #include "configdialog.moc"
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index fc7a42e..1a9d063 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -1,534 +1,538 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qgroupbox.h> 31#include <q3groupbox.h>
32 32
33#ifdef DESKTOP_VERSION 33#ifdef DESKTOP_VERSION
34#include <qinputdialog.h> 34#include <qinputdialog.h>
35#else 35#else
36#include <qtcompat/qinputdialog.h> 36#include <qtcompat/qinputdialog.h>
37#endif 37#endif
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <Q3GridLayout>
42#include <Q3ValueList>
43#include <Q3VBoxLayout>
40#include <kapplication.h> 44#include <kapplication.h>
41#include <kcombobox.h> 45#include <kcombobox.h>
42#include <kdebug.h> 46#include <kdebug.h>
43#include <klocale.h> 47#include <klocale.h>
44#include <kmessagebox.h> 48#include <kmessagebox.h>
45#include <ksimpleconfig.h> 49#include <ksimpleconfig.h>
46#include <kstandarddirs.h> 50#include <kstandarddirs.h>
47#include <kurlrequester.h> 51#include <kurlrequester.h>
48#include <klistview.h> 52#include <klistview.h>
49#include <kbuttonbox.h> 53#include <kbuttonbox.h>
50//US #include <ktrader.h> 54//US #include <ktrader.h>
51 55
52#include "resource.h" 56#include "resource.h"
53#include "configdialog.h" 57#include "configdialog.h"
54 58
55#include "configpage.h" 59#include "configpage.h"
56 60
57//US 61//US
58#include <qpushbutton.h> 62#include <qpushbutton.h>
59#include <qfile.h> 63#include <qfile.h>
60#include <kglobal.h> 64#include <kglobal.h>
61 65
62using namespace KRES; 66using namespace KRES;
63 67
64class ConfigViewItem : public QCheckListItem 68class ConfigViewItem : public Q3CheckListItem
65{ 69{
66 public: 70 public:
67 ConfigViewItem( QListView *parent, Resource* resource ) : 71 ConfigViewItem( Q3ListView *parent, Resource* resource ) :
68 QCheckListItem( parent, resource->resourceName(), CheckBox ), 72 Q3CheckListItem( parent, resource->resourceName(), CheckBox ),
69 mResource( resource ), 73 mResource( resource ),
70 mIsStandard( false ) 74 mIsStandard( false )
71 { 75 {
72 setText( 1, mResource->type() ); 76 setText( 1, mResource->type() );
73 setOn( mResource->isActive() ); 77 setOn( mResource->isActive() );
74 } 78 }
75 79
76 void setStandard( bool value ) 80 void setStandard( bool value )
77 { 81 {
78 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) ); 82 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) );
79 mIsStandard = value; 83 mIsStandard = value;
80 } 84 }
81 85
82 bool standard() const { return mIsStandard; } 86 bool standard() const { return mIsStandard; }
83 bool readOnly() const { return mResource->readOnly(); } 87 bool readOnly() const { return mResource->readOnly(); }
84 88
85 Resource *resource() { return mResource; } 89 Resource *resource() { return mResource; }
86 90
87 private: 91 private:
88 Resource* mResource; 92 Resource* mResource;
89 93
90 bool mIsStandard; 94 bool mIsStandard;
91}; 95};
92 96
93ConfigPage::ConfigPage( QWidget *parent, const char *name ) 97ConfigPage::ConfigPage( QWidget *parent, const char *name )
94 : QWidget( parent, name ), 98 : QWidget( parent, name ),
95 mCurrentManager( 0 ), 99 mCurrentManager( 0 ),
96 mCurrentConfig( 0 ) 100 mCurrentConfig( 0 )
97{ 101{
98 setCaption( i18n( "Resource Configuration" ) ); 102 setCaption( i18n( "Resource Configuration" ) );
99 103
100 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 104 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( this );
101 105
102 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); 106 Q3GroupBox *groupBox = new Q3GroupBox( i18n( "Resources" ), this );
103 groupBox->setColumnLayout(0, Qt::Vertical ); 107 groupBox->setColumnLayout(0, Qt::Vertical );
104 groupBox->layout()->setSpacing( 3 ); 108 groupBox->layout()->setSpacing( 3 );
105 groupBox->layout()->setMargin( 5 ); 109 groupBox->layout()->setMargin( 5 );
106 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 ); 110 Q3GridLayout *groupBoxLayout = new Q3GridLayout( groupBox->layout(), 4, 2 );
107 111
108//US mFamilyCombo = new KComboBox( false, groupBox ); 112//US mFamilyCombo = new KComboBox( false, groupBox );
109 mFamilyCombo = new KComboBox( groupBox ); 113 mFamilyCombo = new KComboBox( groupBox );
110 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); 114 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 );
111 115
112 mListView = new KListView( groupBox ); 116 mListView = new KListView( groupBox );
113 mListView->setAllColumnsShowFocus( true ); 117 mListView->setAllColumnsShowFocus( true );
114 mListView->addColumn( i18n( "Name" ) ); 118 mListView->addColumn( i18n( "Name" ) );
115 mListView->addColumn( i18n( "Type" ) ); 119 mListView->addColumn( i18n( "Type" ) );
116 mListView->addColumn( i18n( "Standard" ) ); 120 mListView->addColumn( i18n( "Standard" ) );
117 121
118//US groupBoxLayout->addWidget( mListView, 1, 0 ); 122//US groupBoxLayout->addWidget( mListView, 1, 0 );
119 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); 123 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 );
120 124
121 125
122 mAddButton = new QPushButton( i18n( "&Add..." ), groupBox ); 126 mAddButton = new QPushButton( i18n( "&Add..." ), groupBox );
123 groupBoxLayout->addWidget( mAddButton, 2, 0 ); 127 groupBoxLayout->addWidget( mAddButton, 2, 0 );
124 mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox ); 128 mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox );
125 groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); 129 groupBoxLayout->addWidget( mRemoveButton, 2, 1 );
126 mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox ); 130 mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox );
127 groupBoxLayout->addWidget( mEditButton, 3, 0 ); 131 groupBoxLayout->addWidget( mEditButton, 3, 0 );
128 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox ); 132 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox );
129 groupBoxLayout->addWidget( mStandardButton, 3, 1 ); 133 groupBoxLayout->addWidget( mStandardButton, 3, 1 );
130 134
131 mRemoveButton->setEnabled( false ); 135 mRemoveButton->setEnabled( false );
132 mEditButton->setEnabled( false ); 136 mEditButton->setEnabled( false );
133 mStandardButton->setEnabled( false ); 137 mStandardButton->setEnabled( false );
134 138
135 139
136 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); 140 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) );
137 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); 141 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) );
138 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); 142 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) );
139 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); 143 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) );
140 144
141 145
142 mainLayout->addWidget( groupBox ); 146 mainLayout->addWidget( groupBox );
143 147
144 connect( mFamilyCombo, SIGNAL( activated( int ) ), 148 connect( mFamilyCombo, SIGNAL( activated( int ) ),
145 SLOT( slotFamilyChanged( int ) ) ); 149 SLOT( slotFamilyChanged( int ) ) );
146 connect( mListView, SIGNAL( selectionChanged() ), 150 connect( mListView, SIGNAL( selectionChanged() ),
147 SLOT( slotSelectionChanged() ) ); 151 SLOT( slotSelectionChanged() ) );
148 connect( mListView, SIGNAL( clicked( QListViewItem * ) ), 152 connect( mListView, SIGNAL( clicked( Q3ListViewItem * ) ),
149 SLOT( slotItemClicked( QListViewItem * ) ) ); 153 SLOT( slotItemClicked( Q3ListViewItem * ) ) );
150 154
151 mLastItem = 0; 155 mLastItem = 0;
152 156
153//US mConfig = new KConfig( "kcmkresourcesrc" ); 157//US mConfig = new KConfig( "kcmkresourcesrc" );
154 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); 158 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") );
155 mConfig->setGroup( "General" ); 159 mConfig->setGroup( "General" );
156 160
157 load(); 161 load();
158} 162}
159 163
160ConfigPage::~ConfigPage() 164ConfigPage::~ConfigPage()
161{ 165{
162 QValueList<ResourcePageInfo>::Iterator it; 166 Q3ValueList<ResourcePageInfo>::Iterator it;
163 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { 167 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
164 (*it).mManager->removeListener( this ); 168 (*it).mManager->removeListener( this );
165 delete (*it).mManager; 169 delete (*it).mManager;
166 delete (*it).mConfig; 170 delete (*it).mConfig;
167 } 171 }
168 172
169 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); 173 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
170 delete mConfig; 174 delete mConfig;
171 mConfig = 0; 175 mConfig = 0;
172} 176}
173 177
174void ConfigPage::load() 178void ConfigPage::load()
175{ 179{
176 kdDebug(5650) << "ConfigPage::load()" << endl; 180 kdDebug(5650) << "ConfigPage::load()" << endl;
177 181
178 mListView->clear(); 182 mListView->clear();
179 183
180//US we remove the dynamic pluginloader, and set the one family we need (contact) manually. 184//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
181 185
182//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); 186//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
183//US KTrader::OfferList::ConstIterator it; 187//US KTrader::OfferList::ConstIterator it;
184//US for ( it = plugins.begin(); it != plugins.end(); ++it ) { 188//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
185//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); 189//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
186//US QString family = tmp.toString(); 190//US QString family = tmp.toString();
187 QStringList families; 191 QStringList families;
188 families << "contact"; 192 families << "contact";
189 193
190 194
191 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 195 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
192 { 196 {
193 QString family = (*it); 197 QString family = (*it);
194 if ( !family.isEmpty() ) { 198 if ( !family.isEmpty() ) {
195 if ( !mFamilyMap.contains( family ) ) { 199 if ( !mFamilyMap.contains( family ) ) {
196 mCurrentManager = new Manager<Resource>( family ); 200 mCurrentManager = new Manager<Resource>( family );
197 if ( mCurrentManager ) { 201 if ( mCurrentManager ) {
198 mFamilyMap.append( family ); 202 mFamilyMap.append( family );
199 mCurrentManager->addListener( this ); 203 mCurrentManager->addListener( this );
200 204
201 ResourcePageInfo info; 205 ResourcePageInfo info;
202 info.mManager = mCurrentManager; 206 info.mManager = mCurrentManager;
203 QString configDir = KGlobal::dirs()->saveLocation( "config" ); 207 QString configDir = KGlobal::dirs()->saveLocation( "config" );
204 //QString configDir = KStandardDirs::appDir() + "/config"; 208 //QString configDir = KStandardDirs::appDir() + "/config";
205 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { 209 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
206 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); 210 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
207 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { 211 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
208 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); 212 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
209 } else { 213 } else {
210 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); 214 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
211 info.mConfig = new KConfig( configFile ); 215 info.mConfig = new KConfig( configFile );
212 } 216 }
213 info.mManager->readConfig( info.mConfig ); 217 info.mManager->readConfig( info.mConfig );
214 218
215 mInfoMap.append( info ); 219 mInfoMap.append( info );
216 } 220 }
217 } 221 }
218 } 222 }
219 } 223 }
220 mCurrentManager = 0; 224 mCurrentManager = 0;
221 225
222 mFamilyCombo->insertStringList( mFamilyMap ); 226 mFamilyCombo->insertStringList( mFamilyMap );
223 227
224 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); 228 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
225 mFamilyCombo->setCurrentItem( currentFamily ); 229 mFamilyCombo->setCurrentItem( currentFamily );
226 slotFamilyChanged( currentFamily ); 230 slotFamilyChanged( currentFamily );
227} 231}
228 232
229void ConfigPage::save() 233void ConfigPage::save()
230{ 234{
231 saveResourceSettings(); 235 saveResourceSettings();
232 236
233 QValueList<ResourcePageInfo>::Iterator it; 237 Q3ValueList<ResourcePageInfo>::Iterator it;
234 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) 238 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
235 (*it).mManager->writeConfig( (*it).mConfig ); 239 (*it).mManager->writeConfig( (*it).mConfig );
236 240
237 emit changed( false ); 241 emit changed( false );
238} 242}
239 243
240void ConfigPage::defaults() 244void ConfigPage::defaults()
241{ 245{
242} 246}
243 247
244void ConfigPage::slotFamilyChanged( int pos ) 248void ConfigPage::slotFamilyChanged( int pos )
245{ 249{
246 if ( pos < 0 || pos >= (int)mFamilyMap.count() ) 250 if ( pos < 0 || pos >= (int)mFamilyMap.count() )
247 return; 251 return;
248 252
249 saveResourceSettings(); 253 saveResourceSettings();
250 254
251 mFamily = mFamilyMap[ pos ]; 255 mFamily = mFamilyMap[ pos ];
252 256
253//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); 257//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
254 258
255 mCurrentManager = mInfoMap[ pos ].mManager; 259 mCurrentManager = mInfoMap[ pos ].mManager;
256 mCurrentConfig = mInfoMap[ pos ].mConfig; 260 mCurrentConfig = mInfoMap[ pos ].mConfig;
257 261
258 if ( !mCurrentManager ) 262 if ( !mCurrentManager )
259 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl; 263 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
260 264
261 mListView->clear(); 265 mListView->clear();
262 266
263 if ( mCurrentManager->isEmpty() ) { 267 if ( mCurrentManager->isEmpty() ) {
264//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); 268//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
265 269
266 defaults(); 270 defaults();
267 } 271 }
268 272
269 Resource *standardResource = mCurrentManager->standardResource(); 273 Resource *standardResource = mCurrentManager->standardResource();
270 274
271//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); 275//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
272 276
273 277
274 Manager<Resource>::Iterator it; 278 Manager<Resource>::Iterator it;
275 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { 279 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
276 ConfigViewItem *item = new ConfigViewItem( mListView, *it ); 280 ConfigViewItem *item = new ConfigViewItem( mListView, *it );
277 if ( *it == standardResource ) 281 if ( *it == standardResource )
278 item->setStandard( true ); 282 item->setStandard( true );
279 } 283 }
280 284
281 if ( mListView->childCount() == 0 ) { 285 if ( mListView->childCount() == 0 ) {
282//US qDebug("ConfigPage::slotFamilyChanged 4.5 "); 286//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
283 287
284 defaults(); 288 defaults();
285 emit changed( true ); 289 emit changed( true );
286 mCurrentManager->writeConfig( mCurrentConfig ); 290 mCurrentManager->writeConfig( mCurrentConfig );
287 } else { 291 } else {
288//US qDebug("ConfigPage::slotFamilyChanged 4.6 "); 292//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
289 293
290 if ( !standardResource ) { 294 if ( !standardResource ) {
291 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); 295 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
292 296
293//US qDebug("ConfigPage::slotFamilyChanged 4.7" ); 297//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
294 298
295 } 299 }
296 300
297 emit changed( false ); 301 emit changed( false );
298 } 302 }
299} 303}
300 304
301void ConfigPage::slotAdd() 305void ConfigPage::slotAdd()
302{ 306{
303 if ( !mCurrentManager ) 307 if ( !mCurrentManager )
304 return; 308 return;
305 309
306 QStringList types = mCurrentManager->resourceTypeNames(); 310 QStringList types = mCurrentManager->resourceTypeNames();
307 QStringList descs = mCurrentManager->resourceTypeDescriptions(); 311 QStringList descs = mCurrentManager->resourceTypeDescriptions();
308 bool ok = false; 312 bool ok = false;
309 313
310 QString desc; 314 QString desc;
311 315
312 desc = QInputDialog::getItem( i18n( "Resource Configuration" ), 316 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
313 i18n( "Select type of the new resource:" ), descs, 0, 317 i18n( "Select type of the new resource:" ), descs, 0,
314 false, &ok, this ); 318 false, &ok, this );
315 319
316 if ( !ok ) 320 if ( !ok )
317 return; 321 return;
318 322
319 QString type = types[ descs.findIndex( desc ) ]; 323 QString type = types[ descs.findIndex( desc ) ];
320 324
321 // Create new resource 325 // Create new resource
322 Resource *resource = mCurrentManager->createResource( type ); 326 Resource *resource = mCurrentManager->createResource( type );
323 if ( !resource ) { 327 if ( !resource ) {
324 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") 328 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
325 .arg( type ) ); 329 .arg( type ) );
326 return; 330 return;
327 } 331 }
328 332
329 resource->setResourceName( type + "-resource" ); 333 resource->setResourceName( type + "-resource" );
330 334
331 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 335 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
332 336
333 if ( dlg.exec() ) { 337 if ( dlg.exec() ) {
334 mCurrentManager->add( resource ); 338 mCurrentManager->add( resource );
335 339
336 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 340 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
337 341
338 mLastItem = item; 342 mLastItem = item;
339 343
340 // if there are only read-only resources we'll set this resource 344 // if there are only read-only resources we'll set this resource
341 // as standard resource 345 // as standard resource
342 if ( !resource->readOnly() ) { 346 if ( !resource->readOnly() ) {
343 bool onlyReadOnly = true; 347 bool onlyReadOnly = true;
344 QListViewItem *it = mListView->firstChild(); 348 Q3ListViewItem *it = mListView->firstChild();
345 while ( it != 0 ) { 349 while ( it != 0 ) {
346 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); 350 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it );
347 if ( !confIt->readOnly() && confIt != item ) 351 if ( !confIt->readOnly() && confIt != item )
348 onlyReadOnly = false; 352 onlyReadOnly = false;
349 353
350 it = it->itemBelow(); 354 it = it->itemBelow();
351 } 355 }
352 356
353 if ( onlyReadOnly ) 357 if ( onlyReadOnly )
354 item->setStandard( true ); 358 item->setStandard( true );
355 } 359 }
356 360
357 emit changed( true ); 361 emit changed( true );
358 } else { 362 } else {
359 delete resource; 363 delete resource;
360 resource = 0; 364 resource = 0;
361 } 365 }
362} 366}
363 367
364void ConfigPage::slotRemove() 368void ConfigPage::slotRemove()
365{ 369{
366 if ( !mCurrentManager ) 370 if ( !mCurrentManager )
367 return; 371 return;
368 372
369 QListViewItem *item = mListView->currentItem(); 373 Q3ListViewItem *item = mListView->currentItem();
370 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item ); 374 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item );
371 375
372 if ( !confItem ) 376 if ( !confItem )
373 return; 377 return;
374 378
375 if ( confItem->standard() ) { 379 if ( confItem->standard() ) {
376 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) ); 380 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) );
377 return; 381 return;
378 } 382 }
379 383
380 mCurrentManager->remove( confItem->resource() ); 384 mCurrentManager->remove( confItem->resource() );
381 385
382 if ( item == mLastItem ) 386 if ( item == mLastItem )
383 mLastItem = 0; 387 mLastItem = 0;
384 388
385 mListView->takeItem( item ); 389 mListView->takeItem( item );
386 delete item; 390 delete item;
387 391
388 emit changed( true ); 392 emit changed( true );
389} 393}
390 394
391void ConfigPage::slotEdit() 395void ConfigPage::slotEdit()
392{ 396{
393 if ( !mCurrentManager ) 397 if ( !mCurrentManager )
394 return; 398 return;
395 399
396 QListViewItem *item = mListView->currentItem(); 400 Q3ListViewItem *item = mListView->currentItem();
397 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item ); 401 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
398 if ( !configItem ) 402 if ( !configItem )
399 return; 403 return;
400 404
401 Resource *resource = configItem->resource(); 405 Resource *resource = configItem->resource();
402 406
403 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 407 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
404 408
405 if ( dlg.exec() ) { 409 if ( dlg.exec() ) {
406 configItem->setText( 0, resource->resourceName() ); 410 configItem->setText( 0, resource->resourceName() );
407 configItem->setText( 1, resource->type() ); 411 configItem->setText( 1, resource->type() );
408 412
409 if ( configItem->standard() && configItem->readOnly() ) { 413 if ( configItem->standard() && configItem->readOnly() ) {
410 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) ); 414 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
411 configItem->setStandard( false ); 415 configItem->setStandard( false );
412 } 416 }
413 417
414 mCurrentManager->resourceChanged( resource ); 418 mCurrentManager->resourceChanged( resource );
415 emit changed( true ); 419 emit changed( true );
416 } 420 }
417} 421}
418 422
419void ConfigPage::slotStandard() 423void ConfigPage::slotStandard()
420{ 424{
421 if ( !mCurrentManager ) 425 if ( !mCurrentManager )
422 return; 426 return;
423 427
424 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() ); 428 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() );
425 if ( !item ) 429 if ( !item )
426 return; 430 return;
427 431
428 if ( item->readOnly() ) { 432 if ( item->readOnly() ) {
429 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) ); 433 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) );
430 return; 434 return;
431 } 435 }
432 436
433 if ( !item->isOn() ) { 437 if ( !item->isOn() ) {
434 KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) ); 438 KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
435 return; 439 return;
436 } 440 }
437 441
438 QListViewItem *it = mListView->firstChild(); 442 Q3ListViewItem *it = mListView->firstChild();
439 while ( it != 0 ) { 443 while ( it != 0 ) {
440 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it ); 444 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it );
441 if ( configItem->standard() ) 445 if ( configItem->standard() )
442 configItem->setStandard( false ); 446 configItem->setStandard( false );
443 it = it->itemBelow(); 447 it = it->itemBelow();
444 } 448 }
445 449
446 item->setStandard( true ); 450 item->setStandard( true );
447 mCurrentManager->setStandardResource( item->resource() ); 451 mCurrentManager->setStandardResource( item->resource() );
448 emit changed( true ); 452 emit changed( true );
449 453
450} 454}
451 455
452void ConfigPage::slotSelectionChanged() 456void ConfigPage::slotSelectionChanged()
453{ 457{
454 bool state = ( mListView->currentItem() != 0 ); 458 bool state = ( mListView->currentItem() != 0 );
455 459
456 mRemoveButton->setEnabled( state ); 460 mRemoveButton->setEnabled( state );
457 mEditButton->setEnabled( state ); 461 mEditButton->setEnabled( state );
458 mStandardButton->setEnabled( state ); 462 mStandardButton->setEnabled( state );
459} 463}
460 464
461void ConfigPage::resourceAdded( Resource* resource ) 465void ConfigPage::resourceAdded( Resource* resource )
462{ 466{
463 qDebug("ConfigPage::resourceAdded : %s", resource->resourceName().latin1()); 467 qDebug("ConfigPage::resourceAdded : %s", resource->resourceName().latin1());
464 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 468 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
465 469
466 // FIXME: this sucks. This should be in the config file, 470 // FIXME: this sucks. This should be in the config file,
467 // or application-dependent, in which case it's always Off 471 // or application-dependent, in which case it's always Off
468 item->setOn( false ); 472 item->setOn( false );
469 473
470 mLastItem = item; 474 mLastItem = item;
471 475
472 emit changed( true ); 476 emit changed( true );
473} 477}
474 478
475void ConfigPage::resourceModified( Resource* resource ) 479void ConfigPage::resourceModified( Resource* resource )
476{ 480{
477 qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1()); 481 qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1());
478} 482}
479 483
480void ConfigPage::resourceDeleted( Resource* resource ) 484void ConfigPage::resourceDeleted( Resource* resource )
481{ 485{
482 qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1()); 486 qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1());
483} 487}
484 488
485void ConfigPage::slotItemClicked( QListViewItem *item ) 489void ConfigPage::slotItemClicked( Q3ListViewItem *item )
486{ 490{
487 ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item ); 491 ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item );
488 if ( !configItem ) return; 492 if ( !configItem ) return;
489 493
490 if ( configItem->standard() && !configItem->isOn() ) { 494 if ( configItem->standard() && !configItem->isOn() ) {
491 KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) ); 495 KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) );
492 configItem->setOn( true ); 496 configItem->setOn( true );
493 return; 497 return;
494 } 498 }
495 499
496 if ( configItem->isOn() != configItem->resource()->isActive() ) { 500 if ( configItem->isOn() != configItem->resource()->isActive() ) {
497 emit changed( true ); 501 emit changed( true );
498 } 502 }
499} 503}
500 504
501void ConfigPage::saveResourceSettings() 505void ConfigPage::saveResourceSettings()
502{ 506{
503 //qDebug("ConfigPage::saveResourceSettings() begin"); 507 //qDebug("ConfigPage::saveResourceSettings() begin");
504 508
505 if ( mCurrentManager ) { 509 if ( mCurrentManager ) {
506 510
507 QListViewItem *item = mListView->firstChild(); 511 Q3ListViewItem *item = mListView->firstChild();
508 while ( item ) { 512 while ( item ) {
509 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item ); 513 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
510 514
511 // check if standard resource 515 // check if standard resource
512 if ( configItem->standard() && !configItem->readOnly() && 516 if ( configItem->standard() && !configItem->readOnly() &&
513 configItem->isOn() ) { 517 configItem->isOn() ) {
514 518
515 mCurrentManager->setStandardResource( configItem->resource() ); 519 mCurrentManager->setStandardResource( configItem->resource() );
516 } 520 }
517 521
518 // check if active or passive resource 522 // check if active or passive resource
519 configItem->resource()->setActive( configItem->isOn() ); 523 configItem->resource()->setActive( configItem->isOn() );
520 524
521 item = item->nextSibling(); 525 item = item->nextSibling();
522 } 526 }
523 mCurrentManager->writeConfig( mCurrentConfig ); 527 mCurrentManager->writeConfig( mCurrentConfig );
524 528
525 if ( !mCurrentManager->standardResource() ) 529 if ( !mCurrentManager->standardResource() )
526 KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) ); 530 KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) );
527 } 531 }
528 532
529 //qDebug("ConfigPage::saveResourceSettings() end"); 533 //qDebug("ConfigPage::saveResourceSettings() end");
530 534
531} 535}
532 536
533//US #include "configpage.moc" 537//US #include "configpage.moc"
534 538
diff --git a/microkde/kresources/configpage.h b/microkde/kresources/configpage.h
index be9239e..dc1aa50 100644
--- a/microkde/kresources/configpage.h
+++ b/microkde/kresources/configpage.h
@@ -1,104 +1,106 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22 22
23#ifndef KRESOURCES_CONFIGPAGE_H 23#ifndef KRESOURCES_CONFIGPAGE_H
24#define KRESOURCES_CONFIGPAGE_H 24#define KRESOURCES_CONFIGPAGE_H
25 25
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qwidget.h> 27#include <qwidget.h>
28//Added by qt3to4:
29#include <Q3ValueList>
28 30
29#include "manager.h" 31#include "manager.h"
30 32
31class KComboBox; 33class KComboBox;
32class KListView; 34class KListView;
33 35
34class QListViewItem; 36class Q3ListViewItem;
35class QPushButton; 37class QPushButton;
36 38
37 39
38namespace KRES { 40namespace KRES {
39 41
40class ResourcePageInfo 42class ResourcePageInfo
41{ 43{
42 public: 44 public:
43 Manager<Resource> *mManager; 45 Manager<Resource> *mManager;
44 KConfig *mConfig; 46 KConfig *mConfig;
45}; 47};
46 48
47class Resource; 49class Resource;
48 50
49class ConfigPage : public QWidget, public ManagerListener<Resource> 51class ConfigPage : public QWidget, public ManagerListener<Resource>
50{ 52{
51 Q_OBJECT 53 Q_OBJECT
52 54
53 public: 55 public:
54 ConfigPage( QWidget *parent = 0, const char *name = 0 ); 56 ConfigPage( QWidget *parent = 0, const char *name = 0 );
55 virtual ~ConfigPage(); 57 virtual ~ConfigPage();
56 58
57 void load(); 59 void load();
58 void save(); 60 void save();
59 virtual void defaults(); 61 virtual void defaults();
60 62
61 public slots: 63 public slots:
62 void slotFamilyChanged( int ); 64 void slotFamilyChanged( int );
63 void slotAdd(); 65 void slotAdd();
64 void slotRemove(); 66 void slotRemove();
65 void slotEdit(); 67 void slotEdit();
66 void slotStandard(); 68 void slotStandard();
67 void slotSelectionChanged(); 69 void slotSelectionChanged();
68 70
69 // From ManagerListener<Resource> 71 // From ManagerListener<Resource>
70 public: 72 public:
71 virtual void resourceAdded( Resource* resource ); 73 virtual void resourceAdded( Resource* resource );
72 virtual void resourceModified( Resource* resource ); 74 virtual void resourceModified( Resource* resource );
73 virtual void resourceDeleted( Resource* resource ); 75 virtual void resourceDeleted( Resource* resource );
74 76
75 protected slots: 77 protected slots:
76 void slotItemClicked( QListViewItem * ); 78 void slotItemClicked( Q3ListViewItem * );
77 79
78 signals: 80 signals:
79 void changed( bool ); 81 void changed( bool );
80 82
81 private: 83 private:
82 void saveResourceSettings(); 84 void saveResourceSettings();
83 85
84 Manager<Resource>* mCurrentManager; 86 Manager<Resource>* mCurrentManager;
85 KConfig* mCurrentConfig; 87 KConfig* mCurrentConfig;
86 KConfig* mConfig; 88 KConfig* mConfig;
87 QString mFamily; 89 QString mFamily;
88 QStringList mFamilyMap; 90 QStringList mFamilyMap;
89 QValueList<ResourcePageInfo> mInfoMap; 91 Q3ValueList<ResourcePageInfo> mInfoMap;
90 92
91 KComboBox* mFamilyCombo; 93 KComboBox* mFamilyCombo;
92 KListView* mListView; 94 KListView* mListView;
93 QPushButton* mAddButton; 95 QPushButton* mAddButton;
94 QPushButton* mRemoveButton; 96 QPushButton* mRemoveButton;
95 QPushButton* mEditButton; 97 QPushButton* mEditButton;
96 QPushButton* mStandardButton; 98 QPushButton* mStandardButton;
97 99
98 QListViewItem* mLastItem; 100 Q3ListViewItem* mLastItem;
99 static const QString syncfamily; 101 static const QString syncfamily;
100}; 102};
101 103
102} 104}
103 105
104#endif 106#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 86b22b2..4f286d1 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,295 +1,295 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION 29//#ifndef DESKTOP_VERSION
30#include <klibloader.h> 30#include <klibloader.h>
31//#endif 31//#endif
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "resource.h" 34#include "resource.h"
35#include "factory.h" 35#include "factory.h"
36 36
37#ifdef STATIC_RESOURCES 37#ifdef STATIC_RESOURCES
38#include <file/resourcefile.h> 38#include <file/resourcefile.h>
39#include <dir/resourcedir.h> 39#include <dir/resourcedir.h>
40#include <qtopia/resourceqtopia.h> 40#include <qtopia/resourceqtopia.h>
41#endif 41#endif
42using namespace KRES; 42using namespace KRES;
43 43
44QDict<Factory> *Factory::mSelves = 0; 44Q3Dict<Factory> *Factory::mSelves = 0;
45static KStaticDeleter< QDict<Factory> > staticDeleter; 45static KStaticDeleter< Q3Dict<Factory> > staticDeleter;
46 46
47Factory *Factory::self( const QString& resourceFamily) 47Factory *Factory::self( const QString& resourceFamily)
48{ 48{
49 49
50 50
51 Factory *factory = 0; 51 Factory *factory = 0;
52 if ( !mSelves ) 52 if ( !mSelves )
53 { 53 {
54 mSelves = staticDeleter.setObject( new QDict<Factory> ); 54 mSelves = staticDeleter.setObject( new Q3Dict<Factory> );
55 } 55 }
56 56
57 factory = mSelves->find( resourceFamily ); 57 factory = mSelves->find( resourceFamily );
58 58
59 if ( !factory ) { 59 if ( !factory ) {
60 factory = new Factory( resourceFamily); 60 factory = new Factory( resourceFamily);
61 mSelves->insert( resourceFamily, factory ); 61 mSelves->insert( resourceFamily, factory );
62 } 62 }
63 63
64 return factory; 64 return factory;
65} 65}
66 66
67Factory::Factory( const QString& resourceFamily) : 67Factory::Factory( const QString& resourceFamily) :
68 mResourceFamily( resourceFamily ) 68 mResourceFamily( resourceFamily )
69{ 69{
70//US so far we have three types available for resourceFamily "contact" 70//US so far we have three types available for resourceFamily "contact"
71// and that are "file", "dir", "ldap" 71// and that are "file", "dir", "ldap"
72/*US 72/*US
73 73
74 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 74 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
75 .arg( resourceFamily ) ); 75 .arg( resourceFamily ) );
76 KTrader::OfferList::ConstIterator it; 76 KTrader::OfferList::ConstIterator it;
77 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 77 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
78 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 78 QVariant type = (*it)->property( "X-KDE-ResourceType" );
79 if ( !type.toString().isEmpty() ) 79 if ( !type.toString().isEmpty() )
80 mTypeMap.insert( type.toString(), *it ); 80 mTypeMap.insert( type.toString(), *it );
81 } 81 }
82*/ 82*/
83 83
84//US new 84//US new
85 PluginInfo* info = new PluginInfo; 85 PluginInfo* info = new PluginInfo;
86 info->library = "microkabc_file"; 86 info->library = "microkabc_file";
87 info->nameLabel = i18n( "file" ); 87 info->nameLabel = i18n( "file" );
88 info->descriptionLabel = i18n( "One file" ); 88 info->descriptionLabel = i18n( "One file" );
89 mTypeMap.insert( "file", info ); 89 mTypeMap.insert( "file", info );
90 90
91 info = new PluginInfo; 91 info = new PluginInfo;
92 info->library = "microkabc_dir"; 92 info->library = "microkabc_dir";
93 info->nameLabel = i18n( "dir" ); 93 info->nameLabel = i18n( "dir" );
94 info->descriptionLabel = i18n( "A directory with many files" ); 94 info->descriptionLabel = i18n( "A directory with many files" );
95 mTypeMap.insert( "dir", info ); 95 mTypeMap.insert( "dir", info );
96 96
97 info = new PluginInfo; 97 info = new PluginInfo;
98 info->library = "microkabc_ldap"; 98 info->library = "microkabc_ldap";
99 info->nameLabel = i18n( "ldap" ); 99 info->nameLabel = i18n( "ldap" );
100 info->descriptionLabel = i18n( "Connect to a directory server" ); 100 info->descriptionLabel = i18n( "Connect to a directory server" );
101 mTypeMap.insert( "ldap", info ); 101 mTypeMap.insert( "ldap", info );
102 102
103 //US add opie plugin only, if the library exists. 103 //US add opie plugin only, if the library exists.
104 /*US 104 /*US
105 QString libname = "microkabc_opie"; 105 QString libname = "microkabc_opie";
106 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 106 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
107 if ( !path.isEmpty() ) 107 if ( !path.isEmpty() )
108 { 108 {
109 info = new PluginInfo; 109 info = new PluginInfo;
110 info->library = libname; 110 info->library = libname;
111 info->nameLabel = i18n( "opie" ); 111 info->nameLabel = i18n( "opie" );
112 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 112 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
113 mTypeMap.insert( "opie", info ); 113 mTypeMap.insert( "opie", info );
114 } 114 }
115 */ 115 */
116 //US add qtopia plugin only, if the library exists. 116 //US add qtopia plugin only, if the library exists.
117 QString libname = "microkabc_qtopia"; 117 QString libname = "microkabc_qtopia";
118 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 118 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
119 if ( !path.isEmpty() ) 119 if ( !path.isEmpty() )
120 { 120 {
121 info = new PluginInfo; 121 info = new PluginInfo;
122 info->library = libname; 122 info->library = libname;
123 info->nameLabel = i18n( "qtopia" ); 123 info->nameLabel = i18n( "qtopia" );
124 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 124 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
125 mTypeMap.insert( "qtopia", info ); 125 mTypeMap.insert( "qtopia", info );
126 } 126 }
127 127
128 //US add sharp plugin only, if the library exists. 128 //US add sharp plugin only, if the library exists.
129 libname = "microkabc_sharpdtm"; 129 libname = "microkabc_sharpdtm";
130 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 130 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
131 if ( !path.isEmpty() ) 131 if ( !path.isEmpty() )
132 { 132 {
133 info = new PluginInfo; 133 info = new PluginInfo;
134 info->library = libname; 134 info->library = libname;
135 info->nameLabel = i18n( "sharp" ); 135 info->nameLabel = i18n( "sharp" );
136 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 136 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
137 mTypeMap.insert( "sharp", info ); 137 mTypeMap.insert( "sharp", info );
138 } 138 }
139 139
140 140
141 //LR add ol plugin only, if the library exists. 141 //LR add ol plugin only, if the library exists.
142 libname = "microkabc_olaccess"; 142 libname = "microkabc_olaccess";
143 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 143 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
144 if ( !path.isEmpty() ) 144 if ( !path.isEmpty() )
145 { 145 {
146 info = new PluginInfo; 146 info = new PluginInfo;
147 info->library = libname; 147 info->library = libname;
148 info->nameLabel = i18n( "olaccess" ); 148 info->nameLabel = i18n( "olaccess" );
149 info->descriptionLabel = i18n( "Outlook Addressbook." ); 149 info->descriptionLabel = i18n( "Outlook Addressbook." );
150 mTypeMap.insert( "olaccess", info ); 150 mTypeMap.insert( "olaccess", info );
151 } 151 }
152 152
153 153
154} 154}
155 155
156Factory::~Factory() 156Factory::~Factory()
157{ 157{
158} 158}
159 159
160QStringList Factory::typeNames() const 160QStringList Factory::typeNames() const
161{ 161{
162//US method QMap::keys() not available yet. SO collect the data manually 162//US method QMap::keys() not available yet. SO collect the data manually
163//US return mTypeMap.keys(); 163//US return mTypeMap.keys();
164 164
165 QStringList result; 165 QStringList result;
166 166
167 QMap<QString, PluginInfo*>::ConstIterator it; 167 QMap<QString, PluginInfo*>::ConstIterator it;
168 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 168 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
169 result << it.key().latin1(); 169 result << it.key().latin1();
170// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 170// qDebug("Factory::typeNames() : %s ", it.key().latin1());
171 171
172 } 172 }
173 return result; 173 return result;
174} 174}
175 175
176ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 176ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
177{ 177{
178 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 178 if ( type.isEmpty() || !mTypeMap.contains( type ) )
179 return 0; 179 return 0;
180 180
181//US KService::Ptr ptr = mTypeMap[ type ]; 181//US KService::Ptr ptr = mTypeMap[ type ];
182//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 182//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
183 PluginInfo* pi = mTypeMap[ type ]; 183 PluginInfo* pi = mTypeMap[ type ];
184 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 184 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
185 if ( !factory ) { 185 if ( !factory ) {
186 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 186 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
187 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 187 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
188 return 0; 188 return 0;
189 } 189 }
190 190
191 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 191 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
192 192
193 if ( !pluginFactory ) { 193 if ( !pluginFactory ) {
194 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 194 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
195 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 195 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
196 return 0; 196 return 0;
197 } 197 }
198 198
199 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 199 ConfigWidget *wdg = pluginFactory->configWidget( parent );
200 if ( !wdg ) { 200 if ( !wdg ) {
201//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 201//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
202 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 202 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
203 return 0; 203 return 0;
204 } 204 }
205 return wdg; 205 return wdg;
206 206
207} 207}
208 208
209QString Factory::typeName( const QString &type ) const 209QString Factory::typeName( const QString &type ) const
210{ 210{
211 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 211 if ( type.isEmpty() || !mTypeMap.contains( type ) )
212 return QString(); 212 return QString();
213 213
214 214
215//US KService::Ptr ptr = mTypeMap[ type ]; 215//US KService::Ptr ptr = mTypeMap[ type ];
216//US return ptr->name(); 216//US return ptr->name();
217 PluginInfo* pi = mTypeMap[ type ]; 217 PluginInfo* pi = mTypeMap[ type ];
218 return pi->nameLabel; 218 return pi->nameLabel;
219 219
220} 220}
221 221
222QString Factory::typeDescription( const QString &type ) const 222QString Factory::typeDescription( const QString &type ) const
223{ 223{
224 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 224 if ( type.isEmpty() || !mTypeMap.contains( type ) )
225 return QString(); 225 return QString();
226 226
227//US KService::Ptr ptr = mTypeMap[ type ]; 227//US KService::Ptr ptr = mTypeMap[ type ];
228//US return ptr->comment(); 228//US return ptr->comment();
229 PluginInfo* pi = mTypeMap[ type ]; 229 PluginInfo* pi = mTypeMap[ type ];
230 return pi->descriptionLabel; 230 return pi->descriptionLabel;
231} 231}
232 232
233Resource *Factory::resource( const QString& type, const KConfig *config ) 233Resource *Factory::resource( const QString& type, const KConfig *config )
234{ 234{
235 235
236 236
237 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 237 if ( type.isEmpty() || !mTypeMap.contains( type ) )
238 return 0; 238 return 0;
239 239
240#ifdef STATIC_RESOURCES 240#ifdef STATIC_RESOURCES
241 qDebug("NEW STATIC RESOURCE %s", type.latin1()); 241 qDebug("NEW STATIC RESOURCE %s", type.latin1());
242 Resource *resource = 0; 242 Resource *resource = 0;
243 if ( type == "file" ) { 243 if ( type == "file" ) {
244 resource = (Resource *) new KABC::ResourceFile( config ); 244 resource = (Resource *) new KABC::ResourceFile( config );
245 } else if ( type == "dir" ) { 245 } else if ( type == "dir" ) {
246 resource = new KABC::ResourceDir( config ); 246 resource = new KABC::ResourceDir( config );
247 } else if ( type == "qtopia" ) { 247 } else if ( type == "qtopia" ) {
248 resource = new KABC::ResourceQtopia( config ); 248 resource = new KABC::ResourceQtopia( config );
249 } 249 }
250 if ( !resource) 250 if ( !resource)
251 qDebug("Factory::resource:: resources are statically linked. resource type %s is not supported ",type.latin1() ); 251 qDebug("Factory::resource:: resources are statically linked. resource type %s is not supported ",type.latin1() );
252 else 252 else
253 resource->setType( type ); 253 resource->setType( type );
254 return resource; 254 return resource;
255#else 255#else
256 256
257 257
258 258
259/*US load the lib not dynamicly. !! 259/*US load the lib not dynamicly. !!
260 KService::Ptr ptr = mTypeMap[ type ]; 260 KService::Ptr ptr = mTypeMap[ type ];
261 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 261 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
262 if ( !factory ) { 262 if ( !factory ) {
263 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 263 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
264 return 0; 264 return 0;
265 } 265 }
266*/ 266*/
267 PluginInfo* pi = mTypeMap[ type ]; 267 PluginInfo* pi = mTypeMap[ type ];
268 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 268 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
269 if ( !factory ) { 269 if ( !factory ) {
270 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 270 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
271 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 271 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
272 return 0; 272 return 0;
273 } 273 }
274 274
275 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 275 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
276 276
277 if ( !pluginFactory ) { 277 if ( !pluginFactory ) {
278 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 278 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
279 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 279 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
280 return 0; 280 return 0;
281 } 281 }
282 282
283 Resource *resource = pluginFactory->resource( config ); 283 Resource *resource = pluginFactory->resource( config );
284 if ( !resource ) { 284 if ( !resource ) {
285//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 285//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
286 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 286 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
287 return 0; 287 return 0;
288 } 288 }
289 289
290 resource->setType( type ); 290 resource->setType( type );
291 291
292 return resource; 292 return resource;
293 293
294#endif 294#endif
295} 295}
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h
index ea01b23..709fde0 100644
--- a/microkde/kresources/factory.h
+++ b/microkde/kresources/factory.h
@@ -1,126 +1,126 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_FACTORY_H 24#ifndef KRESOURCES_FACTORY_H
25#define KRESOURCES_FACTORY_H 25#define KRESOURCES_FACTORY_H
26 26
27#include <qdict.h> 27#include <q3dict.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <kconfig.h> 30#include <kconfig.h>
31 31
32 32
33#include "resource.h" 33#include "resource.h"
34 34
35namespace KRES { 35namespace KRES {
36 36
37class ConfigWidget; 37class ConfigWidget;
38 38
39//US 39//US
40struct PluginInfo 40struct PluginInfo
41{ 41{
42 QString library; 42 QString library;
43 QString nameLabel; 43 QString nameLabel;
44 QString descriptionLabel; 44 QString descriptionLabel;
45}; 45};
46 46
47 47
48/** 48/**
49 * Class for loading resource plugins. 49 * Class for loading resource plugins.
50 * Do not use this class directly. Use ResourceManager instead 50 * Do not use this class directly. Use ResourceManager instead
51 * 51 *
52 * Example: 52 * Example:
53 * 53 *
54 * <pre> 54 * <pre>
55 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); 55 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
56 * 56 *
57 * QStringList list = factory->resources(); 57 * QStringList list = factory->resources();
58 * QStringList::Iterator it; 58 * QStringList::Iterator it;
59 * for ( it = list.begin(); it != list.end(); ++it ) { 59 * for ( it = list.begin(); it != list.end(); ++it ) {
60 * Resource<Calendar> *resource = factory->resource( (*it), 60 * Resource<Calendar> *resource = factory->resource( (*it),
61 * KABC::StdAddressBook::self(), 0 ); 61 * KABC::StdAddressBook::self(), 0 );
62 * // do something with resource 62 * // do something with resource
63 * } 63 * }
64 * </pre> 64 * </pre>
65 */ 65 */
66class Factory 66class Factory
67{ 67{
68 public: 68 public:
69 69
70 70
71 /** 71 /**
72 * Returns the global resource factory. 72 * Returns the global resource factory.
73 */ 73 */
74 static Factory *self( const QString& resourceFamily ); 74 static Factory *self( const QString& resourceFamily );
75 75
76 ~Factory(); 76 ~Factory();
77 77
78 /** 78 /**
79 * Returns the config widget for the given resource type, 79 * Returns the config widget for the given resource type,
80 * or a null pointer if resource type doesn't exist. 80 * or a null pointer if resource type doesn't exist.
81 * 81 *
82 * @param type The type of the resource, returned by @ref resources() 82 * @param type The type of the resource, returned by @ref resources()
83 * @param resource The resource to be editted. 83 * @param resource The resource to be editted.
84 * @param parent The parent widget 84 * @param parent The parent widget
85 */ 85 */
86 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); 86 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
87 87
88 /** 88 /**
89 * Returns a pointer to a resource object or a null pointer 89 * Returns a pointer to a resource object or a null pointer
90 * if resource type doesn't exist. 90 * if resource type doesn't exist.
91 * 91 *
92 * @param type The type of the resource, returned by @ref resources() 92 * @param type The type of the resource, returned by @ref resources()
93 * @param ab The address book, the resource should belong to 93 * @param ab The address book, the resource should belong to
94 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. 94 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
95 */ 95 */
96 Resource *resource( const QString& type, const KConfig *config); 96 Resource *resource( const QString& type, const KConfig *config);
97 97
98 /** 98 /**
99 * Returns a list of all available resource types. 99 * Returns a list of all available resource types.
100 */ 100 */
101 QStringList typeNames() const; 101 QStringList typeNames() const;
102 102
103 /** 103 /**
104 * Returns the name for a special type. 104 * Returns the name for a special type.
105 */ 105 */
106 QString typeName( const QString &type ) const; 106 QString typeName( const QString &type ) const;
107 107
108 /** 108 /**
109 * Returns the description for a special type. 109 * Returns the description for a special type.
110 */ 110 */
111 QString typeDescription( const QString &type ) const; 111 QString typeDescription( const QString &type ) const;
112 112
113 protected: 113 protected:
114 Factory( const QString& resourceFamily); 114 Factory( const QString& resourceFamily);
115 115
116 private: 116 private:
117 static QDict<Factory> *mSelves; 117 static Q3Dict<Factory> *mSelves;
118 118
119 QString mResourceFamily; 119 QString mResourceFamily;
120//US QMap<QString, KService::Ptr> mTypeMap; 120//US QMap<QString, KService::Ptr> mTypeMap;
121//US lets store the pluginfo struct as value instead of a KService 121//US lets store the pluginfo struct as value instead of a KService
122 QMap<QString, PluginInfo*> mTypeMap; 122 QMap<QString, PluginInfo*> mTypeMap;
123}; 123};
124 124
125} 125}
126#endif 126#endif
diff --git a/microkde/kresources/kcmkresources.cpp b/microkde/kresources/kcmkresources.cpp
index d600a31..f5eb826 100644
--- a/microkde/kresources/kcmkresources.cpp
+++ b/microkde/kresources/kcmkresources.cpp
@@ -1,89 +1,92 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qlayout.h> 22#include <qlayout.h>
23//Added by qt3to4:
24#include <Q3VBoxLayout>
25#include <Q3Frame>
23 26
24//US #include <kaboutdata.h> 27//US #include <kaboutdata.h>
25//US #include <kgenericfactory.h> 28//US #include <kgenericfactory.h>
26#include <klocale.h> 29#include <klocale.h>
27 30
28#include "configpage.h" 31#include "configpage.h"
29 32
30#include "kcmkresources.h" 33#include "kcmkresources.h"
31 34
32using namespace KRES; 35using namespace KRES;
33 36
34//US typedef KGenericFactory<KCMKResources, QWidget> ResourcesFactory; 37//US typedef KGenericFactory<KCMKResources, QWidget> ResourcesFactory;
35//US K_EXPORT_COMPONENT_FACTORY( kcm_kresources, ResourcesFactory( "kcmkresources" ) ); 38//US K_EXPORT_COMPONENT_FACTORY( kcm_kresources, ResourcesFactory( "kcmkresources" ) );
36 39
37//US KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& ) 40//US KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
38//US : KCModule( ResourcesFactory::instance(), parent, name ) 41//US : KCModule( ResourcesFactory::instance(), parent, name )
39KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& ) 42KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
40 : KDialogBase( parent, name, true, i18n( "Configure Resources" ), 43 : KDialogBase( parent, name, true, i18n( "Configure Resources" ),
41 Ok|Cancel, Ok, true ) 44 Ok|Cancel, Ok, true )
42{ 45{
43 QFrame *main = plainPage(); 46 Q3Frame *main = plainPage();
44 47
45 QVBoxLayout *layout = new QVBoxLayout( main ); 48 Q3VBoxLayout *layout = new Q3VBoxLayout( main );
46 mConfigPage = new KRES::ConfigPage( main ); 49 mConfigPage = new KRES::ConfigPage( main );
47 layout->addWidget( mConfigPage ); 50 layout->addWidget( mConfigPage );
48 51
49 52
50 connect( mConfigPage, SIGNAL( changed( bool ) ), SLOT( changed( bool ) ) ); 53 connect( mConfigPage, SIGNAL( changed( bool ) ), SLOT( changed( bool ) ) );
51#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
52 showMaximized(); 55 showMaximized();
53#endif 56#endif
54} 57}
55 58
56void KCMKResources::changed( bool changed) 59void KCMKResources::changed( bool changed)
57{ 60{
58 modified = changed; 61 modified = changed;
59} 62}
60 63
61void KCMKResources::slotOk() 64void KCMKResources::slotOk()
62{ 65{
63 if (modified) { 66 if (modified) {
64 mConfigPage->save(); 67 mConfigPage->save();
65 modified = false; 68 modified = false;
66 } 69 }
67 70
68 KDialogBase::slotOk(); 71 KDialogBase::slotOk();
69} 72}
70 73
71void KCMKResources::load() 74void KCMKResources::load()
72{ 75{
73 qDebug("KCMKResources::load" ); 76 qDebug("KCMKResources::load" );
74 mConfigPage->load(); 77 mConfigPage->load();
75} 78}
76 79
77void KCMKResources::save() 80void KCMKResources::save()
78{ 81{
79 qDebug("KCMKResources::save" ); 82 qDebug("KCMKResources::save" );
80 mConfigPage->save(); 83 mConfigPage->save();
81} 84}
82 85
83void KCMKResources::defaults() 86void KCMKResources::defaults()
84{ 87{
85 qDebug("KCMKResources::defaults" ); 88 qDebug("KCMKResources::defaults" );
86 mConfigPage->defaults(); 89 mConfigPage->defaults();
87} 90}
88 91
89//US #include "kcmkresources.moc" 92//US #include "kcmkresources.moc"
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h
index 69062da..88705d4 100644
--- a/microkde/kresources/manager.h
+++ b/microkde/kresources/manager.h
@@ -1,338 +1,340 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 Copyright (c) 2004 Ulf Schenk 7 Copyright (c) 2004 Ulf Schenk
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either 11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version. 12 version 2 of the License, or (at your option) any later version.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#ifndef KRESOURCES_MANAGER_H 32#ifndef KRESOURCES_MANAGER_H
33#define KRESOURCES_MANAGER_H 33#define KRESOURCES_MANAGER_H
34 34
35#include <qdict.h> 35#include <q3dict.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37//Added by qt3to4:
38#include <Q3PtrList>
37 39
38#include "factory.h" 40#include "factory.h"
39#include "managerimpl.h" 41#include "managerimpl.h"
40 42
41namespace KRES { 43namespace KRES {
42 44
43class Resource; 45class Resource;
44 46
45template<class T> 47template<class T>
46class ManagerListener 48class ManagerListener
47{ 49{
48 public: 50 public:
49 virtual void resourceAdded( T *resource ) = 0; 51 virtual void resourceAdded( T *resource ) = 0;
50 virtual void resourceModified( T *resource ) = 0; 52 virtual void resourceModified( T *resource ) = 0;
51 virtual void resourceDeleted( T *resource ) = 0; 53 virtual void resourceDeleted( T *resource ) = 0;
52}; 54};
53 55
54// TODO: 56// TODO:
55// The resource manager should provide some signals 57// The resource manager should provide some signals
56// to warn applications that resources have been added, 58// to warn applications that resources have been added,
57// removed or modified. 59// removed or modified.
58// 60//
59// The manager should also keep track of which (or at least 61// The manager should also keep track of which (or at least
60// how many) applications hve opened a resource, so that it 62// how many) applications hve opened a resource, so that it
61// is only closed if none of them is using it any more 63// is only closed if none of them is using it any more
62 64
63template<class T> 65template<class T>
64class Manager : private ManagerImplListener 66class Manager : private ManagerImplListener
65{ 67{
66 public: 68 public:
67 class Iterator 69 class Iterator
68 { 70 {
69 friend class Manager; 71 friend class Manager;
70 public: 72 public:
71 Iterator() {}; 73 Iterator() {};
72 Iterator( const Iterator &it ) { mIt = it.mIt; } 74 Iterator( const Iterator &it ) { mIt = it.mIt; }
73 75
74 T *operator*() { return static_cast<T *>( *mIt ); } 76 T *operator*() { return static_cast<T *>( *mIt ); }
75 Iterator &operator++() { mIt++; return *this; } 77 Iterator &operator++() { mIt++; return *this; }
76 Iterator &operator++(int) { mIt++; return *this; } 78 Iterator &operator++(int) { mIt++; return *this; }
77 Iterator &operator--() { mIt--; return *this; } 79 Iterator &operator--() { mIt--; return *this; }
78 Iterator &operator--(int) { mIt--; return *this; } 80 Iterator &operator--(int) { mIt--; return *this; }
79 bool operator==( const Iterator &it ) { return mIt == it.mIt; } 81 bool operator==( const Iterator &it ) { return mIt == it.mIt; }
80 bool operator!=( const Iterator &it ) { return mIt != it.mIt; } 82 bool operator!=( const Iterator &it ) { return mIt != it.mIt; }
81 83
82 private: 84 private:
83 Resource::List::Iterator mIt; 85 Resource::List::Iterator mIt;
84 }; 86 };
85 87
86 Iterator begin() 88 Iterator begin()
87 { 89 {
88 Iterator it; 90 Iterator it;
89 it.mIt = mImpl->resourceList()->begin(); 91 it.mIt = mImpl->resourceList()->begin();
90 return it; 92 return it;
91 } 93 }
92 94
93 Iterator end() 95 Iterator end()
94 { 96 {
95 Iterator it; 97 Iterator it;
96 it.mIt = mImpl->resourceList()->end(); 98 it.mIt = mImpl->resourceList()->end();
97 return it; 99 return it;
98 } 100 }
99 101
100 class ActiveIterator 102 class ActiveIterator
101 { 103 {
102 friend class Manager; 104 friend class Manager;
103 public: 105 public:
104 ActiveIterator() : mList( 0 ) {}; 106 ActiveIterator() : mList( 0 ) {};
105 ActiveIterator( const ActiveIterator &it ) 107 ActiveIterator( const ActiveIterator &it )
106 { 108 {
107 mIt = it.mIt; 109 mIt = it.mIt;
108 mList = it.mList; 110 mList = it.mList;
109 } 111 }
110 112
111 T *operator*() { return static_cast<T *>( *mIt ); } 113 T *operator*() { return static_cast<T *>( *mIt ); }
112 ActiveIterator &operator++() 114 ActiveIterator &operator++()
113 { 115 {
114 do { mIt++; } while ( checkActive() ); 116 do { mIt++; } while ( checkActive() );
115 return *this; 117 return *this;
116 } 118 }
117 ActiveIterator &operator++(int) 119 ActiveIterator &operator++(int)
118 { 120 {
119 do { mIt++; } while ( checkActive() ); 121 do { mIt++; } while ( checkActive() );
120 return *this; 122 return *this;
121 } 123 }
122 ActiveIterator &operator--() 124 ActiveIterator &operator--()
123 { 125 {
124 do { mIt--; } while ( checkActive() ); 126 do { mIt--; } while ( checkActive() );
125 return *this; 127 return *this;
126 } 128 }
127 ActiveIterator &operator--(int) 129 ActiveIterator &operator--(int)
128 { 130 {
129 do { mIt--; } while ( checkActive() ); 131 do { mIt--; } while ( checkActive() );
130 return *this; 132 return *this;
131 } 133 }
132 bool operator==( const ActiveIterator &it ) { return mIt == it.mIt; } 134 bool operator==( const ActiveIterator &it ) { return mIt == it.mIt; }
133 bool operator!=( const ActiveIterator &it ) { return mIt != it.mIt; } 135 bool operator!=( const ActiveIterator &it ) { return mIt != it.mIt; }
134 136
135 private: 137 private:
136 /** 138 /**
137 Check if iterator needs to be advanced once more. 139 Check if iterator needs to be advanced once more.
138 */ 140 */
139 bool checkActive() 141 bool checkActive()
140 { 142 {
141 if ( !mList || mIt == mList->end() ) return false; 143 if ( !mList || mIt == mList->end() ) return false;
142 return !(*mIt)->isActive(); 144 return !(*mIt)->isActive();
143 } 145 }
144 146
145 Resource::List::Iterator mIt; 147 Resource::List::Iterator mIt;
146 Resource::List *mList; 148 Resource::List *mList;
147 }; 149 };
148 150
149 ActiveIterator activeBegin() 151 ActiveIterator activeBegin()
150 { 152 {
151 ActiveIterator it; 153 ActiveIterator it;
152 it.mIt = mImpl->resourceList()->begin(); 154 it.mIt = mImpl->resourceList()->begin();
153 it.mList = mImpl->resourceList(); 155 it.mList = mImpl->resourceList();
154 if ( it.mIt != mImpl->resourceList()->end() ) { 156 if ( it.mIt != mImpl->resourceList()->end() ) {
155 if ( !(*it)->isActive() ) it++; 157 if ( !(*it)->isActive() ) it++;
156 } 158 }
157 return it; 159 return it;
158 } 160 }
159 161
160 ActiveIterator activeEnd() 162 ActiveIterator activeEnd()
161 { 163 {
162 ActiveIterator it; 164 ActiveIterator it;
163 it.mIt = mImpl->resourceList()->end(); 165 it.mIt = mImpl->resourceList()->end();
164 it.mList = mImpl->resourceList(); 166 it.mList = mImpl->resourceList();
165 return it; 167 return it;
166 } 168 }
167 169
168 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } 170 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); }
169 171
170 Manager( const QString &family ) 172 Manager( const QString &family )
171 { 173 {
172 mFactory = Factory::self( family ); 174 mFactory = Factory::self( family );
173 // The managerimpl will use the same Factory object as the manager 175 // The managerimpl will use the same Factory object as the manager
174 // because of the Factory::self() pattern 176 // because of the Factory::self() pattern
175 mImpl = new ManagerImpl( family ); 177 mImpl = new ManagerImpl( family );
176 mImpl->setListener( this ); 178 mImpl->setListener( this );
177 179
178 mListeners = new QPtrList<ManagerListener<T> >; 180 mListeners = new Q3PtrList<ManagerListener<T> >;
179 } 181 }
180 182
181 virtual ~Manager() 183 virtual ~Manager()
182 { 184 {
183 mImpl->setListener( 0 ); 185 mImpl->setListener( 0 );
184 delete mListeners; 186 delete mListeners;
185 delete mImpl; 187 delete mImpl;
186 } 188 }
187 189
188 /** 190 /**
189 Recreate Resource objects from configuration file. If cfg is 0, read standard 191 Recreate Resource objects from configuration file. If cfg is 0, read standard
190 configuration file. 192 configuration file.
191 */ 193 */
192 void readConfig( KConfig *cfg = 0 ) 194 void readConfig( KConfig *cfg = 0 )
193 { 195 {
194 mImpl->readConfig( cfg ); 196 mImpl->readConfig( cfg );
195 } 197 }
196 198
197 /** 199 /**
198 Write configuration of Resource objects to configuration file. If cfg is 0, write 200 Write configuration of Resource objects to configuration file. If cfg is 0, write
199 to standard configuration file. 201 to standard configuration file.
200 */ 202 */
201 void writeConfig( KConfig *cfg = 0 ) 203 void writeConfig( KConfig *cfg = 0 )
202 { 204 {
203 mImpl->writeConfig( cfg ); 205 mImpl->writeConfig( cfg );
204 } 206 }
205 207
206 /** 208 /**
207 Add resource to manager. This passes ownership of the Resource object 209 Add resource to manager. This passes ownership of the Resource object
208 to the manager. 210 to the manager.
209 */ 211 */
210 void add( Resource *resource ) 212 void add( Resource *resource )
211 { 213 {
212 if ( resource ) mImpl->add( resource ); 214 if ( resource ) mImpl->add( resource );
213 } 215 }
214 216
215 void remove( Resource *resource ) 217 void remove( Resource *resource )
216 { 218 {
217 if ( resource ) mImpl->remove( resource ); 219 if ( resource ) mImpl->remove( resource );
218 } 220 }
219 221
220 T* standardResource() 222 T* standardResource()
221 { 223 {
222 return static_cast<T *>( mImpl->standardResource() ); 224 return static_cast<T *>( mImpl->standardResource() );
223 } 225 }
224 226
225 void setStandardResource( T *resource ) 227 void setStandardResource( T *resource )
226 { 228 {
227 if ( resource ) mImpl->setStandardResource( resource ); 229 if ( resource ) mImpl->setStandardResource( resource );
228 } 230 }
229 231
230 void setActive( Resource *resource, bool active ) 232 void setActive( Resource *resource, bool active )
231 { 233 {
232 if ( resource ) mImpl->setActive( resource, active ); 234 if ( resource ) mImpl->setActive( resource, active );
233 } 235 }
234 236
235 /** 237 /**
236 Returns a list of the names of the reources managed by the 238 Returns a list of the names of the reources managed by the
237 Manager for this family. 239 Manager for this family.
238 */ 240 */
239 QStringList resourceNames() const 241 QStringList resourceNames() const
240 { 242 {
241 return mImpl->resourceNames(); 243 return mImpl->resourceNames();
242 } 244 }
243 245
244 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ) 246 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 )
245 { 247 {
246 return mFactory->configWidget( type, parent ); 248 return mFactory->configWidget( type, parent );
247 } 249 }
248 250
249 /** 251 /**
250 Creates a new resource of type @param type, with default 252 Creates a new resource of type @param type, with default
251 settings. The resource is 253 settings. The resource is
252 not added to the manager, the application has to do that. 254 not added to the manager, the application has to do that.
253 Returns a pointer to a resource object or a null pointer 255 Returns a pointer to a resource object or a null pointer
254 if resource type doesn't exist. 256 if resource type doesn't exist.
255 257
256 @param type The type of the resource, one of those returned 258 @param type The type of the resource, one of those returned
257 by @ref resourceTypeNames() 259 by @ref resourceTypeNames()
258 */ 260 */
259 T *createResource( const QString& type ) 261 T *createResource( const QString& type )
260 { 262 {
261 return (T *)( mFactory->resource( type, 0 ) ); 263 return (T *)( mFactory->resource( type, 0 ) );
262 } 264 }
263 265
264 /** 266 /**
265 Returns a list of the names of all available resource types. 267 Returns a list of the names of all available resource types.
266 */ 268 */
267 QStringList resourceTypeNames() const 269 QStringList resourceTypeNames() const
268 { 270 {
269 return mFactory->typeNames(); 271 return mFactory->typeNames();
270 } 272 }
271 273
272 QStringList resourceTypeDescriptions() const 274 QStringList resourceTypeDescriptions() const
273 { 275 {
274 QStringList typeDescs; 276 QStringList typeDescs;
275 QStringList types = mFactory->typeNames(); 277 QStringList types = mFactory->typeNames();
276 278
277 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) { 279 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) {
278 QString desc = mFactory->typeName( *it ); 280 QString desc = mFactory->typeName( *it );
279 if ( !mFactory->typeDescription( *it ).isEmpty() ) 281 if ( !mFactory->typeDescription( *it ).isEmpty() )
280 desc += " (" + mFactory->typeDescription( *it ) + ")"; 282 desc += " (" + mFactory->typeDescription( *it ) + ")";
281 283
282 typeDescs.append( desc ); 284 typeDescs.append( desc );
283 } 285 }
284 286
285 return typeDescs; 287 return typeDescs;
286 } 288 }
287 289
288 void resourceChanged( T *resource ) 290 void resourceChanged( T *resource )
289 { 291 {
290 mImpl->resourceChanged( resource ); 292 mImpl->resourceChanged( resource );
291 } 293 }
292 294
293 void addListener( ManagerListener<T> *listener ) 295 void addListener( ManagerListener<T> *listener )
294 { 296 {
295 mListeners->append( listener ); 297 mListeners->append( listener );
296 } 298 }
297 299
298 void removeListener( ManagerListener<T> *listener ) 300 void removeListener( ManagerListener<T> *listener )
299 { 301 {
300 mListeners->remove( listener ); 302 mListeners->remove( listener );
301 } 303 }
302 304
303 virtual void resourceAdded( Resource *res ) 305 virtual void resourceAdded( Resource *res )
304 { 306 {
305 T* resource = (T *)( res ); 307 T* resource = (T *)( res );
306 ManagerListener<T> *listener; 308 ManagerListener<T> *listener;
307 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) 309 for ( listener = mListeners->first(); listener; listener = mListeners->next() )
308 listener->resourceAdded( resource ); 310 listener->resourceAdded( resource );
309 } 311 }
310 312
311 virtual void resourceModified( Resource *res ) 313 virtual void resourceModified( Resource *res )
312 { 314 {
313 315
314 T* resource = (T *)( res ); 316 T* resource = (T *)( res );
315 ManagerListener<T> *listener; 317 ManagerListener<T> *listener;
316 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) 318 for ( listener = mListeners->first(); listener; listener = mListeners->next() )
317 listener->resourceModified( resource ); 319 listener->resourceModified( resource );
318 } 320 }
319 321
320 virtual void resourceDeleted( Resource *res ) 322 virtual void resourceDeleted( Resource *res )
321 { 323 {
322 324
323 T* resource = (T *)( res ); 325 T* resource = (T *)( res );
324 ManagerListener<T> *listener; 326 ManagerListener<T> *listener;
325 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) { 327 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) {
326 listener->resourceDeleted( resource ); 328 listener->resourceDeleted( resource );
327 } 329 }
328 } 330 }
329 331
330 private: 332 private:
331 ManagerImpl *mImpl; 333 ManagerImpl *mImpl;
332 Factory *mFactory; 334 Factory *mFactory;
333 QPtrList<ManagerListener<T> > *mListeners; 335 Q3PtrList<ManagerListener<T> > *mListeners;
334}; 336};
335 337
336} 338}
337 339
338#endif 340#endif
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index a6d2007..4c0751c 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -1,376 +1,378 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32 32
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37#include <qfile.h> 37#include <qfile.h>
38//Added by qt3to4:
39#include <Q3PtrList>
38 40
39#include "resource.h" 41#include "resource.h"
40#include "factory.h" 42#include "factory.h"
41#include "managerimpl.h" 43#include "managerimpl.h"
42 44
43 45
44 46
45using namespace KRES; 47using namespace KRES;
46 48
47ManagerImpl::ManagerImpl( const QString &family ) 49ManagerImpl::ManagerImpl( const QString &family )
48 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), 50 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
49 mFactory( 0 ) 51 mFactory( 0 )
50 52
51{ 53{
52 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; 54 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
53 55
54 56
55} 57}
56 58
57ManagerImpl::~ManagerImpl() 59ManagerImpl::~ManagerImpl()
58{ 60{
59 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; 61 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
60 62
61 Resource::List::ConstIterator it; 63 Resource::List::ConstIterator it;
62 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 64 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
63 delete *it; 65 delete *it;
64 } 66 }
65 67
66 delete mStdConfig; 68 delete mStdConfig;
67} 69}
68 70
69void ManagerImpl::createStandardConfig() 71void ManagerImpl::createStandardConfig()
70{ 72{
71 if ( !mStdConfig ) { 73 if ( !mStdConfig ) {
72 QString file = locateLocal( "data", KGlobal::getAppName() 74 QString file = locateLocal( "data", KGlobal::getAppName()
73 + "/kresources/" + mFamily + "rc" ); 75 + "/kresources/" + mFamily + "rc" );
74 if ( mFamily == "tmpcontact" ) { 76 if ( mFamily == "tmpcontact" ) {
75 if (QFile::exists ( file ) ){ 77 if (QFile::exists ( file ) ){
76 QFile::remove ( file ); 78 QFile::remove ( file );
77 qDebug("removed tmp rc file: %s ", file.latin1()); 79 qDebug("removed tmp rc file: %s ", file.latin1());
78 } 80 }
79 } 81 }
80 mStdConfig = new KConfig( file ); 82 mStdConfig = new KConfig( file );
81 } 83 }
82 84
83 mConfig = mStdConfig; 85 mConfig = mStdConfig;
84} 86}
85 87
86void ManagerImpl::readConfig( KConfig *cfg ) 88void ManagerImpl::readConfig( KConfig *cfg )
87{ 89{
88 kdDebug(5650) << "ManagerImpl::readConfig()" << endl; 90 kdDebug(5650) << "ManagerImpl::readConfig()" << endl;
89 91
90 delete mFactory; 92 delete mFactory;
91 mFactory = Factory::self( mFamily ); 93 mFactory = Factory::self( mFamily );
92 94
93 if ( !cfg ) { 95 if ( !cfg ) {
94 createStandardConfig(); 96 createStandardConfig();
95 } else { 97 } else {
96 mConfig = cfg; 98 mConfig = cfg;
97 } 99 }
98 100
99 mStandard = 0; 101 mStandard = 0;
100 102
101 mConfig->setGroup( "General" ); 103 mConfig->setGroup( "General" );
102 104
103 QStringList keys = mConfig->readListEntry( "ResourceKeys" ); 105 QStringList keys = mConfig->readListEntry( "ResourceKeys" );
104 keys += mConfig->readListEntry( "PassiveResourceKeys" ); 106 keys += mConfig->readListEntry( "PassiveResourceKeys" );
105 107
106 QString standardKey = mConfig->readEntry( "Standard" ); 108 QString standardKey = mConfig->readEntry( "Standard" );
107 109
108 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { 110 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
109 readResourceConfig( *it, false ); 111 readResourceConfig( *it, false );
110 } 112 }
111 113
112} 114}
113 115
114void ManagerImpl::writeConfig( KConfig *cfg ) 116void ManagerImpl::writeConfig( KConfig *cfg )
115{ 117{
116//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); 118//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
117 119
118 120
119 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; 121 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl;
120 122
121 if ( !cfg ) { 123 if ( !cfg ) {
122 createStandardConfig(); 124 createStandardConfig();
123 } else { 125 } else {
124 mConfig = cfg; 126 mConfig = cfg;
125 } 127 }
126 128
127 QStringList activeKeys; 129 QStringList activeKeys;
128 QStringList passiveKeys; 130 QStringList passiveKeys;
129 131
130 // First write all keys, collect active and passive keys on the way 132 // First write all keys, collect active and passive keys on the way
131 Resource::List::Iterator it; 133 Resource::List::Iterator it;
132 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 134 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
133 writeResourceConfig( *it, false ); 135 writeResourceConfig( *it, false );
134 136
135 QString key = (*it)->identifier(); 137 QString key = (*it)->identifier();
136 if( (*it)->isActive() ) 138 if( (*it)->isActive() )
137 activeKeys.append( key ); 139 activeKeys.append( key );
138 else 140 else
139 passiveKeys.append( key ); 141 passiveKeys.append( key );
140 } 142 }
141 143
142 // And then the general group 144 // And then the general group
143 145
144 kdDebug(5650) << "Saving general info" << endl; 146 kdDebug(5650) << "Saving general info" << endl;
145 mConfig->setGroup( "General" ); 147 mConfig->setGroup( "General" );
146 mConfig->writeEntry( "ResourceKeys", activeKeys ); 148 mConfig->writeEntry( "ResourceKeys", activeKeys );
147 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 149 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
148 if ( mStandard ) 150 if ( mStandard )
149 mConfig->writeEntry( "Standard", mStandard->identifier() ); 151 mConfig->writeEntry( "Standard", mStandard->identifier() );
150 else 152 else
151 mConfig->writeEntry( "Standard", "" ); 153 mConfig->writeEntry( "Standard", "" );
152 154
153 mConfig->sync(); 155 mConfig->sync();
154 kdDebug(5650) << "ManagerImpl::save() finished" << endl; 156 kdDebug(5650) << "ManagerImpl::save() finished" << endl;
155 157
156//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); 158//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
157 159
158} 160}
159 161
160void ManagerImpl::add( Resource *resource, bool useDCOP ) 162void ManagerImpl::add( Resource *resource, bool useDCOP )
161{ 163{
162 //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); 164 //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
163 165
164 resource->setActive( true ); 166 resource->setActive( true );
165 167
166 if ( mResources.isEmpty() ) { 168 if ( mResources.isEmpty() ) {
167 mStandard = resource; 169 mStandard = resource;
168 } 170 }
169 171
170 mResources.append( resource ); 172 mResources.append( resource );
171 173
172 writeResourceConfig( resource, true ); 174 writeResourceConfig( resource, true );
173 175
174 //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); 176 //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
175 177
176} 178}
177 179
178void ManagerImpl::remove( Resource *resource, bool useDCOP ) 180void ManagerImpl::remove( Resource *resource, bool useDCOP )
179{ 181{
180 if ( mStandard == resource ) mStandard = 0; 182 if ( mStandard == resource ) mStandard = 0;
181 removeResource( resource ); 183 removeResource( resource );
182 184
183 mResources.remove( resource ); 185 mResources.remove( resource );
184 186
185 delete resource; 187 delete resource;
186 188
187 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; 189 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl;
188} 190}
189 191
190void ManagerImpl::setActive( Resource *resource, bool active ) 192void ManagerImpl::setActive( Resource *resource, bool active )
191{ 193{
192 if ( resource && resource->isActive() != active ) { 194 if ( resource && resource->isActive() != active ) {
193 resource->setActive( active ); 195 resource->setActive( active );
194 } 196 }
195} 197}
196 198
197Resource *ManagerImpl::standardResource() 199Resource *ManagerImpl::standardResource()
198{ 200{
199 return mStandard; 201 return mStandard;
200} 202}
201 203
202void ManagerImpl::setStandardResource( Resource *resource ) 204void ManagerImpl::setStandardResource( Resource *resource )
203{ 205{
204 mStandard = resource; 206 mStandard = resource;
205} 207}
206 208
207void ManagerImpl::resourceChanged( Resource *resource ) 209void ManagerImpl::resourceChanged( Resource *resource )
208{ 210{
209 writeResourceConfig( resource, true ); 211 writeResourceConfig( resource, true );
210 212
211 213
212// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); 214// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() );
213// allManagers.dcopResourceModified( resource->identifier() ); 215// allManagers.dcopResourceModified( resource->identifier() );
214} 216}
215 217
216// DCOP asynchronous functions 218// DCOP asynchronous functions
217//US since we work from inside the application, we call the methods directly. 219//US since we work from inside the application, we call the methods directly.
218 220
219QStringList ManagerImpl::resourceNames() 221QStringList ManagerImpl::resourceNames()
220{ 222{
221 QStringList result; 223 QStringList result;
222 224
223 Resource::List::ConstIterator it; 225 Resource::List::ConstIterator it;
224 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 226 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
225 result.append( (*it)->resourceName() ); 227 result.append( (*it)->resourceName() );
226 } 228 }
227 return result; 229 return result;
228} 230}
229 231
230Resource::List *ManagerImpl::resourceList() 232Resource::List *ManagerImpl::resourceList()
231{ 233{
232 return &mResources; 234 return &mResources;
233} 235}
234 236
235QPtrList<Resource> ManagerImpl::resources() 237Q3PtrList<Resource> ManagerImpl::resources()
236{ 238{
237 QPtrList<Resource> result; 239 Q3PtrList<Resource> result;
238 240
239 Resource::List::ConstIterator it; 241 Resource::List::ConstIterator it;
240 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 242 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
241 result.append( *it ); 243 result.append( *it );
242 } 244 }
243 return result; 245 return result;
244} 246}
245 247
246QPtrList<Resource> ManagerImpl::resources( bool active ) 248Q3PtrList<Resource> ManagerImpl::resources( bool active )
247{ 249{
248 QPtrList<Resource> result; 250 Q3PtrList<Resource> result;
249 251
250 Resource::List::ConstIterator it; 252 Resource::List::ConstIterator it;
251 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 253 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
252 if ( (*it)->isActive() == active ) { 254 if ( (*it)->isActive() == active ) {
253 result.append( *it ); 255 result.append( *it );
254 } 256 }
255 } 257 }
256 return result; 258 return result;
257} 259}
258 260
259void ManagerImpl::setListener( ManagerImplListener *listener ) 261void ManagerImpl::setListener( ManagerImplListener *listener )
260{ 262{
261 mListener = listener; 263 mListener = listener;
262} 264}
263 265
264Resource* ManagerImpl::readResourceConfig( const QString& identifier, 266Resource* ManagerImpl::readResourceConfig( const QString& identifier,
265 bool checkActive ) 267 bool checkActive )
266{ 268{
267 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 269 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
268 270
269// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 271// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
270 272
271 mConfig->setGroup( "Resource_" + identifier ); 273 mConfig->setGroup( "Resource_" + identifier );
272#ifdef _WIN32_ 274#ifdef _WIN32_
273 // we use plugins on win32. the group is stored in a static variable 275 // we use plugins on win32. the group is stored in a static variable
274 // such that gourp info not avail on win32 plugins 276 // such that gourp info not avail on win32 plugins
275 // to fix that, it would be a looooot of work 277 // to fix that, it would be a looooot of work
276 mConfig->setTempGroup( "Resource_" + identifier ); 278 mConfig->setTempGroup( "Resource_" + identifier );
277#endif 279#endif
278 QString type = mConfig->readEntry( "ResourceType" ); 280 QString type = mConfig->readEntry( "ResourceType" );
279 QString name = mConfig->readEntry( "ResourceName" ); 281 QString name = mConfig->readEntry( "ResourceName" );
280 Resource *resource = mFactory->resource( type, mConfig ); 282 Resource *resource = mFactory->resource( type, mConfig );
281 if ( !resource ) { 283 if ( !resource ) {
282 qDebug("Failed to create resource with id %s ",identifier.latin1() ); 284 qDebug("Failed to create resource with id %s ",identifier.latin1() );
283 return 0; 285 return 0;
284 } 286 }
285 287
286 if ( resource->identifier().isEmpty() ) 288 if ( resource->identifier().isEmpty() )
287 resource->setIdentifier( identifier ); 289 resource->setIdentifier( identifier );
288 290
289 mConfig->setGroup( "General" ); 291 mConfig->setGroup( "General" );
290 292
291 QString standardKey = mConfig->readEntry( "Standard" ); 293 QString standardKey = mConfig->readEntry( "Standard" );
292 if ( standardKey == identifier ) { 294 if ( standardKey == identifier ) {
293 mStandard = resource; 295 mStandard = resource;
294 } 296 }
295 297
296 if ( checkActive ) { 298 if ( checkActive ) {
297 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 299 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
298 resource->setActive( activeKeys.contains( identifier ) ); 300 resource->setActive( activeKeys.contains( identifier ) );
299 } 301 }
300 mResources.append( resource ); 302 mResources.append( resource );
301 303
302 return resource; 304 return resource;
303} 305}
304 306
305void ManagerImpl::writeResourceConfig( Resource *resource, 307void ManagerImpl::writeResourceConfig( Resource *resource,
306 bool checkActive ) 308 bool checkActive )
307{ 309{
308 QString key = resource->identifier(); 310 QString key = resource->identifier();
309 311
310 kdDebug(5650) << "Saving resource " << key << endl; 312 kdDebug(5650) << "Saving resource " << key << endl;
311 313
312 if ( !mConfig ) createStandardConfig(); 314 if ( !mConfig ) createStandardConfig();
313 315
314 mConfig->setGroup( "Resource_" + key ); 316 mConfig->setGroup( "Resource_" + key );
315 resource->writeConfig( mConfig ); 317 resource->writeConfig( mConfig );
316 318
317 mConfig->setGroup( "General" ); 319 mConfig->setGroup( "General" );
318 QString standardKey = mConfig->readEntry( "Standard" ); 320 QString standardKey = mConfig->readEntry( "Standard" );
319 321
320 if ( resource == mStandard && standardKey != key ) 322 if ( resource == mStandard && standardKey != key )
321 mConfig->writeEntry( "Standard", resource->identifier() ); 323 mConfig->writeEntry( "Standard", resource->identifier() );
322 else if ( resource != mStandard && standardKey == key ) 324 else if ( resource != mStandard && standardKey == key )
323 mConfig->writeEntry( "Standard", "" ); 325 mConfig->writeEntry( "Standard", "" );
324 326
325 if ( checkActive ) { 327 if ( checkActive ) {
326 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 328 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
327 if ( resource->isActive() && !activeKeys.contains( key ) ) { 329 if ( resource->isActive() && !activeKeys.contains( key ) ) {
328 activeKeys.append( resource->identifier() ); 330 activeKeys.append( resource->identifier() );
329 mConfig->writeEntry( "ResourceKeys", activeKeys ); 331 mConfig->writeEntry( "ResourceKeys", activeKeys );
330 } else if ( !resource->isActive() && activeKeys.contains( key ) ) { 332 } else if ( !resource->isActive() && activeKeys.contains( key ) ) {
331 activeKeys.remove( key ); 333 activeKeys.remove( key );
332 mConfig->writeEntry( "ResourceKeys", activeKeys ); 334 mConfig->writeEntry( "ResourceKeys", activeKeys );
333 } 335 }
334 } 336 }
335 337
336 mConfig->sync(); 338 mConfig->sync();
337} 339}
338 340
339void ManagerImpl::removeResource( Resource *resource ) 341void ManagerImpl::removeResource( Resource *resource )
340{ 342{
341 QString key = resource->identifier(); 343 QString key = resource->identifier();
342 344
343 if ( !mConfig ) createStandardConfig(); 345 if ( !mConfig ) createStandardConfig();
344 346
345 mConfig->setGroup( "General" ); 347 mConfig->setGroup( "General" );
346 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 348 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
347 if ( activeKeys.contains( key ) ) { 349 if ( activeKeys.contains( key ) ) {
348 activeKeys.remove( key ); 350 activeKeys.remove( key );
349 mConfig->writeEntry( "ResourceKeys", activeKeys ); 351 mConfig->writeEntry( "ResourceKeys", activeKeys );
350 } else { 352 } else {
351 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); 353 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" );
352 passiveKeys.remove( key ); 354 passiveKeys.remove( key );
353 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 355 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
354 } 356 }
355 357
356 QString standardKey = mConfig->readEntry( "Standard" ); 358 QString standardKey = mConfig->readEntry( "Standard" );
357 if ( standardKey == key ) { 359 if ( standardKey == key ) {
358 mConfig->writeEntry( "Standard", "" ); 360 mConfig->writeEntry( "Standard", "" );
359 } 361 }
360 362
361 mConfig->deleteGroup( "Resource_" + resource->identifier() ); 363 mConfig->deleteGroup( "Resource_" + resource->identifier() );
362 364
363 mConfig->sync(); 365 mConfig->sync();
364} 366}
365 367
366Resource* ManagerImpl::getResource( const QString& identifier ) 368Resource* ManagerImpl::getResource( const QString& identifier )
367{ 369{
368 Resource::List::ConstIterator it; 370 Resource::List::ConstIterator it;
369 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 371 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
370 if ( (*it)->identifier() == identifier ) 372 if ( (*it)->identifier() == identifier )
371 return *it; 373 return *it;
372 } 374 }
373 return 0; 375 return 0;
374} 376}
375 377
376 378
diff --git a/microkde/kresources/managerimpl.h b/microkde/kresources/managerimpl.h
index 56a2db6..1f728e5 100644
--- a/microkde/kresources/managerimpl.h
+++ b/microkde/kresources/managerimpl.h
@@ -1,120 +1,120 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KRESOURCES_MANAGERIMPL_H 31#ifndef KRESOURCES_MANAGERIMPL_H
32#define KRESOURCES_MANAGERIMPL_H 32#define KRESOURCES_MANAGERIMPL_H
33 33
34#include <qstring.h> 34#include <qstring.h>
35#include <qptrlist.h> 35#include <q3ptrlist.h>
36#include <qdict.h> 36#include <q3dict.h>
37//US 37//US
38#include <qobject.h> 38#include <qobject.h>
39 39
40#include "resource.h" 40#include "resource.h"
41 41
42 42
43class KConfig; 43class KConfig;
44 44
45namespace KRES { 45namespace KRES {
46 46
47class Resource; 47class Resource;
48class Factory; 48class Factory;
49 49
50class ManagerImplListener 50class ManagerImplListener
51{ 51{
52 public: 52 public:
53 virtual void resourceAdded( Resource *resource ) = 0; 53 virtual void resourceAdded( Resource *resource ) = 0;
54 virtual void resourceModified( Resource *resource ) = 0; 54 virtual void resourceModified( Resource *resource ) = 0;
55 virtual void resourceDeleted( Resource *resource ) = 0; 55 virtual void resourceDeleted( Resource *resource ) = 0;
56}; 56};
57 57
58 58
59/** 59/**
60 @internal 60 @internal
61 61
62 Do not use this class directly. Use ResourceManager instead 62 Do not use this class directly. Use ResourceManager instead
63*/ 63*/
64class ManagerImpl : public QObject 64class ManagerImpl : public QObject
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 public: 67 public:
68 ManagerImpl( const QString &family); 68 ManagerImpl( const QString &family);
69 ~ManagerImpl(); 69 ~ManagerImpl();
70 70
71 void readConfig( KConfig * ); 71 void readConfig( KConfig * );
72 void writeConfig( KConfig * ); 72 void writeConfig( KConfig * );
73 73
74 void add( Resource *resource, bool useDCOP = true ); 74 void add( Resource *resource, bool useDCOP = true );
75 void remove( Resource *resource, bool useDCOP = true ); 75 void remove( Resource *resource, bool useDCOP = true );
76 76
77 Resource *standardResource(); 77 Resource *standardResource();
78 void setStandardResource( Resource *resource ); 78 void setStandardResource( Resource *resource );
79 79
80 void setActive( Resource *resource, bool active ); 80 void setActive( Resource *resource, bool active );
81 81
82 Resource::List *resourceList(); 82 Resource::List *resourceList();
83 83
84 QPtrList<Resource> resources(); 84 Q3PtrList<Resource> resources();
85 85
86 // Get only active or passive resources 86 // Get only active or passive resources
87 QPtrList<Resource> resources( bool active ); 87 Q3PtrList<Resource> resources( bool active );
88 88
89 QStringList resourceNames(); 89 QStringList resourceNames();
90 90
91 void setListener( ManagerImplListener *listener ); 91 void setListener( ManagerImplListener *listener );
92 92
93 public slots: 93 public slots:
94 void resourceChanged( Resource *resource ); 94 void resourceChanged( Resource *resource );
95 95
96 private: 96 private:
97 // dcop calls 97 // dcop calls
98 98
99 private: 99 private:
100 void createStandardConfig(); 100 void createStandardConfig();
101 101
102 Resource *readResourceConfig( const QString& identifier, bool checkActive ); 102 Resource *readResourceConfig( const QString& identifier, bool checkActive );
103 void writeResourceConfig( Resource *resource, bool checkActive ); 103 void writeResourceConfig( Resource *resource, bool checkActive );
104 104
105 void removeResource( Resource *resource ); 105 void removeResource( Resource *resource );
106 Resource *getResource( Resource *resource ); 106 Resource *getResource( Resource *resource );
107 Resource *getResource( const QString& identifier ); 107 Resource *getResource( const QString& identifier );
108 108
109 QString mFamily; 109 QString mFamily;
110 KConfig *mConfig; 110 KConfig *mConfig;
111 KConfig *mStdConfig; 111 KConfig *mStdConfig;
112 Resource *mStandard; 112 Resource *mStandard;
113 Factory *mFactory; 113 Factory *mFactory;
114 Resource::List mResources; 114 Resource::List mResources;
115 ManagerImplListener *mListener; 115 ManagerImplListener *mListener;
116}; 116};
117 117
118} 118}
119 119
120#endif 120#endif
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index ed5af96..1f9527c 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -1,404 +1,404 @@
1/* 1/*
2 This file is part of libkresources 2 This file is part of libkresources
3 3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef KRESOURCES_RESOURCE_H 23#ifndef KRESOURCES_RESOURCE_H
24#define KRESOURCES_RESOURCE_H 24#define KRESOURCES_RESOURCE_H
25 25
26//US 26//US
27#ifdef QT_THREAD_SUPPORT 27#ifdef QT_THREAD_SUPPORT
28#include <qmutex.h> 28#include <qmutex.h>
29#endif //QT_THREAD_SUPPORT 29#endif //QT_THREAD_SUPPORT
30 30
31#include <qvaluelist.h> 31#include <q3valuelist.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
36#include <klibloader.h> 36#include <klibloader.h>
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43 43
44/** 44/**
45 * @internal 45 * @internal
46 * @libdoc The KDE Resource library 46 * @libdoc The KDE Resource library
47 * 47 *
48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
49 * interface, it is in constant flux. 49 * interface, it is in constant flux.
50 * 50 *
51 * The KDE Resource framework can be used to manage resources of 51 * The KDE Resource framework can be used to manage resources of
52 * different types, organized in families. The Resource framework 52 * different types, organized in families. The Resource framework
53 * is currently used for addressbook resources in libkabc and for 53 * is currently used for addressbook resources in libkabc and for
54 * calendar resources in libkcal. 54 * calendar resources in libkcal.
55 * 55 *
56 * When you want to use the framework for a new family, you need to 56 * When you want to use the framework for a new family, you need to
57 * <ul><li>Define a name for your resource family</li> 57 * <ul><li>Define a name for your resource family</li>
58 * <li>subclass Resource and add the fields and method that are needed 58 * <li>subclass Resource and add the fields and method that are needed
59 * in your application</li> 59 * in your application</li>
60 * <li>If needed, override the doOpen() and doClose() methods. 60 * <li>If needed, override the doOpen() and doClose() methods.
61 * <li> Provide a configuration possibility for resources in your 61 * <li> Provide a configuration possibility for resources in your
62 * new family. You can use @ref ResourcesConfigPage to easily create a 62 * new family. You can use @ref ResourcesConfigPage to easily create a
63 * KControl applet</li> 63 * KControl applet</li>
64 * <li>In your application, you can use @ref ResourceManager to keep track 64 * <li>In your application, you can use @ref ResourceManager to keep track
65 * of the resources in your family, and you can use @ref ResourceSelectDialog 65 * of the resources in your family, and you can use @ref ResourceSelectDialog
66 * to let the user select a single resource.</li> 66 * to let the user select a single resource.</li>
67 * </ul> 67 * </ul>
68 * 68 *
69 * When you want to add a new resource type to an existing resource family, 69 * When you want to add a new resource type to an existing resource family,
70 * you need to 70 * you need to
71 * <ul><li>Further subclass the family-specific Resource to implement 71 * <ul><li>Further subclass the family-specific Resource to implement
72 * resource type-specific operation</li> 72 * resource type-specific operation</li>
73 * <li>Subclass ResourceConfigWidget to provide a configuration widget 73 * <li>Subclass ResourceConfigWidget to provide a configuration widget
74 * for your new resource type</li> 74 * for your new resource type</li>
75 * <li>Provide a .desktop file so that the new resource type can be found 75 * <li>Provide a .desktop file so that the new resource type can be found
76 * automatically by the ResourceManager</li> 76 * automatically by the ResourceManager</li>
77 * </ul> 77 * </ul>
78 * 78 *
79 * Example: 79 * Example:
80 * 80 *
81<B>resourceexample.h</B>: 81<B>resourceexample.h</B>:
82<pre> 82<pre>
83#include <kconfig.h> 83#include <kconfig.h>
84#include <kresources/resource.h> 84#include <kresources/resource.h>
85 85
86class ResourceExample : public KRES::ResourceExample 86class ResourceExample : public KRES::ResourceExample
87{ 87{
88public: 88public:
89 ResourceExample( const KConfig * ); 89 ResourceExample( const KConfig * );
90 ~ResourceCalendarExchange(); 90 ~ResourceCalendarExchange();
91 void writeConfig( KConfig *config ); 91 void writeConfig( KConfig *config );
92private: 92private:
93 QString mLocation; 93 QString mLocation;
94 QString mPassword; 94 QString mPassword;
95} 95}
96</pre> 96</pre>
97<B>resourceexample.cpp</B>: 97<B>resourceexample.cpp</B>:
98<pre> 98<pre>
99#include <kconfig.h> 99#include <kconfig.h>
100 100
101#include "resourceexample.h" 101#include "resourceexample.h"
102 102
103ResourceExample::ResourceExample( const KConfig *config ) 103ResourceExample::ResourceExample( const KConfig *config )
104 : Resource( config ) 104 : Resource( config )
105{ 105{
106 if ( config ) { 106 if ( config ) {
107 mLocation = config->readEntry( "Location" ); 107 mLocation = config->readEntry( "Location" );
108 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) ); 108 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) );
109 } else { 109 } else {
110 mLocation = ""; // Or some sensible default 110 mLocation = ""; // Or some sensible default
111 mPassword = ""; 111 mPassword = "";
112 } 112 }
113} 113}
114 114
115void ResourceExample::writeConfig( KConfig *config ) 115void ResourceExample::writeConfig( KConfig *config )
116{ 116{
117 KRES::Resource::writeConfig( config ); 117 KRES::Resource::writeConfig( config );
118 config->writeEntry( "Location", mLocation ); 118 config->writeEntry( "Location", mLocation );
119 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) ); 119 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) );
120} 120}
121 121
122extern "C" 122extern "C"
123{ 123{
124 KRES::ResourceExample *config_widget( QWidget *parent ) { 124 KRES::ResourceExample *config_widget( QWidget *parent ) {
125 return new ResourceExampleConfig( parent, "Configure Example Resource" ); 125 return new ResourceExampleConfig( parent, "Configure Example Resource" );
126 } 126 }
127 127
128 KRES::Resource *resource( const KConfig *config ) { 128 KRES::Resource *resource( const KConfig *config ) {
129 return new ResourceExample( config ); 129 return new ResourceExample( config );
130 } 130 }
131} 131}
132</pre> 132</pre>
133* <B>resourceexampleconfig.h</B>: 133* <B>resourceexampleconfig.h</B>:
134<pre> 134<pre>
135#include <klineedit.h> 135#include <klineedit.h>
136#include <kresources/resourceconfigwidget.h> 136#include <kresources/resourceconfigwidget.h>
137 137
138#include "resourceexample.h" 138#include "resourceexample.h"
139 139
140class ResourceExampleConfig : public KRES::ResourceConfigWidget 140class ResourceExampleConfig : public KRES::ResourceConfigWidget
141{ 141{
142 Q_OBJECT 142 Q_OBJECT
143 143
144public: 144public:
145 ResourceExampleConfig( QWidget* parent = 0, const char* name = 0 ); 145 ResourceExampleConfig( QWidget* parent = 0, const char* name = 0 );
146 146
147public slots: 147public slots:
148 virtual void loadSettings( KRES::Resource *resource); 148 virtual void loadSettings( KRES::Resource *resource);
149 virtual void saveSettings( KRES::Resource *resource ); 149 virtual void saveSettings( KRES::Resource *resource );
150 150
151private: 151private:
152 KLineEdit* mLocationEdit; 152 KLineEdit* mLocationEdit;
153 KLineEdit* mPasswordEdit; 153 KLineEdit* mPasswordEdit;
154}; 154};
155</pre> 155</pre>
156* <B>resourceexampleconfig.cpp</B>: 156* <B>resourceexampleconfig.cpp</B>:
157<pre> 157<pre>
158#include <qlayout.h> 158#include <qlayout.h>
159#include <qlabel.h" 159#include <qlabel.h"
160#include <kresources/resourceconfigwidget.h> 160#include <kresources/resourceconfigwidget.h>
161#include "resourceexample.h" 161#include "resourceexample.h"
162#include "resourceexampleconfig.h" 162#include "resourceexampleconfig.h"
163 163
164ResourceExampleConfig::ResourceExampleConfig( QWidget* parent, const char* name ) 164ResourceExampleConfig::ResourceExampleConfig( QWidget* parent, const char* name )
165 : KRES::ResourceConfigWidget( parent, name ) 165 : KRES::ResourceConfigWidget( parent, name )
166{ 166{
167 resize( 245, 115 ); 167 resize( 245, 115 );
168 QGridLayout *mainLayout = new QGridLayout( this, 2, 2 ); 168 QGridLayout *mainLayout = new QGridLayout( this, 2, 2 );
169 169
170 QLabel *label = new QLabel( i18n( "Location:" ), this ); 170 QLabel *label = new QLabel( i18n( "Location:" ), this );
171 mHostEdit = new KLineEdit( this ); 171 mHostEdit = new KLineEdit( this );
172 mainLayout->addWidget( label, 1, 0 ); 172 mainLayout->addWidget( label, 1, 0 );
173 mainLayout->addWidget( mHostEdit, 1, 1 ); 173 mainLayout->addWidget( mHostEdit, 1, 1 );
174 174
175 label = new QLabel( i18n( "Password:" ), this ); 175 label = new QLabel( i18n( "Password:" ), this );
176 mPasswordEdit = new KLineEdit( this ); 176 mPasswordEdit = new KLineEdit( this );
177 mPasswordEdit->setEchoMode( QLineEdit::Password ); 177 mPasswordEdit->setEchoMode( QLineEdit::Password );
178 mainLayout->addWidget( label, 2, 0 ); 178 mainLayout->addWidget( label, 2, 0 );
179 mainLayout->addWidget( mPasswordEdit, 2, 1 ); 179 mainLayout->addWidget( mPasswordEdit, 2, 1 );
180} 180}
181 181
182void ResourceExampleConfig::loadSettings( KRES::Resource *resource ) 182void ResourceExampleConfig::loadSettings( KRES::Resource *resource )
183{ 183{
184 ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); 184 ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
185 if (res) { 185 if (res) {
186 mHostEdit->setText( res->host() ); 186 mHostEdit->setText( res->host() );
187 mPasswordEdit->setText( res->password() ); 187 mPasswordEdit->setText( res->password() );
188 } else 188 } else
189 kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl; 189 kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl;
190} 190}
191 191
192void ResourceExampleConfig::saveSettings( KRES::Resource *resource ) 192void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
193{ 193{
194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); 194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
195 if (res) { 195 if (res) {
196 res->setHost(mHostEdit->text()); 196 res->setHost(mHostEdit->text());
197 res->setPassword(mPasswordEdit->text()); 197 res->setPassword(mPasswordEdit->text());
198 } else 198 } else
199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl; 199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl;
200} 200}
201</pre> 201</pre>
202* <B>resourceexample.desktop</B>: 202* <B>resourceexample.desktop</B>:
203<pre> 203<pre>
204[Desktop Entry] 204[Desktop Entry]
205Type=Service 205Type=Service
206 206
207[Misc] 207[Misc]
208Encoding=UTF-8 208Encoding=UTF-8
209Name=Example Resource 209Name=Example Resource
210 210
211[Plugin] 211[Plugin]
212Type=exchange 212Type=exchange
213X-KDE-Library=resourceexample 213X-KDE-Library=resourceexample
214</pre> 214</pre>
215* <B>Makefile.am</B> 215* <B>Makefile.am</B>
216<pre> 216<pre>
217kde_module_LTLIBRARIES = resourceexample.la 217kde_module_LTLIBRARIES = resourceexample.la
218 218
219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp 219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) 220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
221resourceexample_la_LIBADD= -lkderesources 221resourceexample_la_LIBADD= -lkderesources
222 222
223linkdir= $(kde_datadir)/resources/family 223linkdir= $(kde_datadir)/resources/family
224link_DATA= resourceexample.desktop 224link_DATA= resourceexample.desktop
225</pre> 225</pre>
226 * 226 *
227 * 227 *
228 */ 228 */
229 229
230/** 230/**
231 * A @ref Resource is a ... 231 * A @ref Resource is a ...
232 * 232 *
233 * A subclass should reimplement at least the constructor and the 233 * A subclass should reimplement at least the constructor and the
234k * @ref writeConfig method. 234k * @ref writeConfig method.
235 * 235 *
236 */ 236 */
237class Resource : public QObject 237class Resource : public QObject
238{ 238{
239 Q_OBJECT 239 Q_OBJECT
240 240
241 public: 241 public:
242 typedef QValueList<Resource *> List; 242 typedef Q3ValueList<Resource *> List;
243 243
244 /** 244 /**
245 * Constructor. Construct resource from config. 245 * Constructor. Construct resource from config.
246 * @param config Configuration to read persistence information from. 246 * @param config Configuration to read persistence information from.
247 * If config==0, create object using default settings. 247 * If config==0, create object using default settings.
248 */ 248 */
249 Resource( const KConfig* config ); 249 Resource( const KConfig* config );
250 250
251 /** 251 /**
252 * Destructor. 252 * Destructor.
253 */ 253 */
254 virtual ~Resource(); 254 virtual ~Resource();
255 255
256 /** 256 /**
257 * Write configuration information for this resource to a configuration 257 * Write configuration information for this resource to a configuration
258 * file. If you override this method, remember to call Resource::writeConfig 258 * file. If you override this method, remember to call Resource::writeConfig
259 * or Terrible Things(TM) will happen. 259 * or Terrible Things(TM) will happen.
260 * @param config Configuration to write persistence information to. 260 * @param config Configuration to write persistence information to.
261 */ 261 */
262 virtual void writeConfig( KConfig* config ); 262 virtual void writeConfig( KConfig* config );
263 263
264 /** 264 /**
265 * Open this resource, if it not already open. Increase the open 265 * Open this resource, if it not already open. Increase the open
266 * count of this object, and open the resource by calling @ref doOpen(). 266 * count of this object, and open the resource by calling @ref doOpen().
267 * This method may block while another thread is concurrently opening 267 * This method may block while another thread is concurrently opening
268 * or closing the resource. 268 * or closing the resource.
269 * 269 *
270 * Returns true if the resource was already opened or if it was opened 270 * Returns true if the resource was already opened or if it was opened
271 * successfully; returns false if the resource was not opened successfully. 271 * successfully; returns false if the resource was not opened successfully.
272 */ 272 */
273 bool open(); 273 bool open();
274 274
275 /** 275 /**
276 * Decrease the open count of this object, and if the count reaches 276 * Decrease the open count of this object, and if the count reaches
277 * zero, close this resource by calling @ref doClose(). 277 * zero, close this resource by calling @ref doClose().
278 * This method may block while another thread is concurrently closing 278 * This method may block while another thread is concurrently closing
279 * or opening the resource. 279 * or opening the resource.
280 */ 280 */
281 void close(); 281 void close();
282 282
283 /** 283 /**
284 * Returns whether the resource is open or not. 284 * Returns whether the resource is open or not.
285 */ 285 */
286 bool isOpen() const; 286 bool isOpen() const;
287 287
288 /** 288 /**
289 * Returns a unique identifier. The identifier is unique for this resource. 289 * Returns a unique identifier. The identifier is unique for this resource.
290 * It is created when the resource is first created, and it is retained 290 * It is created when the resource is first created, and it is retained
291 * in the resource family configuration file for this resource. 291 * in the resource family configuration file for this resource.
292 * @return This resource's identifier 292 * @return This resource's identifier
293 */ 293 */
294 QString identifier() const; 294 QString identifier() const;
295 295
296 /** 296 /**
297 * Returns the type of this resource. 297 * Returns the type of this resource.
298 */ 298 */
299 QString type() const; 299 QString type() const;
300 300
301 /** 301 /**
302 * Mark the resource as read-only. You can override this method, 302 * Mark the resource as read-only. You can override this method,
303 * but also remember to call Resource::setReadOnly(). 303 * but also remember to call Resource::setReadOnly().
304 */ 304 */
305 virtual void setReadOnly( bool value ); 305 virtual void setReadOnly( bool value );
306 306
307 /** 307 /**
308 * Returns, if the resource is read-only. 308 * Returns, if the resource is read-only.
309 */ 309 */
310 virtual bool readOnly() const; 310 virtual bool readOnly() const;
311 311
312 void setIncludeInSync( bool value ); 312 void setIncludeInSync( bool value );
313 bool includeInSync() const; 313 bool includeInSync() const;
314 /** 314 /**
315 * Set the name of resource.You can override this method, 315 * Set the name of resource.You can override this method,
316 * but also remember to call Resource::setResourceName(). 316 * but also remember to call Resource::setResourceName().
317 */ 317 */
318 virtual void setResourceName( const QString &name ); 318 virtual void setResourceName( const QString &name );
319 319
320 /** 320 /**
321 * Returns the name of resource. 321 * Returns the name of resource.
322 */ 322 */
323 virtual QString resourceName() const; 323 virtual QString resourceName() const;
324 324
325 /** 325 /**
326 Sets, if the resource is active. 326 Sets, if the resource is active.
327 */ 327 */
328 void setActive( bool active ); 328 void setActive( bool active );
329 329
330 /** 330 /**
331 Return true, if the resource is active. 331 Return true, if the resource is active.
332 */ 332 */
333 bool isActive() const; 333 bool isActive() const;
334 334
335 friend class Factory; 335 friend class Factory;
336 friend class ManagerImpl; 336 friend class ManagerImpl;
337 337
338 /** 338 /**
339 Print resource information as debug output. 339 Print resource information as debug output.
340 */ 340 */
341 virtual void dump() const; 341 virtual void dump() const;
342 342
343 343
344 protected: 344 protected:
345 /** 345 /**
346 * Open this resource. When called, the resource must be in 346 * Open this resource. When called, the resource must be in
347 * a closed state. 347 * a closed state.
348 * 348 *
349 * Returns true if the resource was opened successfully; 349 * Returns true if the resource was opened successfully;
350 * returns false if the resource was not opened successfully. 350 * returns false if the resource was not opened successfully.
351 * 351 *
352 * The result of this call can be accessed later by @ref isOpen() 352 * The result of this call can be accessed later by @ref isOpen()
353 */ 353 */
354 virtual bool doOpen() { return true; } 354 virtual bool doOpen() { return true; }
355 355
356 /** 356 /**
357 * Close this resource. Pre-condition: resource is open. 357 * Close this resource. Pre-condition: resource is open.
358 * Post-condition: resource is closed. 358 * Post-condition: resource is closed.
359 */ 359 */
360 virtual void doClose() {} 360 virtual void doClose() {}
361 361
362 void setIdentifier( const QString& identifier ); 362 void setIdentifier( const QString& identifier );
363 void setType( const QString& type ); 363 void setType( const QString& type );
364 364
365 private: 365 private:
366 class ResourcePrivate; 366 class ResourcePrivate;
367 ResourcePrivate *d; 367 ResourcePrivate *d;
368}; 368};
369 369
370class PluginFactoryBase : public KLibFactory 370class PluginFactoryBase : public KLibFactory
371{ 371{
372 public: 372 public:
373 virtual Resource *resource( const KConfig *config) = 0; 373 virtual Resource *resource( const KConfig *config) = 0;
374 374
375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
376 376
377 protected: 377 protected:
378 virtual QObject* createObject( QObject*, const char*, const char*, 378 virtual QObject* createObject( QObject*, const char*, const char*,
379 const QStringList & ) 379 const QStringList & )
380 { 380 {
381 return 0; 381 return 0;
382 } 382 }
383}; 383};
384 384
385template<class TR,class TC> 385template<class TR,class TC>
386class PluginFactory : public PluginFactoryBase 386class PluginFactory : public PluginFactoryBase
387{ 387{
388 public: 388 public:
389 Resource *resource( const KConfig *config) 389 Resource *resource( const KConfig *config)
390 { 390 {
391 return new TR( config ); 391 return new TR( config );
392 } 392 }
393 393
394 ConfigWidget *configWidget( QWidget *parent ) 394 ConfigWidget *configWidget( QWidget *parent )
395 { 395 {
396 return new TC( parent ); 396 return new TC( parent );
397 } 397 }
398}; 398};
399 399
400 400
401 401
402} 402}
403 403
404#endif 404#endif
diff --git a/microkde/kresources/selectdialog.cpp b/microkde/kresources/selectdialog.cpp
index fba8648..d5b83e9 100644
--- a/microkde/kresources/selectdialog.cpp
+++ b/microkde/kresources/selectdialog.cpp
@@ -1,154 +1,158 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/*US 24/*US
25#include <kbuttonbox.h> 25#include <kbuttonbox.h>
26#include <klistbox.h> 26#include <klistbox.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <kmessagebox.h> 28#include <kmessagebox.h>
29 29
30*/ 30*/
31#include <klocale.h> 31#include <klocale.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34//US 34//US
35#include <kglobal.h> 35#include <kglobal.h>
36 36
37#include <qlistbox.h> 37#include <q3listbox.h>
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qgroupbox.h> 39#include <q3groupbox.h>
40//Added by qt3to4:
41#include <Q3VBoxLayout>
42#include <Q3Frame>
43#include <Q3PtrList>
40 44
41#include "resource.h" 45#include "resource.h"
42 46
43#include "selectdialog.h" 47#include "selectdialog.h"
44 48
45using namespace KRES; 49using namespace KRES;
46 50
47//US I am using KBaseDialog instead of KDialog 51//US I am using KBaseDialog instead of KDialog
48//US : KDialog( parent, name, true ) 52//US : KDialog( parent, name, true )
49SelectDialog::SelectDialog( QPtrList<Resource> list, QWidget *parent, 53SelectDialog::SelectDialog( Q3PtrList<Resource> list, QWidget *parent,
50 const char *name ) 54 const char *name )
51 : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel, 55 : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel,
52 Ok, true) 56 Ok, true)
53 57
54{ 58{
55//US setCaption( i18n( "Resource Selection" ) ); 59//US setCaption( i18n( "Resource Selection" ) );
56//US resize( 300, 200 ); 60//US resize( 300, 200 );
57 resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) ); 61 resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) );
58 62
59//US 63//US
60 QFrame *main = plainPage(); 64 Q3Frame *main = plainPage();
61/*US 65/*US
62 QVBoxLayout *layout = new QVBoxLayout( main ); 66 QVBoxLayout *layout = new QVBoxLayout( main );
63 mConfigPage = new KRES::ConfigPage( main ); 67 mConfigPage = new KRES::ConfigPage( main );
64 layout->addWidget( mConfigPage ); 68 layout->addWidget( mConfigPage );
65*/ 69*/
66 70
67//US QVBoxLayout *mainLayout = new QVBoxLayout( this ); 71//US QVBoxLayout *mainLayout = new QVBoxLayout( this );
68 QVBoxLayout *mainLayout = new QVBoxLayout( main ); 72 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main );
69 mainLayout->setMargin( marginHint() ); 73 mainLayout->setMargin( marginHint() );
70 74
71//US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this ); 75//US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this );
72 QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, main ); 76 Q3GroupBox *groupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
73 groupBox->setTitle( i18n( "Resources" ) ); 77 groupBox->setTitle( i18n( "Resources" ) );
74 78
75//US mResourceId = new KListBox( groupBox ); 79//US mResourceId = new KListBox( groupBox );
76 mResourceId = new QListBox( groupBox ); 80 mResourceId = new Q3ListBox( groupBox );
77 81
78 mainLayout->addWidget( groupBox ); 82 mainLayout->addWidget( groupBox );
79 83
80 mainLayout->addSpacing( 40 ); 84 mainLayout->addSpacing( 40 );
81 85
82/*US 86/*US
83 KButtonBox *buttonBox = new KButtonBox( this ); 87 KButtonBox *buttonBox = new KButtonBox( this );
84 88
85 buttonBox->addStretch(); 89 buttonBox->addStretch();
86 buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) ); 90 buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) );
87 buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) ); 91 buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) );
88 buttonBox->layout(); 92 buttonBox->layout();
89 93
90 mainLayout->addWidget( buttonBox ); 94 mainLayout->addWidget( buttonBox );
91*/ 95*/
92 // setup listbox 96 // setup listbox
93 uint counter = 0; 97 uint counter = 0;
94 for ( uint i = 0; i < list.count(); ++i ) { 98 for ( uint i = 0; i < list.count(); ++i ) {
95 Resource *resource = list.at( i ); 99 Resource *resource = list.at( i );
96 if ( resource && !resource->readOnly() ) { 100 if ( resource && !resource->readOnly() ) {
97 mResourceMap.insert( counter, resource ); 101 mResourceMap.insert( counter, resource );
98 mResourceId->insertItem( resource->resourceName() ); 102 mResourceId->insertItem( resource->resourceName() );
99 counter++; 103 counter++;
100 } 104 }
101 } 105 }
102 106
103 mResourceId->setCurrentItem( 0 ); 107 mResourceId->setCurrentItem( 0 );
104 connect( mResourceId, SIGNAL(returnPressed(QListBoxItem*)), 108 connect( mResourceId, SIGNAL(returnPressed(Q3ListBoxItem*)),
105 SLOT(accept()) ); 109 SLOT(accept()) );
106} 110}
107 111
108Resource *SelectDialog::resource() 112Resource *SelectDialog::resource()
109{ 113{
110 if ( mResourceId->currentItem() != -1 ) 114 if ( mResourceId->currentItem() != -1 )
111 return mResourceMap[ mResourceId->currentItem() ]; 115 return mResourceMap[ mResourceId->currentItem() ];
112 else 116 else
113 return 0; 117 return 0;
114} 118}
115 119
116Resource *SelectDialog::getResource( QPtrList<Resource> list, QWidget *parent ) 120Resource *SelectDialog::getResource( Q3PtrList<Resource> list, QWidget *parent )
117{ 121{
118 if ( list.count() == 0 ) { 122 if ( list.count() == 0 ) {
119 KMessageBox::error( parent, i18n( "There is no resource available!" ) ); 123 KMessageBox::error( parent, i18n( "There is no resource available!" ) );
120 return 0; 124 return 0;
121 } 125 }
122 126
123 if ( list.count() == 1 ) return list.first(); 127 if ( list.count() == 1 ) return list.first();
124 128
125 // the following lines will return a writeable resource if only _one_ writeable 129 // the following lines will return a writeable resource if only _one_ writeable
126 // resource exists 130 // resource exists
127 Resource *found = 0; 131 Resource *found = 0;
128 Resource *it = list.first(); 132 Resource *it = list.first();
129 while ( it ) { 133 while ( it ) {
130 if ( !it->readOnly() ) { 134 if ( !it->readOnly() ) {
131 if ( found ) { 135 if ( found ) {
132 found = 0; 136 found = 0;
133 break; 137 break;
134 } else 138 } else
135 found = it; 139 found = it;
136 } 140 }
137 it = list.next(); 141 it = list.next();
138 } 142 }
139 143
140 if ( found ) 144 if ( found )
141 return found; 145 return found;
142 146
143 SelectDialog dlg( list, parent); 147 SelectDialog dlg( list, parent);
144//US if ( dlg.exec() == KDialog::Accepted ) 148//US if ( dlg.exec() == KDialog::Accepted )
145 if ( dlg.exec() ) 149 if ( dlg.exec() )
146 return dlg.resource(); 150 return dlg.resource();
147 else 151 else
148 return 0; 152 return 0;
149} 153}
150 154
151/*US 155/*US
152#include "selectdialog.moc" 156#include "selectdialog.moc"
153*/ 157*/
154 158
diff --git a/microkde/kresources/selectdialog.h b/microkde/kresources/selectdialog.h
index 7026212..be5152b 100644
--- a/microkde/kresources/selectdialog.h
+++ b/microkde/kresources/selectdialog.h
@@ -1,92 +1,92 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_SELECTDIALOG_H 24#ifndef KRESOURCES_SELECTDIALOG_H
25#define KRESOURCES_SELECTDIALOG_H 25#define KRESOURCES_SELECTDIALOG_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qmap.h> 29#include <qmap.h>
30 30
31#include <kdialogbase.h> 31#include <kdialogbase.h>
32 32
33//US class KListBox; 33//US class KListBox;
34class QListBox; 34class Q3ListBox;
35 35
36namespace KRES { 36namespace KRES {
37 37
38class Resource; 38class Resource;
39 39
40/** 40/**
41 * Dialog for selecting a resource. 41 * Dialog for selecting a resource.
42 * 42 *
43 * Example: 43 * Example:
44 * 44 *
45 * <pre> 45 * <pre>
46 * KABC::Resource *res = KABC::SelectDialog::getResource(); 46 * KABC::Resource *res = KABC::SelectDialog::getResource();
47 * if ( !( res ) ) { 47 * if ( !( res ) ) {
48 * // no resource selected 48 * // no resource selected
49 * } else { 49 * } else {
50 * // do something with resource 50 * // do something with resource
51 * } 51 * }
52 * </pre> 52 * </pre>
53 */ 53 */
54//US class SelectDialog : KDialog 54//US class SelectDialog : KDialog
55class SelectDialog : KDialogBase 55class SelectDialog : KDialogBase
56{ 56{
57 // Q_OBJECT 57 // Q_OBJECT
58 public: 58 public:
59 /** 59 /**
60 * Constructor. 60 * Constructor.
61 * @param ab The address book you want to select the resource from 61 * @param ab The address book you want to select the resource from
62 * @param parent The parent widget 62 * @param parent The parent widget
63 * @param name The name of the dialog 63 * @param name The name of the dialog
64 */ 64 */
65 SelectDialog( QPtrList<Resource> list, QWidget *parent = 0, 65 SelectDialog( Q3PtrList<Resource> list, QWidget *parent = 0,
66 const char *name = 0); 66 const char *name = 0);
67 67
68 // ~SelectDialog(); 68 // ~SelectDialog();
69 69
70 /** 70 /**
71 * Return selected resource. 71 * Return selected resource.
72 */ 72 */
73 Resource *resource(); 73 Resource *resource();
74 74
75 /** 75 /**
76 * Open a dialog showing the available resources and return the resource the 76 * Open a dialog showing the available resources and return the resource the
77 * user has selected. Returns 0, if the dialog was canceled. 77 * user has selected. Returns 0, if the dialog was canceled.
78 */ 78 */
79 static Resource *getResource( QPtrList<Resource> list, QWidget *parent = 0 ); 79 static Resource *getResource( Q3PtrList<Resource> list, QWidget *parent = 0 );
80 80
81 private: 81 private:
82//US KListBox *mResourceId; 82//US KListBox *mResourceId;
83 QListBox *mResourceId; 83 Q3ListBox *mResourceId;
84 84
85 QMap<int, Resource*> mResourceMap; 85 QMap<int, Resource*> mResourceMap;
86}; 86};
87 87
88 88
89 89
90} 90}
91 91
92#endif 92#endif