diff src/gui/pages/anime_list.cc @ 114:ab191e28e69d

*: add initial torrent stuff WOAH! these checkboxes are a pain in my fucking ass
author Paper <mrpapersonic@gmail.com>
date Tue, 07 Nov 2023 08:03:42 -0500
parents 80f49f623d30
children 39521c47c7a3
line wrap: on
line diff
--- a/src/gui/pages/anime_list.cc	Mon Nov 06 13:48:11 2023 -0500
+++ b/src/gui/pages/anime_list.cc	Tue Nov 07 08:03:42 2023 -0500
@@ -47,7 +47,9 @@
 	}
 }
 
-AnimeListPageModel::AnimeListPageModel(QWidget* parent, Anime::ListStatus _status) : QAbstractListModel(parent) {
+/* -------------------------------------------------- */
+
+AnimeListPageModel::AnimeListPageModel(QObject* parent, Anime::ListStatus _status) : QAbstractListModel(parent) {
 	status = _status;
 	return;
 }
@@ -180,6 +182,8 @@
 	endResetModel();
 }
 
+/* ----------------------------------------------------------------- */
+
 int AnimeListPage::VisibleColumnsCount() const {
 	int count = 0;
 
@@ -316,24 +320,24 @@
 	dialog->activateWindow();
 }
 
-void AnimeListPage::paintEvent(QPaintEvent*) {
-	QStylePainter p(this);
-
-	QStyleOptionTabWidgetFrame opt;
-	InitStyle(&opt);
-	opt.rect = panelRect;
-	p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);
+void AnimeListPage::RefreshList() {
+	for (unsigned int i = 0; i < sort_models.size(); i++)
+		reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList();
 }
 
-void AnimeListPage::resizeEvent(QResizeEvent* e) {
-	QWidget::resizeEvent(e);
-	SetupLayout();
+void AnimeListPage::RefreshTabs() {
+	for (unsigned int i = 0; i < sort_models.size(); i++)
+		tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" +
+		                           QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")");
 }
 
-void AnimeListPage::showEvent(QShowEvent*) {
-	SetupLayout();
+void AnimeListPage::Refresh() {
+	RefreshList();
+	RefreshTabs();
 }
 
+/* -------- QTabWidget replication begin --------- */
+
 void AnimeListPage::InitBasicStyle(QStyleOptionTabWidgetFrame* option) const {
 	if (!option)
 		return;
@@ -378,6 +382,26 @@
 	tree_view->parentWidget()->setGeometry(contentsRect);
 }
 
+void AnimeListPage::paintEvent(QPaintEvent*) {
+	QStylePainter p(this);
+
+	QStyleOptionTabWidgetFrame opt;
+	InitStyle(&opt);
+	opt.rect = panelRect;
+	p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);
+}
+
+void AnimeListPage::resizeEvent(QResizeEvent* e) {
+	QWidget::resizeEvent(e);
+	SetupLayout();
+}
+
+void AnimeListPage::showEvent(QShowEvent*) {
+	SetupLayout();
+}
+
+/* --------- QTabWidget replication end ---------- */
+
 AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent) {
 	/* Tab bar */
 	tab_bar = new QTabBar(this);
@@ -438,30 +462,4 @@
 	Refresh();
 }
 
-void AnimeListPage::RefreshList() {
-	for (unsigned int i = 0; i < sort_models.size(); i++)
-		reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList();
-}
-
-void AnimeListPage::RefreshTabs() {
-	for (unsigned int i = 0; i < sort_models.size(); i++)
-		tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" +
-		                           QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")");
-}
-
-void AnimeListPage::Refresh() {
-	RefreshList();
-	RefreshTabs();
-}
-
-/* This function, really, really should not be called.
-   Ever. Why would you ever need to clear the anime list?
-   Also, this sucks. */
-void AnimeListPage::Reset() {
-	while (tab_bar->count())
-		tab_bar->removeTab(0);
-	for (unsigned int i = 0; i < sort_models.size(); i++)
-		delete sort_models[i];
-}
-
 #include "gui/pages/moc_anime_list.cpp"