Mercurial > minori
annotate src/gui/pages/anime_list.cc @ 367:8d45d892be88 default tip
*: instead of pugixml, use Qt XML features
this means we have one extra Qt dependency though...
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 17 Nov 2024 22:55:47 -0500 |
parents | 886f66775f31 |
children |
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" |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
17 #include "library/library.h" |
10 | 18 #include "gui/dialog/information.h" |
19 #include "gui/translate/anime.h" | |
52
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
20 #include "services/services.h" |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
21 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
22 #include <QDate> |
15 | 23 #include <QDebug> |
10 | 24 #include <QHBoxLayout> |
25 #include <QHeaderView> | |
26 #include <QMenu> | |
27 #include <QProgressBar> | |
28 #include <QShortcut> | |
29 #include <QStylePainter> | |
30 #include <QStyledItemDelegate> | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
31 #include <QThreadPool> |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
32 #include <QRunnable> |
258 | 33 #include <QTreeView> |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
34 #include <QDesktopServices> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
35 #include <QUrl> |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
36 |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
37 #include <iostream> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
38 #include <vector> |
10 | 39 |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
40 AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(QObject* parent) : QThread(parent) {} |
273
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 void AnimeListPageUpdateEntryThread::AddToQueue(int id) { |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
43 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
|
44 queue_.push(id); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
45 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
46 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
47 /* processes the queue... */ |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
48 void AnimeListPageUpdateEntryThread::run() { |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
49 queue_mutex_.lock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
50 while (!queue_.empty() && !isInterruptionRequested()) { |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
51 int id = queue_.front(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
52 |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
53 /* 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
|
54 * can be added without worry */ |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
55 queue_mutex_.unlock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
56 Services::UpdateAnimeEntry(id); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
57 queue_mutex_.lock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
58 |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
59 queue_.pop(); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
60 } |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
61 queue_mutex_.unlock(); |
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
62 |
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
|
63 emit NeedRefresh(); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
64 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
65 |
64 | 66 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { |
10 | 67 } |
68 | |
64 | 69 bool AnimeListPageSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const { |
10 | 70 QVariant left = sourceModel()->data(l, sortRole()); |
71 QVariant right = sourceModel()->data(r, sortRole()); | |
72 | |
73 switch (left.userType()) { | |
74 case QMetaType::Int: | |
75 case QMetaType::UInt: | |
76 case QMetaType::LongLong: | |
77 case QMetaType::ULongLong: return left.toInt() < right.toInt(); | |
78 case QMetaType::QDate: return left.toDate() < right.toDate(); | |
79 case QMetaType::QString: | |
80 default: return QString::compare(left.toString(), right.toString(), Qt::CaseInsensitive) < 0; | |
81 } | |
82 } | |
83 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
84 /* -------------------------------------------------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
85 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
86 AnimeListPageModel::AnimeListPageModel(QObject* parent, Anime::ListStatus _status) : QAbstractListModel(parent) { |
10 | 87 status = _status; |
88 return; | |
89 } | |
90 | |
64 | 91 int AnimeListPageModel::rowCount(const QModelIndex& parent) const { |
10 | 92 return list.size(); |
93 (void)(parent); | |
94 } | |
95 | |
64 | 96 int AnimeListPageModel::columnCount(const QModelIndex& parent) const { |
10 | 97 return NB_COLUMNS; |
98 (void)(parent); | |
99 } | |
100 | |
64 | 101 QVariant AnimeListPageModel::headerData(const int section, const Qt::Orientation orientation, const int role) const { |
10 | 102 if (role == Qt::DisplayRole) { |
103 switch (section) { | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 default: return {}; |
10 | 116 } |
117 } else if (role == Qt::TextAlignmentRole) { | |
118 switch (section) { | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
119 case AL_TITLE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
120 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
|
121 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
122 case AL_EPISODES: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
123 case AL_TYPE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
124 case AL_SCORE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
125 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
|
126 case AL_SEASON: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
127 case AL_STARTED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
128 case AL_COMPLETED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
129 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
|
130 default: return QAbstractListModel::headerData(section, orientation, role); |
10 | 131 } |
132 } | |
133 return QAbstractListModel::headerData(section, orientation, role); | |
134 } | |
135 | |
64 | 136 QVariant AnimeListPageModel::data(const QModelIndex& index, int role) const { |
10 | 137 if (!index.isValid()) |
138 return QVariant(); | |
139 switch (role) { | |
140 case Qt::DisplayRole: | |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
141 switch (index.column()) { |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
142 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
|
143 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
144 return QString::number(list[index.row()].GetUserProgress()) + "/" + |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 case AL_UPDATED: { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
154 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
|
155 return QString("-"); |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
156 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
|
157 } |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
158 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
|
159 default: return ""; |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
160 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
161 break; |
10 | 162 case Qt::UserRole: |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
163 switch (index.column()) { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
172 break; |
10 | 173 case Qt::TextAlignmentRole: |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
174 switch (index.column()) { |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 case AL_TITLE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
176 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
|
177 case AL_PROGRESS: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
178 case AL_EPISODES: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
179 case AL_TYPE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
180 case AL_SCORE: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
181 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
|
182 case AL_SEASON: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
183 case AL_STARTED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
184 case AL_COMPLETED: |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
185 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
|
186 default: break; |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
187 } |
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
188 break; |
10 | 189 } |
190 return QVariant(); | |
191 } | |
192 | |
64 | 193 Anime::Anime* AnimeListPageModel::GetAnimeFromIndex(QModelIndex index) { |
10 | 194 return &list.at(index.row()); |
195 } | |
196 | |
64 | 197 void AnimeListPageModel::RefreshList() { |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
198 /* equivalent to hasChildren()... */ |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
199 if (!rowCount(index(0))) { |
77 | 200 beginInsertRows(QModelIndex(), 0, 0); |
201 endInsertRows(); | |
15 | 202 } |
203 | |
77 | 204 beginResetModel(); |
205 | |
10 | 206 list.clear(); |
207 | |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
208 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
|
209 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
|
210 list.push_back(a.second); |
15 | 211 |
77 | 212 endResetModel(); |
10 | 213 } |
214 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
215 /* ----------------------------------------------------------------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
216 |
64 | 217 int AnimeListPage::VisibleColumnsCount() const { |
10 | 218 int count = 0; |
219 | |
220 for (int i = 0, end = tree_view->header()->count(); i < end; i++) { | |
221 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
|
222 count++; |
10 | 223 } |
224 | |
225 return count; | |
226 } | |
227 | |
64 | 228 void AnimeListPage::SetColumnDefaults() { |
229 tree_view->setColumnHidden(AnimeListPageModel::AL_SEASON, false); | |
230 tree_view->setColumnHidden(AnimeListPageModel::AL_TYPE, false); | |
231 tree_view->setColumnHidden(AnimeListPageModel::AL_UPDATED, false); | |
232 tree_view->setColumnHidden(AnimeListPageModel::AL_PROGRESS, false); | |
233 tree_view->setColumnHidden(AnimeListPageModel::AL_SCORE, false); | |
234 tree_view->setColumnHidden(AnimeListPageModel::AL_TITLE, false); | |
235 tree_view->setColumnHidden(AnimeListPageModel::AL_EPISODES, true); | |
236 tree_view->setColumnHidden(AnimeListPageModel::AL_AVG_SCORE, true); | |
237 tree_view->setColumnHidden(AnimeListPageModel::AL_STARTED, true); | |
238 tree_view->setColumnHidden(AnimeListPageModel::AL_COMPLETED, true); | |
239 tree_view->setColumnHidden(AnimeListPageModel::AL_UPDATED, true); | |
240 tree_view->setColumnHidden(AnimeListPageModel::AL_NOTES, true); | |
10 | 241 } |
242 | |
77 | 243 void AnimeListPage::UpdateAnime(int id) { |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
244 /* 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
|
245 if (update_entry_thread_.isRunning()) |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
246 update_entry_thread_.requestInterruption(); |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
211
diff
changeset
|
247 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
248 update_entry_thread_.AddToQueue(id); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
249 update_entry_thread_.start(); |
77 | 250 } |
251 | |
252 void AnimeListPage::RemoveAnime(int id) { | |
253 Anime::Anime& anime = Anime::db.items[id]; | |
254 anime.RemoveFromUserList(); | |
255 Refresh(); | |
256 } | |
257 | |
64 | 258 void AnimeListPage::DisplayColumnHeaderMenu() { |
10 | 259 QMenu* menu = new QMenu(this); |
260 menu->setAttribute(Qt::WA_DeleteOnClose); | |
261 menu->setTitle(tr("Column visibility")); | |
262 menu->setToolTipsVisible(true); | |
263 | |
64 | 264 for (int i = 0; i < AnimeListPageModel::NB_COLUMNS; i++) { |
265 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
|
266 continue; |
10 | 267 const auto column_name = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
268 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
|
269 |
10 | 270 QAction* action = menu->addAction(column_name, this, [this, i](const bool checked) { |
271 if (!checked && (VisibleColumnsCount() <= 1)) | |
272 return; | |
273 | |
274 tree_view->setColumnHidden(i, !checked); | |
275 | |
276 if (checked && (tree_view->columnWidth(i) <= 5)) | |
277 tree_view->resizeColumnToContents(i); | |
278 | |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
279 // FIXME save the state of this |
10 | 280 }); |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
281 |
10 | 282 action->setCheckable(true); |
283 action->setChecked(!tree_view->isColumnHidden(i)); | |
284 } | |
285 | |
286 menu->addSeparator(); | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
287 menu->addAction(tr("Reset to defaults"), this, [this]() { |
10 | 288 for (int i = 0, count = tree_view->header()->count(); i < count; ++i) { |
289 SetColumnDefaults(); | |
290 } | |
291 // SaveSettings(); | |
292 }); | |
293 menu->popup(QCursor::pos()); | |
294 } | |
295 | |
64 | 296 void AnimeListPage::DisplayListMenu() { |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
297 QMenu *const menu = new QMenu(this); |
10 | 298 menu->setAttribute(Qt::WA_DeleteOnClose); |
299 menu->setToolTipsVisible(true); | |
300 | |
77 | 301 AnimeListPageModel* source_model = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
302 reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); |
15 | 303 const QItemSelection selection = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
304 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); |
77 | 305 |
306 std::set<Anime::Anime*> animes; | |
307 for (const auto& index : selection.indexes()) { | |
308 if (!index.isValid()) | |
309 continue; | |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
310 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
311 Anime::Anime *const anime = source_model->GetAnimeFromIndex(index); |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
312 if (!anime) |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
313 continue; |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
314 |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
315 animes.insert(&Anime::db.items[anime->GetId()]); |
10 | 316 } |
317 | |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
318 if (animes.size() > 1) { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
319 // menu in Taiga: |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
320 // |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
321 // Set date started -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
322 // Clear |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
323 // Set to date started airing |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
324 // Set date completed -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
325 // Clear |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
326 // Set to date finished airing |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
327 // Set to last updated |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
328 // Set episode... |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
329 // Set score -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
330 // 0 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
331 // 10 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
332 // ... |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
333 // 100 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
334 // Set status -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
335 // Currently watching |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
336 // ... |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
337 // Plan to watch |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
338 // Set notes... |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
339 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
340 // Invert selection |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
341 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
342 // Delete from list... <Del> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
343 } else if (animes.size() > 0) { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
344 // menu in Taiga: |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
345 // |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
346 // Information |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
347 // Search -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
348 // AniDB |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
349 // AniList |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
350 // Anime News Network |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
351 // Kitsu |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
352 // MyAnimeList |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
353 // Reddit |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
354 // Wikipedia |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
355 // YouTube |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
356 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
357 // Custom RSS feed |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
358 // Nyaa.si |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
359 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
360 // Edit |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
361 // Delete from list... <Del> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
362 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
363 // Open folder <Ctrl+O> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
364 // Scan available episodes <F5> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
365 // ---------------- |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
366 // Play episode -> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
367 // grid of episodes (dunno how to implement this) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
368 // Play last episode (#<episode>) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
369 // Play next episode (#<episode>) <Ctrl+N> |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
370 // Play random episode <Ctrl+R> (why?) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
371 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
372 Anime::Anime *anime = *animes.begin(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
373 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
374 menu->addAction(tr("Information"), [this, anime] { |
258 | 375 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
|
376 anime, [this](Anime::Anime* anime) { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); |
10 | 377 |
77 | 378 dialog->show(); |
379 dialog->raise(); | |
380 dialog->activateWindow(); | |
291 | 381 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
382 }); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
383 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
384 menu->addSeparator(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
385 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
386 menu->addAction(tr("Edit"), [this, anime] { |
258 | 387 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
|
388 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
|
389 |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
390 dialog->show(); |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
391 dialog->raise(); |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
392 dialog->activateWindow(); |
291 | 393 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
394 }); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
395 menu->addAction(tr("Delete from list..."), [this, anime] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
396 RemoveAnime(anime->GetId()); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
397 }, QKeySequence(QKeySequence::Delete)); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
398 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
399 menu->addSeparator(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
400 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
401 menu->addAction(tr("Open folder"), [this, anime] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
402 std::optional<std::filesystem::path> path = Library::db.GetAnimeFolder(anime->GetId()); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
403 if (!path) // ... |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
404 return; |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
405 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
406 QDesktopServices::openUrl(QUrl::fromLocalFile(Strings::ToQString(path.value().u8string()))); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
407 }); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
408 menu->addAction(tr("Scan available episodes"), [this, anime] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
409 Library::db.Refresh(anime->GetId()); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
410 }); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
411 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
412 menu->addSeparator(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
413 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
414 { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
415 QMenu *submenu = menu->addMenu(tr("Play episode")); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
416 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
417 // this submenu actually uses win32 API magic to |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
418 // make a *grid* of episodes (weird!) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
419 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
420 (void)submenu; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
421 } |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
422 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
423 const int progress = anime->GetUserProgress(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
424 const int episodes = anime->GetEpisodes(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
425 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
426 // I think this is right? |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
427 if (progress > 0) { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
428 menu->addAction(tr("Play last episode (#%1)").arg(progress), [this, anime, progress] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
429 const int id = anime->GetId(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
430 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
431 if (Library::db.items.find(id) == Library::db.items.end() |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
432 || Library::db.items[id].find(progress) == Library::db.items[id].end()) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
433 return; |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
434 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
435 QDesktopServices::openUrl(QUrl::fromLocalFile(Strings::ToQString(Library::db.items[id][progress].u8string()))); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
436 }); |
77 | 437 } |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
438 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
439 if (progress < episodes) { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
440 menu->addAction(tr("Play next episode (#%1)").arg(progress + 1), [this, anime, progress] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
441 const int id = anime->GetId(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
442 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
443 if (Library::db.items.find(id) == Library::db.items.end() |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
444 || Library::db.items[id].find(progress + 1) == Library::db.items[id].end()) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
445 return; |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
446 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
447 QDesktopServices::openUrl(QUrl::fromLocalFile(Strings::ToQString(Library::db.items[id][progress + 1].u8string()))); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
448 }, QKeySequence(Qt::CTRL | Qt::Key_N)); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
449 } |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
450 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
451 menu->addAction(tr("Play random episode"), [this, anime, episodes] { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
452 const int id = anime->GetId(); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
453 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
454 std::uniform_int_distribution<int> distrib(1, episodes); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
455 const int episode = distrib(session.gen); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
456 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
457 if (Library::db.items.find(id) == Library::db.items.end() |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
458 || Library::db.items[id].find(episode) == Library::db.items[id].end()) |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
459 return; |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
460 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
461 QDesktopServices::openUrl(QUrl::fromLocalFile(Strings::ToQString(Library::db.items[id][episode].u8string()))); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
462 }, QKeySequence(Qt::CTRL | Qt::Key_R)); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
463 |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
464 menu->popup(QCursor::pos()); |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
465 } else { |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
466 // Where are we now? |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
327
diff
changeset
|
467 } |
10 | 468 } |
469 | |
64 | 470 void AnimeListPage::ItemDoubleClicked() { |
10 | 471 /* throw out any other garbage */ |
472 const QItemSelection selection = | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
473 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); |
10 | 474 if (!selection.indexes().first().isValid()) { |
475 return; | |
476 } | |
477 | |
64 | 478 AnimeListPageModel* source_model = |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
479 reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); |
64 | 480 |
481 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
|
482 Anime::Anime& anime = Anime::db.items[source_model->GetAnimeFromIndex(index)->GetId()]; |
10 | 483 |
258 | 484 InformationDialog* dialog = new InformationDialog( |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
485 &anime, [this](Anime::Anime* anime) { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); |
10 | 486 |
487 dialog->show(); | |
488 dialog->raise(); | |
489 dialog->activateWindow(); | |
291 | 490 connect(dialog, &InformationDialog::finished, dialog, &InformationDialog::deleteLater); |
10 | 491 } |
492 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
493 void AnimeListPage::RefreshList() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
494 for (unsigned int i = 0; i < sort_models.size(); i++) |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
495 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); |
10 | 496 } |
497 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
498 void AnimeListPage::RefreshTabs() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
499 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
|
500 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
|
501 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
10 | 502 } |
503 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
504 void AnimeListPage::Refresh() { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
505 RefreshList(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
506 RefreshTabs(); |
10 | 507 } |
508 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
509 /* -------- QTabWidget replication begin --------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
510 |
64 | 511 void AnimeListPage::InitBasicStyle(QStyleOptionTabWidgetFrame* option) const { |
10 | 512 if (!option) |
513 return; | |
514 | |
515 option->initFrom(this); | |
516 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this); | |
517 option->shape = QTabBar::RoundedNorth; | |
518 option->tabBarRect = tab_bar->geometry(); | |
519 } | |
520 | |
64 | 521 void AnimeListPage::InitStyle(QStyleOptionTabWidgetFrame* option) const { |
10 | 522 if (!option) |
523 return; | |
524 | |
525 InitBasicStyle(option); | |
526 | |
527 QSize t(0, tree_view->frameWidth()); | |
528 if (tab_bar->isVisibleTo(this)) { | |
529 t = tab_bar->sizeHint(); | |
530 t.setWidth(width()); | |
531 } | |
46 | 532 |
10 | 533 option->tabBarSize = t; |
534 | |
535 QRect selected_tab_rect = tab_bar->tabRect(tab_bar->currentIndex()); | |
536 selected_tab_rect.moveTopLeft(selected_tab_rect.topLeft() + option->tabBarRect.topLeft()); | |
537 option->selectedTabRect = selected_tab_rect; | |
538 | |
539 option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this); | |
540 } | |
541 | |
64 | 542 void AnimeListPage::SetupLayout() { |
10 | 543 QStyleOptionTabWidgetFrame option; |
544 InitStyle(&option); | |
545 | |
546 QRect tabRect = style()->subElementRect(QStyle::SE_TabWidgetTabBar, &option, this); | |
547 tabRect.setLeft(tabRect.left() + 1); | |
548 panelRect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &option, this); | |
549 QRect contentsRect = style()->subElementRect(QStyle::SE_TabWidgetTabContents, &option, this); | |
550 | |
551 tab_bar->setGeometry(tabRect); | |
552 tree_view->parentWidget()->setGeometry(contentsRect); | |
553 } | |
554 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
555 void AnimeListPage::paintEvent(QPaintEvent*) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
556 QStylePainter p(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
557 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
558 QStyleOptionTabWidgetFrame opt; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
559 InitStyle(&opt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
560 opt.rect = panelRect; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
561 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
562 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
563 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
564 void AnimeListPage::resizeEvent(QResizeEvent* e) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
565 QWidget::resizeEvent(e); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
566 SetupLayout(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
567 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
568 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
569 void AnimeListPage::showEvent(QShowEvent*) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
570 SetupLayout(); |
250 | 571 Refresh(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
572 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
573 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
574 /* --------- QTabWidget replication end ---------- */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
575 |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
576 AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent) { |
10 | 577 /* Tab bar */ |
578 tab_bar = new QTabBar(this); | |
579 tab_bar->setExpanding(false); | |
580 tab_bar->setDrawBase(false); | |
581 | |
582 /* Tree view... */ | |
583 QWidget* tree_widget = new QWidget(this); | |
584 tree_view = new QTreeView(tree_widget); | |
585 tree_view->setUniformRowHeights(true); | |
586 tree_view->setAllColumnsShowFocus(false); | |
587 tree_view->setAlternatingRowColors(true); | |
588 tree_view->setSortingEnabled(true); | |
589 tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection); | |
590 tree_view->setItemsExpandable(false); | |
591 tree_view->setRootIsDecorated(false); | |
592 tree_view->setContextMenuPolicy(Qt::CustomContextMenu); | |
593 tree_view->setFrameShape(QFrame::NoFrame); | |
594 | |
83 | 595 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
|
596 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
|
597 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
64 | 598 sort_models[i] = new AnimeListPageSortFilter(tree_view); |
599 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); | |
10 | 600 sort_models[i]->setSortRole(Qt::UserRole); |
601 sort_models[i]->setSortCaseSensitivity(Qt::CaseInsensitive); | |
602 } | |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
603 |
15 | 604 tree_view->setModel(sort_models[0]); |
10 | 605 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
606 /* Set column widths */ |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
607 tree_view->setColumnWidth(AnimeListPageModel::AL_TITLE, 300); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
608 tree_view->setColumnWidth(AnimeListPageModel::AL_PROGRESS, 200); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
609 tree_view->setColumnWidth(AnimeListPageModel::AL_SCORE, 50); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
610 tree_view->setColumnWidth(AnimeListPageModel::AL_AVG_SCORE, 55); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
611 tree_view->setColumnWidth(AnimeListPageModel::AL_TYPE, 65); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
612 tree_view->setColumnWidth(AnimeListPageModel::AL_SEASON, 95); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
613 tree_view->setColumnWidth(AnimeListPageModel::AL_STARTED, 90); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
614 tree_view->setColumnWidth(AnimeListPageModel::AL_COMPLETED, 90); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
615 tree_view->setColumnWidth(AnimeListPageModel::AL_UPDATED, 100); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
616 tree_view->setColumnWidth(AnimeListPageModel::AL_NOTES, 100); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
617 |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
618 QHBoxLayout* layout = new QHBoxLayout(tree_widget); |
10 | 619 layout->addWidget(tree_view); |
62 | 620 layout->setContentsMargins(0, 0, 0, 0); |
10 | 621 |
622 /* Double click stuff */ | |
64 | 623 connect(tree_view, &QAbstractItemView::doubleClicked, this, &AnimeListPage::ItemDoubleClicked); |
624 connect(tree_view, &QWidget::customContextMenuRequested, this, &AnimeListPage::DisplayListMenu); | |
10 | 625 |
626 /* Enter & return keys */ | |
15 | 627 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
|
628 &AnimeListPage::ItemDoubleClicked); |
10 | 629 |
15 | 630 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
|
631 &AnimeListPage::ItemDoubleClicked); |
10 | 632 |
633 tree_view->header()->setStretchLastSection(false); | |
634 tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu); | |
64 | 635 connect(tree_view->header(), &QWidget::customContextMenuRequested, this, &AnimeListPage::DisplayColumnHeaderMenu); |
10 | 636 |
637 connect(tab_bar, &QTabBar::currentChanged, this, [this](int index) { | |
638 if (sort_models[index]) | |
639 tree_view->setModel(sort_models[index]); | |
640 }); | |
641 | |
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
|
642 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
|
643 |
69 | 644 SetColumnDefaults(); |
10 | 645 setFocusPolicy(Qt::TabFocus); |
646 setFocusProxy(tab_bar); | |
647 } |