summaryrefslogtreecommitdiffstats
path: root/kitchensync/src/groupconfig.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kitchensync/src/groupconfig.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kitchensync/src/groupconfig.cpp')
-rw-r--r--kitchensync/src/groupconfig.cpp179
1 files changed, 179 insertions, 0 deletions
diff --git a/kitchensync/src/groupconfig.cpp b/kitchensync/src/groupconfig.cpp
new file mode 100644
index 000000000..2ad4af631
--- /dev/null
+++ b/kitchensync/src/groupconfig.cpp
@@ -0,0 +1,179 @@
+/*
+ This file is part of KitchenSync.
+
+ Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include "groupconfig.h"
+
+#include "groupconfigcommon.h"
+#include "memberconfig.h"
+#include "memberinfo.h"
+#include "pluginpicker.h"
+#include "syncprocess.h"
+#include "syncprocessmanager.h"
+
+#include <libqopensync/group.h>
+#include <libqopensync/plugin.h>
+
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <kjanuswidget.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+GroupConfig::GroupConfig( QWidget *parent )
+ : QWidget( parent )
+{
+ QBoxLayout *topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ QFrame *titleFrame = new QFrame( this );
+ topLayout->addWidget( titleFrame );
+
+ titleFrame->setPaletteForegroundColor( colorGroup().light() );
+ titleFrame->setPaletteBackgroundColor( colorGroup().mid() );
+
+ QBoxLayout *nameLayout = new QHBoxLayout( titleFrame );
+ nameLayout->setMargin( 4 );
+
+ QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_summary",
+ KIcon::Desktop );
+
+ QLabel *iconLabel = new QLabel( titleFrame );
+ iconLabel->setPixmap( icon );
+ nameLayout->addWidget( iconLabel );
+
+ nameLayout->addSpacing( 8 );
+
+ QLabel *label = new QLabel( i18n("Group:"), titleFrame );
+ QFont font = label->font();
+ font.setBold( true );
+ font.setPointSize( font.pointSize() + 2 );
+ label->setFont( font );
+ nameLayout->addWidget( label );
+
+ mNameLabel = new QLabel( titleFrame );
+ font = mNameLabel->font();
+ font.setBold( true );
+ font.setPointSize( font.pointSize() + 2 );
+ mNameLabel->setFont( font );
+ nameLayout->addWidget( mNameLabel );
+
+ nameLayout->addStretch( 1 );
+
+ mMemberView = new KJanusWidget( this, 0, KJanusWidget::IconList );
+ topLayout->addWidget( mMemberView );
+
+ QBoxLayout *buttonLayout = new QHBoxLayout( topLayout );
+
+ QPushButton *addButton = new QPushButton( i18n("Add Member..."), this );
+ connect( addButton, SIGNAL( clicked() ), SLOT( addMember() ) );
+ buttonLayout->addWidget( addButton );
+
+ buttonLayout->addStretch( 1 );
+
+ icon = KGlobal::iconLoader()->loadIcon( "bookmark", KIcon::Desktop );
+ QFrame *page = mMemberView->addPage( i18n("Group"),
+ i18n("General Group Settings"), icon );
+ QBoxLayout *pageLayout = new QVBoxLayout( page );
+
+ mCommonConfig = new GroupConfigCommon( page );
+ pageLayout->addWidget( mCommonConfig );
+}
+
+void GroupConfig::setSyncProcess( SyncProcess *process )
+{
+ mProcess = process;
+
+ mNameLabel->setText( mProcess->group().name() );
+ mCommonConfig->setSyncProcess( mProcess );
+
+ updateMembers();
+}
+
+void GroupConfig::updateMembers()
+{
+ QValueList<MemberConfig *>::ConstIterator memberIt;
+ for ( memberIt = mMemberConfigs.begin(); memberIt != mMemberConfigs.end(); ++memberIt )
+ (*memberIt)->saveData();
+
+ QValueList<QFrame *>::ConstIterator it2;
+ for ( it2 = mConfigPages.begin(); it2 != mConfigPages.end(); ++it2 ) {
+ mMemberView->removePage( *it2 );
+ delete *it2;
+ }
+ mConfigPages.clear();
+ mMemberConfigs.clear();
+
+ QSync::Group group = mProcess->group();
+ QSync::Group::Iterator it( group.begin() );
+ for ( ; it != group.end(); ++it ) {
+ QSync::Member member = *it;
+ MemberInfo mi( member );
+ QFrame *page = mMemberView->addPage( mi.name(),
+ QString( "%1 (%2)" ).arg( mi.name() ).arg(member.pluginName()), mi.desktopIcon() );
+
+ QBoxLayout *pageLayout = new QVBoxLayout( page );
+ mConfigPages.append( page );
+
+ MemberConfig *memberConfig = new MemberConfig( page, member );
+ mMemberConfigs.append( memberConfig );
+ pageLayout->addWidget( memberConfig );
+
+ memberConfig->loadData();
+ }
+}
+
+void GroupConfig::saveConfig()
+{
+ mProcess->group().save();
+
+ QValueList<MemberConfig *>::ConstIterator it;
+ for ( it = mMemberConfigs.begin(); it != mMemberConfigs.end(); ++it )
+ (*it)->saveData();
+
+ mCommonConfig->save();
+
+ mProcess->reinitEngine();
+}
+
+void GroupConfig::addMember()
+{
+ QSync::Plugin plugin = PluginPickerDialog::getPlugin( this );
+
+ if ( plugin.isValid() ) {
+ QSync::Result result = SyncProcessManager::self()->addMember( mProcess, plugin );
+ if ( result.isError() ) {
+ KMessageBox::error( this, i18n("Error adding member %1\n%2\nType: %3")
+ .arg( plugin.name() ).arg( result.message() ).arg( result.type() ) );
+ } else {
+ updateMembers();
+
+ // select last (added) page
+ int index = mMemberView->pageIndex( mConfigPages.last() );
+ mMemberView->showPage( index );
+ }
+ }
+}
+
+#include "groupconfig.moc"