summaryrefslogtreecommitdiffstats
path: root/kdat/BackupProfileManager.h
blob: fa6939efae9f40cee25cb138ee4e09722c4d0cc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// KDat - a tar-based DAT archiver
// Copyright (C) 1998-2000  Sean Vyain, svyain@mail.tds.net
// Copyright (C) 2001-2002  Lawrence Widman, kdat@cardiothink.com
//
// 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

#ifndef _BackupProfileManager_h_
#define _BackupProfileManager_h_

#include <qdict.h>
#include <qobject.h>

#include "BackupProfile.h"

/**
 * @short Control access to the set of backup profiles.
 *
 * Each user has a set of backup profiles that are stored under
 * <TT>$HOME/.kde/share/apps/kdat/</TT>.  (Changed from $HOME/.kdat in KDE1.)
 * This class provides a single point of access for reading and writing 
 * these backup profiles.
 *
 * Other objects can register to be notified when a backup profile is added or
 * removed, and when a backup profile is modified.
 *
 * The BackupProfileManager follows the Singleton pattern.
 */
class BackupProfileManager : public QObject {
    Q_OBJECT

    static BackupProfileManager* _instance;

    QDict<BackupProfile> _backupProfiles;
    QStringList             _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 QStringList containing the backup profile names.
     */
    const QStringList& getBackupProfileNames();

    /**
     * Retrieve the named backup profile.
     *
     * @param name The name of the backup profile.
     * @return A pointer to the backup profile.
     */
    BackupProfile* findBackupProfile( const QString & 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 );
};

#endif