File indexing completed on 2024-04-14 14:32:23

0001 //
0002 // C++ Interface: cProfileManager
0003 //
0004 // Description: profile manager
0005 //
0006 /*
0007 Copyright 2008-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef CPROFILEMANAGER_H
0024 #define CPROFILEMANAGER_H
0025 
0026 #include <QStringList>
0027 
0028 #include <kmuddy_export.h>
0029 
0030 class cProfileSettings;
0031 class QAbstractTableModel;
0032 
0033 /** cProfileManager - manages the profiles */
0034 
0035 class KMUDDY_EXPORT cProfileManager {
0036  public:
0037   static cProfileManager *self ();
0038   ~cProfileManager ();
0039 
0040   /** Returns the profile list. */
0041   QStringList profileList () const;
0042 
0043   // a data model for the connect dialog
0044   QAbstractTableModel *model () const;
0045 
0046   /** Path to profile files - takes internal profile name as param. */
0047   QString profilePath (const QString &profileName) const;
0048 
0049   bool profileExists (const QString &name);
0050 
0051   /** Assign a session to a particular profile. */
0052   void assignSession (int sess, const QString &profileName);
0053 
0054   /** Remove the session assignation */
0055   void unassignSession (int sess);
0056 
0057   /** Is the session assigned to a profile ? If the session exists and isn't
0058    assigned, it s quick connection */
0059   bool sessionAssigned (int sess);
0060 
0061   /** Does this profile have any session assigned ? */
0062   bool hasSessionAssigned (const QString &profile);
0063 
0064   /** Path to profile files belonging to a session. */
0065   QString profilePath (int sess);
0066 
0067   /** Profile name associated to this session. */
0068   QString profileName (int sess);
0069 
0070   /** Return visible profile name. */
0071   QString visibleProfileName (QString name);
0072 
0073   /** Return profile settings. */
0074   cProfileSettings *settings (const QString &profileName);
0075 
0076   /** Return profile settings for a session. */
0077   cProfileSettings *settings (int sess);
0078 
0079   /** Create new profile. */
0080   QString newProfile (const QString &name);
0081 
0082   /** Rename profile's visible name. The internal name stays the same. */
0083   bool renameProfile (const QString &name, const QString &newName);
0084 
0085   /** Delete profile. */
0086   bool deleteProfile (const QString &name, bool deleteFiles = false);
0087 
0088   /** Duplicate profile. */
0089   bool duplicateProfile (const QString &name, const QString &newName);
0090 
0091   /** Base profile info has been changed, react accordingly. */
0092   void profileInfoChanged (const QString &name);
0093 
0094  private:
0095   cProfileManager ();
0096   static cProfileManager *_self;
0097 
0098   /** Load the profile list. */
0099   void load ();
0100   /** Save the profile list. */
0101   void save ();
0102   /** Initialize the object after loading. */
0103   void init ();
0104 
0105   struct Private;
0106   Private *d;
0107 };
0108 
0109 #endif   // CPROFILEMANAGER_H
0110