Mercurial > minori
annotate src/gui/pages/anime_list.cc @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 5d3c9b31aa6e |
children | 886f66775f31 |
rev | line source |
---|---|
10 | 1 /** |
2 * anime_list.cpp: defines the anime list page | |
3 * and widgets. | |
4 * | |
5 * much of this file is based around | |
6 * Qt's original QTabWidget implementation, because | |
7 * I needed a somewhat native way to create a tabbed | |
8 * widget with only one subwidget that worked exactly | |
9 * like a native tabbed widget. | |
10 **/ | |
11 #include "gui/pages/anime_list.h" | |
12 #include "core/anime.h" | |
13 #include "core/anime_db.h" | |
14 #include "core/session.h" | |
76 | 15 #include "core/strings.h" |
10 | 16 #include "core/time.h" |
17 #include "gui/dialog/information.h" | |
18 #include "gui/translate/anime.h" | |
52
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
19 #include "services/services.h" |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
20 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
21 #include <QDate> |
15 | 22 #include <QDebug> |
10 | 23 #include <QHBoxLayout> |
24 #include <QHeaderView> | |
25 #include <QMenu> | |
26 #include <QProgressBar> | |
27 #include <QShortcut> | |
28 #include <QStylePainter> | |
29 #include <QStyledItemDelegate> | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
30 #include <QThreadPool> |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
31 #include <QRunnable> |
258 | 32 #include <QTreeView> |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
33 |
77 | 34 #include <set> |
10 | 35 |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
36 AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(QObject* parent) : QThread(parent) {} |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
37 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
38 void AnimeListPageUpdateEntryThread::AddToQueue(int id) { |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
39 const std::lock_guard<std::mutex> guard(queue_mutex_); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
40 queue_.push(id); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
41 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
42 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
43 /* processes the queue... */ |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
44 void AnimeListPageUpdateEntryThread::run() { |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
45 queue_mutex_.lock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
46 while (!queue_.empty() && !isInterruptionRequested()) { |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
47 int id = queue_.front(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
48 |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
49 /* unlock the mutex for a long blocking operation, so items |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
50 * can be added without worry */ |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
51 queue_mutex_.unlock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
52 Services::UpdateAnimeEntry(id); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
53 queue_mutex_.lock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
54 |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
55 queue_.pop(); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
56 } |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
57 queue_mutex_.unlock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
58 |
307
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
59 emit NeedRefresh(); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
60 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
61 |
64 | 62 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { |
10 | 63 } |
64 | |
64 | 65 bool AnimeListPageSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const { |
10 | 66 QVariant left = sourceModel()->data(l, sortRole()); |
67 QVariant right = sourceModel()->data(r, sortRole()); | |
68 | |
69 switch (left.userType()) { | |
70 case QMetaType::Int: | |
71 case QMetaType::UInt: | |
72 case QMetaType::LongLong: | |
73 case QMetaType::ULongLong: return left.toInt() < right.toInt(); | |
74 case QMetaType::QDate: return left.toDate() < right.toDate(); | |
75 case QMetaType::QString: | |
76 default: return QString::compare(left.toString(), right.toString(), Qt::CaseInsensitive) < 0; | |
77 } | |
78 } | |
79 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
80 /* -------------------------------------------------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
81 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
82 AnimeListPageModel::AnimeListPageModel(QObject* parent, Anime::ListStatus _status) : QAbstractListModel(parent) { |
10 | 83 status = _status; |
84 return; | |
85 } | |
86 | |
64 | 87 int AnimeListPageModel::rowCount(const QModelIndex& parent) const { |
10 | 88 return list.size(); |
89 (void)(parent); | |
90 } | |
91 | |
64 | 92 int AnimeListPageModel::columnCount(const QModelIndex& parent) const { |
10 | 93 return NB_COLUMNS; |
94 (void)(parent); | |
95 } | |
96 | |
64 | 97 QVariant AnimeListPageModel::headerData(const int section, const Qt::Orientation orientation, const int role) const { |
10 | 98 if (role == Qt::DisplayRole) { |
99 switch (section) { | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
100 case AL_TITLE: return tr("Anime title"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
101 case AL_PROGRESS: return tr("Progress"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
102 case AL_EPISODES: return tr("Episodes"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
103 case AL_TYPE: return tr("Type"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
104 case AL_SCORE: return tr("Score"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
105 case AL_SEASON: return tr("Season"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
106 case AL_STARTED: return tr("Date started"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
107 case AL_COMPLETED: return tr("Date completed"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
108 case AL_NOTES: return tr("Notes"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
109 case AL_AVG_SCORE: return tr("Average score"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
110 case AL_UPDATED: return tr("Last updated"); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
111 default: return {}; |
10 | 112 } |
113 } else if (role == Qt::TextAlignmentRole) { | |
114 switch (section) { | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
115 case AL_TITLE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
116 case AL_NOTES: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
117 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
118 case AL_EPISODES: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
119 case AL_TYPE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
120 case AL_SCORE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
121 case AL_AVG_SCORE: return QVariant(Qt::AlignCenter | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
122 case AL_SEASON: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
123 case AL_STARTED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
124 case AL_COMPLETED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
125 case AL_UPDATED: return QVariant(Qt::AlignRight | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
126 default: return QAbstractListModel::headerData(section, orientation, role); |
10 | 127 } |
128 } | |
129 return QAbstractListModel::headerData(section, orientation, role); | |
130 } | |
131 | |
64 | 132 QVariant AnimeListPageModel::data(const QModelIndex& index, int role) const { |
10 | 133 if (!index.isValid()) |
134 return QVariant(); | |
135 switch (role) { | |
136 case Qt::DisplayRole: | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
137 switch (index.column()) { |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
138 case AL_TITLE: return Strings::ToQString(list[index.row()].GetUserPreferredTitle()); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
139 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
140 return QString::number(list[index.row()].GetUserProgress()) + "/" + |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
141 QString::number(list[index.row()].GetEpisodes()); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
142 case AL_EPISODES: return list[index.row()].GetEpisodes(); |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
143 case AL_SCORE: return Strings::ToQString(list[index.row()].GetUserPresentableScore()); |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
144 case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat())); |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
145 case AL_SEASON: return Strings::ToQString(Translate::ToLocalString(list[index.row()].GetSeason())); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
146 case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%"; |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
147 case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate(); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
148 case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate(); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
149 case AL_UPDATED: { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
150 if (list[index.row()].GetUserTimeUpdated() == 0) |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
151 return QString("-"); |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
152 return Strings::ToQString(Time::GetSecondsAsRelativeString(Time::GetSystemTime() - list[index.row()].GetUserTimeUpdated())); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
153 } |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
154 case AL_NOTES: return Strings::ToQString(list[index.row()].GetUserNotes()); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
155 default: return ""; |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
156 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
157 break; |
10 | 158 case Qt::UserRole: |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
159 switch (index.column()) { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
160 case AL_PROGRESS: return list[index.row()].GetUserProgress(); |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
161 case AL_SCORE: return list[index.row()].GetUserScore(); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
162 case AL_TYPE: return static_cast<int>(list[index.row()].GetFormat()); |
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
320
diff
changeset
|
163 case AL_SEASON: return list[index.row()].GetStartedDate().GetAsQDate(); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
164 case AL_AVG_SCORE: return list[index.row()].GetAudienceScore(); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
165 case AL_UPDATED: return QVariant::fromValue(list[index.row()].GetUserTimeUpdated()); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
166 default: return data(index, Qt::DisplayRole); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
167 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
168 break; |
10 | 169 case Qt::TextAlignmentRole: |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
170 switch (index.column()) { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
171 case AL_TITLE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
172 case AL_NOTES: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
173 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
174 case AL_EPISODES: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 case AL_TYPE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
176 case AL_SCORE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
177 case AL_AVG_SCORE: return QVariant(Qt::AlignCenter | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
178 case AL_SEASON: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
179 case AL_STARTED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
180 case AL_COMPLETED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
181 case AL_UPDATED: return QVariant(Qt::AlignRight | Qt::AlignVCenter); |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
182 default: break; |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
183 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
184 break; |
10 | 185 } |
186 return QVariant(); | |
187 } | |
188 | |
64 | 189 Anime::Anime* AnimeListPageModel::GetAnimeFromIndex(QModelIndex index) { |
10 | 190 return &list.at(index.row()); |
191 } | |
192 | |
64 | 193 void AnimeListPageModel::RefreshList() { |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
194 /* equivalent to hasChildren()... */ |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
195 if (!rowCount(index(0))) { |
77 | 196 beginInsertRows(QModelIndex(), 0, 0); |
197 endInsertRows(); | |
15 | 198 } |
199 | |
77 | 200 beginResetModel(); |
201 | |
10 | 202 list.clear(); |
203 | |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
204 for (const auto& a : Anime::db.items) |
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
205 if (a.second.IsInUserList() && a.second.GetUserStatus() == status) |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
206 list.push_back(a.second); |
15 | 207 |
77 | 208 endResetModel(); |
10 | 209 } |
210 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
211 /* ----------------------------------------------------------------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
212 |
64 | 213 int AnimeListPage::VisibleColumnsCount() const { |
10 | 214 int count = 0; |
215 | |
216 for (int i = 0, end = tree_view->header()->count(); i < end; i++) { | |
217 if (!tree_view->isColumnHidden(i)) | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
218 count++; |
10 | 219 } |
220 | |
221 return count; | |
222 } | |
223 | |
64 | 224 void AnimeListPage::SetColumnDefaults() { |
225 tree_view->setColumnHidden(AnimeListPageModel::AL_SEASON, false); | |
226 tree_view->setColumnHidden(AnimeListPageModel::AL_TYPE, false); | |
227 tree_view->setColumnHidden(AnimeListPageModel::AL_UPDATED, false); | |
228 tree_view->setColumnHidden(AnimeListPageModel::AL_PROGRESS, false); | |
229 tree_view->setColumnHidden(AnimeListPageModel::AL_SCORE, false); | |
230 tree_view->setColumnHidden(AnimeListPageModel::AL_TITLE, false); | |
231 tree_view->setColumnHidden(AnimeListPageModel::AL_EPISODES, true); | |
232 tree_view->setColumnHidden(AnimeListPageModel::AL_AVG_SCORE, true); | |
233 tree_view->setColumnHidden(AnimeListPageModel::AL_STARTED, true); | |
234 tree_view->setColumnHidden(AnimeListPageModel::AL_COMPLETED, true); | |
235 tree_view->setColumnHidden(AnimeListPageModel::AL_UPDATED, true); | |
236 tree_view->setColumnHidden(AnimeListPageModel::AL_NOTES, true); | |
10 | 237 } |
238 | |
77 | 239 void AnimeListPage::UpdateAnime(int id) { |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
240 /* this ought to just add to the thread's buffer. */ |
274
f6a756c19bfb
anime_list.cc: use mutexes so we don't sex the stack
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
241 if (update_entry_thread_.isRunning()) |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
242 update_entry_thread_.requestInterruption(); |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
211
diff
changeset
|
243 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
244 update_entry_thread_.AddToQueue(id); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
245 update_entry_thread_.start(); |
77 | 246 } |
247 | |
248 void AnimeListPage::RemoveAnime(int id) { | |
249 Anime::Anime& anime = Anime::db.items[id]; | |
250 anime.RemoveFromUserList(); | |
251 Refresh(); | |
252 } | |
253 | |
64 | 254 void AnimeListPage::DisplayColumnHeaderMenu() { |
10 | 255 QMenu* menu = new QMenu(this); |
256 menu->setAttribute(Qt::WA_DeleteOnClose); | |
257 menu->setTitle(tr("Column visibility")); | |
258 menu->setToolTipsVisible(true); | |
259 | |
64 | 260 for (int i = 0; i < AnimeListPageModel::NB_COLUMNS; i++) { |
261 if (i == AnimeListPageModel::AL_TITLE) | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
262 continue; |
10 | 263 const auto column_name = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
264 sort_models[tab_bar->currentIndex()]->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
265 |
10 | 266 QAction* action = menu->addAction(column_name, this, [this, i](const bool checked) { |
267 if (!checked && (VisibleColumnsCount() <= 1)) | |
268 return; | |
269 | |
270 tree_view->setColumnHidden(i, !checked); | |
271 | |
272 if (checked && (tree_view->columnWidth(i) <= 5)) | |
273 tree_view->resizeColumnToContents(i); | |
274 | |
275 // SaveSettings(); | |
276 }); | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
277 |
10 | 278 action->setCheckable(true); |
279 action->setChecked(!tree_view->isColumnHidden(i)); | |
280 } | |
281 | |
282 menu->addSeparator(); | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
283 menu->addAction(tr("Reset to defaults"), this, [this]() { |
10 | 284 for (int i = 0, count = tree_view->header()->count(); i < count; ++i) { |
285 SetColumnDefaults(); | |
286 } | |
287 // SaveSettings(); | |
288 }); | |
289 menu->popup(QCursor::pos()); | |
290 } | |
291 | |
64 | 292 void AnimeListPage::DisplayListMenu() { |
10 | 293 QMenu* menu = new QMenu(this); |
294 menu->setAttribute(Qt::WA_DeleteOnClose); | |
295 menu->setToolTipsVisible(true); | |
296 | |
77 | 297 AnimeListPageModel* source_model = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
298 reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); |
15 | 299 const QItemSelection selection = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
300 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); |
77 | 301 |
302 std::set<Anime::Anime*> animes; | |
303 for (const auto& index : selection.indexes()) { | |
304 if (!index.isValid()) | |
305 continue; | |
306 Anime::Anime* anime = source_model->GetAnimeFromIndex(index); | |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
307 if (!anime) |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
308 continue; |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
309 animes.insert(&Anime::db.items[anime->GetId()]); |
10 | 310 } |
311 | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
312 menu->addAction(tr("Information"), [this, animes] { |
77 | 313 for (auto& anime : animes) { |
258 | 314 InformationDialog* dialog = new InformationDialog( |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
315 anime, [this](Anime::Anime* anime) { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); |
10 | 316 |
77 | 317 dialog->show(); |
318 dialog->raise(); | |
319 dialog->activateWindow(); | |
291 | 320 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
77 | 321 } |
322 }); | |
323 menu->addSeparator(); | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
324 menu->addAction(tr("Edit"), [this, animes] { |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
325 for (auto& anime : animes) { |
258 | 326 InformationDialog* dialog = new InformationDialog( |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
327 anime, [this](Anime::Anime* anime) { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MY_LIST, this); |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
328 |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
329 dialog->show(); |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
330 dialog->raise(); |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
331 dialog->activateWindow(); |
291 | 332 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
333 } |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
334 }); |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
335 menu->addAction(tr("Delete from list..."), [this, animes] { |
77 | 336 for (auto& anime : animes) { |
337 RemoveAnime(anime->GetId()); | |
338 } | |
10 | 339 }); |
340 menu->popup(QCursor::pos()); | |
341 } | |
342 | |
64 | 343 void AnimeListPage::ItemDoubleClicked() { |
10 | 344 /* throw out any other garbage */ |
345 const QItemSelection selection = | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
346 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); |
10 | 347 if (!selection.indexes().first().isValid()) { |
348 return; | |
349 } | |
350 | |
64 | 351 AnimeListPageModel* source_model = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
352 reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); |
64 | 353 |
354 const QModelIndex index = source_model->index(selection.indexes().first().row()); | |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
355 Anime::Anime& anime = Anime::db.items[source_model->GetAnimeFromIndex(index)->GetId()]; |
10 | 356 |
258 | 357 InformationDialog* dialog = new InformationDialog( |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
358 &anime, [this](Anime::Anime* anime) { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); |
10 | 359 |
360 dialog->show(); | |
361 dialog->raise(); | |
362 dialog->activateWindow(); | |
291 | 363 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
10 | 364 } |
365 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
366 void AnimeListPage::RefreshList() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
367 for (unsigned int i = 0; i < sort_models.size(); i++) |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
368 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); |
10 | 369 } |
370 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
371 void AnimeListPage::RefreshTabs() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
372 for (unsigned int i = 0; i < sort_models.size(); i++) |
211
7cf53145de11
strings: use templates for ToInt, std::to_string -> Strings::ToUtf8String
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
373 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
374 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
10 | 375 } |
376 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
377 void AnimeListPage::Refresh() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
378 RefreshList(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
379 RefreshTabs(); |
10 | 380 } |
381 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
382 /* -------- QTabWidget replication begin --------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
383 |
64 | 384 void AnimeListPage::InitBasicStyle(QStyleOptionTabWidgetFrame* option) const { |
10 | 385 if (!option) |
386 return; | |
387 | |
388 option->initFrom(this); | |
389 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this); | |
390 option->shape = QTabBar::RoundedNorth; | |
391 option->tabBarRect = tab_bar->geometry(); | |
392 } | |
393 | |
64 | 394 void AnimeListPage::InitStyle(QStyleOptionTabWidgetFrame* option) const { |
10 | 395 if (!option) |
396 return; | |
397 | |
398 InitBasicStyle(option); | |
399 | |
400 QSize t(0, tree_view->frameWidth()); | |
401 if (tab_bar->isVisibleTo(this)) { | |
402 t = tab_bar->sizeHint(); | |
403 t.setWidth(width()); | |
404 } | |
46 | 405 |
10 | 406 option->tabBarSize = t; |
407 | |
408 QRect selected_tab_rect = tab_bar->tabRect(tab_bar->currentIndex()); | |
409 selected_tab_rect.moveTopLeft(selected_tab_rect.topLeft() + option->tabBarRect.topLeft()); | |
410 option->selectedTabRect = selected_tab_rect; | |
411 | |
412 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this); | |
413 } | |
414 | |
64 | 415 void AnimeListPage::SetupLayout() { |
10 | 416 QStyleOptionTabWidgetFrame option; |
417 InitStyle(&option); | |
418 | |
419 QRect tabRect = style()->subElementRect(QStyle::SE_TabWidgetTabBar, &option, this); | |
420 tabRect.setLeft(tabRect.left() + 1); | |
421 panelRect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &option, this); | |
422 QRect contentsRect = style()->subElementRect(QStyle::SE_TabWidgetTabContents, &option, this); | |
423 | |
424 tab_bar->setGeometry(tabRect); | |
425 tree_view->parentWidget()->setGeometry(contentsRect); | |
426 } | |
427 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
428 void AnimeListPage::paintEvent(QPaintEvent*) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
429 QStylePainter p(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
430 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
431 QStyleOptionTabWidgetFrame opt; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
432 InitStyle(&opt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
433 opt.rect = panelRect; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
434 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
435 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
436 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
437 void AnimeListPage::resizeEvent(QResizeEvent* e) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
438 QWidget::resizeEvent(e); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
439 SetupLayout(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
440 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
441 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
442 void AnimeListPage::showEvent(QShowEvent*) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
443 SetupLayout(); |
250 | 444 Refresh(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
445 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
446 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
447 /* --------- QTabWidget replication end ---------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
448 |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
449 AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent) { |
10 | 450 /* Tab bar */ |
451 tab_bar = new QTabBar(this); | |
452 tab_bar->setExpanding(false); | |
453 tab_bar->setDrawBase(false); | |
454 | |
455 /* Tree view... */ | |
456 QWidget* tree_widget = new QWidget(this); | |
457 tree_view = new QTreeView(tree_widget); | |
458 tree_view->setUniformRowHeights(true); | |
459 tree_view->setAllColumnsShowFocus(false); | |
460 tree_view->setAlternatingRowColors(true); | |
461 tree_view->setSortingEnabled(true); | |
462 tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection); | |
463 tree_view->setItemsExpandable(false); | |
464 tree_view->setRootIsDecorated(false); | |
465 tree_view->setContextMenuPolicy(Qt::CustomContextMenu); | |
466 tree_view->setFrameShape(QFrame::NoFrame); | |
467 | |
83 | 468 for (unsigned int i = 0; i < sort_models.size(); i++) { |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
469 tab_bar->addTab(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
470 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
64 | 471 sort_models[i] = new AnimeListPageSortFilter(tree_view); |
472 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); | |
10 | 473 sort_models[i]->setSortRole(Qt::UserRole); |
474 sort_models[i]->setSortCaseSensitivity(Qt::CaseInsensitive); | |
475 } | |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
476 |
15 | 477 tree_view->setModel(sort_models[0]); |
10 | 478 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
479 /* Set column widths */ |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
480 tree_view->setColumnWidth(AnimeListPageModel::AL_TITLE, 300); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
481 tree_view->setColumnWidth(AnimeListPageModel::AL_PROGRESS, 200); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
482 tree_view->setColumnWidth(AnimeListPageModel::AL_SCORE, 50); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
483 tree_view->setColumnWidth(AnimeListPageModel::AL_AVG_SCORE, 55); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
484 tree_view->setColumnWidth(AnimeListPageModel::AL_TYPE, 65); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
485 tree_view->setColumnWidth(AnimeListPageModel::AL_SEASON, 95); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
486 tree_view->setColumnWidth(AnimeListPageModel::AL_STARTED, 90); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
487 tree_view->setColumnWidth(AnimeListPageModel::AL_COMPLETED, 90); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
488 tree_view->setColumnWidth(AnimeListPageModel::AL_UPDATED, 100); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
489 tree_view->setColumnWidth(AnimeListPageModel::AL_NOTES, 100); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
490 |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
491 QHBoxLayout* layout = new QHBoxLayout(tree_widget); |
10 | 492 layout->addWidget(tree_view); |
62 | 493 layout->setContentsMargins(0, 0, 0, 0); |
10 | 494 |
495 /* Double click stuff */ | |
64 | 496 connect(tree_view, &QAbstractItemView::doubleClicked, this, &AnimeListPage::ItemDoubleClicked); |
497 connect(tree_view, &QWidget::customContextMenuRequested, this, &AnimeListPage::DisplayListMenu); | |
10 | 498 |
499 /* Enter & return keys */ | |
15 | 500 connect(new QShortcut(Qt::Key_Return, tree_view, nullptr, nullptr, Qt::WidgetShortcut), &QShortcut::activated, this, |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
501 &AnimeListPage::ItemDoubleClicked); |
10 | 502 |
15 | 503 connect(new QShortcut(Qt::Key_Enter, tree_view, nullptr, nullptr, Qt::WidgetShortcut), &QShortcut::activated, this, |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
504 &AnimeListPage::ItemDoubleClicked); |
10 | 505 |
506 tree_view->header()->setStretchLastSection(false); | |
507 tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu); | |
64 | 508 connect(tree_view->header(), &QWidget::customContextMenuRequested, this, &AnimeListPage::DisplayColumnHeaderMenu); |
10 | 509 |
510 connect(tab_bar, &QTabBar::currentChanged, this, [this](int index) { | |
511 if (sort_models[index]) | |
512 tree_view->setModel(sort_models[index]); | |
513 }); | |
514 | |
307
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
515 connect(&update_entry_thread_, &AnimeListPageUpdateEntryThread::NeedRefresh, this, &AnimeListPage::Refresh); |
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
516 |
69 | 517 SetColumnDefaults(); |
10 | 518 setFocusPolicy(Qt::TabFocus); |
519 setFocusProxy(tab_bar); | |
520 } |