File: application_context_impl.h

package info (click to toggle)
sigviewer 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,232 kB
  • sloc: cpp: 15,174; sh: 32; xml: 29; makefile: 6
file content (85 lines) | stat: -rw-r--r-- 3,084 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
// Copyright (c) 2016 The SigViewer Development Team
// Licensed under the GNU General Public License (GPL)
// https://www.gnu.org/licenses/gpl


#ifndef APPLICATION_CONTEXT_IMPL_H
#define APPLICATION_CONTEXT_IMPL_H

#include "base/application_states.h"
#include "gui/application_context.h"

#include <QObject>
#include <QSharedPointer>


namespace sigviewer
{

//-----------------------------------------------------------------------------
/// ApplicationContext
///
/// exists once in an application
class ApplicationContextImpl : public QObject, public ApplicationContext
{
    Q_OBJECT
public:
    //-------------------------------------------------------------------------
    static QSharedPointer<ApplicationContextImpl> getInstance (bool cleanup = false);

    //-------------------------------------------------------------------------
    static void init (std::set<ApplicationMode> activated_modes);

    //-------------------------------------------------------------------------
    static void cleanup ();

    //-------------------------------------------------------------------------
    ApplicationContextImpl () {}
    virtual ~ApplicationContextImpl ();

    //-------------------------------------------------------------------------
    virtual bool modeActivated (ApplicationMode mode) const;

    //-------------------------------------------------------------------------
    virtual QSharedPointer<FileContext> getCurrentFileContext ();

    //-------------------------------------------------------------------------
    virtual void setCurrentTabContext (QSharedPointer<TabContext> tab_context);

    //-------------------------------------------------------------------------
    virtual QSharedPointer<CommandExecuter> getCurrentCommandExecuter ();

    //-------------------------------------------------------------------------
    /// NO MULTI-FILE SUPPORT IMPLEMENTED YET!!!
    /// THIS CALL WILL REPLACE ACTUAL FILE CONTEXT
    virtual void addFileContext (QSharedPointer<FileContext> file_context);

    //-------------------------------------------------------------------------
    virtual void removeCurrentFileContext ();

    //-------------------------------------------------------------------------
    virtual QSharedPointer<MainWindowModel> getMainWindowModel ();

    //-------------------------------------------------------------------------
    virtual QSharedPointer<ColorManager> getEventColorManager ();

    QSharedPointer<ColorManager> color_manager_;

signals:
    void stateChanged (ApplicationState state);
    void currentFileStateChanged (FileState state);
    void currentTabSelectionStateChanged (TabSelectionState state);
    void currentTabEditStateChanged (TabEditState state);

private:
    void setState (ApplicationState state);
    std::set<ApplicationMode> activated_modes_;
    QSharedPointer<MainWindowModel> main_window_model_;
    QSharedPointer<FileContext> current_file_context_;
    QSharedPointer<TabContext> current_tab_context_;
    ApplicationState state_;
};

}

#endif // APPLICATION_CONTEXT_IMPL_H