mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:15:07 +00:00
UI: Don't use QHostInfo.
This commit is contained in:
parent
44a1625ead
commit
89d3a7a58d
@ -12,8 +12,9 @@ HostInfo::~HostInfo()
|
|||||||
|
|
||||||
void HostInfo::lookupHost(const QString &name)
|
void HostInfo::lookupHost(const QString &name)
|
||||||
{
|
{
|
||||||
const int lookupId = QHostInfo::lookupHost(
|
// const int lookupId = QHostInfo::lookupHost(
|
||||||
name, this, &HostInfo::handleLookedupHost);
|
// name, this, &HostInfo::handleLookedupHost);
|
||||||
|
const int lookupId = -1;
|
||||||
|
|
||||||
m_lookupIds.insert(lookupId, name);
|
m_lookupIds.insert(lookupId, name);
|
||||||
}
|
}
|
||||||
@ -22,7 +23,7 @@ void HostInfo::abortHostLookup(int lookupId)
|
|||||||
{
|
{
|
||||||
m_lookupIds.remove(lookupId);
|
m_lookupIds.remove(lookupId);
|
||||||
|
|
||||||
QHostInfo::abortHostLookup(lookupId);
|
// QHostInfo::abortHostLookup(lookupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInfo::abortHostLookups()
|
void HostInfo::abortHostLookups()
|
||||||
@ -32,15 +33,15 @@ void HostInfo::abortHostLookups()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInfo::handleLookedupHost(const QHostInfo &info)
|
//void HostInfo::handleLookedupHost(const QHostInfo &info)
|
||||||
{
|
//{
|
||||||
const int lookupId = info.lookupId();
|
// const int lookupId = info.lookupId();
|
||||||
const QString name = m_lookupIds.value(lookupId);
|
// const QString name = m_lookupIds.value(lookupId);
|
||||||
const bool success = (info.error() == QHostInfo::NoError);
|
// const bool success = (info.error() == QHostInfo::NoError);
|
||||||
|
|
||||||
m_info = info;
|
// m_info = info;
|
||||||
|
|
||||||
m_lookupIds.remove(lookupId);
|
// m_lookupIds.remove(lookupId);
|
||||||
|
|
||||||
emit hostLookedup(name, success);
|
// emit hostLookedup(name, success);
|
||||||
}
|
//}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define HOSTINFO_H
|
#define HOSTINFO_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHostInfo>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
typedef QHash<int, QString> lookupids_map_t;
|
typedef QHash<int, QString> lookupids_map_t;
|
||||||
@ -10,14 +9,14 @@ typedef QHash<int, QString> lookupids_map_t;
|
|||||||
class HostInfo : public QObject
|
class HostInfo : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString hostName READ hostName CONSTANT)
|
// Q_PROPERTY(QString hostName READ hostName CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HostInfo(QObject *parent = nullptr);
|
explicit HostInfo(QObject *parent = nullptr);
|
||||||
virtual ~HostInfo();
|
virtual ~HostInfo();
|
||||||
|
|
||||||
QString hostName() const { return m_info.hostName(); }
|
// QString hostName() const { return m_info.hostName(); }
|
||||||
QString errorString() const { return m_info.errorString(); }
|
// QString errorString() const { return m_info.errorString(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hostLookedup(const QString &name, bool success);
|
void hostLookedup(const QString &name, bool success);
|
||||||
@ -28,13 +27,13 @@ public slots:
|
|||||||
void abortHostLookups();
|
void abortHostLookups();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleLookedupHost(const QHostInfo &info);
|
// void handleLookedupHost(const QHostInfo &info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void abortHostLookup(int lookupId);
|
void abortHostLookup(int lookupId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHostInfo m_info;
|
// QHostInfo m_info;
|
||||||
|
|
||||||
lookupids_map_t m_lookupIds;
|
lookupids_map_t m_lookupIds;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user