comparison src/gui/pages/torrents.cc @ 273:f31305b9f60a

*: various code safety changes this also makes the code build on Qt 5.7. I can't test it though because I don't have it working... FAIL!
author Paper <paper@paper.us.eu.org>
date Thu, 18 Apr 2024 16:53:17 -0400
parents 9a04802848c0
children 9a88e1725fd2
comparison
equal deleted inserted replaced
272:5437009cb10e 273:f31305b9f60a
12 #include <QHeaderView> 12 #include <QHeaderView>
13 #include <QThread> 13 #include <QThread>
14 #include <QToolBar> 14 #include <QToolBar>
15 #include <QTreeView> 15 #include <QTreeView>
16 #include <QVBoxLayout> 16 #include <QVBoxLayout>
17 #include <QtGlobal>
17 18
18 #include <algorithm> 19 #include <algorithm>
19 #include <fstream> 20 #include <fstream>
20 #include <iostream> 21 #include <iostream>
21 #include <sstream> 22 #include <sstream>
254 case Qt::DisplayRole: 255 case Qt::DisplayRole:
255 switch (index.column()) { 256 switch (index.column()) {
256 case TL_TITLE: return Strings::ToQString(item.GetTitle()); 257 case TL_TITLE: return Strings::ToQString(item.GetTitle());
257 case TL_EPISODE: return Strings::ToQString(item.GetEpisode()); 258 case TL_EPISODE: return Strings::ToQString(item.GetEpisode());
258 case TL_GROUP: return Strings::ToQString(item.GetGroup()); 259 case TL_GROUP: return Strings::ToQString(item.GetGroup());
259 case TL_SIZE: return session.config.locale.GetLocale().formattedDataSize(item.GetSize()); 260 case TL_SIZE: return Strings::ToQString(Strings::BytesToHumanReadableSize(item.GetSize()));
260 case TL_RESOLUTION: return Strings::ToQString(item.GetResolution()); 261 case TL_RESOLUTION: return Strings::ToQString(item.GetResolution());
261 case TL_SEEDERS: return item.GetSeeders(); 262 case TL_SEEDERS: return item.GetSeeders();
262 case TL_LEECHERS: return item.GetLeechers(); 263 case TL_LEECHERS: return item.GetLeechers();
263 case TL_DOWNLOADS: return item.GetDownloads(); 264 case TL_DOWNLOADS: return item.GetDownloads();
264 case TL_DESCRIPTION: return Strings::ToQString(item.GetDescription()); 265 case TL_DESCRIPTION: return Strings::ToQString(item.GetDescription());
282 default: { 283 default: {
283 /* max horizontal size of 100, height size = size of current font */ 284 /* max horizontal size of 100, height size = size of current font */
284 const QString d = data(index, Qt::DisplayRole).toString(); 285 const QString d = data(index, Qt::DisplayRole).toString();
285 const QFontMetrics metric = QFontMetrics(QFont()); 286 const QFontMetrics metric = QFontMetrics(QFont());
286 287
287 return QSize(std::max(metric.horizontalAdvance(d), 100), metric.height()); 288 return QSize(std::max(metric.boundingRect(d).width(), 100), metric.height());
288 } 289 }
289 } 290 }
290 break; 291 break;
291 } 292 }
292 case Qt::TextAlignmentRole: 293 case Qt::TextAlignmentRole: