kitchensync Library API Documentation

actionmanager.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #include <klocale.h>
00023 #include <kstatusbar.h>
00024 #include <kdebug.h>
00025 #include <kglobal.h>
00026 #include <kconfig.h>
00027 
00028 #include "actionmanager.h"
00029 
00030 using namespace KSync;
00031 
00032 ActionManager::ActionManager( KActionCollection *actionCollection )
00033   : mActionCollection( actionCollection ), mView( 0 )
00034 {
00035 }
00036 
00037 ActionManager::~ActionManager()
00038 {
00039   writeConfig();
00040 }
00041 
00042 void ActionManager::setView( KitchenSync *view )
00043 {
00044   mView = view;
00045 }
00046 
00047 void ActionManager::initActions()
00048 {
00049   if ( !mView ) {
00050     kdError() << "Call KSync::ActionManager::setView() before "
00051               << "KSync::ActionManager::initActions()." << endl;
00052     return;
00053   }
00054 
00055   new KAction( i18n("Synchronize" ), "reload", 0, mView, SLOT( slotSync() ),
00056                mActionCollection, "sync" );
00057 
00058   new KAction( i18n("Configure Profiles..."), "configure", 0,
00059                mView, SLOT( configureProfiles() ),
00060                mActionCollection, "config_profile" );
00061 
00062   new KAction( i18n("Configure Current Profile..."), "configure", 0,
00063                mView, SLOT( configureCurrentProfile() ),
00064                mActionCollection, "config_current" );
00065 
00066   m_profAct = new KSelectAction( i18n("Profile"), KShortcut(), mView,
00067                                  SLOT( activateProfile() ),
00068                                  mActionCollection, "select_prof");
00069 
00070   KStdAction::preferences( mView, SLOT( slotPreferences() ),
00071                            mActionCollection );
00072 }
00073 
00074 int ActionManager::currentProfile()
00075 {
00076   return m_profAct->currentItem();
00077 }
00078 
00079 void ActionManager::setProfiles( const QStringList &profiles )
00080 {
00081   m_profAct->setItems( profiles );
00082 }
00083 
00084 void ActionManager::readConfig()
00085 {
00086   KConfig *cfg = KGlobal::config();
00087   cfg->setGroup( "Profiles" );
00088   int currentProfile = cfg->readNumEntry( "CurrentProfile", 0 );
00089   m_profAct->setCurrentItem( currentProfile );
00090 }
00091 
00092 void ActionManager::writeConfig()
00093 {
00094   KConfig *cfg = KGlobal::config();
00095   cfg->setGroup( "Profiles" );
00096   int currentProfile = m_profAct->currentItem();
00097   cfg->writeEntry( "CurrentProfile", currentProfile );
00098   cfg->sync();
00099 }
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 04:47:07 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003