annotate src/gui/pages/search.cc @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents c130f47f6f48
children f31305b9f60a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/pages/search.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
2 #include "core/anime.h"
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
3 #include "core/anime_db.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
4 #include "core/filesystem.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
5 #include "core/http.h"
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
6 #include "core/session.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
7 #include "core/strings.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
8 #include "gui/dialog/information.h"
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
9 #include "gui/translate/anime.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
10 #include "gui/widgets/text.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
11 #include "services/services.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
12 #include "track/media.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
13
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
14 #include <QDate>
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
15 #include <QHeaderView>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
16 #include <QMenu>
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
17 #include <QToolBar>
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
18 #include <QTreeView>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
19 #include <QVBoxLayout>
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
20
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
21 #include <algorithm>
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
22 #include <fstream>
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
23 #include <iostream>
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
24 #include <sstream>
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
25
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
26 #include "anitomy/anitomy.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
27 #include "pugixml.hpp"
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
28
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
29 SearchPageListSortFilter::SearchPageListSortFilter(QObject* parent) : QSortFilterProxyModel(parent) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
30 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
31
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
32 bool SearchPageListSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
33 QVariant left = sourceModel()->data(l, sortRole());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
34 QVariant right = sourceModel()->data(r, sortRole());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
35
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
36 switch (left.userType()) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
37 case QMetaType::Int:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
38 case QMetaType::UInt:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
39 case QMetaType::LongLong:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
40 case QMetaType::ULongLong: return left.toInt() < right.toInt();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
41 case QMetaType::QDate: return left.toDate() < right.toDate();
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
42 case QMetaType::QString:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
43 default: // meh
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
44 return QString::compare(left.toString(), right.toString(), Qt::CaseInsensitive) < 0;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
45 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
46 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
47
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
48 /* -------------------------------------------- */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
49
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
50 SearchPageListModel::SearchPageListModel(QObject* parent) : QAbstractListModel(parent) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
51 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
52
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
53 void SearchPageListModel::ParseSearch(const std::vector<int>& ids) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
54 /* hack!!! */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
55 if (!rowCount(index(0))) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
56 beginInsertRows(QModelIndex(), 0, 0);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
57 endInsertRows();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
58 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
59
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
60 beginResetModel();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
61
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
62 this->ids = ids;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
63
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
64 endResetModel();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
65 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
66
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
67 int SearchPageListModel::rowCount(const QModelIndex& parent) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
68 return ids.size();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
69 (void)(parent);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
70 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
71
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
72 int SearchPageListModel::columnCount(const QModelIndex& parent) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
73 return NB_COLUMNS;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
74 (void)(parent);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
75 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
76
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
77 QVariant SearchPageListModel::headerData(const int section, const Qt::Orientation orientation, const int role) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
78 switch (role) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
79 case Qt::DisplayRole: {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
80 switch (section) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
81 case SR_TITLE: return tr("Anime title");
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
82 case SR_EPISODES: return tr("Episode");
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
83 case SR_TYPE: return tr("Type");
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
84 case SR_SCORE: return tr("Score");
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
85 case SR_SEASON: return tr("Season");
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
86 default: return {};
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
87 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
88 break;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
89 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
90 case Qt::TextAlignmentRole: {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
91 switch (section) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
92 case SR_TITLE: return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
93 case SR_TYPE: return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
94 case SR_EPISODES:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
95 case SR_SCORE:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
96 case SR_SEASON: return QVariant(Qt::AlignRight | Qt::AlignVCenter);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
97 default: return {};
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
98 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
99 break;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
100 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
101 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
102 return QAbstractListModel::headerData(section, orientation, role);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
103 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
104
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
105 QVariant SearchPageListModel::data(const QModelIndex& index, int role) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
106 if (!index.isValid())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
107 return QVariant();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
108
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
109 const Anime::Anime& anime = Anime::db.items[ids[index.row()]];
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
110
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
111 switch (role) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
112 case Qt::DisplayRole:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
113 switch (index.column()) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
114 case SR_TITLE: return Strings::ToQString(anime.GetUserPreferredTitle());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
115 case SR_TYPE: return Strings::ToQString(Translate::ToLocalString(anime.GetFormat()));
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
116 case SR_EPISODES: return anime.GetEpisodes();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
117 case SR_SCORE: return QString::number(anime.GetAudienceScore()) + "%";
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
118 case SR_SEASON:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
119 return Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) + " " +
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
120 QString::number(anime.GetAirDate().GetYear().value_or(2000));
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
121 default: return {};
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
122 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
123 break;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
124 case Qt::UserRole:
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
125 switch (index.column()) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
126 case SR_SCORE: return anime.GetAudienceScore();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
127 case SR_EPISODES: return anime.GetEpisodes();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
128 case SR_SEASON: return anime.GetAirDate().GetAsQDate();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
129 /* We have to use this to work around some stupid
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
130 * "conversion ambiguous" error on Linux
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
131 */
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
132 default: return data(index, Qt::DisplayRole);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
133 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
134 break;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
135 case Qt::SizeHintRole: {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
136 switch (index.column()) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
137 default: {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
138 /* max horizontal size of 100, height size = size of current font */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
139 const QString d = data(index, Qt::DisplayRole).toString();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
140 const QFontMetrics metric = QFontMetrics(QFont());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
141
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
142 return QSize(std::max(metric.horizontalAdvance(d), 100), metric.height());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
143 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
144 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
145 break;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
146 }
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
147 case Qt::TextAlignmentRole: return headerData(index.column(), Qt::Horizontal, Qt::TextAlignmentRole);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
148 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
149 return QVariant();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
150 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
151
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
152 Qt::ItemFlags SearchPageListModel::flags(const QModelIndex& index) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
153 if (!index.isValid())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
154 return Qt::NoItemFlags;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
155
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
156 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
157 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
158
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
159 Anime::Anime* SearchPageListModel::GetAnimeFromIndex(const QModelIndex& index) const {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
160 return &Anime::db.items[ids[index.row()]];
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
161 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
162
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
163 void SearchPage::DisplayListMenu() {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
164 QMenu* menu = new QMenu(this);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
165 menu->setAttribute(Qt::WA_DeleteOnClose);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
166 menu->setToolTipsVisible(true);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
167
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
168 const QItemSelection selection = sort_model->mapSelectionToSource(treeview->selectionModel()->selection());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
169
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
170 bool add_to_list_enable = true;
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
172 std::set<Anime::Anime*> animes;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
173 for (const auto& index : selection.indexes()) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
174 if (!index.isValid())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
175 continue;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
176
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
177 Anime::Anime* anime = model->GetAnimeFromIndex(index);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
178 if (anime) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
179 animes.insert(anime);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
180 if (anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
181 add_to_list_enable = false;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
182 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
183 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
184
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
185 menu->addAction(tr("Information"), [this, animes] {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
186 for (auto& anime : animes) {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
187 InformationDialog* dialog = new InformationDialog(
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
188 *anime,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
189 [this, anime] {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
190 // UpdateAnime(anime->GetId());
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
191 },
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
192 InformationDialog::PAGE_MAIN_INFO, this);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
193
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
194 dialog->show();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
195 dialog->raise();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
196 dialog->activateWindow();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
197 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
198 });
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
199 menu->addSeparator();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
200 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
201 QMenu* submenu = menu->addMenu(tr("Add to list..."));
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
202 submenu->addAction(tr("Currently watching"), [animes] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
203 for (auto& anime : animes) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
204 if (!anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
205 anime->AddToUserList();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
206 anime->SetUserStatus(Anime::ListStatus::CURRENT);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
207 Services::UpdateAnimeEntry(anime->GetId());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
208 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
209 });
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
210 submenu->addAction(tr("Completed"), [animes] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
211 for (auto& anime : animes) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
212 if (!anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
213 anime->AddToUserList();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
214 anime->SetUserStatus(Anime::ListStatus::COMPLETED);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
215 Services::UpdateAnimeEntry(anime->GetId());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
216 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
217 });
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
218 submenu->addAction(tr("On hold"), [animes] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
219 for (auto& anime : animes) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
220 if (!anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
221 anime->AddToUserList();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
222 anime->SetUserStatus(Anime::ListStatus::PAUSED);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
223 Services::UpdateAnimeEntry(anime->GetId());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
224 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
225 });
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
226 submenu->addAction(tr("Dropped"), [animes] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
227 for (auto& anime : animes) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
228 if (!anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
229 anime->AddToUserList();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
230 anime->SetUserStatus(Anime::ListStatus::DROPPED);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
231 Services::UpdateAnimeEntry(anime->GetId());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
232 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
233 });
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
234 submenu->addAction(tr("Plan to watch"), [animes] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
235 for (auto& anime : animes) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
236 if (!anime->IsInUserList())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
237 anime->AddToUserList();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
238 anime->SetUserStatus(Anime::ListStatus::PLANNING);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
239 Services::UpdateAnimeEntry(anime->GetId());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
240 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
241 });
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
242 submenu->setEnabled(add_to_list_enable);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
243 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
244 menu->popup(QCursor::pos());
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 }
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
246
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
247 void SearchPage::ItemDoubleClicked() {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
248 /* throw out any other garbage */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
249 const QItemSelection selection = sort_model->mapSelectionToSource(treeview->selectionModel()->selection());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
250 if (!selection.indexes().first().isValid())
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
251 return;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
252
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
253 const QModelIndex index = model->index(selection.indexes().first().row());
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
254 Anime::Anime* anime = model->GetAnimeFromIndex(index);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
255
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
256 InformationDialog* dialog = new InformationDialog(
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
257 *anime,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
258 [this, anime] {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
259 // UpdateAnime(anime->GetId());
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
260 },
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
261 InformationDialog::PAGE_MAIN_INFO, this);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
262
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
263 dialog->show();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
264 dialog->raise();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
265 dialog->activateWindow();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
266 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
267
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
268 SearchPage::SearchPage(QWidget* parent) : QFrame(parent) {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
269 setFrameShape(QFrame::Box);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
270 setFrameShadow(QFrame::Sunken);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
271
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
272 QVBoxLayout* layout = new QVBoxLayout(this);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
273 layout->setContentsMargins(0, 0, 0, 0);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
274 layout->setSpacing(0);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
275
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
276 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
277 /* Toolbar */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
278 QToolBar* toolbar = new QToolBar(this);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
279 toolbar->setMovable(false);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
280
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
281 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
282 QLineEdit* line_edit = new QLineEdit("", toolbar);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
283 connect(line_edit, &QLineEdit::returnPressed, this, [this, line_edit] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
284 /* static thread here. */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
285 static QThread* thread = nullptr;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
286
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
287 if (thread)
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
288 return;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
289
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
290 thread = QThread::create([this, line_edit] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
291 model->ParseSearch(Services::Search(Strings::ToUtf8String(line_edit->text())));
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
292 });
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
293
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
294 connect(thread, &QThread::finished, this, [] {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
295 thread->deleteLater();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
296 thread = nullptr;
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
297 });
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
298
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
299 thread->start();
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
300 });
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
301 toolbar->addWidget(line_edit);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
302 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
303
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
304 layout->addWidget(toolbar);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
305 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
306
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
307 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
308 QFrame* line = new QFrame(this);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
309 line->setFrameShape(QFrame::HLine);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
310 line->setFrameShadow(QFrame::Sunken);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
311 line->setLineWidth(1);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
312 layout->addWidget(line);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
313 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
314
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
315 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
316 treeview = new QTreeView(this);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
317 treeview->setUniformRowHeights(true);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
318 treeview->setAllColumnsShowFocus(false);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
319 treeview->setAlternatingRowColors(true);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
320 treeview->setSortingEnabled(true);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
321 treeview->setSelectionMode(QAbstractItemView::ExtendedSelection);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
322 treeview->setItemsExpandable(false);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
323 treeview->setRootIsDecorated(false);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
324 treeview->setContextMenuPolicy(Qt::CustomContextMenu);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
325 treeview->setFrameShape(QFrame::NoFrame);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
326
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
327 {
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
328 sort_model = new SearchPageListSortFilter(treeview);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
329 model = new SearchPageListModel(treeview);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
330 sort_model->setSourceModel(model);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
331 sort_model->setSortRole(Qt::UserRole);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
332 sort_model->setSortCaseSensitivity(Qt::CaseInsensitive);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
333 treeview->setModel(sort_model);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
334 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
335
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
336 // set column sizes
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
337 treeview->setColumnWidth(SearchPageListModel::SR_TITLE, 400);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
338 treeview->setColumnWidth(SearchPageListModel::SR_TYPE, 60);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
339 treeview->setColumnWidth(SearchPageListModel::SR_EPISODES, 60);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
340 treeview->setColumnWidth(SearchPageListModel::SR_SCORE, 60);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
341 treeview->setColumnWidth(SearchPageListModel::SR_SEASON, 100);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
342
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
343 treeview->header()->setStretchLastSection(false);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
344
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
345 /* Double click stuff */
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
346 connect(treeview, &QAbstractItemView::doubleClicked, this, &SearchPage::ItemDoubleClicked);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
347 connect(treeview, &QWidget::customContextMenuRequested, this, &SearchPage::DisplayListMenu);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
348
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
349 layout->addWidget(treeview);
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
350 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
351 }