diff --git a/src/plugins/android/androiddeviceinfo.cpp b/src/plugins/android/androiddeviceinfo.cpp index 2c79ced2c0f..a489065a94b 100644 --- a/src/plugins/android/androiddeviceinfo.cpp +++ b/src/plugins/android/androiddeviceinfo.cpp @@ -3,33 +3,28 @@ #include "androiddeviceinfo.h" +using namespace ProjectExplorer; + namespace Android::Internal { -bool AndroidDeviceInfo::operator<(const AndroidDeviceInfo &other) const +bool operator<(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs) { - if (serialNumber.contains("????") != other.serialNumber.contains("????")) - return !serialNumber.contains("????"); - if (type != other.type) - return type == ProjectExplorer::IDevice::Hardware; - if (sdk != other.sdk) - return sdk < other.sdk; - if (avdName != other.avdName) - return avdName < other.avdName; + if (lhs.serialNumber.contains("????") != rhs.serialNumber.contains("????")) + return !lhs.serialNumber.contains("????"); + if (lhs.type != rhs.type) + return lhs.type == IDevice::Hardware; + if (lhs.sdk != rhs.sdk) + return lhs.sdk < rhs.sdk; + if (lhs.avdName != rhs.avdName) + return lhs.avdName < rhs.avdName; - return serialNumber < other.serialNumber; -} - -bool AndroidDeviceInfo::operator==(const AndroidDeviceInfo &other) const -{ - return serialNumber == other.serialNumber && avdName == other.avdName - && avdPath == other.avdPath && cpuAbi == other.cpuAbi - && sdk == other.sdk && state == other.state && type == other.type; + return lhs.serialNumber < rhs.serialNumber; } QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device) { stream.nospace() - << "Type:" << (device.type == ProjectExplorer::IDevice::Emulator ? "Emulator" : "Device") + << "Type:" << (device.type == IDevice::Emulator ? "Emulator" : "Device") << ", ABI:" << device.cpuAbi << ", Serial:" << device.serialNumber << ", Name:" << device.avdName << ", API:" << device.sdk << ", Authorised:" << (device.state == IDevice::DeviceReadyToUse); diff --git a/src/plugins/android/androiddeviceinfo.h b/src/plugins/android/androiddeviceinfo.h index 6a66e821218..cca9bc9609c 100644 --- a/src/plugins/android/androiddeviceinfo.h +++ b/src/plugins/android/androiddeviceinfo.h @@ -10,29 +10,29 @@ #include -using namespace ProjectExplorer; - namespace Android::Internal { class AndroidDeviceInfo { public: + bool isValid() const { return !serialNumber.isEmpty() || !avdName.isEmpty(); } + QString serialNumber; QString avdName; QStringList cpuAbi; int sdk = -1; - IDevice::DeviceState state = IDevice::DeviceDisconnected; - IDevice::MachineType type = IDevice::Emulator; + ProjectExplorer::IDevice::DeviceState state = ProjectExplorer::IDevice::DeviceDisconnected; + ProjectExplorer::IDevice::MachineType type = ProjectExplorer::IDevice::Emulator; Utils::FilePath avdPath; - bool isValid() const { return !serialNumber.isEmpty() || !avdName.isEmpty(); } - bool operator<(const AndroidDeviceInfo &other) const; - bool operator==(const AndroidDeviceInfo &other) const; // should be = default with C++20 - bool operator!=(const AndroidDeviceInfo &other) const { return !(*this == other); } +private: + friend bool operator<(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs); + friend bool operator==(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs) = default; + friend bool operator!=(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs) = default; + friend QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device); }; -using AndroidDeviceInfoList = QList; -QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device); +using AndroidDeviceInfoList = QList; } // namespace Android::Internal diff --git a/src/plugins/android/avdmanageroutputparser.cpp b/src/plugins/android/avdmanageroutputparser.cpp index 2357b90dfe1..fc43df72420 100644 --- a/src/plugins/android/avdmanageroutputparser.cpp +++ b/src/plugins/android/avdmanageroutputparser.cpp @@ -15,6 +15,7 @@ #include #include +using namespace ProjectExplorer; using namespace Utils; namespace Android::Internal { diff --git a/tests/auto/android/tst_avdmanageroutputparser.cpp b/tests/auto/android/tst_avdmanageroutputparser.cpp index e65a2bb15a4..22038729ce3 100644 --- a/tests/auto/android/tst_avdmanageroutputparser.cpp +++ b/tests/auto/android/tst_avdmanageroutputparser.cpp @@ -7,6 +7,7 @@ using namespace Android; using namespace Android::Internal; +using namespace ProjectExplorer; class tst_AvdManagerOutputParser : public QObject {