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