Commit 44a7538e authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Skip the beginning of the ALPM log

We just want the recent output, if any
parent eda97469
......@@ -23,7 +23,7 @@
ReadFile::ReadFile()
{
connect(&m_watcher, &QFileSystemWatcher::fileChanged, this, &ReadFile::openNow);
connect(&m_file, &QFile::readyRead, this, &ReadFile::processAll);
connect(&m_file, &QFile::readyRead, this, &ReadFile::process);
}
void ReadFile::componentComplete()
......@@ -45,6 +45,7 @@ void ReadFile::setPath(QString path)
m_watcher.removePath(m_file.fileName());
m_file.setFileName(path);
m_sizeOnSet = m_file.size() + 1;
openNow();
m_watcher.addPath(m_file.fileName());
......@@ -66,7 +67,8 @@ void ReadFile::openNow()
return;
m_stream.reset(new QTextStream(&m_file));
processAll();
m_stream->seek(m_sizeOnSet);
process();
}
void ReadFile::processPath(QString& path)
......@@ -79,13 +81,11 @@ void ReadFile::processPath(QString& path)
}
}
void ReadFile::process(uint max)
void ReadFile::process()
{
QString read = m_stream->readAll();
if (max>0)
read = read.right(max);
const QString read = m_stream->readAll();
if (m_filter.isValid()) {
if (m_filter.isValid() && !m_filter.pattern().isEmpty()) {
auto it = m_filter.globalMatch(read);
while(it.hasNext()) {
const auto match = it.next();
......
......@@ -52,8 +52,7 @@ Q_SIGNALS:
void contentsChanged(const QString &contents);
private:
void processAll() { return process(0); }
void process(uint max);
void process();
void openNow();
void processPath(QString& path);
......@@ -63,6 +62,7 @@ private:
QSharedPointer<QTextStream> m_stream;
QFileSystemWatcher m_watcher;
QRegularExpression m_filter;
qint64 m_sizeOnSet = 0;
};
#endif // READFILE_H
......@@ -54,7 +54,7 @@ DiscoverPage
readOnly: true
text: log.contents
onTextChanged: cursorPosition = text.length
cursorPosition: text.length - 1
font.family: "monospace"
ReadFile {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment