videodownloader/model/downloadfinderresultsmodel.h

88 lines
2.1 KiB
C
Raw Normal View History

2015-04-22 19:32:04 +02:00
#ifndef DOWNLOADFINDERRESULTSMODEL_H
#define DOWNLOADFINDERRESULTSMODEL_H
#include <QAbstractTableModel>
2019-06-10 22:50:15 +02:00
namespace CppUtilities {
2015-04-22 19:32:04 +02:00
class TimeSpan;
}
namespace Network {
class Download;
class DownloadFinder;
2019-07-20 20:20:58 +02:00
} // namespace Network
2015-04-22 19:32:04 +02:00
namespace QtGui {
2017-05-01 03:22:50 +02:00
class DownloadFinderResultsModel : public QAbstractTableModel {
2015-04-22 19:32:04 +02:00
Q_OBJECT
public:
explicit DownloadFinderResultsModel(Network::DownloadFinder *finder = nullptr, QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
bool canFetchMore(const QModelIndex &parent = QModelIndex()) const;
Network::DownloadFinder *finder() const;
void setFinder(Network::DownloadFinder *finder);
static constexpr int titleColumn();
static constexpr int uploaderColumn();
static constexpr int indexColumn();
static constexpr int durationColumn();
static constexpr int idColumn();
static constexpr int lastColumn();
private slots:
void downloadChangedStatus(Network::Download *download);
private:
static const QString &infoString(const QString &string);
static QString infoString(int num);
2019-06-10 22:50:15 +02:00
static QString infoString(const CppUtilities::TimeSpan &timeSpan);
2015-04-22 19:32:04 +02:00
Network::DownloadFinder *m_finder;
};
/*!
* \brief Returns the finder.
*/
inline Network::DownloadFinder *DownloadFinderResultsModel::finder() const
{
return m_finder;
}
constexpr int DownloadFinderResultsModel::titleColumn()
{
return 0;
}
constexpr int DownloadFinderResultsModel::uploaderColumn()
{
return 1;
}
constexpr int DownloadFinderResultsModel::indexColumn()
{
return 2;
}
constexpr int DownloadFinderResultsModel::durationColumn()
{
return 3;
}
constexpr int DownloadFinderResultsModel::idColumn()
{
return 4;
}
constexpr int DownloadFinderResultsModel::lastColumn()
{
return idColumn();
}
2019-07-20 20:20:58 +02:00
} // namespace QtGui
2015-04-22 19:32:04 +02:00
#endif // DOWNLOADFINDERRESULTSMODEL_H