File indexing completed on 2024-12-22 05:17:14

0001 /*
0002  * This file is part of the KDE wacomtablet project. For copyright
0003  * information and license terms see the AUTHORS and COPYING files
0004  * in the top-level directory of this distribution.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "deviceinformation.h"
0021 
0022 namespace Wacom
0023 {
0024 class DeviceInformationPrivate
0025 {
0026 public:
0027     DeviceInformationPrivate(const DeviceType &type)
0028         : deviceType(type)
0029     {
0030     }
0031 
0032     QString deviceName;
0033     QString deviceNode;
0034     DeviceType deviceType;
0035     long deviceId = 0;
0036     long productId = 0;
0037     long tabletSerial = 0;
0038     long vendorId = 0;
0039 };
0040 }
0041 
0042 using namespace Wacom;
0043 
0044 DeviceInformation::DeviceInformation(const DeviceType &deviceType, const QString &deviceName)
0045     : d_ptr(new DeviceInformationPrivate(deviceType))
0046 {
0047     Q_D(DeviceInformation);
0048 
0049     d->deviceName = deviceName;
0050 }
0051 
0052 DeviceInformation::DeviceInformation(const DeviceInformation &that)
0053     : d_ptr(new DeviceInformationPrivate(that.d_ptr->deviceType))
0054 {
0055     operator=(that);
0056 }
0057 
0058 DeviceInformation::~DeviceInformation()
0059 {
0060     delete d_ptr;
0061 }
0062 
0063 DeviceInformation &DeviceInformation::operator=(const DeviceInformation &that)
0064 {
0065     Q_D(DeviceInformation);
0066 
0067     d->deviceId = that.d_ptr->deviceId;
0068     d->deviceName = that.d_ptr->deviceName;
0069     d->deviceNode = that.d_ptr->deviceNode;
0070     d->deviceType = that.d_ptr->deviceType;
0071     d->productId = that.d_ptr->productId;
0072     d->tabletSerial = that.d_ptr->tabletSerial;
0073     d->vendorId = that.d_ptr->vendorId;
0074 
0075     return *this;
0076 }
0077 
0078 bool DeviceInformation::operator!=(const DeviceInformation &that) const
0079 {
0080     return !operator==(that);
0081 }
0082 
0083 bool DeviceInformation::operator==(const DeviceInformation &that) const
0084 {
0085     Q_D(const DeviceInformation);
0086 
0087     if (d->deviceName.compare(that.d_ptr->deviceName, Qt::CaseInsensitive) != 0 || d->deviceNode.compare(that.d_ptr->deviceNode, Qt::CaseInsensitive) != 0
0088         || d->deviceId != that.d_ptr->deviceId || d->deviceType != that.d_ptr->deviceType || d->productId != that.d_ptr->productId
0089         || d->tabletSerial != that.d_ptr->tabletSerial || d->vendorId != that.d_ptr->vendorId) {
0090         return false;
0091     }
0092 
0093     return true;
0094 }
0095 
0096 long int DeviceInformation::getDeviceId() const
0097 {
0098     Q_D(const DeviceInformation);
0099     return d->deviceId;
0100 }
0101 
0102 const QString &DeviceInformation::getDeviceNode() const
0103 {
0104     Q_D(const DeviceInformation);
0105     return d->deviceNode;
0106 }
0107 
0108 const QString &DeviceInformation::getName() const
0109 {
0110     Q_D(const DeviceInformation);
0111     return d->deviceName;
0112 }
0113 
0114 long int DeviceInformation::getProductId() const
0115 {
0116     Q_D(const DeviceInformation);
0117     return d->productId;
0118 }
0119 
0120 long int DeviceInformation::getTabletSerial() const
0121 {
0122     Q_D(const DeviceInformation);
0123     return d->tabletSerial;
0124 }
0125 
0126 const DeviceType &DeviceInformation::getType() const
0127 {
0128     Q_D(const DeviceInformation);
0129     return d->deviceType;
0130 }
0131 
0132 long int DeviceInformation::getVendorId() const
0133 {
0134     Q_D(const DeviceInformation);
0135     return d->vendorId;
0136 }
0137 
0138 void DeviceInformation::setDeviceId(long int deviceId)
0139 {
0140     Q_D(DeviceInformation);
0141     d->deviceId = deviceId;
0142 }
0143 
0144 void DeviceInformation::setDeviceNode(const QString &deviceNode)
0145 {
0146     Q_D(DeviceInformation);
0147     d->deviceNode = deviceNode;
0148 }
0149 
0150 void DeviceInformation::setProductId(long productId)
0151 {
0152     Q_D(DeviceInformation);
0153     d->productId = productId;
0154 }
0155 
0156 void DeviceInformation::setTabletSerial(long tabletSerial)
0157 {
0158     Q_D(DeviceInformation);
0159     d->tabletSerial = tabletSerial;
0160 }
0161 
0162 void DeviceInformation::setVendorId(long vendorId)
0163 {
0164     Q_D(DeviceInformation);
0165     d->vendorId = vendorId;
0166 }