0e860be by Jan Ekholm at 2009-10-21 1
#ifndef MAINWINDOW_HH
2
#define MAINWINDOW_HH
3
4
#include <QMainWindow>
5
f0b78e7 by Jan Ekholm at 2010-01-31 6
#include "DiagramView.hh"
7
e6006ea by Jan Ekholm at 2010-01-31 8
class QActionGroup;
85db9fa by Jan Ekholm at 2009-11-04 9
class Selectable;
4e84e01 by Jan Ekholm at 2009-10-31 10
0e860be by Jan Ekholm at 2009-10-21 11
namespace Ui {
12
    class MainWindow;
13
}
14
e6006ea by Jan Ekholm at 2010-01-31 15
/**
16
 * @todo docs
17
 **/
0e860be by Jan Ekholm at 2009-10-21 18
class MainWindow : public QMainWindow {
2af2b63 by Jan Ekholm at 2009-10-27 19
0e860be by Jan Ekholm at 2009-10-21 20
    Q_OBJECT
2af2b63 by Jan Ekholm at 2009-10-27 21
0e860be by Jan Ekholm at 2009-10-21 22
public:
23
24
    MainWindow(QWidget *parent = 0);
25
    ~MainWindow();
26
2af2b63 by Jan Ekholm at 2009-10-27 27
0e860be by Jan Ekholm at 2009-10-21 28
protected:
29
30
    void changeEvent(QEvent *e);
31
32
    /**
33
     * Event handler for close events. Saves the window size and position into settings.
34
     *
35
     * @param event not used.
36
     **/
37
    void closeEvent (QCloseEvent * event);
38
39
2af2b63 by Jan Ekholm at 2009-10-27 40
private slots:
41
cb669c4 by jan.ekholm@plenware.fi at 2009-10-29 42
    /**
f06bb88 by jan.ekholm@plenware.fi at 2009-10-30 43
     * Shows the given @p message in the status bar.
44
     *
45
     * @param message the message to show.
46
     * @param timeout optional timeout in ms or 0 for a permanent message.
47
     **/
48
    void showMessage (const QString & message, int timeout);
49
85db9fa by Jan Ekholm at 2009-11-04 50
    /**
e6006ea by Jan Ekholm at 2010-01-31 51
     * Callback for when the user has clicked something in the toolbar of available shapes. Sets a new mode for the diagram view
85db9fa by Jan Ekholm at 2009-11-04 52
     * so that it knows what to do when it's clicked.
53
     *
e6006ea by Jan Ekholm at 2010-01-31 54
     * @param action the triggered action
85db9fa by Jan Ekholm at 2009-11-04 55
     **/
e6006ea by Jan Ekholm at 2010-01-31 56
    void actionSelected (QAction * action);
4e84e01 by Jan Ekholm at 2009-10-31 57
d4142ce by Jan Ekholm at 2009-11-05 58
    /**
f0b78e7 by Jan Ekholm at 2010-01-31 59
     * Callback for when the diagram view has a new @p mode. Sets the select action to be active if the @p mode is back to
60
     * standard mode (nothing active).
61
     *
62
     * @param mode the new mode.
63
     **/
64
    void modeChanged (DiagramView::OperationMode mode);
65
66
    /**
d4142ce by Jan Ekholm at 2009-11-05 67
     * Callback for when the user has clicked something in the diagram. Updates the edit panel to show the editor for the current @p selectable.
68
     * If there is no suitable editor part then the panel is made empty.
69
     *
70
     * @param selectable the clicked shape or 0 for no shape.
71
     **/
85db9fa by Jan Ekholm at 2009-11-04 72
    void diagramShapeSelected (Selectable * selectable);
73
d4142ce by Jan Ekholm at 2009-11-05 74
    /**
75
     * Callback for the @e New action. Asks the user for confirmation and then recreates the diagram, deleteing the old.
76
     **/
77
    void newDiagram ();
78
79
    /**
80
     * Callback for the @e Open action. Asks the user for the file to open and loads it if valid.
81
     **/
82
    void openDiagram ();
83
84
    /**
85
     * Callback for the @e Save action. If no filename has been set then calls saveDiagramAs() so get a filename.
86
     **/
87
    void saveDiagram ();
88
89
    /**
90
     * Callback for the @e Save @e As action. Calls saveDiagram() to do the real saving.
91
     **/
92
    void saveDiagramAs ();
93
93aed59 by Jan Ekholm at 2009-11-08 94
    /**
99e077a by Jan Ekholm at 2009-12-17 95
     * Callback for the @e Validate action. Opens a validation dialog.
62aecf3 by jan.ekholm@plenware.fi at 2009-11-10 96
     **/
97
    void validate ();
98
99
    /**
99e077a by Jan Ekholm at 2009-12-17 100
     * Callback for the @e Generate action. Opens a code generation dialog.
101
     **/
102
    void generate ();
103
104
    /**
93aed59 by Jan Ekholm at 2009-11-08 105
     * Callback for the @e About action. Opens an about dialog.
106
     **/
107
    void about ();
108
109
    /**
110
     * Callback for the @e Help action. Opens a browser for the homepage.
111
     **/
112
    void help ();
113
2af2b63 by Jan Ekholm at 2009-10-27 114
0e860be by Jan Ekholm at 2009-10-21 115
private:
4e84e01 by Jan Ekholm at 2009-10-31 116
117
    /**
e6006ea by Jan Ekholm at 2010-01-31 118
     * Set up the action in the object toolbar. Sets some internal properties for the actions.
4e84e01 by Jan Ekholm at 2009-10-31 119
     **/
e6006ea by Jan Ekholm at 2010-01-31 120
    void setupActions ();
4e84e01 by Jan Ekholm at 2009-10-31 121
0e860be by Jan Ekholm at 2009-10-21 122
    Ui::MainWindow *ui;
d4142ce by Jan Ekholm at 2009-11-05 123
124
    //! the name of the current diagram file
125
    QString m_filename;
e6006ea by Jan Ekholm at 2010-01-31 126
127
    //! a group for the state action in the toolbar
128
    QActionGroup * m_action_group;
0e860be by Jan Ekholm at 2009-10-21 129
};
130
131
#endif // MAINWINDOW_HH