File indexing completed on 2024-04-28 16:26:34

0001 /*************************************************************************************************
0002    Copyright (C) 2015 Andreas Cord-Landwehr (cordlandwehr@kde.org)
0003                  2016 by Michel Ludwig (michel.ludwig@kdemail.net)
0004  *************************************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #include "statusbar.h"
0016 
0017 #include <QLabel>
0018 
0019 #include <KLocalizedString>
0020 
0021 #include "errorhandler.h"
0022 #include "kiledebug.h"
0023 
0024 KileWidget::StatusBar::StatusBar(KileErrorHandler *errorHandler, QWidget* parent)
0025     : QStatusBar(parent),
0026       m_errorHandler(errorHandler)
0027 {
0028     m_hintTextLabel = new QLabel();
0029     m_parserStatusLabel = new QLabel();
0030     m_lineColumnLabel = new QLabel();
0031     m_viewModeLabel = new QLabel();
0032     m_selectionModeLabel = new QLabel();
0033 
0034     addPermanentWidget(m_hintTextLabel, 10);
0035     addPermanentWidget(m_errorHandler->compilationResultLabel());
0036     addPermanentWidget(m_parserStatusLabel, 0);
0037     addPermanentWidget(m_lineColumnLabel, 0);
0038     addPermanentWidget(m_viewModeLabel, 0);
0039     addPermanentWidget(m_selectionModeLabel, 0);
0040 
0041     reset();
0042 }
0043 
0044 KileWidget::StatusBar::~StatusBar()
0045 {
0046 }
0047 
0048 void KileWidget::StatusBar::setHintText(const QString& text)
0049 {
0050     m_hintTextLabel->setText(text);
0051 }
0052 
0053 void KileWidget::StatusBar::clearHintText()
0054 {
0055     m_hintTextLabel->clear();
0056 }
0057 
0058 void KileWidget::StatusBar::setParserStatus(const QString& text)
0059 {
0060     m_parserStatusLabel->setText(text);
0061 }
0062 
0063 void KileWidget::StatusBar::clearParserStatus()
0064 {
0065     m_parserStatusLabel->clear();
0066 }
0067 
0068 void KileWidget::StatusBar::setLineColumn(int line, int column)
0069 {
0070     m_lineColumnLabel->setText(i18n("Line: %1 Col: %2", line, column));
0071 }
0072 
0073 void KileWidget::StatusBar::clearLineColumn()
0074 {
0075     m_lineColumnLabel->clear();
0076 }
0077 
0078 void KileWidget::StatusBar::setViewMode(const QString& text)
0079 {
0080     m_viewModeLabel->setText(text);
0081 }
0082 
0083 void KileWidget::StatusBar::clearViewMode()
0084 {
0085     m_viewModeLabel->clear();
0086 }
0087 
0088 void KileWidget::StatusBar::setSelectionMode(const QString& text)
0089 {
0090     m_selectionModeLabel->setText(text);
0091 }
0092 
0093 void KileWidget::StatusBar::clearSelectionMode()
0094 {
0095     m_selectionModeLabel->clear();
0096 }
0097 
0098 void KileWidget::StatusBar::reset()
0099 {
0100     clearHintText();
0101     clearParserStatus();
0102     clearLineColumn();
0103     clearViewMode();
0104     clearSelectionMode();
0105 }