~ubuntu-branches/ubuntu/oneiric/partitionmanager/oneiric

« back to all changes in this revision

Viewing changes to src/core/operationstack.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-01-23 17:57:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090123175736-2ltrhgg3m55dokbm
Tags: upstream-1.0.0~beta1a
ImportĀ upstreamĀ versionĀ 1.0.0~beta1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Volker Lanz <vl@fidra.de>                       *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
 
18
 ***************************************************************************/
 
19
 
 
20
#if !defined(OPERATIONSTACK__H)
 
21
 
 
22
#define OPERATIONSTACK__H
 
23
 
 
24
#include <QList>
 
25
#include <qglobal.h>
 
26
 
 
27
class Device;
 
28
class Partition;
 
29
class LibParted;
 
30
class Operation;
 
31
 
 
32
/** @brief The list of Operations the user wants to have performed.
 
33
 
 
34
        OperationStack also handles the Devices that were found on this computer and the merging of
 
35
        Operations, e.g., when the user first creates a Partition, then deletes it.
 
36
 
 
37
        @author vl@fidra.de
 
38
*/
 
39
class OperationStack
 
40
{
 
41
        Q_DISABLE_COPY(OperationStack)
 
42
 
 
43
        friend class LibParted;
 
44
 
 
45
        public:
 
46
                typedef QList<Device*> Devices;
 
47
                typedef QList<Operation*> Operations;
 
48
                
 
49
        public:
 
50
                OperationStack();
 
51
                ~OperationStack();
 
52
 
 
53
        public:
 
54
                void push(Operation* o);
 
55
                void pop();
 
56
                void clearOperations();
 
57
                int size() const { return operations().size(); } /**< @return number of operations */
 
58
                
 
59
                Devices& previewDevices() { return m_PreviewDevices; } /**< @return the list of Devices */
 
60
                const Devices& previewDevices() const { return m_PreviewDevices; } /**< @return the list of Devices */
 
61
                
 
62
                Operations& operations() { return m_Operations; } /**< @return the list of operations */
 
63
                const Operations& operations() const { return m_Operations; } /**< @return the list of operations */
 
64
 
 
65
                Device* findDeviceForPartition(const Partition* p);
 
66
 
 
67
        protected:
 
68
                void clearDevices();
 
69
                void addDevice(Device* d);
 
70
                
 
71
                bool mergeNewOperation(Operation*& currentOp, Operation*& pushedOp);
 
72
                bool mergeCopyOperation(Operation*& currentOp, Operation*& pushedOp);
 
73
                bool mergeRestoreOperation(Operation*& currentOp, Operation*& pushedOp);
 
74
                bool mergePartFlagsOperation(Operation*& currentOp, Operation*& pushedOp);
 
75
                bool mergePartLabelOperation(Operation*& currentOp, Operation*& pushedOp);
 
76
 
 
77
        private:
 
78
                Operations m_Operations;
 
79
                mutable Devices m_PreviewDevices;
 
80
};
 
81
 
 
82
#endif