summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/configpage.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kresources/configpage.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kresources/configpage.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 8782ffd..912c62e 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -12,24 +12,31 @@
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 <qinputdialog.h>
#include <qlabel.h>
#include <qlayout.h>
#include <kapplication.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
@@ -41,24 +48,27 @@
#include "resource.h"
#include "configdialog.h"
#include "configpage.h"
//US
#include <qpushbutton.h>
#include <qfile.h>
#include <kglobal.h>
using namespace KRES;
+const QString ConfigPage::syncfamily = "syncprofiles";
+
+
class ConfigViewItem : public QCheckListItem
{
public:
ConfigViewItem( QListView *parent, Resource* resource ) :
QCheckListItem( parent, resource->resourceName(), CheckBox ),
mResource( resource ),
mIsStandard( false )
{
setText( 1, mResource->type() );
setOn( mResource->isActive() );
}
@@ -155,31 +165,33 @@ 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" << "sync-contacts";
+ families << "contact" << syncfamily;
+
+
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 );
+ mCurrentManager = new Manager<Resource>( family, (family == syncfamily) );
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" ) );
@@ -256,45 +268,58 @@ void ConfigPage::slotFamilyChanged( int pos )
}
if ( mListView->childCount() == 0 ) {
//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
defaults();
emit changed( true );
mCurrentManager->writeConfig( mCurrentConfig );
} else {
//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
if ( !standardResource ) {
- KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) );
+ KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
}
emit changed( false );
}
}
void ConfigPage::slotAdd()
{
if ( !mCurrentManager )
return;
QStringList types = mCurrentManager->resourceTypeNames();
QStringList descs = mCurrentManager->resourceTypeDescriptions();
bool ok = false;
- QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
+
+ QString desc;
+
+ if (mFamily == syncfamily)
+ {
+ desc = QInputDialog::getItem( i18n( "Sync Configuration" ),
+ i18n( "Please select resource type for new sync profile:" ), descs, 0,
+ false, &ok, this );
+ }
+ else
+ {
+ desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
i18n( "Please 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;
}
@@ -371,49 +396,49 @@ void ConfigPage::slotEdit()
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 resource as standard!" ) );
+ 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 resource as standard!" ) );
+ 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 resource as standard!" ) );
+ KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
return;
}
QListViewItem *it = mListView->firstChild();
while ( it != 0 ) {
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it );
if ( configItem->standard() )
configItem->setStandard( false );
it = it->itemBelow();
}
item->setStandard( true );
@@ -455,25 +480,25 @@ void ConfigPage::resourceModified( Resource* resource )
void ConfigPage::resourceDeleted( Resource* resource )
{
qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1());
kdDebug(5650) << "ConfigPage::resourceDeleted( " << resource->resourceName() << " )" << endl;
}
void ConfigPage::slotItemClicked( QListViewItem *item )
{
ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item );
if ( !configItem ) return;
if ( configItem->standard() && !configItem->isOn() ) {
- KMessageBox::sorry( this, i18n( "You cannot deactivate the standard resource. Choose another standard resource first." ) );
+ 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");
@@ -490,21 +515,21 @@ void ConfigPage::saveResourceSettings()
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! Please select one which is neither read-only nor inactive." ) );
+ 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"