2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2022-05-22 12:35:59 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtGui/QValidator>
|
2024-05-05 17:14:55 +00:00
|
|
|
#include <QtWidgets/QStyledItemDelegate>
|
2022-05-22 12:35:59 +00:00
|
|
|
|
|
|
|
struct HostEntryUi
|
|
|
|
{
|
|
|
|
std::string Url;
|
|
|
|
std::string Desc;
|
|
|
|
std::string Address = "0.0.0.0";
|
|
|
|
bool Enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IPValidator : public QValidator
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit IPValidator(QObject* parent = nullptr, bool allowEmpty = false);
|
|
|
|
virtual State validate(QString& input, int& pos) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const QRegularExpression intermediateRegex;
|
|
|
|
static const QRegularExpression finalRegex;
|
|
|
|
|
|
|
|
bool m_allowEmpty;
|
|
|
|
};
|
|
|
|
|
2024-05-05 17:14:55 +00:00
|
|
|
class IPItemDelegate : public QStyledItemDelegate
|
2022-05-22 12:35:59 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit IPItemDelegate(QObject* parent = nullptr);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
|
|
|
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
|
|
|
void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
};
|