1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "LogViewer.hxx"
26 LogViewer::LogViewer(std::string label, QWidget *parent)
30 browser->setLineWrapMode(QTextEdit::NoWrap);
31 browser->setReadOnly(1);
32 connect(pushButton,SIGNAL(clicked()),this, SLOT(close()));
35 LogViewer::~LogViewer()
39 void LogViewer::setText(std::string text)
41 string atext = _label + "\n\n" + text;
42 browser->setText(atext.c_str());
45 void LogViewer::readFile(std::string fileName)
47 std::ifstream f(fileName.c_str());
48 std::stringstream hfile;
50 string atext = _label + "\n" + fileName + "\n\n";
51 QString qtext = atext.c_str();
52 browser->setText(qtext + hfile.str().c_str());
56 ContainerLogViewer::ContainerLogViewer(std::string label, QWidget *parent):LogViewer(label,parent)
58 gridLayout->removeWidget(browser);
59 gridLayout->addWidget(browser, 0, 0, 1, 3);
61 QPushButton* next = new QPushButton("next execution",this);
62 gridLayout->addWidget(next, 1, 1, 1, 1);
63 connect(next,SIGNAL(clicked()),this, SLOT(onNext()));
64 QPushButton* previous = new QPushButton("previous execution",this);
65 gridLayout->addWidget(previous, 1, 2, 1, 1);
66 connect(previous,SIGNAL(clicked()),this, SLOT(onPrevious()));
69 void ContainerLogViewer::readFile(std::string fileName)
71 LogViewer::readFile(fileName);
72 //move cursor to the end
73 QTextCursor cursor=browser->textCursor();
74 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
75 browser->setTextCursor(cursor);
78 //go to next begin execution schema
79 void ContainerLogViewer::onNext()
81 QTextCursor orig = browser->textCursor();
82 QTextCursor find_result = browser->document()->find("**************************Begin schema execution", orig);
84 if(find_result.isNull())
86 //Try to find from the beginning
87 find_result = browser->document()->find("**************************Begin schema execution",0);
90 if(!find_result.isNull())
91 browser->setTextCursor(find_result);
94 //go to previous begin execution schema
95 void ContainerLogViewer::onPrevious()
97 QTextCursor orig = browser->textCursor();
98 QTextCursor find_result = browser->document()->find("**************************Begin schema execution",
99 orig, QTextDocument::FindBackward);
100 if(find_result.isNull())
102 //Try to find from the end
103 find_result = browser->document()->find("**************************Begin schema execution",
104 browser->document()->characterCount()-1, QTextDocument::FindBackward);
107 if(!find_result.isNull())
108 browser->setTextCursor(find_result);