KSaneCore

baseoption.h
1/*
2 * SPDX-FileCopyrightText: 2009 Kare Sars <kare dot sars at iki dot fi>
3 * SPDX-FileCopyrightText: 2014 Gregor Mitsch : port to KDE5 frameworks
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8#ifndef KSANE_BASE_OPTION_H
9#define KSANE_BASE_OPTION_H
10
11// Qt includes
12#include <QObject>
13
14//KDE includes
15
16#include <KLocalizedString>
17
18// Sane includes
19extern "C"
20{
21#include <sane/sane.h>
22#include <sane/saneopts.h>
23}
24
25#include "../option.h"
26
27#define SANE_TRANSLATION_DOMAIN "sane-backends"
28
29namespace KSaneCore
30{
31
32inline QString sane_i18n(const char *text) {
33 return i18nd(SANE_TRANSLATION_DOMAIN, text);
34}
35
36
37class BaseOption : public QObject
38{
40
41public:
42
43 BaseOption();
44 BaseOption(const SANE_Handle handle, const int index);
45 ~BaseOption() override;
46 static Option::OptionType optionType(const SANE_Option_Descriptor *optDesc);
47
48 bool needsPolling() const;
49 virtual void readOption();
50 virtual void readValue();
51
52
53 virtual QString name() const;
54 virtual QString title() const;
55 virtual QString description() const;
56 virtual Option::OptionType type() const;
57 virtual Option::OptionState state() const;
58 virtual QVariant minimumValue() const;
59 virtual QVariant maximumValue() const;
60 virtual QVariant stepValue() const;
61 virtual QVariant value() const;
62 virtual QVariantList valueList() const;
63 virtual QVariantList internalValueList() const;
64 virtual Option::OptionUnit valueUnit() const;
65 virtual int valueSize() const;
66 virtual QString valueAsString() const;
67
68 bool storeCurrentData();
69 bool restoreSavedData();
70
72 void optionsNeedReload();
73 void valuesNeedReload();
74 void optionReloaded();
75 void valueChanged(const QVariant &value);
76
77public Q_SLOTS:
78
79 virtual bool setValue(const QVariant &value);
80
81protected:
82
83 static SANE_Word toSANE_Word(unsigned char *data);
84 static void fromSANE_Word(unsigned char *data, SANE_Word from);
85 bool writeData(void *data);
86 void beginOptionReload();
87 void endOptionReload();
88
89 SANE_Handle m_handle = nullptr;
90 int m_index = -1;
91 const SANE_Option_Descriptor *m_optDesc = nullptr; ///< This pointer is provided by sane
92 unsigned char *m_data= nullptr;
93 Option::OptionType m_optionType = Option::TypeDetectFail;
94};
95
96} // namespace KSaneCore
97
98#endif // KSANE_BASE_OPTION_H
99
OptionType
This enumeration describes the type of the option.
Definition option.h:34
OptionState
This enumeration describes the current statue of the value of the option, indicating if this option s...
Definition option.h:46
OptionUnit
This enumeration describes the unit of the value of the option, if any.
Definition option.h:40
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.