Source Code (Use browser search to find items of interest.)

Class Index

kdat'BackupProfileManager (./kdeadmin/kdat/BackupProfileManager.h:38)

class BackupProfileManager : public QObject {
    Q_OBJECT

    static BackupProfileManager* _instance;

    QDict<BackupProfile> _backupProfiles;
    QStrList             _backupProfileNames;
    
    BackupProfileManager();
public:
    ~BackupProfileManager();

    /**
     * All access to the BackupProfileManager goes through this method.
     *
     * @return a pointer to the single instance of the BackupProfileManager.
     */
    static BackupProfileManager* instance();

    /**
     * Get the list of all known backup profiles.
     *
     * @return a QStrList containing the backup profile names.
     */
    const QStrList& getBackupProfileNames();

    /**
     * Retrieve the named backup profile.
     *
     * @param name The name of the backup profile.
     * @return A pointer to the backup profile.
     */
    BackupProfile* findBackupProfile( const char* name );

    /**
     * Add a new backup profile.
     *
     * @param backupProfile A pointer to the new backup profile.
     */
    void addBackupProfile( BackupProfile* backupProfile );

    /**
     * Remove a backup profile.  The backup profile is removed from memory and
     * from disk.  A signal is emitted before the profile is actually removed.
     *
     * @param backupProfile A pointer to the backup profile to remove.
     */
    void removeBackupProfile( BackupProfile* backupProfile );

    /**
     * Notify anyone who cares that the backup profile has been modified.
     *
     * @param backupProfile A pointer to the backup profile that was modified.
     */
    void backupProfileModified( BackupProfile* backupProfile );
signals:
    /**
     * Emitted after a new backup profile is created.
     *
     * @param backupProfile A pointer to the new backup profile.
     */
    void sigBackupProfileAdded( BackupProfile* backupProfile );

    /**
     * Emitted before a backup profile is destroyed.  This signal is emitted
     * immediately before the backup profile is deleted.
     *
     * @param backupProfile A pointer to the backup profile that is about to
     *                      be destroyed.
     */
    void sigBackupProfileRemoved( BackupProfile* backupProfile );

    /**
     * Emitted after a backup profile has been changed in some way.
     *
     * @param backupProfile A pointer to the backup profile that has been modified.
     */
    void sigBackupProfileModified( BackupProfile* backupProfile );
};

kdat'BackupProfileManager::BackupProfileManager() (./kdeadmin/kdat/BackupProfileManager.cpp:31)

BackupProfileManager::BackupProfileManager()
{
    _backupProfiles.setAutoDelete( TRUE );

    // Get a list of all available backup profiles.
    QStringList relList;
    (void) KGlobal::dirs()->findAllResources( "appdata", "*.bp", false, true, relList);
    
    for(QStringList::Iterator it = relList.begin();
        it != relList.end();
        it++)
    {
        QString fn = *it;
        // Strip extension
        _backupProfileNames.append( fn.left( fn.length() - 3 ) );
    }
}


kdat'BackupProfileManager::~BackupProfileManager() (./kdeadmin/kdat/BackupProfileManager.cpp:49)

BackupProfileManager::~BackupProfileManager()
{
}


kdat'BackupProfileManager::instance() (./kdeadmin/kdat/BackupProfileManager.cpp:55)

BackupProfileManager* BackupProfileManager::instance()
{
    if ( _instance == 0 ) {
        _instance = new BackupProfileManager();
    }

    return _instance;
}


kdat'BackupProfileManager::getBackupProfileNames() (./kdeadmin/kdat/BackupProfileManager.cpp:64)

const QStrList& BackupProfileManager::getBackupProfileNames()
{
    return _backupProfileNames;
}


kdat'BackupProfileManager::findBackupProfile() (./kdeadmin/kdat/BackupProfileManager.cpp:69)

BackupProfile* BackupProfileManager::findBackupProfile( const char* name )
{
    BackupProfile* backupProfile = _backupProfiles[ name ];

    if ( !backupProfile ) {
        backupProfile = new BackupProfile( name );
        _backupProfiles.insert( backupProfile->getName(), backupProfile );
    }

    return backupProfile;
}


kdat'BackupProfileManager::addBackupProfile() (./kdeadmin/kdat/BackupProfileManager.cpp:81)

void BackupProfileManager::addBackupProfile( BackupProfile* backupProfile )
{
    BackupProfile* old = _backupProfiles[ backupProfile->getName() ];
    if ( old ) {
        removeBackupProfile( old );
    }

    _backupProfileNames.append( backupProfile->getName() );
    _backupProfiles.insert( backupProfile->getName(), backupProfile );

    emit sigBackupProfileAdded( backupProfile );
}


kdat'BackupProfileManager::removeBackupProfile() (./kdeadmin/kdat/BackupProfileManager.cpp:94)

void BackupProfileManager::removeBackupProfile( BackupProfile* backupProfile )
{
    emit sigBackupProfileRemoved( backupProfile );

    // Remove the index file.
    QString filename = locateLocal( "appdata", 
                                    QString(backupProfile->getName()) + ".bp");
    
    unlink( QFile::encodeName(filename) );

    _backupProfileNames.remove( backupProfile->getName() );
    _backupProfiles.remove( backupProfile->getName() );
}


kdat'BackupProfileManager::backupProfileModified() (./kdeadmin/kdat/BackupProfileManager.cpp:108)

void BackupProfileManager::backupProfileModified( BackupProfile* backupProfile )
{
    emit sigBackupProfileModified( backupProfile );
}