From b999efe016a5b8be86b35e89364f370634b5bb0b Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 13 Jan 2026 14:34:39 -0700 Subject: [PATCH] Add testing parser --- CMakeLists.txt | 1 + src/main.cpp | 7 +++++-- src/ui/content.cpp | 31 +++++++++++++++++++++++++++++++ src/ui/content.h | 17 +++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/ui/content.cpp create mode 100644 src/ui/content.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 822208f..fbf10cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ qt_standard_project_setup() add_executable(CrabCrawler src/main.cpp src/ui/navbar.cpp + src/ui/content.cpp ) target_link_libraries(CrabCrawler diff --git a/src/main.cpp b/src/main.cpp index 8a52c65..d0bf3e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include "ui/navbar.h" +#include "ui/content.h" int main(int argc, char *argv[]) { @@ -19,9 +20,11 @@ int main(int argc, char *argv[]) auto *navBar = new NavBar(&window); layout->addWidget(navBar); - layout->addStretch(); - QObject::connect(navBar, &NavBar::addressEntered, [](const QString &text) + auto *content = new Content(&window); + layout->addWidget(content, 1); + + QObject::connect(navBar, &NavBar::addressEntered, [content](const QString &text) { qDebug() << "navigate to:" << text; }); window.show(); diff --git a/src/ui/content.cpp b/src/ui/content.cpp new file mode 100644 index 0000000..d017a16 --- /dev/null +++ b/src/ui/content.cpp @@ -0,0 +1,31 @@ +#include "content.h" + +#include +#include + +Content::Content(QWidget *parent) : QWidget(parent) +{ + auto *layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + + display = new QTextEdit(this); + display->setReadOnly(true); + + layout->addWidget(display); +} + +void Content::parseCrabcontent(const QString &input) +{ + QStringList lines = input.split('\n', Qt::SkipEmptyParts); + QString result; + + for (const QString &line : lines) + { + if (line.startsWith("text:")) + { + result += "

" + line.mid(5).trimmed() + "

\n"; + } + } + + display->setHtml(result); +} diff --git a/src/ui/content.h b/src/ui/content.h new file mode 100644 index 0000000..1240908 --- /dev/null +++ b/src/ui/content.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include + +class Content : public QWidget +{ + Q_OBJECT +public: + explicit Content(QWidget *parent = nullptr); + + void parseCrabcontent(const QString &input); + +private: + QTextEdit *display; +};