Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
song-header-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_HEADER_EDITOR_HH__
20 #define __SONG_HEADER_EDITOR_HH__
21 
22 #include <QWidget>
23 
24 #include "song.hh"
25 
26 #include <QString>
27 #include <QLabel>
28 #include <QPixmap>
29 
30 class CSongEditor;
31 class CCoverDropArea;
32 class CDiagramArea;
33 class CLibrary;
34 class LineEdit;
35 
36 class QSpinBox;
37 class QComboBox;
38 class QBoxLayout;
39 class QStackedLayout;
40 
58 class CSongHeaderEditor : public QWidget
59 {
60  Q_OBJECT
61 
62 public:
67  enum ViewMode {
70  };
71 
73  CSongHeaderEditor(QWidget *parent = 0);
76 
80  Song & song();
81 
84  CSongEditor * songEditor() const;
85 
89 
92  const QImage & cover();
93 
98  void setLibrary(CLibrary* library);
99 
103  LineEdit* titleLineEdit() const;
104 
108  LineEdit* artistLineEdit() const;
109 
113  QSize sizeHint() const;
114 
115 private slots:
116  void onIndexChanged(const QString &text);
117  void onTextEdited(const QString &text);
118  void onValueChanged(int value);
119  void onDiagramsChanged();
120  void onCoverChanged();
121 
122 public slots:
126  void update();
127 
131  void toggleView();
132 
133 signals:
137  void contentsChanged();
138 
142  void languageChanged(const QLocale &);
143 
144 private:
145  CSongEditor *m_songEditor;
146 
147  LineEdit *m_titleLineEdit;
148  LineEdit *m_artistLineEdit;
149  LineEdit *m_albumLineEdit;
150  LineEdit *m_originalSongLineEdit;
151  LineEdit *m_urlLineEdit;
152  QComboBox *m_languageComboBox;
153  QSpinBox *m_columnCountSpinBox;
154  QSpinBox *m_capoSpinBox;
155  QSpinBox *m_transposeSpinBox;
156  CCoverDropArea *m_coverLabel;
157 
158  CDiagramArea *m_diagramArea;
159 
160  ViewMode m_viewMode;
161  QStackedLayout *m_stackedLayout;
162 };
163 
164 
165 class QMimeData;
166 class QDragEnterEvent;
167 class QDragMoveEvent;
168 class QDragLeaveEvent;
169 class QDragDropEvent;
170 
186 class CCoverDropArea : public QLabel
187 {
188  Q_OBJECT
189 
190  public:
193 
197  Song & song();
198 
203  const QImage & cover();
204 
209  void setCover(const QImage &cover);
210 
216  void setCover(const QString &filename);
217 
222  CSongHeaderEditor * parent() const;
223 
228  void setParent(CSongHeaderEditor *p);
229 
230 private slots:
231  void selectCover();
232  void clearCover();
233 
234 public slots:
238  void clear();
239 
243  void update();
244 
245 signals:
250  void changed(const QMimeData *mimeData = 0);
251 
256  void coverChanged();
257 
262  void miniCoverChanged(const QPixmap & thumbnail);
263 
264 protected:
265  void dragEnterEvent(QDragEnterEvent *event);
266  void dragMoveEvent(QDragMoveEvent *event);
267  void dragLeaveEvent(QDragLeaveEvent *event);
268  void dropEvent(QDropEvent *event);
269  virtual void mousePressEvent(QMouseEvent *event);
270  virtual void mouseReleaseEvent(QMouseEvent *event);
271  virtual void contextMenuEvent(QContextMenuEvent *event);
272 
273 private:
274  QString m_filename;
275  QImage m_cover;
276  CSongHeaderEditor * m_parent;
277 };
278 
279 #endif // __SONG_HEADER_EDITOR_HH__