NewServerSettings qml rework

This commit is contained in:
Pokamest Nikak 2021-09-09 20:15:44 +03:00
parent 3175bc1e48
commit 40fa2d6779
34 changed files with 644 additions and 255 deletions

View file

@ -0,0 +1,41 @@
#ifndef SITESMODEL_H
#define SITESMODEL_H
#include <QAbstractListModel>
#include "settings.h"
class SitesModel : public QAbstractListModel
{
Q_OBJECT
public:
enum SiteRoles {
UrlRole = Qt::UserRole + 1,
IpRole
};
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;
QVariant data(int row, int column);
protected:
QHash<int, QByteArray> roleNames() const override;
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