1 | #ifndef PUNCH_CARD_EDITOR_MAINWINDOW_H |
---|
2 | #define PUNCH_CARD_EDITOR_MAINWINDOW_H |
---|
3 | |
---|
4 | #include <QMainWindow> |
---|
5 | #include <QAction> |
---|
6 | #include <QMenu> |
---|
7 | #include <QMenuBar> |
---|
8 | #include <QStatusBar> |
---|
9 | #include <QToolBar> |
---|
10 | #include <QPointer> |
---|
11 | #include <QFile> |
---|
12 | |
---|
13 | namespace QPunchCard { |
---|
14 | namespace App { |
---|
15 | class MainWindow; |
---|
16 | }; |
---|
17 | }; |
---|
18 | |
---|
19 | #include "qpunchcard/card.h" |
---|
20 | #include "qpunchcard/deck.h" |
---|
21 | #include "deckviewer/navigatordock.h" |
---|
22 | #include "deckviewer/cardeditor.h" |
---|
23 | #include "text/editordock.h" |
---|
24 | |
---|
25 | namespace QPunchCard { |
---|
26 | namespace App { |
---|
27 | |
---|
28 | class MainWindow : public QMainWindow { |
---|
29 | Q_OBJECT |
---|
30 | DeckIndex current_index; |
---|
31 | |
---|
32 | public: |
---|
33 | // gerade offenes *Dokument* |
---|
34 | QPointer< Deck > deck; |
---|
35 | //QPointer< QFile > file; |
---|
36 | QFile file; |
---|
37 | |
---|
38 | QPointer<Navigator::Dock> navigator; |
---|
39 | QPointer<CardEditor> graphical_editor; |
---|
40 | QList< QPointer<Text::EditorDock> > text_editors; // eigentlich nur fuer exportText() |
---|
41 | |
---|
42 | MainWindow(); |
---|
43 | |
---|
44 | bool hasFileOpened() const { return deck; } |
---|
45 | QPointer< Deck > getDeck() const { return deck; } |
---|
46 | DeckIndex getCurrentIndex() const { return current_index; } |
---|
47 | |
---|
48 | /// speichert die Datei wenn noetig, auf Benutzeranfrage |
---|
49 | /// @returns ob weitergemacht werden darf (wenn nicht, will Benutzer |
---|
50 | /// an seiner Datei weiterarbeiten) |
---|
51 | bool maybeSave(); |
---|
52 | |
---|
53 | // Low-Level-Funktionen ohne GUI-Interaktion |
---|
54 | void loadDeck(const QString& filename); |
---|
55 | void closeDeck(); |
---|
56 | |
---|
57 | |
---|
58 | public slots: |
---|
59 | void newFile(); |
---|
60 | void newWindow(); |
---|
61 | void openFile(); |
---|
62 | /// Speichert Datei. Wenn kein Dateiname, ruft saveFileAs auf. |
---|
63 | /// @returns True bei erfolgreichem Speichern, sonst false. |
---|
64 | bool saveFile(); |
---|
65 | /// Oeffnet Speichern unter-Dialog |
---|
66 | /// @returns true, wenn erfolgreich gespeichert |
---|
67 | bool saveFileAs(); |
---|
68 | void exportText(); |
---|
69 | void exportPicture(); |
---|
70 | void closeFile(); |
---|
71 | void help(); |
---|
72 | void quit(); |
---|
73 | void about(); |
---|
74 | void newTextEditor(); |
---|
75 | |
---|
76 | void newCard(); |
---|
77 | void moveCardForwards(); |
---|
78 | void moveCardBackwards(); |
---|
79 | |
---|
80 | // durchreichen an alle Kindobjekte |
---|
81 | void nextCard(); |
---|
82 | void prevCard(); |
---|
83 | void setCard(DeckIndex i); |
---|
84 | |
---|
85 | signals: |
---|
86 | void cardSelected(DeckIndex i); |
---|
87 | |
---|
88 | // broadcasting from deck |
---|
89 | void contentsChanged(DeckIndex lower_index, DeckIndex upper_index); |
---|
90 | |
---|
91 | void fileOpened(bool opened); |
---|
92 | |
---|
93 | private slots: |
---|
94 | void window_update_on_file_state(bool opened); |
---|
95 | |
---|
96 | private: |
---|
97 | void createGraphicalEditor(); |
---|
98 | void createActions(); |
---|
99 | void createMenus(); |
---|
100 | void createToolBars(); |
---|
101 | void createStatusBar(); |
---|
102 | void createDockWindows(); |
---|
103 | |
---|
104 | void notifyFileOpened(); |
---|
105 | |
---|
106 | QMenu* file_menu; |
---|
107 | QMenu* edit_menu; |
---|
108 | QMenu* view_menu; |
---|
109 | QMenu* devices_menu; |
---|
110 | QMenu* help_menu; |
---|
111 | |
---|
112 | QToolBar* navi_bar; |
---|
113 | |
---|
114 | // Hauptactions |
---|
115 | QAction* new_file_action; |
---|
116 | QAction* new_window_action; |
---|
117 | QAction* open_file_action; |
---|
118 | QAction* save_file_action; |
---|
119 | QAction* save_file_as_action; |
---|
120 | QAction* export_text_action; |
---|
121 | QAction* export_picture_action; |
---|
122 | QAction* close_file_action; |
---|
123 | QAction* quit_action; |
---|
124 | QAction* help_action; |
---|
125 | QAction* about_action; |
---|
126 | |
---|
127 | // Editactions |
---|
128 | QAction* undo_action; |
---|
129 | QAction* redo_action; |
---|
130 | |
---|
131 | QAction* new_text_editor_action; |
---|
132 | |
---|
133 | // Naviactions |
---|
134 | QAction* next_card_action; |
---|
135 | QAction* prev_card_action; |
---|
136 | QAction* new_card_action; |
---|
137 | QAction* move_forwards_action; |
---|
138 | QAction* move_backwards_action; |
---|
139 | |
---|
140 | protected: |
---|
141 | void closeEvent(QCloseEvent* event); |
---|
142 | }; |
---|
143 | |
---|
144 | }; // namespace App |
---|
145 | }; // namespace QPunchCard |
---|
146 | |
---|
147 | #endif // PUNCH_CARD_EDITOR_MAINWINDOW_H |
---|