ExtendedLabel.h 2.09 KB
Newer Older
1
/*****************************************************************************
2
 * ExtendedLabel.h: Provide a QLabel with elidable text in it.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *****************************************************************************
 * Copyright (C) 2008-2010 VideoLAN
 *
 * Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef ELIDABLELABEL_H
#define ELIDABLELABEL_H

#include <QLabel>

28
class ExtendedLabel : public QLabel
29 30 31 32
{
    Q_OBJECT

    public:
33 34
        ExtendedLabel( QWidget* parent );
        ExtendedLabel( const QString& text, QWidget* parent );
35 36 37 38 39 40 41 42
        Qt::TextElideMode       elideMode() const;
        void                    setElideMode( Qt::TextElideMode mode );
        virtual QSize           minimumSizeHint() const;
        virtual QSize           sizeHint() const;
        void                    setText( const QString &text );

    protected:
        virtual void            resizeEvent( QResizeEvent *event );
43 44
        virtual void            mousePressEvent( QMouseEvent *ev );
        virtual void            mouseDoubleClickEvent( QMouseEvent *ev );
45 46 47 48

    private:
        Qt::TextElideMode       m_elideMode;
        QString                 m_text;
49 50 51 52

    signals:
        void                    clicked( QWidget* sender, QMouseEvent* ev );
        void                    doubleClicked();
53 54 55
};

#endif // ELIDABLELABEL_H