SelectableLabel.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2008 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_SELECTABLE_LABEL_H
17 #define SV_SELECTABLE_LABEL_H
18 
19 #include <QLabel>
20 
21 class SelectableLabel : public QLabel
22 {
23  Q_OBJECT
24 
25 public:
26  SelectableLabel(QWidget *parent = 0);
27  virtual ~SelectableLabel();
28 
29  void setSelectedText(QString);
30  void setUnselectedText(QString);
31 
32  bool isSelected() const { return m_selected; }
33 
34 signals:
35  void selectionChanged();
36  void doubleClicked();
37 
38 public slots:
39  void setSelected(bool);
40  void toggle();
41 
42 protected:
43  void mousePressEvent(QMouseEvent *e) override;
44  void mouseReleaseEvent(QMouseEvent *e) override;
45  void mouseDoubleClickEvent(QMouseEvent *e) override;
46  void enterEvent(QEvent *) override;
47  void leaveEvent(QEvent *) override;
48  void setupStyle();
49  QString m_selectedText;
51  bool m_selected;
53 };
54 
55 #endif
void setSelected(bool)
SelectableLabel(QWidget *parent=0)
void enterEvent(QEvent *) override
void mouseDoubleClickEvent(QMouseEvent *e) override
void doubleClicked()
void mouseReleaseEvent(QMouseEvent *e) override
virtual ~SelectableLabel()
QString m_selectedText
bool isSelected() const
void setUnselectedText(QString)
QString m_unselectedText
void setSelectedText(QString)
void mousePressEvent(QMouseEvent *e) override
void selectionChanged()
void leaveEvent(QEvent *) override