File indexing completed on 2024-05-05 04:49:26

0001 /****************************************************************************************
0002  * Copyright (c) 2006 Martin Aumueller <aumuell@reserv.at>                              *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "HintLineEdit.h"
0018 
0019 #include "widgets/BoxWidget.h"
0020 
0021 #include <QFont>
0022 #include <QLabel>
0023 
0024 HintLineEdit::HintLineEdit( const QString &hint, const QString &text, QWidget *parent )
0025    : QLineEdit( text, nullptr )
0026    , m_vbox( new BoxWidget( true, parent ) )
0027 {
0028     init();
0029     m_hint->setText( hint );
0030 }
0031 
0032 HintLineEdit::HintLineEdit( const QString &text, QWidget *parent )
0033    : QLineEdit( text, nullptr )
0034    , m_vbox( new BoxWidget( true, parent ) )
0035 {
0036     init();
0037 }
0038 
0039 HintLineEdit::HintLineEdit( QWidget *parent )
0040    : QLineEdit( nullptr )
0041    , m_vbox( new BoxWidget( true, parent ) )
0042 {
0043     init();
0044 }
0045 
0046 void
0047 HintLineEdit::init()
0048 {
0049     setParent( m_vbox );
0050     show();
0051     m_hint = new QLabel( m_vbox );
0052     //m_hint->setBuddy( this );
0053     m_hint->setFocusPolicy( Qt::NoFocus );
0054     QFont font;
0055     font.setPointSize( font.pointSize() - 2);
0056     m_hint->setFont( font );
0057 }
0058 
0059 HintLineEdit::~HintLineEdit()
0060 {
0061     setParent( nullptr );
0062     delete m_vbox;
0063 }
0064 
0065 void
0066 HintLineEdit::setHint( const QString &hint )
0067 {
0068     m_hint->setText( hint );
0069 }
0070 
0071 QObject *
0072 HintLineEdit::parent()
0073 {
0074     return m_vbox->parent();
0075 }
0076