Files
ResInsight/ApplicationLibCode/UserInterface/RiuResultInfoPanel.cpp
T

86 lines
2.9 KiB
C++
Raw Normal View History

2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
2012-05-18 09:45:23 +02:00
// ResInsight 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 3 of the License, or
// (at your option) any later version.
//
2012-05-18 09:45:23 +02:00
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
2012-05-18 09:45:23 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
2013-03-22 17:30:50 +01:00
#include "RiuResultInfoPanel.h"
2012-05-18 09:45:23 +02:00
2015-09-25 15:57:43 +02:00
#include <QTextEdit>
#include <QVBoxLayout>
2012-05-18 09:45:23 +02:00
//==================================================================================================
///
2013-03-22 17:30:50 +01:00
/// \class RiuResultInfoPanel
2012-05-18 09:45:23 +02:00
/// \ingroup ResInsight
///
///
2012-05-18 09:45:23 +02:00
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2022-07-07 12:03:02 +02:00
RiuResultInfoPanel::RiuResultInfoPanel( QWidget* parent )
: QWidget( parent )
2012-05-18 09:45:23 +02:00
{
m_textEdit = new QTextEdit( this );
m_textEdit->setReadOnly( true );
m_textEdit->setLineWrapMode( QTextEdit::NoWrap );
2012-05-18 09:45:23 +02:00
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget( m_textEdit );
// Use a nonexisting font family to trigger the use of QFont::Monospace
// https://forum.qt.io/topic/35999/solved-qplaintextedit-how-to-change-the-font-to-be-monospaced/7
QFont font( "does not exist" );
font.setStyleHint( QFont::Monospace );
m_textEdit->setFont( font );
layout->setContentsMargins( 0, 0, 0, 0 );
setLayout( layout );
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
void RiuResultInfoPanel::setInfo( const QString& info )
2012-05-18 09:45:23 +02:00
{
QString tmp( info );
2012-05-18 09:45:23 +02:00
convertStringToHTML( &tmp );
2012-05-18 09:45:23 +02:00
m_textEdit->setText( info );
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
void RiuResultInfoPanel::convertStringToHTML( QString* str )
2012-05-18 09:45:23 +02:00
{
str->replace( "\n", "<br>" );
str->replace( " ", "&nbsp;" );
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
QSize RiuResultInfoPanel::sizeHint() const
2012-05-18 09:45:23 +02:00
{
2017-03-29 11:22:04 +02:00
// As small as possible for now
return QSize( 20, 20 );
2012-05-18 09:45:23 +02:00
}