Files
amnezia-client/client/ui/models/sites_model.h
T

42 lines
876 B
C++
Raw Normal View History

2021-05-27 22:18:36 +03:00
#ifndef SITESMODEL_H
#define SITESMODEL_H
2021-08-09 00:41:52 +07:00
#include <QAbstractListModel>
2021-05-27 22:18:36 +03:00
#include "settings.h"
2021-08-09 00:41:52 +07:00
class SitesModel : public QAbstractListModel
2021-05-27 22:18:36 +03:00
{
Q_OBJECT
public:
2021-08-09 00:41:52 +07:00
enum SiteRoles {
UrlRole = Qt::UserRole + 1,
IpRole
};
2021-05-27 22:18:36 +03:00
explicit SitesModel(Settings::RouteMode mode, QObject *parent = nullptr);
void resetCache();
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
2021-08-09 00:41:52 +07:00
QVariant data(int row, int column);
protected:
QHash<int, QByteArray> roleNames() const override;
2021-05-27 22:18:36 +03:00
private:
void genCache() const;
private:
Settings::RouteMode m_mode;
Settings m_settings;
mutable QVector<QPair<QString, QString>> m_ipsCache;
mutable bool m_cacheReady = false;
};
#endif // SITESMODEL_H