svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2008 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _SELECTABLE_LABEL_H_ 00017 #define _SELECTABLE_LABEL_H_ 00018 00019 #include <QLabel> 00020 00021 class SelectableLabel : public QLabel 00022 { 00023 Q_OBJECT 00024 00025 public: 00026 SelectableLabel(QWidget *parent = 0); 00027 virtual ~SelectableLabel(); 00028 00029 void setSelectedText(QString); 00030 void setUnselectedText(QString); 00031 00032 bool isSelected() const { return m_selected; } 00033 00034 signals: 00035 void selectionChanged(); 00036 void doubleClicked(); 00037 00038 public slots: 00039 void setSelected(bool); 00040 void toggle(); 00041 00042 protected: 00043 virtual void mousePressEvent(QMouseEvent *e); 00044 virtual void mouseReleaseEvent(QMouseEvent *e); 00045 virtual void mouseDoubleClickEvent(QMouseEvent *e); 00046 virtual void enterEvent(QEvent *); 00047 virtual void leaveEvent(QEvent *); 00048 void setupStyle(); 00049 QString m_selectedText; 00050 QString m_unselectedText; 00051 bool m_selected; 00052 bool m_swallowRelease; 00053 }; 00054 00055 #endif