Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
main-window.hh
Go to the documentation of this file.
1 // Copyright (C) 2009-2011, Romain Goffe <romain.goffe@gmail.com>
2 // Copyright (C) 2009-2011, Alexandre Dupas <alexandre.dupas@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 // 02110-1301, USA.
18 //******************************************************************************
19 
20 #ifndef __MAIN_WINDOW_HH__
21 #define __MAIN_WINDOW_HH__
22 
23 #include <QMainWindow>
24 
25 #include <QModelIndex>
26 #include <QDir>
27 #include <QProcess>
28 
29 class CSongbook;
30 class CLibrary;
31 class CLibraryView;
32 class CTabWidget;
33 class CSongEditor;
34 class CLabel;
35 class CTabWidget;
36 class CFilterLineEdit;
37 class CNotification;
38 class CProgressBar;
40 
41 class QPlainTextEdit;
42 class QItemSelectionModel;
43 class QSortFilterProxyModel;
44 class QFileSystemModel;
45 class QLabel;
46 
56 class CMainWindow : public QMainWindow
57 {
58  Q_OBJECT
59 
60 public slots:
65  void setBuildCommand(const QString &command);
66 
72  void setCleanCommand(const QString &command);
73 
79  void setCleanallCommand(const QString &command);
80 
81  void songEditor(const QString &filename);
82 
83  void open(const QString &filename);
84 
85 public:
87  CMainWindow(QWidget *parent=0);
88 
90  ~CMainWindow();
91 
95  CProgressBar * progressBar() const;
96 
101  QDockWidget * log() const;
102 
106  CLibraryView * view() const;
107 
111  CLibrary * library() const;
112 
116  CSongbook * songbook() const;
117 
121  const QString workingPath();
122 
127  const QString & buildCommand() const;
128 
133  const QString & cleanCommand() const;
134 
139  const QString & cleanallCommand() const;
140 
145  void make();
146 
152  void makeClean();
153 
159  void makeCleanall();
160 
161 protected:
165  void closeEvent(QCloseEvent *event);
166 
167 private slots:
168  //songbook
169  void newSongbook();
170  void open();
171  void save(bool forced = false);
172  void saveAs();
173  void build();
174  void closeTab(int index);
175  void changeTab(int index);
176 
179  void downloadDialog();
180 
183  void cleanDialog();
184  void updateTempFilesView(int state);
185 
186  //library
187  void newSong();
188  void middleClicked(const QModelIndex &index = QModelIndex());
189  void songEditor(const QModelIndex &index = QModelIndex());
190  void deleteSong();
191 
192  void deleteSong(const QString &filename);
193  void updateNotification(const QString &path);
194  void noDataNotification(const QDir &directory);
195 
196  //model
197  void selectedSongsChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
198 
199  //application
200  void preferences();
201  void setToolBarDisplayed(bool);
202  void setStatusBarDisplayed(bool);
203  void documentation();
204  void reportBug();
205  void about();
206 
207  void updateTitle(const QString &filename);
208  void switchToolBar(QToolBar *toolBar);
209 
210  void buildError(QProcess::ProcessError error);
211 
212  void cancelProcess();
213 
214 private:
215  void readSettings(bool firstLaunch=false);
216  void writeSettings();
217 
218  void createActions();
219  void createMenus();
220  void createToolBar();
221 
222  bool isToolBarDisplayed();
223  bool isStatusBarDisplayed();
224 
225  QItemSelectionModel * selectionModel();
226 
227  // Models and views
228  CLibrary *m_library;
229  CLibraryView *m_view;
230  CSongbook *m_songbook;
231  QSortFilterProxyModel *m_proxyModel;
232  QFileSystemModel* m_tempFilesmodel;
233 
234  // Widgets
235  CTabWidget *m_mainWidget;
236  CProgressBar *m_progressBar;
237  CNotification *m_noDataInfo;
238  CNotification *m_updateAvailable;
239  QLabel *m_infoSelection;
240  CFilterLineEdit *m_filterLineEdit;
241  QDockWidget *m_log;
242 
243  // Settings
244  QString m_workingPath;
245  bool m_isToolBarDisplayed;
246  bool m_isStatusBarDisplayed;
247  QString m_buildCommand;
248  QString m_cleanCommand;
249  QString m_cleanallCommand;
250 
251  // Menus
252  QMenu *m_editorMenu;
253  CSongEditor *m_voidEditor;
254  QToolBar *m_libraryToolBar;
255  QToolBar *m_currentToolBar;
256  QToolBar *m_mainToolBar;
257 
258  // Application actions
259  QAction *m_preferencesAct;
260  QAction *m_documentationAct;
261  QAction *m_bugsAct;
262  QAction *m_aboutAct;
263  QAction *m_exitAct;
264 
265  // Songbook actions
266  QAction *m_newAct;
267  QAction *m_openAct;
268  QAction *m_saveAct;
269  QAction *m_saveAsAct;
270  QAction *m_buildAct;
271  QAction *m_cleanAct;
272  QAction *m_sbInfoAct;
273  CMakeSongbookProcess *m_builder;
274 
275  // Library action
276  QAction *m_newSongAct;
277  QAction *m_selectAllAct;
278  QAction *m_unselectAllAct;
279  QAction *m_invertSelectionAct;
280  QAction *m_libraryUpdateAct;
281  QAction *m_libraryDownloadAct;
282 };
283 
284 #endif // __MAIN_WINDOW_HH__