comparison src/gui/pages/anime_list.cc @ 108:2004b41d4a59

*: huge commit 1. WORKING LOCALIZATION + translation for Spanish and British English 2. idk like 2 changes for the dark theme :)
author Paper <mrpapersonic@gmail.com>
date Sun, 05 Nov 2023 23:31:49 -0500
parents c8c72278f6fd
children 80f49f623d30
comparison
equal deleted inserted replaced
107:49c8d1976869 108:2004b41d4a59
26 #include <QTreeView> 26 #include <QTreeView>
27 #include <QStylePainter> 27 #include <QStylePainter>
28 #include <QStyledItemDelegate> 28 #include <QStyledItemDelegate>
29 #include <QThreadPool> 29 #include <QThreadPool>
30 #include <set> 30 #include <set>
31
32 AnimeListPageDelegate::AnimeListPageDelegate(QObject* parent) : QStyledItemDelegate(parent) {
33 }
34
35 QWidget* AnimeListPageDelegate::createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const {
36 // no edit 4 u
37 return nullptr;
38 }
39
40 void AnimeListPageDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
41 const QModelIndex& index) const {
42 switch (index.column()) {
43 #if 0 /* I'm just commenting this out for now. Seems like a huge headache to do with Qt. */
44 case AnimeListPageModel::AL_PROGRESS: {
45 const int progress = static_cast<int>(index.data(Qt::UserRole).toReal());
46 const int episodes =
47 static_cast<int>(index.siblingAtColumn(AnimeListPageModel::AL_EPISODES).data(Qt::UserRole).toReal());
48
49 int text_width = 59;
50 QRectF text_rect(option.rect.x() + text_width, option.rect.y(), text_width, option.decorationSize.height());
51 painter->save();
52 painter->drawText(text_rect, tr("/"), QTextOption(Qt::AlignCenter | Qt::AlignVCenter));
53 drawText(const QRectF &rectangle, const QString &text, const QTextOption &option =
54 QTextOption()) painter->drawText(QRectF(text_rect.x(), text_rect.y(), text_width / 2 - 2,
55 text_rect.height()), QString::number(progress), QTextOption(Qt::AlignRight | Qt::AlignVCenter));
56 painter->drawText(
57 QRectF(text_rect.x() + text_width / 2 + 2, text_rect.y(), text_width / 2 - 2, text_rect.height()),
58 QString::number(episodes), QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
59 painter->restore();
60 QStyledItemDelegate::paint(painter, option, index);
61 break;
62 }
63 #endif
64 default: QStyledItemDelegate::paint(painter, option, index); break;
65 }
66 }
67 31
68 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { 32 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) {
69 } 33 }
70 34
71 bool AnimeListPageSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const { 35 bool AnimeListPageSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const {
421 tab_bar->setDrawBase(false); 385 tab_bar->setDrawBase(false);
422 386
423 /* Tree view... */ 387 /* Tree view... */
424 QWidget* tree_widget = new QWidget(this); 388 QWidget* tree_widget = new QWidget(this);
425 tree_view = new QTreeView(tree_widget); 389 tree_view = new QTreeView(tree_widget);
426 tree_view->setItemDelegate(new AnimeListPageDelegate(tree_view));
427 tree_view->setUniformRowHeights(true); 390 tree_view->setUniformRowHeights(true);
428 tree_view->setAllColumnsShowFocus(false); 391 tree_view->setAllColumnsShowFocus(false);
429 tree_view->setAlternatingRowColors(true); 392 tree_view->setAlternatingRowColors(true);
430 tree_view->setSortingEnabled(true); 393 tree_view->setSortingEnabled(true);
431 tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection); 394 tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection);