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 TABLETINFO_H
0021 #define TABLETINFO_H
0022 
0023 #include <QString>
0024 
0025 #include "enum.h"
0026 #include "property.h"
0027 
0028 namespace Wacom
0029 {
0030 
0031 // forward declaration
0032 class TabletInfo;
0033 struct TabletInfoTemplateSpecializationLessFunctor;
0034 
0035 /**
0036  * @brief Helper Typedef! Do not use!
0037  *
0038  * This typedef is required by the TabletInfo class. It eases maintenance of template parameters.
0039  */
0040 typedef Enum<TabletInfo, QString, TabletInfoTemplateSpecializationLessFunctor, PropertyKeyEqualsFunctor> TabletInfoTemplateSpecialization;
0041 
0042 /**
0043  * @brief Helper Class! Do not use!
0044  *
0045  * This functor is required by the TabletInfo class to sort its instances.
0046  */
0047 struct TabletInfoTemplateSpecializationLessFunctor {
0048     bool operator()(const TabletInfoTemplateSpecialization *p1, const TabletInfoTemplateSpecialization *p2)
0049     {
0050         return (p1->key() < p2->key());
0051     }
0052 };
0053 
0054 /**
0055  * @brief An enum of all supported device information properties.
0056  *
0057  * This enumeration ensures that only correct tablet info identifiers are sent via
0058  * D-Bus by taking care of converting them to a string and providing a way to map
0059  * these strings back to a tablet info type.
0060  * <br/>
0061  * This class also helps to ease maintenance by passing the responsibility for checking
0062  * for correct tablet info types to the compiler. When using this enumeration it is no
0063  * longer possible to have method/d-bus calls fail because of typos in the tablet info
0064  * identifier. Also refactoring is much easier.
0065  */
0066 class TabletInfo : public TabletInfoTemplateSpecialization
0067 {
0068 public:
0069     static const TabletInfo ButtonLayout; //!< The button layout.
0070     static const TabletInfo CompanyId; //!< The vendor identifier.
0071     static const TabletInfo CompanyName; //!< The vendor name.
0072     static const TabletInfo HasLeftTouchStrip; //!< Flag if this tablet has a left touch strip.
0073     static const TabletInfo HasRightTouchStrip; //!< Flag if this tablet has a right touch strip.
0074     static const TabletInfo HasTouchRing; //!< Flag if this tablet has a touch ring.
0075     static const TabletInfo HasWheel; //!< Flag if this tablet has a wheel.
0076     static const TabletInfo NumPadButtons; //!< Number of pad buttons.
0077     static const TabletInfo StatusLEDs; //!< Number of LED's that can display tablet modes (for Intuos)
0078     static const TabletInfo TabletId; //!< The tablet identifier as a four digit hex code.
0079     static const TabletInfo TabletModel; //!< The tablet model.
0080     static const TabletInfo TabletName; //!< The name of the tablet.
0081     static const TabletInfo TabletSerial; //!< The tablet serial id as reported by the wacom driver.
0082     static const TabletInfo TouchSensorId; // parent device stores touch sensor id here
0083     static const TabletInfo IsTouchSensor; // slave touch device is marked by this and is hidden from the KCM
0084 
0085 private:
0086     /**
0087      * Private constructor for the static members of this class.
0088      */
0089     TabletInfo(const QString &key)
0090         : TabletInfoTemplateSpecialization(this, key)
0091     {
0092     }
0093 
0094 }; // CLASS
0095 
0096 /*
0097  * Declare static instances-container of the TabletInfo template specialization.
0098  */
0099 template<>
0100 TabletInfoTemplateSpecialization::Container TabletInfoTemplateSpecialization::instances;
0101 
0102 } // NAMESPACE
0103 #endif // HEADER PROTECTION