changeset 8:b1f73678ef61

update text paragraphs are now their own objects, as they should be
author Paper <mrpapersonic@gmail.com>
date Sat, 26 Aug 2023 03:39:34 -0400
parents 07a9095eaeed
children 5c0397762b53
files src/dialog/information.cpp src/include/session.h src/include/statistics.h src/include/ui_utils.h src/main.cpp src/pages/statistics.cpp src/ui_utils.cpp
diffstat 7 files changed, 243 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialog/information.cpp	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/dialog/information.cpp	Sat Aug 26 03:39:34 2023 -0400
@@ -25,11 +25,15 @@
 	setWindowTitle(tr("Anime Information"));
 	setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
 	setObjectName("infodiag");
+
+	/* main widget */
 	QWidget* widget = new QWidget(this);
 	widget->resize(842-175, 530);
 	widget->move(175, 0);
 	widget->setStyleSheet(UiUtils::IsInDarkMode() ? "" : "background-color: white");
 	widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+	/* anime title header text */
 	QPlainTextEdit* anime_title = new QPlainTextEdit(QString::fromUtf8(anime->GetUserPreferredTitle().c_str()), widget);
 	anime_title->setReadOnly(true);
 	anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -41,40 +45,41 @@
 	anime_title->setStyleSheet("font-size: 16px; color: blue; background: transparent;");
 	anime_title->resize(636, 28);
 	anime_title->move(0, 12);
+
+	/* tabbed widget */
 	QTabWidget* tabbed_widget = new QTabWidget(widget);
 	tabbed_widget->resize(636, 485);
 	tabbed_widget->move(0, 45);
 	tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+	/* main info tab */
 	QWidget* main_information_widget = new QWidget(tabbed_widget);
 	main_information_widget->setLayout(new QVBoxLayout);
 
-	QString alternative_titles = QString::fromUtf8(StringUtils::Implode(anime->GetTitleSynonyms(), ", ").c_str());
+	/* alt titles */
+	main_information_widget->layout()->addWidget(new UiUtils::SelectableTextParagraph("Alternative titles", QString::fromUtf8(StringUtils::Implode(anime->GetTitleSynonyms(), ", ").c_str()), main_information_widget));
 
-	QWidget* alternative_titles_w = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Alternative titles", alternative_titles)->parentWidget()->parentWidget();
-	//alternative_titles_w->setFixedHeight(60);
-	main_information_widget->layout()->addWidget(alternative_titles_w);
-
-	QString details_data("");
+	/* details */
+	QString details_data;
 	QTextStream details_data_s(&details_data);
 	details_data_s << AnimeFormatToStringMap[anime->type].c_str() << "\n"
 	               << anime->episodes << "\n"
 	               << AnimeAiringToStringMap[anime->airing].c_str() << "\n"
 	               << AnimeSeasonToStringMap[anime->season].c_str() << " " << anime->air_date.GetYear() << "\n"
 	               << StringUtils::Implode(anime->genres, ", ").c_str() << "\n"
-	               << anime->audience_score << "%\n";
-	QWidget* soidjhfh = UiUtils::CreateTextParagraphWithLabels(main_information_widget, "Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data)->parentWidget()->parentWidget();
-	main_information_widget->layout()->addWidget(soidjhfh);
+	               << anime->audience_score << "%";
+	main_information_widget->layout()->addWidget(new UiUtils::LabelledTextParagraph("Details", "Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:", details_data, main_information_widget));
 
-	QPlainTextEdit* synopsis = UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromUtf8(anime->synopsis.c_str()));
-	synopsis->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
-	synopsis->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
-	synopsis->parentWidget()->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
-	((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis->parentWidget()->parentWidget());
+	/* synopsis */
+	UiUtils::SelectableTextParagraph* synopsis = new UiUtils::SelectableTextParagraph("Synopsis", QString::fromUtf8(anime->synopsis.c_str()), main_information_widget);
+	synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+	((QVBoxLayout*)main_information_widget->layout())->addWidget(synopsis);
 
 	//((QVBoxLayout*)main_information_widget->layout())->addStretch();
 
+	QWidget* settings_widget = new QWidget(tabbed_widget);
+
 	tabbed_widget->addTab(main_information_widget, "Main information");
-	QWidget* settings_widget = new QWidget(tabbed_widget);
 	tabbed_widget->addTab(settings_widget, "My list and settings");
 	QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 	connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK);
--- a/src/include/session.h	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/include/session.h	Sat Aug 26 03:39:34 2023 -0400
@@ -6,7 +6,7 @@
 struct Session {
 	Config config;
 	Session() { timer.start(); }
-	int uptime() { return timer.nsecsElapsed() / 1000; }
+	int uptime() { return timer.elapsed(); }
 
 	private: QElapsedTimer timer;
 };
--- a/src/include/statistics.h	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/include/statistics.h	Sat Aug 26 03:39:34 2023 -0400
@@ -12,6 +12,7 @@
 
 	private:
 		std::string MinutesToDateString(int minutes);
+		std::string SecondsToDateString(int seconds);
 
 		AnimeListWidget* anime_list;
 		QPlainTextEdit* anime_list_data;
--- a/src/include/ui_utils.h	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/include/ui_utils.h	Sat Aug 26 03:39:34 2023 -0400
@@ -1,5 +1,7 @@
 #ifndef __ui_utils_h
 #define __ui_utils_h
+#include <QLabel>
+#include <QFrame>
 #include <QWidget>
 #include <QString>
 #include <QPoint>
@@ -11,17 +13,60 @@
 	QIcon CreateSideBarIcon(const char* file);
 	bool IsInDarkMode();
 	std::string GetLengthFromQDateTime(QDateTime stamp);
-	QPlainTextEdit* CreateTextParagraph(QWidget* parent, QString title, QString data);
-	QPlainTextEdit* CreateTextParagraphWithLabels(QWidget* parent, QString title, QString label, QString data);
-	QPlainTextEdit* CreateSelectableTextParagraph(QWidget* parent, QString title, QString data);
 	void SetPlainTextEditData(QPlainTextEdit* text_edit, QString data);
-	void CreateTextHeader(QWidget* parent, QString title);
-};
+
+	class Header : public QWidget {
+		public:
+			Header(QString title, QWidget* parent = nullptr);
+			void SetTitle(QString title);
+
+		private:
+			QLabel* static_text_title;
+			QFrame* static_text_line;
+	};
+
+	class Paragraph : public QPlainTextEdit {
+		public:
+			Paragraph(QString text, QWidget* parent = nullptr);
+			QSize minimumSizeHint() const override;
+			QSize sizeHint() const override;
+	};
+
+	/* Convenience class that combines Paragraph and Header.
+	   Fairly awful naming, but meh :') */
+	class TextParagraph : public QWidget {
+		public:
+			TextParagraph(QString title, QString data, QWidget* parent = nullptr);
+			Header* GetHeader();
+			Paragraph* GetParagraph();
 
-class Paragraph : public QPlainTextEdit {
-	public:
-		Paragraph(QString text, QWidget* parent = nullptr);
-		QSize minimumSizeHint() const override;
-		QSize sizeHint() const override;
+		private:
+			Header* header;
+			Paragraph* paragraph;
+	};
+
+	class LabelledTextParagraph : public QWidget {
+		public:
+			LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent = nullptr);
+			Header* GetHeader();
+			Paragraph* GetLabels();
+			Paragraph* GetParagraph();
+
+		private:
+			Header* header;
+			Paragraph* labels;
+			Paragraph* paragraph;
+	};
+
+	class SelectableTextParagraph : public QWidget {
+		public:
+			SelectableTextParagraph(QString title, QString data, QWidget* parent = nullptr);
+			Header* GetHeader();
+			Paragraph* GetParagraph();
+
+		private:
+			Header* header;
+			Paragraph* paragraph;
+	};
 };
 #endif // __ui_utils_h
\ No newline at end of file
--- a/src/main.cpp	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/main.cpp	Sat Aug 26 03:39:34 2023 -0400
@@ -113,9 +113,11 @@
 		switch (index) {
 			case 0:
 			case 1:
-			case 2:
 				stack->setCurrentIndex(index);
 				break;
+			case 3:
+				stack->setCurrentIndex(2);
+				break;
 			default:
 				break;
 		}
--- a/src/pages/statistics.cpp	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/pages/statistics.cpp	Sat Aug 26 03:39:34 2023 -0400
@@ -8,6 +8,7 @@
 #include "anime_list.h"
 #include "ui_utils.h"
 #include "statistics.h"
+#include "session.h"
 
 StatisticsWidget::StatisticsWidget(AnimeListWidget* listwidget, QWidget* parent)
 	: QFrame(parent) {
@@ -17,7 +18,14 @@
 	setFrameShape(QFrame::Panel);
 	setFrameShadow(QFrame::Plain);
 
-	layout()->addWidget((anime_list_data = UiUtils::CreateTextParagraphWithLabels(this, "Anime list", "Anime count:\nEpisode count:\nTime spent watching:\nTime to complete:\nAverage score:\nScore deviation:", ""))->parentWidget()->parentWidget());
+	UiUtils::LabelledTextParagraph* anime_list_pg = new UiUtils::LabelledTextParagraph("Anime list", "Anime count:\nEpisode count:\nTime spent watching:\nTime to complete:\nAverage score:\nScore deviation:", "", this);
+	anime_list_data = anime_list_pg->GetParagraph();
+
+	UiUtils::LabelledTextParagraph* application_pg = new UiUtils::LabelledTextParagraph("Weeaboo", "Uptime:", "", this);
+	application_data = application_pg->GetParagraph();
+
+	layout()->addWidget(anime_list_pg);
+	layout()->addWidget(application_pg);
 	((QBoxLayout*)layout())->addStretch();
 
 	QPalette pal = QPalette();
@@ -35,6 +43,9 @@
 	timer->start(1000); // update statistics every second
 }
 
+#define ADD_TIME_SEGMENT(r, x, s, p) \
+	if (x.count() > 0) \
+		r << x.count() << ((x.count() == 1) ? s : p)
 std::string StatisticsWidget::MinutesToDateString(int minutes) {
 	/* NOTE: these duration_casts may not be needed... */
 	std::chrono::duration<int, std::ratio<60>> int_total_mins(minutes);
@@ -44,23 +55,38 @@
 	auto int_hours = std::chrono::duration_cast<std::chrono::hours>(int_total_mins-int_years-int_months-int_days);
 	auto int_minutes = std::chrono::duration_cast<std::chrono::minutes>(int_total_mins-int_years-int_months-int_days-int_hours);
 	std::ostringstream return_stream;
-	if (int_years.count() > 0) {
-		return_stream << int_years.count() << " years ";
-	}
-	if (int_months.count() > 0) {
-		return_stream << int_months.count() << " months ";
-	}
-	if (int_days.count() > 0) {
-		return_stream << int_days.count() << " days ";
-	}
-	if (int_hours.count() > 0) {
-		return_stream << int_hours.count() << " hours ";
-	}
-	return_stream << int_minutes.count() << " minutes"; // return minutes anyway
+	ADD_TIME_SEGMENT(return_stream, int_years, " year ", " years ");
+	ADD_TIME_SEGMENT(return_stream, int_months, " month ", " months ");
+	ADD_TIME_SEGMENT(return_stream, int_days, " day ", " days ");
+	ADD_TIME_SEGMENT(return_stream, int_hours, " hour ", " hours ");
+	if (int_minutes.count() > 0 || return_stream.str().size() == 0)
+		return_stream << int_minutes.count() << ((int_minutes.count() == 1) ? " minute" : " minutes");
 	return return_stream.str();
 }
 
+std::string StatisticsWidget::SecondsToDateString(int seconds) {
+	/* this is all fairly unnecessary, but works:tm: */
+	std::chrono::duration<int, std::ratio<1>> int_total_mins(seconds);
+	auto int_years = std::chrono::duration_cast<std::chrono::years>(int_total_mins);
+	auto int_months = std::chrono::duration_cast<std::chrono::months>(int_total_mins-int_years);
+	auto int_days = std::chrono::duration_cast<std::chrono::days>(int_total_mins-int_years-int_months);
+	auto int_hours = std::chrono::duration_cast<std::chrono::hours>(int_total_mins-int_years-int_months-int_days);
+	auto int_minutes = std::chrono::duration_cast<std::chrono::minutes>(int_total_mins-int_years-int_months-int_days-int_hours);
+	auto int_seconds = std::chrono::duration_cast<std::chrono::seconds>(int_total_mins-int_years-int_months-int_days-int_hours-int_minutes);
+	std::ostringstream return_stream;
+	ADD_TIME_SEGMENT(return_stream, int_years, " year ", " years ");
+	ADD_TIME_SEGMENT(return_stream, int_months, " month ", " months ");
+	ADD_TIME_SEGMENT(return_stream, int_days, " day ", " days ");
+	ADD_TIME_SEGMENT(return_stream, int_hours, " hour ", " hours ");
+	ADD_TIME_SEGMENT(return_stream, int_minutes, " minute ", " minutes ");
+	if (int_seconds.count() > 0 || return_stream.str().size() == 0)
+		return_stream << int_seconds.count() << ((int_seconds.count() == 1) ? " second" : " seconds");
+	return return_stream.str();
+}
+#undef ADD_TIME_SEGMENT
+
 void StatisticsWidget::UpdateStatistics() {
+	/* Anime list */
 	QString string = "";
 	QTextStream ts(&string);
 	ts << anime_list->GetTotalAnimeAmount() << '\n';
@@ -70,4 +96,8 @@
 	ts << anime_list->GetAverageScore() << '\n';
 	ts << anime_list->GetScoreDeviation() << '\n';
 	UiUtils::SetPlainTextEditData(anime_list_data, string);
+
+	/* Application */
+	//UiUtils::SetPlainTextEditData(application_data, QString::number(session.uptime() / 1000));
+	UiUtils::SetPlainTextEditData(application_data, QString(SecondsToDateString(session.uptime() / 1000).c_str()));
 }
--- a/src/ui_utils.cpp	Thu Aug 24 23:11:38 2023 -0400
+++ b/src/ui_utils.cpp	Sat Aug 26 03:39:34 2023 -0400
@@ -12,7 +12,9 @@
 #include "sys/win32/dark_theme.h"
 #endif
 
-QIcon UiUtils::CreateSideBarIcon(const char* file) {
+namespace UiUtils {
+
+QIcon CreateSideBarIcon(const char* file) {
 	QPixmap pixmap(file, "PNG");
 	QIcon result;
 	result.addPixmap(pixmap, QIcon::Normal);
@@ -20,7 +22,7 @@
 	return result;
 }
 
-bool UiUtils::IsInDarkMode() {
+bool IsInDarkMode() {
 	if (session.config.theme != OS)
 		return (session.config.theme == DARK);
 #ifdef MACOSX
@@ -43,113 +45,154 @@
 	return (session.config.theme == DARK);
 }
 
-void UiUtils::CreateTextHeader(QWidget* parent, QString title) {
-	QLabel* static_text_title  = new QLabel(title, parent);
+Header::Header(QString title, QWidget* parent)
+	: QWidget(parent) {
+	setLayout(new QVBoxLayout);
+	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+
+	static_text_title  = new QLabel(title, this);
 	static_text_title->setTextFormat(Qt::PlainText);
-
 	QFont font = static_text_title->font();
 	font.setWeight(QFont::Bold);
 	static_text_title->setFont(font);
+	static_text_title->setFixedHeight(16);
 
-	static_text_title->setFixedHeight(16);
-	parent->layout()->addWidget(static_text_title);
-
-	QFrame* static_text_line = new QFrame(parent);
+	static_text_line = new QFrame(this);
 	static_text_line->setFrameShape(QFrame::HLine);
 	static_text_line->setFrameShadow(QFrame::Sunken);
 	static_text_line->setFixedHeight(2);
-	parent->layout()->addWidget(static_text_line);
+
+	layout()->addWidget(static_text_title);
+	layout()->addWidget(static_text_line);
+	layout()->setSpacing(0);
+	layout()->setMargin(0);
+}
+
+void Header::SetTitle(QString title) {
+	static_text_title->setText(title);
 }
 
-QPlainTextEdit* UiUtils::CreateTextParagraph(QWidget* parent, QString title, QString data) {
-	QWidget* paragraph_master = new QWidget(parent);
-	paragraph_master->setLayout(new QVBoxLayout);
-
-	CreateTextHeader(paragraph_master, title);
-
-	Paragraph* paragraph = new Paragraph(data, paragraph_master);
-	paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
-	paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
-	paragraph->setWordWrapMode(QTextOption::NoWrap);
-	paragraph->setContentsMargins(12, 0, 0, 0);
-
-	paragraph_master->layout()->addWidget(paragraph);
-	paragraph_master->layout()->setSpacing(0);
-	paragraph_master->layout()->setMargin(0);
-	paragraph_master->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+TextParagraph::TextParagraph(QString title, QString data, QWidget* parent)
+	: QWidget(parent) {
+	setLayout(new QVBoxLayout);
 
-	return paragraph;
-}
-
-QPlainTextEdit* UiUtils::CreateTextParagraphWithLabels(QWidget* parent, QString title, QString label, QString data) {
-	QWidget* paragraph_master = new QWidget(parent);
-	paragraph_master->setLayout(new QVBoxLayout);
-
-	CreateTextHeader(paragraph_master, title);
+	header = new Header(title, this);
 
-	QWidget* paragraph_and_label = new QWidget(paragraph_master);
-	paragraph_and_label->setLayout(new QHBoxLayout);
-	paragraph_and_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+	QWidget* content = new QWidget(this);
+	content->setLayout(new QHBoxLayout);
 
-	Paragraph* label_t = new Paragraph(label, paragraph_and_label);
-	label_t->setTextInteractionFlags(Qt::NoTextInteraction);
-	label_t->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
-	label_t->setWordWrapMode(QTextOption::NoWrap);
-	label_t->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
-	label_t->setFixedWidth(123);
-
-	Paragraph* paragraph = new Paragraph(data, paragraph_and_label);
+	paragraph = new Paragraph(data, this);
 	paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
 	paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
 	paragraph->setWordWrapMode(QTextOption::NoWrap);
 
-	((QBoxLayout*)paragraph_and_label->layout())->addWidget(label_t, 0, Qt::AlignTop);
-	((QBoxLayout*)paragraph_and_label->layout())->addWidget(paragraph, 0, Qt::AlignTop);
-
-	paragraph_and_label->setContentsMargins(12, 0, 0, 0);
+	content->layout()->addWidget(paragraph);
+	content->layout()->setSpacing(0);
+	content->layout()->setMargin(0);
+	content->setContentsMargins(12, 0, 0, 0);
 
-	paragraph_master->layout()->addWidget(paragraph_and_label);
-	paragraph_master->layout()->setSpacing(0);
-	paragraph_master->layout()->setMargin(0);
-	paragraph_master->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+	layout()->addWidget(header);
+	layout()->addWidget(paragraph);
+	layout()->setSpacing(0);
+	layout()->setMargin(0);
+}
 
+Header* TextParagraph::GetHeader() {
+	return header;
+}
+
+Paragraph* TextParagraph::GetParagraph() {
 	return paragraph;
 }
 
-/* As far as I can tell, this is identical to the way Taiga implements it.
-   Kind of cool, I didn't even look into the source code for it :p */
-QPlainTextEdit* UiUtils::CreateSelectableTextParagraph(QWidget* parent, QString title, QString data) {
-	QWidget* paragraph_master = new QWidget(parent);
-	paragraph_master->setLayout(new QVBoxLayout);
+LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent)
+	: QWidget(parent) {
+	setLayout(new QVBoxLayout);
+
+	header = new Header(title, this);
 
-	CreateTextHeader(paragraph_master, title);
+	// this is not accessible from the object because there's really
+	// no reason to make it accessible...
+	QWidget* content = new QWidget(this);
+	content->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
 
-	QWidget* paragraph_widget = new QWidget(paragraph_master);
-	paragraph_widget->setLayout(new QHBoxLayout);
-	paragraph_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+	labels = new Paragraph(label, this);
+	labels->setTextInteractionFlags(Qt::NoTextInteraction);
+	labels->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
+	labels->setWordWrapMode(QTextOption::NoWrap);
+	labels->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+	labels->setFixedWidth(123);
 
-	Paragraph* text_edit = new Paragraph(data, paragraph_widget);
-
-	paragraph_widget->layout()->addWidget(text_edit);
-
-	paragraph_widget->setContentsMargins(12, 0, 0, 0);
+	paragraph = new Paragraph(data, this);
+	paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
+	paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
+	paragraph->setWordWrapMode(QTextOption::NoWrap);
 
-	paragraph_master->layout()->addWidget(paragraph_widget);
-	paragraph_master->layout()->setSpacing(0);
-	paragraph_master->layout()->setMargin(0);
+	QHBoxLayout* content_layout = new QHBoxLayout;
+	content_layout->addWidget(labels, 0, Qt::AlignTop);
+	content_layout->addWidget(paragraph, 0, Qt::AlignTop);
+	content_layout->setSpacing(0);
+	content_layout->setMargin(0);
+	content->setLayout(content_layout);
 
-	paragraph_master->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+	content->setContentsMargins(12, 0, 0, 0);
 
-	return text_edit;
+	layout()->addWidget(header);
+	layout()->addWidget(content);
+	layout()->setSpacing(0);
+	layout()->setMargin(0);
 }
 
-void UiUtils::SetPlainTextEditData(QPlainTextEdit* text_edit, QString data) {
+Header* LabelledTextParagraph::GetHeader() {
+	return header;
+}
+
+Paragraph* LabelledTextParagraph::GetLabels() {
+	return labels;
+}
+
+Paragraph* LabelledTextParagraph::GetParagraph() {
+	return paragraph;
+}
+
+SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent)
+	: QWidget(parent) {
+	setLayout(new QVBoxLayout);
+
+	header = new Header(title, this);
+
+	QWidget* content = new QWidget(this);
+	content->setLayout(new QHBoxLayout);
+
+	paragraph = new Paragraph(data, content);
+
+	content->layout()->addWidget(paragraph);
+	content->layout()->setSpacing(0);
+	content->layout()->setMargin(0);
+	content->setContentsMargins(12, 0, 0, 0);
+
+	layout()->addWidget(header);
+	layout()->addWidget(content);
+	layout()->setSpacing(0);
+	layout()->setMargin(0);
+}
+
+Header* SelectableTextParagraph::GetHeader() {
+	return header;
+}
+
+Paragraph* SelectableTextParagraph::GetParagraph() {
+	return paragraph;
+}
+
+void SetPlainTextEditData(QPlainTextEdit* text_edit, QString data) {
 	QTextDocument* document = new QTextDocument(text_edit);
 	document->setDocumentLayout(new QPlainTextDocumentLayout(document));
 	document->setPlainText(data);
 	text_edit->setDocument(document);
 }
 
+/* inherits QPlainTextEdit and gives a much more reasonable minimum size */
 Paragraph::Paragraph(QString text, QWidget* parent)
 	: QPlainTextEdit(text, parent) {
 	setReadOnly(true);
@@ -161,6 +204,7 @@
 	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 }
 
+/* highly based upon... some stackoverflow answer for PyQt */
 QSize Paragraph::minimumSizeHint() const {
 	QTextDocument* doc = document();
 	long h = (long)(blockBoundingGeometry(doc->findBlockByNumber(doc->blockCount() - 1)).bottom() + (2 * doc->documentMargin()));
@@ -170,3 +214,5 @@
 QSize Paragraph::sizeHint() const {
 	return minimumSizeHint();
 }
+
+} // namespace UiUtils