summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
Side-by-side diff
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,133 +1,136 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
-#include <qgroupbox.h>
+#include <q3groupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
-#include <qvbox.h>
+#include <q3vbox.h>
#include <qcheckbox.h>
-#include <qscrollview.h>
+#include <q3scrollview.h>
+//Added by qt3to4:
+#include <Q3VBoxLayout>
+#include <Q3Frame>
#include <kbuttonbox.h>
#include <kdialog.h>
#include <klineedit.h>
#include "factory.h"
#include "configwidget.h"
#include "configdialog.h"
using namespace KRES;
ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
Resource* resource, const char *name )
: KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
{
Factory *factory = Factory::self( resourceFamily );
//US resize( 250, 240 );
resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
- QFrame *main;
+ Q3Frame *main;
main = plainPage();
- QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
+ Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main, 0, spacingHint() );
- QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
+ Q3GroupBox *generalGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
generalGroupBox->layout()->setSpacing( spacingHint() );
generalGroupBox->setTitle( i18n( "General Settings" ) );
new QLabel( i18n( "Name:" ), generalGroupBox );
mName = new KLineEdit( generalGroupBox );
new QLabel("", generalGroupBox );
mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
mReadOnly->setChecked( mResource->readOnly() );
new QLabel("", generalGroupBox );
mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox );
mIncludeInSync->setChecked( mResource->includeInSync() );
mName->setText( mResource->resourceName() );
mainLayout->addWidget( generalGroupBox );
- QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
+ Q3GroupBox *resourceGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
resourceGroupBox->layout()->setSpacing( spacingHint());
resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
.arg( factory->typeName( resource->type() ) ) );
mainLayout->addWidget( resourceGroupBox );
mainLayout->addStretch();
mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
if ( mConfigWidget ) {
connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
SLOT( setReadOnly( bool ) ) );
connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ),
SLOT( setIncludeInSync( bool ) ) );
connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
SLOT( setPersistentReadOnly( bool ) ) );
mConfigWidget->setInEditMode( false );
mConfigWidget->loadSettings( mResource );
mConfigWidget->show();
}
connect( mName, SIGNAL( textChanged(const QString &)),
SLOT( slotNameChanged(const QString &)));
slotNameChanged( mName->text() );
//US setMinimumSize( 400, 250 );
setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
}
void ConfigDialog::setInEditMode( bool value )
{
if ( mConfigWidget )
mConfigWidget->setInEditMode( value );
}
void ConfigDialog::slotNameChanged( const QString &text)
{
enableButtonOK( !text.isEmpty() );
}
void ConfigDialog::setReadOnly( bool value )
{
if (mPersistentReadOnly == false)
mReadOnly->setChecked( value );
else
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,281 +1,285 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
-#include <qgroupbox.h>
+#include <q3groupbox.h>
#ifdef DESKTOP_VERSION
#include <qinputdialog.h>
#else
#include <qtcompat/qinputdialog.h>
#endif
#include <qlabel.h>
#include <qlayout.h>
+//Added by qt3to4:
+#include <Q3GridLayout>
+#include <Q3ValueList>
+#include <Q3VBoxLayout>
#include <kapplication.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>
#include <klistview.h>
#include <kbuttonbox.h>
//US #include <ktrader.h>
#include "resource.h"
#include "configdialog.h"
#include "configpage.h"
//US
#include <qpushbutton.h>
#include <qfile.h>
#include <kglobal.h>
using namespace KRES;
-class ConfigViewItem : public QCheckListItem
+class ConfigViewItem : public Q3CheckListItem
{
public:
- ConfigViewItem( QListView *parent, Resource* resource ) :
- QCheckListItem( parent, resource->resourceName(), CheckBox ),
+ ConfigViewItem( Q3ListView *parent, Resource* resource ) :
+ Q3CheckListItem( parent, resource->resourceName(), CheckBox ),
mResource( resource ),
mIsStandard( false )
{
setText( 1, mResource->type() );
setOn( mResource->isActive() );
}
void setStandard( bool value )
{
setText( 2, ( value ? i18n( "Yes" ) : QString::null ) );
mIsStandard = value;
}
bool standard() const { return mIsStandard; }
bool readOnly() const { return mResource->readOnly(); }
Resource *resource() { return mResource; }
private:
Resource* mResource;
bool mIsStandard;
};
ConfigPage::ConfigPage( QWidget *parent, const char *name )
: QWidget( parent, name ),
mCurrentManager( 0 ),
mCurrentConfig( 0 )
{
setCaption( i18n( "Resource Configuration" ) );
- QVBoxLayout *mainLayout = new QVBoxLayout( this );
+ Q3VBoxLayout *mainLayout = new Q3VBoxLayout( this );
- QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this );
+ Q3GroupBox *groupBox = new Q3GroupBox( i18n( "Resources" ), this );
groupBox->setColumnLayout(0, Qt::Vertical );
groupBox->layout()->setSpacing( 3 );
groupBox->layout()->setMargin( 5 );
- QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 );
+ Q3GridLayout *groupBoxLayout = new Q3GridLayout( groupBox->layout(), 4, 2 );
//US mFamilyCombo = new KComboBox( false, groupBox );
mFamilyCombo = new KComboBox( groupBox );
groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 );
mListView = new KListView( groupBox );
mListView->setAllColumnsShowFocus( true );
mListView->addColumn( i18n( "Name" ) );
mListView->addColumn( i18n( "Type" ) );
mListView->addColumn( i18n( "Standard" ) );
//US groupBoxLayout->addWidget( mListView, 1, 0 );
groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 );
mAddButton = new QPushButton( i18n( "&Add..." ), groupBox );
groupBoxLayout->addWidget( mAddButton, 2, 0 );
mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox );
groupBoxLayout->addWidget( mRemoveButton, 2, 1 );
mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox );
groupBoxLayout->addWidget( mEditButton, 3, 0 );
mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox );
groupBoxLayout->addWidget( mStandardButton, 3, 1 );
mRemoveButton->setEnabled( false );
mEditButton->setEnabled( false );
mStandardButton->setEnabled( false );
connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) );
connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) );
connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) );
connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) );
mainLayout->addWidget( groupBox );
connect( mFamilyCombo, SIGNAL( activated( int ) ),
SLOT( slotFamilyChanged( int ) ) );
connect( mListView, SIGNAL( selectionChanged() ),
SLOT( slotSelectionChanged() ) );
- connect( mListView, SIGNAL( clicked( QListViewItem * ) ),
- SLOT( slotItemClicked( QListViewItem * ) ) );
+ connect( mListView, SIGNAL( clicked( Q3ListViewItem * ) ),
+ SLOT( slotItemClicked( Q3ListViewItem * ) ) );
mLastItem = 0;
//US mConfig = new KConfig( "kcmkresourcesrc" );
mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") );
mConfig->setGroup( "General" );
load();
}
ConfigPage::~ConfigPage()
{
- QValueList<ResourcePageInfo>::Iterator it;
+ Q3ValueList<ResourcePageInfo>::Iterator it;
for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
(*it).mManager->removeListener( this );
delete (*it).mManager;
delete (*it).mConfig;
}
mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
delete mConfig;
mConfig = 0;
}
void ConfigPage::load()
{
kdDebug(5650) << "ConfigPage::load()" << endl;
mListView->clear();
//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
//US KTrader::OfferList::ConstIterator it;
//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
//US QString family = tmp.toString();
QStringList families;
families << "contact";
for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
{
QString family = (*it);
if ( !family.isEmpty() ) {
if ( !mFamilyMap.contains( family ) ) {
mCurrentManager = new Manager<Resource>( family );
if ( mCurrentManager ) {
mFamilyMap.append( family );
mCurrentManager->addListener( this );
ResourcePageInfo info;
info.mManager = mCurrentManager;
QString configDir = KGlobal::dirs()->saveLocation( "config" );
//QString configDir = KStandardDirs::appDir() + "/config";
if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
} else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
} else {
QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
info.mConfig = new KConfig( configFile );
}
info.mManager->readConfig( info.mConfig );
mInfoMap.append( info );
}
}
}
}
mCurrentManager = 0;
mFamilyCombo->insertStringList( mFamilyMap );
int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
mFamilyCombo->setCurrentItem( currentFamily );
slotFamilyChanged( currentFamily );
}
void ConfigPage::save()
{
saveResourceSettings();
- QValueList<ResourcePageInfo>::Iterator it;
+ Q3ValueList<ResourcePageInfo>::Iterator it;
for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
(*it).mManager->writeConfig( (*it).mConfig );
emit changed( false );
}
void ConfigPage::defaults()
{
}
void ConfigPage::slotFamilyChanged( int pos )
{
if ( pos < 0 || pos >= (int)mFamilyMap.count() )
return;
saveResourceSettings();
mFamily = mFamilyMap[ pos ];
//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
mCurrentManager = mInfoMap[ pos ].mManager;
mCurrentConfig = mInfoMap[ pos ].mConfig;
if ( !mCurrentManager )
kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
mListView->clear();
if ( mCurrentManager->isEmpty() ) {
//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
defaults();
}
Resource *standardResource = mCurrentManager->standardResource();
//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
Manager<Resource>::Iterator it;
for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
ConfigViewItem *item = new ConfigViewItem( mListView, *it );
if ( *it == standardResource )
item->setStandard( true );
}
if ( mListView->childCount() == 0 ) {
@@ -296,239 +300,239 @@ void ConfigPage::slotFamilyChanged( int pos )
emit changed( false );
}
}
void ConfigPage::slotAdd()
{
if ( !mCurrentManager )
return;
QStringList types = mCurrentManager->resourceTypeNames();
QStringList descs = mCurrentManager->resourceTypeDescriptions();
bool ok = false;
QString desc;
desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
i18n( "Select type of the new resource:" ), descs, 0,
false, &ok, this );
if ( !ok )
return;
QString type = types[ descs.findIndex( desc ) ];
// Create new resource
Resource *resource = mCurrentManager->createResource( type );
if ( !resource ) {
KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
.arg( type ) );
return;
}
resource->setResourceName( type + "-resource" );
ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
if ( dlg.exec() ) {
mCurrentManager->add( resource );
ConfigViewItem *item = new ConfigViewItem( mListView, resource );
mLastItem = item;
// if there are only read-only resources we'll set this resource
// as standard resource
if ( !resource->readOnly() ) {
bool onlyReadOnly = true;
- QListViewItem *it = mListView->firstChild();
+ Q3ListViewItem *it = mListView->firstChild();
while ( it != 0 ) {
ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it );
if ( !confIt->readOnly() && confIt != item )
onlyReadOnly = false;
it = it->itemBelow();
}
if ( onlyReadOnly )
item->setStandard( true );
}
emit changed( true );
} else {
delete resource;
resource = 0;
}
}
void ConfigPage::slotRemove()
{
if ( !mCurrentManager )
return;
- QListViewItem *item = mListView->currentItem();
+ Q3ListViewItem *item = mListView->currentItem();
ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item );
if ( !confItem )
return;
if ( confItem->standard() ) {
KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) );
return;
}
mCurrentManager->remove( confItem->resource() );
if ( item == mLastItem )
mLastItem = 0;
mListView->takeItem( item );
delete item;
emit changed( true );
}
void ConfigPage::slotEdit()
{
if ( !mCurrentManager )
return;
- QListViewItem *item = mListView->currentItem();
+ Q3ListViewItem *item = mListView->currentItem();
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
if ( !configItem )
return;
Resource *resource = configItem->resource();
ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
if ( dlg.exec() ) {
configItem->setText( 0, resource->resourceName() );
configItem->setText( 1, resource->type() );
if ( configItem->standard() && configItem->readOnly() ) {
KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
configItem->setStandard( false );
}
mCurrentManager->resourceChanged( resource );
emit changed( true );
}
}
void ConfigPage::slotStandard()
{
if ( !mCurrentManager )
return;
ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() );
if ( !item )
return;
if ( item->readOnly() ) {
KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) );
return;
}
if ( !item->isOn() ) {
KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
return;
}
- QListViewItem *it = mListView->firstChild();
+ Q3ListViewItem *it = mListView->firstChild();
while ( it != 0 ) {
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it );
if ( configItem->standard() )
configItem->setStandard( false );
it = it->itemBelow();
}
item->setStandard( true );
mCurrentManager->setStandardResource( item->resource() );
emit changed( true );
}
void ConfigPage::slotSelectionChanged()
{
bool state = ( mListView->currentItem() != 0 );
mRemoveButton->setEnabled( state );
mEditButton->setEnabled( state );
mStandardButton->setEnabled( state );
}
void ConfigPage::resourceAdded( Resource* resource )
{
qDebug("ConfigPage::resourceAdded : %s", resource->resourceName().latin1());
ConfigViewItem *item = new ConfigViewItem( mListView, resource );
// FIXME: this sucks. This should be in the config file,
// or application-dependent, in which case it's always Off
item->setOn( false );
mLastItem = item;
emit changed( true );
}
void ConfigPage::resourceModified( Resource* resource )
{
qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1());
}
void ConfigPage::resourceDeleted( Resource* resource )
{
qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1());
}
-void ConfigPage::slotItemClicked( QListViewItem *item )
+void ConfigPage::slotItemClicked( Q3ListViewItem *item )
{
ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item );
if ( !configItem ) return;
if ( configItem->standard() && !configItem->isOn() ) {
KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) );
configItem->setOn( true );
return;
}
if ( configItem->isOn() != configItem->resource()->isActive() ) {
emit changed( true );
}
}
void ConfigPage::saveResourceSettings()
{
//qDebug("ConfigPage::saveResourceSettings() begin");
if ( mCurrentManager ) {
- QListViewItem *item = mListView->firstChild();
+ Q3ListViewItem *item = mListView->firstChild();
while ( item ) {
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
// check if standard resource
if ( configItem->standard() && !configItem->readOnly() &&
configItem->isOn() ) {
mCurrentManager->setStandardResource( configItem->resource() );
}
// check if active or passive resource
configItem->resource()->setActive( configItem->isOn() );
item = item->nextSibling();
}
mCurrentManager->writeConfig( mCurrentConfig );
if ( !mCurrentManager->standardResource() )
KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) );
}
//qDebug("ConfigPage::saveResourceSettings() end");
}
//US #include "configpage.moc"
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 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_CONFIGPAGE_H
#define KRESOURCES_CONFIGPAGE_H
#include <qstringlist.h>
#include <qwidget.h>
+//Added by qt3to4:
+#include <Q3ValueList>
#include "manager.h"
class KComboBox;
class KListView;
-class QListViewItem;
+class Q3ListViewItem;
class QPushButton;
namespace KRES {
class ResourcePageInfo
{
public:
Manager<Resource> *mManager;
KConfig *mConfig;
};
class Resource;
class ConfigPage : public QWidget, public ManagerListener<Resource>
{
Q_OBJECT
public:
ConfigPage( QWidget *parent = 0, const char *name = 0 );
virtual ~ConfigPage();
void load();
void save();
virtual void defaults();
public slots:
void slotFamilyChanged( int );
void slotAdd();
void slotRemove();
void slotEdit();
void slotStandard();
void slotSelectionChanged();
// From ManagerListener<Resource>
public:
virtual void resourceAdded( Resource* resource );
virtual void resourceModified( Resource* resource );
virtual void resourceDeleted( Resource* resource );
protected slots:
- void slotItemClicked( QListViewItem * );
+ void slotItemClicked( Q3ListViewItem * );
signals:
void changed( bool );
private:
void saveResourceSettings();
Manager<Resource>* mCurrentManager;
KConfig* mCurrentConfig;
KConfig* mConfig;
QString mFamily;
QStringList mFamilyMap;
- QValueList<ResourcePageInfo> mInfoMap;
+ Q3ValueList<ResourcePageInfo> mInfoMap;
KComboBox* mFamilyCombo;
KListView* mListView;
QPushButton* mAddButton;
QPushButton* mRemoveButton;
QPushButton* mEditButton;
QPushButton* mStandardButton;
- QListViewItem* mLastItem;
+ Q3ListViewItem* mLastItem;
static const QString syncfamily;
};
}
#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,102 +1,102 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kdebug.h>
#include <klocale.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kstaticdeleter.h>
//#ifndef DESKTOP_VERSION
#include <klibloader.h>
//#endif
#include <qfile.h>
#include "resource.h"
#include "factory.h"
#ifdef STATIC_RESOURCES
#include <file/resourcefile.h>
#include <dir/resourcedir.h>
#include <qtopia/resourceqtopia.h>
#endif
using namespace KRES;
-QDict<Factory> *Factory::mSelves = 0;
-static KStaticDeleter< QDict<Factory> > staticDeleter;
+Q3Dict<Factory> *Factory::mSelves = 0;
+static KStaticDeleter< Q3Dict<Factory> > staticDeleter;
Factory *Factory::self( const QString& resourceFamily)
{
Factory *factory = 0;
if ( !mSelves )
{
- mSelves = staticDeleter.setObject( new QDict<Factory> );
+ mSelves = staticDeleter.setObject( new Q3Dict<Factory> );
}
factory = mSelves->find( resourceFamily );
if ( !factory ) {
factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
}
return factory;
}
Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
{
//US so far we have three types available for resourceFamily "contact"
// and that are "file", "dir", "ldap"
/*US
KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
.arg( resourceFamily ) );
KTrader::OfferList::ConstIterator it;
for ( it = plugins.begin(); it != plugins.end(); ++it ) {
QVariant type = (*it)->property( "X-KDE-ResourceType" );
if ( !type.toString().isEmpty() )
mTypeMap.insert( type.toString(), *it );
}
*/
//US new
PluginInfo* info = new PluginInfo;
info->library = "microkabc_file";
info->nameLabel = i18n( "file" );
info->descriptionLabel = i18n( "One file" );
mTypeMap.insert( "file", info );
info = new PluginInfo;
info->library = "microkabc_dir";
info->nameLabel = i18n( "dir" );
info->descriptionLabel = i18n( "A directory with many files" );
mTypeMap.insert( "dir", info );
info = new PluginInfo;
info->library = "microkabc_ldap";
info->nameLabel = i18n( "ldap" );
info->descriptionLabel = i18n( "Connect to a directory server" );
mTypeMap.insert( "ldap", info );
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 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_FACTORY_H
#define KRESOURCES_FACTORY_H
-#include <qdict.h>
+#include <q3dict.h>
#include <qstring.h>
#include <kconfig.h>
#include "resource.h"
namespace KRES {
class ConfigWidget;
//US
struct PluginInfo
{
QString library;
QString nameLabel;
QString descriptionLabel;
};
/**
* Class for loading resource plugins.
* Do not use this class directly. Use ResourceManager instead
*
* Example:
*
* <pre>
* KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
*
* QStringList list = factory->resources();
* QStringList::Iterator it;
* for ( it = list.begin(); it != list.end(); ++it ) {
* Resource<Calendar> *resource = factory->resource( (*it),
* KABC::StdAddressBook::self(), 0 );
* // do something with resource
* }
* </pre>
*/
class Factory
{
public:
/**
* Returns the global resource factory.
*/
static Factory *self( const QString& resourceFamily );
~Factory();
/**
* Returns the config widget for the given resource type,
* or a null pointer if resource type doesn't exist.
*
* @param type The type of the resource, returned by @ref resources()
* @param resource The resource to be editted.
* @param parent The parent widget
*/
ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
/**
* Returns a pointer to a resource object or a null pointer
* if resource type doesn't exist.
*
* @param type The type of the resource, returned by @ref resources()
* @param ab The address book, the resource should belong to
* @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
*/
Resource *resource( const QString& type, const KConfig *config);
/**
* Returns a list of all available resource types.
*/
QStringList typeNames() const;
/**
* Returns the name for a special type.
*/
QString typeName( const QString &type ) const;
/**
* Returns the description for a special type.
*/
QString typeDescription( const QString &type ) const;
protected:
Factory( const QString& resourceFamily);
private:
- static QDict<Factory> *mSelves;
+ static Q3Dict<Factory> *mSelves;
QString mResourceFamily;
//US QMap<QString, KService::Ptr> mTypeMap;
//US lets store the pluginfo struct as value instead of a KService
QMap<QString, PluginInfo*> mTypeMap;
};
}
#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 @@
/*
This file is part of libkresources.
Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qlayout.h>
+//Added by qt3to4:
+#include <Q3VBoxLayout>
+#include <Q3Frame>
//US #include <kaboutdata.h>
//US #include <kgenericfactory.h>
#include <klocale.h>
#include "configpage.h"
#include "kcmkresources.h"
using namespace KRES;
//US typedef KGenericFactory<KCMKResources, QWidget> ResourcesFactory;
//US K_EXPORT_COMPONENT_FACTORY( kcm_kresources, ResourcesFactory( "kcmkresources" ) );
//US KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
//US : KCModule( ResourcesFactory::instance(), parent, name )
KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
: KDialogBase( parent, name, true, i18n( "Configure Resources" ),
Ok|Cancel, Ok, true )
{
- QFrame *main = plainPage();
+ Q3Frame *main = plainPage();
- QVBoxLayout *layout = new QVBoxLayout( main );
+ Q3VBoxLayout *layout = new Q3VBoxLayout( main );
mConfigPage = new KRES::ConfigPage( main );
layout->addWidget( mConfigPage );
connect( mConfigPage, SIGNAL( changed( bool ) ), SLOT( changed( bool ) ) );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
}
void KCMKResources::changed( bool changed)
{
modified = changed;
}
void KCMKResources::slotOk()
{
if (modified) {
mConfigPage->save();
modified = false;
}
KDialogBase::slotOk();
}
void KCMKResources::load()
{
qDebug("KCMKResources::load" );
mConfigPage->load();
}
void KCMKResources::save()
{
qDebug("KCMKResources::save" );
mConfigPage->save();
}
void KCMKResources::defaults()
{
qDebug("KCMKResources::defaults" );
mConfigPage->defaults();
}
//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,84 +1,86 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2004 Ulf Schenk
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KRESOURCES_MANAGER_H
#define KRESOURCES_MANAGER_H
-#include <qdict.h>
+#include <q3dict.h>
#include <qstringlist.h>
+//Added by qt3to4:
+#include <Q3PtrList>
#include "factory.h"
#include "managerimpl.h"
namespace KRES {
class Resource;
template<class T>
class ManagerListener
{
public:
virtual void resourceAdded( T *resource ) = 0;
virtual void resourceModified( T *resource ) = 0;
virtual void resourceDeleted( T *resource ) = 0;
};
// TODO:
// The resource manager should provide some signals
// to warn applications that resources have been added,
// removed or modified.
//
// The manager should also keep track of which (or at least
// how many) applications hve opened a resource, so that it
// is only closed if none of them is using it any more
template<class T>
class Manager : private ManagerImplListener
{
public:
class Iterator
{
friend class Manager;
public:
Iterator() {};
Iterator( const Iterator &it ) { mIt = it.mIt; }
T *operator*() { return static_cast<T *>( *mIt ); }
Iterator &operator++() { mIt++; return *this; }
Iterator &operator++(int) { mIt++; return *this; }
Iterator &operator--() { mIt--; return *this; }
Iterator &operator--(int) { mIt--; return *this; }
bool operator==( const Iterator &it ) { return mIt == it.mIt; }
bool operator!=( const Iterator &it ) { return mIt != it.mIt; }
private:
Resource::List::Iterator mIt;
};
@@ -130,97 +132,97 @@ class Manager : private ManagerImplListener
return *this;
}
bool operator==( const ActiveIterator &it ) { return mIt == it.mIt; }
bool operator!=( const ActiveIterator &it ) { return mIt != it.mIt; }
private:
/**
Check if iterator needs to be advanced once more.
*/
bool checkActive()
{
if ( !mList || mIt == mList->end() ) return false;
return !(*mIt)->isActive();
}
Resource::List::Iterator mIt;
Resource::List *mList;
};
ActiveIterator activeBegin()
{
ActiveIterator it;
it.mIt = mImpl->resourceList()->begin();
it.mList = mImpl->resourceList();
if ( it.mIt != mImpl->resourceList()->end() ) {
if ( !(*it)->isActive() ) it++;
}
return it;
}
ActiveIterator activeEnd()
{
ActiveIterator it;
it.mIt = mImpl->resourceList()->end();
it.mList = mImpl->resourceList();
return it;
}
bool isEmpty() const { return mImpl->resourceList()->isEmpty(); }
Manager( const QString &family )
{
mFactory = Factory::self( family );
// The managerimpl will use the same Factory object as the manager
// because of the Factory::self() pattern
mImpl = new ManagerImpl( family );
mImpl->setListener( this );
- mListeners = new QPtrList<ManagerListener<T> >;
+ mListeners = new Q3PtrList<ManagerListener<T> >;
}
virtual ~Manager()
{
mImpl->setListener( 0 );
delete mListeners;
delete mImpl;
}
/**
Recreate Resource objects from configuration file. If cfg is 0, read standard
configuration file.
*/
void readConfig( KConfig *cfg = 0 )
{
mImpl->readConfig( cfg );
}
/**
Write configuration of Resource objects to configuration file. If cfg is 0, write
to standard configuration file.
*/
void writeConfig( KConfig *cfg = 0 )
{
mImpl->writeConfig( cfg );
}
/**
Add resource to manager. This passes ownership of the Resource object
to the manager.
*/
void add( Resource *resource )
{
if ( resource ) mImpl->add( resource );
}
void remove( Resource *resource )
{
if ( resource ) mImpl->remove( resource );
}
T* standardResource()
{
return static_cast<T *>( mImpl->standardResource() );
}
void setStandardResource( T *resource )
{
@@ -285,54 +287,54 @@ class Manager : private ManagerImplListener
return typeDescs;
}
void resourceChanged( T *resource )
{
mImpl->resourceChanged( resource );
}
void addListener( ManagerListener<T> *listener )
{
mListeners->append( listener );
}
void removeListener( ManagerListener<T> *listener )
{
mListeners->remove( listener );
}
virtual void resourceAdded( Resource *res )
{
T* resource = (T *)( res );
ManagerListener<T> *listener;
for ( listener = mListeners->first(); listener; listener = mListeners->next() )
listener->resourceAdded( resource );
}
virtual void resourceModified( Resource *res )
{
T* resource = (T *)( res );
ManagerListener<T> *listener;
for ( listener = mListeners->first(); listener; listener = mListeners->next() )
listener->resourceModified( resource );
}
virtual void resourceDeleted( Resource *res )
{
T* resource = (T *)( res );
ManagerListener<T> *listener;
for ( listener = mListeners->first(); listener; listener = mListeners->next() ) {
listener->resourceDeleted( resource );
}
}
private:
ManagerImpl *mImpl;
Factory *mFactory;
- QPtrList<ManagerListener<T> > *mListeners;
+ Q3PtrList<ManagerListener<T> > *mListeners;
};
}
#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,85 +1,87 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kglobal.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <qfile.h>
+//Added by qt3to4:
+#include <Q3PtrList>
#include "resource.h"
#include "factory.h"
#include "managerimpl.h"
using namespace KRES;
ManagerImpl::ManagerImpl( const QString &family )
: mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
mFactory( 0 )
{
kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
}
ManagerImpl::~ManagerImpl()
{
kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
Resource::List::ConstIterator it;
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
delete *it;
}
delete mStdConfig;
}
void ManagerImpl::createStandardConfig()
{
if ( !mStdConfig ) {
QString file = locateLocal( "data", KGlobal::getAppName()
+ "/kresources/" + mFamily + "rc" );
if ( mFamily == "tmpcontact" ) {
if (QFile::exists ( file ) ){
QFile::remove ( file );
qDebug("removed tmp rc file: %s ", file.latin1());
}
}
mStdConfig = new KConfig( file );
}
mConfig = mStdConfig;
}
@@ -187,110 +189,110 @@ void ManagerImpl::remove( Resource *resource, bool useDCOP )
kdDebug(5650) << "Finished ManagerImpl::remove()" << endl;
}
void ManagerImpl::setActive( Resource *resource, bool active )
{
if ( resource && resource->isActive() != active ) {
resource->setActive( active );
}
}
Resource *ManagerImpl::standardResource()
{
return mStandard;
}
void ManagerImpl::setStandardResource( Resource *resource )
{
mStandard = resource;
}
void ManagerImpl::resourceChanged( Resource *resource )
{
writeResourceConfig( resource, true );
// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() );
// allManagers.dcopResourceModified( resource->identifier() );
}
// DCOP asynchronous functions
//US since we work from inside the application, we call the methods directly.
QStringList ManagerImpl::resourceNames()
{
QStringList result;
Resource::List::ConstIterator it;
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
result.append( (*it)->resourceName() );
}
return result;
}
Resource::List *ManagerImpl::resourceList()
{
return &mResources;
}
-QPtrList<Resource> ManagerImpl::resources()
+Q3PtrList<Resource> ManagerImpl::resources()
{
- QPtrList<Resource> result;
+ Q3PtrList<Resource> result;
Resource::List::ConstIterator it;
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
result.append( *it );
}
return result;
}
-QPtrList<Resource> ManagerImpl::resources( bool active )
+Q3PtrList<Resource> ManagerImpl::resources( bool active )
{
- QPtrList<Resource> result;
+ Q3PtrList<Resource> result;
Resource::List::ConstIterator it;
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
if ( (*it)->isActive() == active ) {
result.append( *it );
}
}
return result;
}
void ManagerImpl::setListener( ManagerImplListener *listener )
{
mListener = listener;
}
Resource* ManagerImpl::readResourceConfig( const QString& identifier,
bool checkActive )
{
kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
mConfig->setGroup( "Resource_" + identifier );
#ifdef _WIN32_
// we use plugins on win32. the group is stored in a static variable
// such that gourp info not avail on win32 plugins
// to fix that, it would be a looooot of work
mConfig->setTempGroup( "Resource_" + identifier );
#endif
QString type = mConfig->readEntry( "ResourceType" );
QString name = mConfig->readEntry( "ResourceName" );
Resource *resource = mFactory->resource( type, mConfig );
if ( !resource ) {
qDebug("Failed to create resource with id %s ",identifier.latin1() );
return 0;
}
if ( resource->identifier().isEmpty() )
resource->setIdentifier( identifier );
mConfig->setGroup( "General" );
QString standardKey = mConfig->readEntry( "Standard" );
if ( standardKey == identifier ) {
mStandard = resource;
}
if ( checkActive ) {
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 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KRESOURCES_MANAGERIMPL_H
#define KRESOURCES_MANAGERIMPL_H
#include <qstring.h>
-#include <qptrlist.h>
-#include <qdict.h>
+#include <q3ptrlist.h>
+#include <q3dict.h>
//US
#include <qobject.h>
#include "resource.h"
class KConfig;
namespace KRES {
class Resource;
class Factory;
class ManagerImplListener
{
public:
virtual void resourceAdded( Resource *resource ) = 0;
virtual void resourceModified( Resource *resource ) = 0;
virtual void resourceDeleted( Resource *resource ) = 0;
};
/**
@internal
Do not use this class directly. Use ResourceManager instead
*/
class ManagerImpl : public QObject
{
Q_OBJECT
public:
ManagerImpl( const QString &family);
~ManagerImpl();
void readConfig( KConfig * );
void writeConfig( KConfig * );
void add( Resource *resource, bool useDCOP = true );
void remove( Resource *resource, bool useDCOP = true );
Resource *standardResource();
void setStandardResource( Resource *resource );
void setActive( Resource *resource, bool active );
Resource::List *resourceList();
- QPtrList<Resource> resources();
+ Q3PtrList<Resource> resources();
// Get only active or passive resources
- QPtrList<Resource> resources( bool active );
+ Q3PtrList<Resource> resources( bool active );
QStringList resourceNames();
void setListener( ManagerImplListener *listener );
public slots:
void resourceChanged( Resource *resource );
private:
// dcop calls
private:
void createStandardConfig();
Resource *readResourceConfig( const QString& identifier, bool checkActive );
void writeResourceConfig( Resource *resource, bool checkActive );
void removeResource( Resource *resource );
Resource *getResource( Resource *resource );
Resource *getResource( const QString& identifier );
QString mFamily;
KConfig *mConfig;
KConfig *mStdConfig;
Resource *mStandard;
Factory *mFactory;
Resource::List mResources;
ManagerImplListener *mListener;
};
}
#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,79 +1,79 @@
/*
This file is part of libkresources
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_RESOURCE_H
#define KRESOURCES_RESOURCE_H
//US
#ifdef QT_THREAD_SUPPORT
#include <qmutex.h>
#endif //QT_THREAD_SUPPORT
-#include <qvaluelist.h>
+#include <q3valuelist.h>
#include <qwidget.h>
#include <qobject.h>
#include <klibloader.h>
class KConfig;
namespace KRES {
class ConfigWidget;
/**
* @internal
* @libdoc The KDE Resource library
*
* NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
* interface, it is in constant flux.
*
* The KDE Resource framework can be used to manage resources of
* different types, organized in families. The Resource framework
* is currently used for addressbook resources in libkabc and for
* calendar resources in libkcal.
*
* When you want to use the framework for a new family, you need to
* <ul><li>Define a name for your resource family</li>
* <li>subclass Resource and add the fields and method that are needed
* in your application</li>
* <li>If needed, override the doOpen() and doClose() methods.
* <li> Provide a configuration possibility for resources in your
* new family. You can use @ref ResourcesConfigPage to easily create a
* KControl applet</li>
* <li>In your application, you can use @ref ResourceManager to keep track
* of the resources in your family, and you can use @ref ResourceSelectDialog
* to let the user select a single resource.</li>
* </ul>
*
* When you want to add a new resource type to an existing resource family,
* you need to
* <ul><li>Further subclass the family-specific Resource to implement
* resource type-specific operation</li>
* <li>Subclass ResourceConfigWidget to provide a configuration widget
* for your new resource type</li>
* <li>Provide a .desktop file so that the new resource type can be found
* automatically by the ResourceManager</li>
* </ul>
*
* Example:
@@ -194,97 +194,97 @@ void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
if (res) {
res->setHost(mHostEdit->text());
res->setPassword(mPasswordEdit->text());
} else
kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl;
}
</pre>
* <B>resourceexample.desktop</B>:
<pre>
[Desktop Entry]
Type=Service
[Misc]
Encoding=UTF-8
Name=Example Resource
[Plugin]
Type=exchange
X-KDE-Library=resourceexample
</pre>
* <B>Makefile.am</B>
<pre>
kde_module_LTLIBRARIES = resourceexample.la
resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
resourceexample_la_LIBADD= -lkderesources
linkdir= $(kde_datadir)/resources/family
link_DATA= resourceexample.desktop
</pre>
*
*
*/
/**
* A @ref Resource is a ...
*
* A subclass should reimplement at least the constructor and the
k * @ref writeConfig method.
*
*/
class Resource : public QObject
{
Q_OBJECT
public:
- typedef QValueList<Resource *> List;
+ typedef Q3ValueList<Resource *> List;
/**
* Constructor. Construct resource from config.
* @param config Configuration to read persistence information from.
* If config==0, create object using default settings.
*/
Resource( const KConfig* config );
/**
* Destructor.
*/
virtual ~Resource();
/**
* Write configuration information for this resource to a configuration
* file. If you override this method, remember to call Resource::writeConfig
* or Terrible Things(TM) will happen.
* @param config Configuration to write persistence information to.
*/
virtual void writeConfig( KConfig* config );
/**
* Open this resource, if it not already open. Increase the open
* count of this object, and open the resource by calling @ref doOpen().
* This method may block while another thread is concurrently opening
* or closing the resource.
*
* Returns true if the resource was already opened or if it was opened
* successfully; returns false if the resource was not opened successfully.
*/
bool open();
/**
* Decrease the open count of this object, and if the count reaches
* zero, close this resource by calling @ref doClose().
* This method may block while another thread is concurrently closing
* or opening the resource.
*/
void close();
/**
* Returns whether the resource is open or not.
*/
bool isOpen() const;
/**
* Returns a unique identifier. The identifier is unique for this resource.
* It is created when the resource is first created, and it is retained
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 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*US
#include <kbuttonbox.h>
#include <klistbox.h>
#include <klocale.h>
#include <kmessagebox.h>
*/
#include <klocale.h>
#include <kmessagebox.h>
//US
#include <kglobal.h>
-#include <qlistbox.h>
+#include <q3listbox.h>
#include <qlayout.h>
-#include <qgroupbox.h>
+#include <q3groupbox.h>
+//Added by qt3to4:
+#include <Q3VBoxLayout>
+#include <Q3Frame>
+#include <Q3PtrList>
#include "resource.h"
#include "selectdialog.h"
using namespace KRES;
//US I am using KBaseDialog instead of KDialog
//US : KDialog( parent, name, true )
-SelectDialog::SelectDialog( QPtrList<Resource> list, QWidget *parent,
+SelectDialog::SelectDialog( Q3PtrList<Resource> list, QWidget *parent,
const char *name )
: KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel,
Ok, true)
{
//US setCaption( i18n( "Resource Selection" ) );
//US resize( 300, 200 );
resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) );
//US
- QFrame *main = plainPage();
+ Q3Frame *main = plainPage();
/*US
QVBoxLayout *layout = new QVBoxLayout( main );
mConfigPage = new KRES::ConfigPage( main );
layout->addWidget( mConfigPage );
*/
//US QVBoxLayout *mainLayout = new QVBoxLayout( this );
- QVBoxLayout *mainLayout = new QVBoxLayout( main );
+ Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main );
mainLayout->setMargin( marginHint() );
//US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this );
- QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, main );
+ Q3GroupBox *groupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
groupBox->setTitle( i18n( "Resources" ) );
//US mResourceId = new KListBox( groupBox );
- mResourceId = new QListBox( groupBox );
+ mResourceId = new Q3ListBox( groupBox );
mainLayout->addWidget( groupBox );
mainLayout->addSpacing( 40 );
/*US
KButtonBox *buttonBox = new KButtonBox( this );
buttonBox->addStretch();
buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) );
buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) );
buttonBox->layout();
mainLayout->addWidget( buttonBox );
*/
// setup listbox
uint counter = 0;
for ( uint i = 0; i < list.count(); ++i ) {
Resource *resource = list.at( i );
if ( resource && !resource->readOnly() ) {
mResourceMap.insert( counter, resource );
mResourceId->insertItem( resource->resourceName() );
counter++;
}
}
mResourceId->setCurrentItem( 0 );
- connect( mResourceId, SIGNAL(returnPressed(QListBoxItem*)),
+ connect( mResourceId, SIGNAL(returnPressed(Q3ListBoxItem*)),
SLOT(accept()) );
}
Resource *SelectDialog::resource()
{
if ( mResourceId->currentItem() != -1 )
return mResourceMap[ mResourceId->currentItem() ];
else
return 0;
}
-Resource *SelectDialog::getResource( QPtrList<Resource> list, QWidget *parent )
+Resource *SelectDialog::getResource( Q3PtrList<Resource> list, QWidget *parent )
{
if ( list.count() == 0 ) {
KMessageBox::error( parent, i18n( "There is no resource available!" ) );
return 0;
}
if ( list.count() == 1 ) return list.first();
// the following lines will return a writeable resource if only _one_ writeable
// resource exists
Resource *found = 0;
Resource *it = list.first();
while ( it ) {
if ( !it->readOnly() ) {
if ( found ) {
found = 0;
break;
} else
found = it;
}
it = list.next();
}
if ( found )
return found;
SelectDialog dlg( list, parent);
//US if ( dlg.exec() == KDialog::Accepted )
if ( dlg.exec() )
return dlg.resource();
else
return 0;
}
/*US
#include "selectdialog.moc"
*/
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 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_SELECTDIALOG_H
#define KRESOURCES_SELECTDIALOG_H
#include <qobject.h>
-#include <qptrlist.h>
+#include <q3ptrlist.h>
#include <qmap.h>
#include <kdialogbase.h>
//US class KListBox;
-class QListBox;
+class Q3ListBox;
namespace KRES {
class Resource;
/**
* Dialog for selecting a resource.
*
* Example:
*
* <pre>
* KABC::Resource *res = KABC::SelectDialog::getResource();
* if ( !( res ) ) {
* // no resource selected
* } else {
* // do something with resource
* }
* </pre>
*/
//US class SelectDialog : KDialog
class SelectDialog : KDialogBase
{
// Q_OBJECT
public:
/**
* Constructor.
* @param ab The address book you want to select the resource from
* @param parent The parent widget
* @param name The name of the dialog
*/
- SelectDialog( QPtrList<Resource> list, QWidget *parent = 0,
+ SelectDialog( Q3PtrList<Resource> list, QWidget *parent = 0,
const char *name = 0);
// ~SelectDialog();
/**
* Return selected resource.
*/
Resource *resource();
/**
* Open a dialog showing the available resources and return the resource the
* user has selected. Returns 0, if the dialog was canceled.
*/
- static Resource *getResource( QPtrList<Resource> list, QWidget *parent = 0 );
+ static Resource *getResource( Q3PtrList<Resource> list, QWidget *parent = 0 );
private:
//US KListBox *mResourceId;
- QListBox *mResourceId;
+ Q3ListBox *mResourceId;
QMap<int, Resource*> mResourceMap;
};
}
#endif