Fix transfer list architecture

Model returns string for DisplayRole.
Text alignment is set by Model (using TextAlignmentRole).
Delegate performs custom painting only where necessary
(i.e. for Progress bar).
This commit is contained in:
Vladimir Golovnev (Glassez)
2019-12-17 21:57:36 +03:00
parent 18de63f743
commit 766cfb67df
6 changed files with 375 additions and 346 deletions

View File

@@ -26,8 +26,7 @@
* exception statement from your version.
*/
#ifndef TRANSFERLISTSORTMODEL_H
#define TRANSFERLISTSORTMODEL_H
#pragma once
#include <QSortFilterProxyModel>
#include "base/torrentfilter.h"
@@ -37,9 +36,10 @@ class QStringList;
class TransferListSortModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_DISABLE_COPY(TransferListSortModel)
public:
TransferListSortModel(QObject *parent = nullptr);
explicit TransferListSortModel(QObject *parent = nullptr);
void setStatusFilter(TorrentFilter::Type filter);
void setCategoryFilter(const QString &category);
@@ -51,13 +51,9 @@ public:
private:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
bool dateLessThan(int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
bool lessThan_impl(const QModelIndex &left, const QModelIndex &right) const;
private:
TorrentFilter m_filter;
};
#endif // TRANSFERLISTSORTMODEL_H