annotate widgets/SelectableLabel.h @ 1025:c02de0e34233 spectrogram-minor-refactor

Make paint method do its own timing and abandon if it's taking too long (still needs some work on queueing correct repaints of the remainder)
author Chris Cannam
date Mon, 25 Jan 2016 16:16:21 +0000
parents f8fcfbe13c8f
children a18e78b9c78b
rev   line source
Chris@424 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@424 2
Chris@424 3 /*
Chris@424 4 Sonic Visualiser
Chris@424 5 An audio file viewer and annotation editor.
Chris@424 6 Centre for Digital Music, Queen Mary, University of London.
Chris@424 7 This file copyright 2008 QMUL.
Chris@424 8
Chris@424 9 This program is free software; you can redistribute it and/or
Chris@424 10 modify it under the terms of the GNU General Public License as
Chris@424 11 published by the Free Software Foundation; either version 2 of the
Chris@424 12 License, or (at your option) any later version. See the file
Chris@424 13 COPYING included with this distribution for more information.
Chris@424 14 */
Chris@424 15
Chris@424 16 #ifndef _SELECTABLE_LABEL_H_
Chris@424 17 #define _SELECTABLE_LABEL_H_
Chris@424 18
Chris@424 19 #include <QLabel>
Chris@424 20
Chris@424 21 class SelectableLabel : public QLabel
Chris@424 22 {
Chris@424 23 Q_OBJECT
Chris@424 24
Chris@424 25 public:
Chris@424 26 SelectableLabel(QWidget *parent = 0);
Chris@424 27 virtual ~SelectableLabel();
Chris@424 28
Chris@424 29 void setSelectedText(QString);
Chris@424 30 void setUnselectedText(QString);
Chris@424 31
Chris@424 32 bool isSelected() const { return m_selected; }
Chris@424 33
Chris@424 34 signals:
Chris@424 35 void selectionChanged();
Chris@424 36 void doubleClicked();
Chris@424 37
Chris@424 38 public slots:
Chris@424 39 void setSelected(bool);
Chris@424 40 void toggle();
Chris@424 41
Chris@424 42 protected:
Chris@424 43 virtual void mousePressEvent(QMouseEvent *e);
Chris@441 44 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@424 45 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@424 46 virtual void enterEvent(QEvent *);
Chris@424 47 virtual void leaveEvent(QEvent *);
Chris@424 48 void setupStyle();
Chris@424 49 QString m_selectedText;
Chris@424 50 QString m_unselectedText;
Chris@424 51 bool m_selected;
Chris@441 52 bool m_swallowRelease;
Chris@424 53 };
Chris@424 54
Chris@424 55 #endif