File: Workflow.h

package info (click to toggle)
fotowall 0.9-8
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,280 kB
  • sloc: cpp: 23,275; makefile: 51; sh: 25
file content (97 lines) | stat: -rw-r--r-- 3,369 bytes parent folder | download | duplicates (3)
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
/***************************************************************************
 *                                                                         *
 *   This file is part of the Fotowall project,                            *
 *       http://www.enricoros.com/opensource/fotowall                      *
 *                                                                         *
 *   Copyright (C) 2009 by Enrico Ros <enrico.ros@gmail.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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __Workflow_h__
#define __Workflow_h__

#include <QObject>
#include <QVariant>
#include "Shared/PlugGui/AbstractAppliance.h"
#include "Shared/AbstractResourceProvider.h"
namespace Wordcloud { class Cloud; }
class BreadCrumbBar;
class Canvas;

// TODO: add checkes to avoid enqueueing while processing a command, or a list

class Workflow : public QObject
{
    Q_OBJECT
    public:
        Workflow(PlugGui::Container * container, BreadCrumbBar * bar, QObject * parent = 0);
        ~Workflow();

        // change workflow
        bool loadCanvas_A(const QString & fwFilePath = QString());
        void startCanvas_A();
        void stackSlaveCanvas_A(SingleResourceLoaner *);
#ifndef NO_WORDCLOUD_APPLIANCE
        void startWordcloud_A();
        void stackSlaveWordcloud_A(SingleResourceLoaner *);
#endif
        void stackHelpAppliance();
        void popCurrentAppliance();

        // other utilities
        QString applianceName() const;
        bool applianceCommand(int command);
        bool requestExit();

    private:
        struct Command {
            enum Type {
                ResetToLevel, MasterCanvas, SlaveCanvas
#ifndef NO_WORDCLOUD_APPLIANCE
                , MasterWordcloud, SlaveWordcloud
#endif
            };

            Type type;
            QVariant param;
            SingleResourceLoaner * loaner;

            Command(Type type, const QVariant & param = QVariant(), SingleResourceLoaner * loaner = 0) : type(type), param(param), loaner(loaner) {}
        };
        void scheduleCommand(const Command & command);
        bool processCommand(const Command & command);

        struct Node {
            PlugGui::AbstractAppliance * appliance;
            SingleResourceLoaner * loaner;

            Node(PlugGui::AbstractAppliance * app, SingleResourceLoaner * loaner = 0) : appliance(app), loaner(loaner) {}
        };

        void pushNode(const Node & node);
        bool popNode(bool allowSaving);
        void updateBreadcrumb();

        // external objects
        PlugGui::Container * m_container;
        BreadCrumbBar * m_bar;

        // commands
        QTimer * m_commandTimer;
        QList<Command> m_commands;
        bool m_processingQueue;

        // nodes structure
        QList<Node> m_stack;

    private Q_SLOTS:
        void slotNodeClicked(quint32);
        void slotProcessQueue();
};

#endif