| 1 |
#ifndef MAINWINDOW_HH |
| 2 |
#define MAINWINDOW_HH |
| 3 |
|
| 4 |
#include <QMainWindow> |
| 5 |
|
| 6 |
#include "DiagramView.hh" |
| 7 |
|
| 8 |
class QActionGroup; |
| 9 |
class Selectable; |
| 10 |
|
| 11 |
namespace Ui { |
| 12 |
class MainWindow; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* @todo docs |
| 17 |
**/ |
| 18 |
class MainWindow : public QMainWindow { |
| 19 |
|
| 20 |
Q_OBJECT |
| 21 |
|
| 22 |
public: |
| 23 |
|
| 24 |
MainWindow(QWidget *parent = 0); |
| 25 |
~MainWindow(); |
| 26 |
|
| 27 |
|
| 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 |
|
| 40 |
private slots: |
| 41 |
|
| 42 |
/** |
| 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 |
|
| 50 |
/** |
| 51 |
* Callback for when the user has clicked something in the toolbar of available shapes. Sets a new mode for the diagram view |
| 52 |
* so that it knows what to do when it's clicked. |
| 53 |
* |
| 54 |
* @param action the triggered action |
| 55 |
**/ |
| 56 |
void actionSelected (QAction * action); |
| 57 |
|
| 58 |
/** |
| 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 |
/** |
| 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 |
**/ |
| 72 |
void diagramShapeSelected (Selectable * selectable); |
| 73 |
|
| 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 |
|
| 94 |
/** |
| 95 |
* Callback for the @e Validate action. Opens a validation dialog. |
| 96 |
**/ |
| 97 |
void validate (); |
| 98 |
|
| 99 |
/** |
| 100 |
* Callback for the @e Generate action. Opens a code generation dialog. |
| 101 |
**/ |
| 102 |
void generate (); |
| 103 |
|
| 104 |
/** |
| 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 |
|
| 114 |
|
| 115 |
private: |
| 116 |
|
| 117 |
/** |
| 118 |
* Set up the action in the object toolbar. Sets some internal properties for the actions. |
| 119 |
**/ |
| 120 |
void setupActions (); |
| 121 |
|
| 122 |
Ui::MainWindow *ui; |
| 123 |
|
| 124 |
//! the name of the current diagram file |
| 125 |
QString m_filename; |
| 126 |
|
| 127 |
//! a group for the state action in the toolbar |
| 128 |
QActionGroup * m_action_group; |
| 129 |
}; |
| 130 |
|
| 131 |
#endif // MAINWINDOW_HH |