Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
song-editor.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 #ifndef __SONG_EDITOR_HH__
20 #define __SONG_EDITOR_HH__
21 
22 #include "config.hh"
23 #include "song.hh"
24 
25 #include <QWidget>
26 #include <QString>
27 
28 class QAction;
29 class QActionGroup;
30 class QToolBar;
31 class CFindReplaceDialog;
32 class CLibrary;
33 class CSongCodeEditor;
34 class CSongHeaderEditor;
35 
48 class CSongEditor : public QWidget
49 {
50  Q_OBJECT
51  Q_PROPERTY(bool newSong READ isNewSong WRITE setNewSong)
52  Q_PROPERTY(bool newCover READ isNewCover WRITE setNewCover)
53 
54 public:
55  CSongEditor(QWidget *parent = 0);
56  ~CSongEditor();
57 
58  QToolBar * toolBar() const;
59  CLibrary * library() const;
60  void setLibrary(CLibrary *library);
61 
62  QActionGroup * actionGroup() const;
63 
64  void readSettings();
65  void writeSettings();
66 
67  void installHighlighter();
68 
69  Song & song();
70  void setSong(const Song &song);
71 
72  CSongCodeEditor * codeEditor() const;
73 
74  bool isModified() const;
75  bool isNewSong() const;
76 
78  bool isNewCover() const;
79 
81  void setNewCover(bool newCover);
82 
83  bool isSpellCheckAvailable() const;
84  void setSpellCheckAvailable(const bool);
85 
86 public slots:
87  void setModified(bool modified);
88  void setNewSong(bool newSong);
89  void setDictionary(const QLocale & locale);
90 
91 signals:
92  void labelChanged(const QString &label);
93  void saved(const QString &path);
94 
95 protected:
96  void closeEvent(QCloseEvent *event);
97 
98 private slots:
99  //write modifications of the textEdit into sg file.
100  void save();
101  void documentWasModified();
102 
103 private:
104  void parseText();
105  bool checkSongMandatoryFields();
106  void saveNewSong();
107  void createNewSong();
108 
109  CSongCodeEditor *m_codeEditor;
110  CSongHeaderEditor *m_songHeaderEditor;
111  CLibrary *m_library;
112  QToolBar *m_toolBar;
113  QActionGroup *m_actions;
114 
115  CFindReplaceDialog* m_findReplaceDialog;
116  QAction* m_spellCheckingAct;
117 
118  Song m_song;
119  bool m_newSong;
120  bool m_newCover;
121 };
122 
123 #endif // __SONG_EDITOR_HH__