MuseScore  3.4
Music composition and notation
scoreBrowser.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2014 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __SCOREBROWSER_H__
14 #define __SCOREBROWSER_H__
15 
16 #include "ui_scoreBrowser.h"
17 #include "scoreInfo.h"
18 
19 namespace Ms {
20 
21 class ScoreItem;
22 
23 //---------------------------------------------------------
24 // ScoreListWidget
25 //---------------------------------------------------------
26 
27 class ScoreListWidget : public QListWidget
28  {
29  Q_OBJECT
30  int CELLW { 140 };
31  int CELLH { 228 };
32  int SPACE { 10 };
33 
34  virtual QSize sizeHint() const override;
35 
36  public:
37  ScoreListWidget(QWidget* parent = 0) : QListWidget(parent) {}
38  int cellWidth() const { return CELLW; }
39  int cellHeight() const { return CELLH; }
40  int space() const { return SPACE; }
41  QSize cellSize() const { return QSize(CELLW, CELLH); }
42 
43  // override so we pass wheel event to the parent scroll area
44  virtual void wheelEvent(QWheelEvent*) {};
45  };
46 
47 //---------------------------------------------------------
48 // ScoreBrowser
49 //---------------------------------------------------------
50 
51 class ScoreBrowser : public QWidget, public Ui::ScoreBrowser
52  {
53  Q_OBJECT
54 
55  QList<ScoreListWidget*> scoreLists;
56  bool _stripNumbers { false };
57  bool _showPreview { false }; // no preview: - no selection
58  // - single click action
59  bool _boldTitle { false }; // score title are displayed in bold
60  bool _showCustomCategory { false };// show a custom category for files
61  QLabel* _noMatchedScoresLabel; // displayed when no scores are matching the search
62 
63  ScoreListWidget* createScoreList();
64  ScoreItem* genScoreItem(const QFileInfo&, ScoreListWidget*);
65 
66  private slots:
67  void scoreClicked(QListWidgetItem*);
68  void setScoreActivated(QListWidgetItem*);
69 
70  signals:
71  void leave();
72  void scoreSelected(QString);
73  void scoreActivated(QString);
74 
75  public:
76  ScoreBrowser(QWidget* parent = 0);
77  void setScores(QFileInfoList&);
78  void setStripNumbers(bool val) { _stripNumbers = val; }
79  void selectFirst();
80  void selectLast();
81  void setBoldTitle(bool bold) { _boldTitle = bold; }
82  void setShowCustomCategory(bool showCustomCategory) { _showCustomCategory = showCustomCategory; }
83  void filter(const QString&);
84  };
85 }
86 
87 #endif
88 
Definition: scoreBrowser.cpp:45
int CELLW
Definition: scoreBrowser.h:30
int SPACE
Definition: scoreBrowser.h:32
QSize cellSize() const
Definition: scoreBrowser.h:41
QLabel * _noMatchedScoresLabel
Definition: scoreBrowser.h:61
Definition: scoreBrowser.h:51
int cellWidth() const
Definition: scoreBrowser.h:38
Definition: scoreBrowser.h:27
int cellHeight() const
Definition: scoreBrowser.h:39
virtual void wheelEvent(QWheelEvent *)
Definition: scoreBrowser.h:44
virtual QSize sizeHint() const override
Definition: scoreBrowser.cpp:24
int CELLH
Definition: scoreBrowser.h:31
void setShowCustomCategory(bool showCustomCategory)
Definition: scoreBrowser.h:82
void setBoldTitle(bool bold)
Definition: scoreBrowser.h:81
Definition: aeolus.cpp:26
void setStripNumbers(bool val)
Definition: scoreBrowser.h:78
ScoreListWidget(QWidget *parent=0)
Definition: scoreBrowser.h:37
int space() const
Definition: scoreBrowser.h:40
QList< ScoreListWidget * > scoreLists
Definition: scoreBrowser.h:55