aboutsummaryrefslogtreecommitdiff
path: root/src/trustedhostcollection.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/trustedhostcollection.hpp')
-rw-r--r--src/trustedhostcollection.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/trustedhostcollection.hpp b/src/trustedhostcollection.hpp
new file mode 100644
index 0000000..6974a10
--- /dev/null
+++ b/src/trustedhostcollection.hpp
@@ -0,0 +1,48 @@
+#ifndef TRUSTEDHOSTCOLLECTION_HPP
+#define TRUSTEDHOSTCOLLECTION_HPP
+
+#include <QAbstractTableModel>
+
+#include "trustedhost.hpp"
+#include <optional>
+
+class TrustedHostCollection : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ explicit TrustedHostCollection(QObject *parent = nullptr);
+
+ TrustedHostCollection(TrustedHostCollection const &);
+ TrustedHostCollection(TrustedHostCollection &&);
+
+ // Header:
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+
+ // Basic functionality:
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+public:
+ TrustedHostCollection & operator=(TrustedHostCollection const &);
+ TrustedHostCollection & operator=(TrustedHostCollection &&);
+
+ void clear();
+
+ bool insert(TrustedHost const & host);
+
+ std::optional<TrustedHost> get(QString const & host_name) const;
+
+ std::optional<TrustedHost> get(QModelIndex const & index) const;
+
+ void remove(QModelIndex const & index);
+
+ QVector<TrustedHost> getAll() const;
+
+private:
+ QVector<TrustedHost> items;
+};
+
+#endif // TRUSTEDHOSTCOLLECTION_HPP