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

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 #ifndef TABLETPROFILE_H
0021 #define TABLETPROFILE_H
0022 
0023 #include <KConfigGroup>
0024 #include <QString>
0025 
0026 #include "deviceprofile.h"
0027 
0028 namespace Wacom
0029 {
0030 
0031 class TabletProfilePrivate;
0032 
0033 /**
0034  * This class implements the profile of a single device (stylus/eraser/cursor/pad/touch)
0035  */
0036 class TabletProfile
0037 {
0038 public:
0039     /**
0040      * Default constructor
0041      */
0042     TabletProfile();
0043 
0044     /**
0045      * Initializes new instance with name.
0046      *
0047      * @param name The name of this profile.
0048      */
0049     explicit TabletProfile(const QString &name);
0050 
0051     /**
0052      * Copy Constructor
0053      *
0054      * @param profile The profile to copy.
0055      */
0056     TabletProfile(const TabletProfile &profile);
0057 
0058     /**
0059      * Default destructor
0060      */
0061     ~TabletProfile();
0062 
0063     /**
0064      * Copy operator.
0065      *
0066      * @param that The instance to copy.
0067      */
0068     TabletProfile &operator=(const TabletProfile &that);
0069 
0070     /**
0071      * Clears all devices from the current profile.
0072      */
0073     void clearDevices();
0074 
0075     /**
0076      * Gets the name of this tablet configuration.
0077      *
0078      * @return The name of this tablet configuration.
0079      */
0080     QString getName() const;
0081 
0082     /**
0083      * Gets the profile of a device. If the device does not exist within this
0084      * tablet configuration and empty device profile is returned.
0085      *
0086      * @param device The name of the device profile to get.
0087      *
0088      * @return The requested device profile or an empty one if the requested one does not exist.
0089      */
0090     const DeviceProfile getDevice(const DeviceType &device) const;
0091 
0092     /**
0093      * Checks if this tablet has a configuration for the given device (stylus/eraser/touch/pad/...)
0094      *
0095      * @param device The device type (stylus/eraser/touch/pad/...).
0096      *
0097      * @return True if a configuration is present, else false.
0098      */
0099     bool hasDevice(const DeviceType &device) const;
0100 
0101     /**
0102      * Checks if the tablet has configuration for the given device.
0103      * The parameters has to be a string as returned by DeviceType::key().
0104      *
0105      * @param device The device type to check for.
0106      *
0107      * @return True if a configuration is present, else false.
0108      */
0109     bool hasDevice(const QString &device) const;
0110 
0111     /**
0112      * Lists all device profile names of this tablet configuration.
0113      *
0114      * @return A list of device profile names.
0115      */
0116     QStringList listDevices() const;
0117 
0118     /**
0119      * Sets a device profile. For this to work, the profile has to have a name set.
0120      *
0121      * @param profile The profile to add.
0122      *
0123      * @return True if the profile was added, else false.
0124      */
0125     bool setDevice(const DeviceProfile &profile);
0126 
0127     /**
0128      * Sets the name of this profile.
0129      *
0130      * @param name The new name of this profile.
0131      */
0132     void setName(const QString &name);
0133 
0134 private:
0135     Q_DECLARE_PRIVATE(TabletProfile)
0136 
0137     TabletProfilePrivate *const d_ptr; /**< d-pointer for this class */
0138 };
0139 
0140 } // NAMESPACE
0141 #endif // HEADER PROTECTION