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 virtual QString name() const;
53 virtual QString title() const;
54 virtual QString description() const;
55 virtual Option::OptionType type() const;
56 virtual Option::OptionState state() const;
57 virtual QVariant minimumValue() const;
58 virtual QVariant maximumValue() const;
59 virtual QVariant stepValue() const;
60 virtual QVariant value() const;
61 virtual QVariantList valueList() const;
62 virtual QVariantList internalValueList() const;
63 virtual Option::OptionUnit valueUnit() const;
64 virtual int valueSize() const;
65 virtual QString valueAsString() const;
66
67 bool storeCurrentData();
68 bool restoreSavedData();
69
71 void optionsNeedReload();
72 void valuesNeedReload();
73 void optionReloaded();
74 void valueChanged(const QVariant &value);
75
76public Q_SLOTS:
77 virtual bool setValue(const QVariant &value);
78
79protected:
80 static SANE_Word toSANE_Word(unsigned char *data);
81 static void fromSANE_Word(unsigned char *data, SANE_Word from);
82 bool writeData(void *data);
83 void beginOptionReload();
84 void endOptionReload();
85
86 SANE_Handle m_handle = nullptr;
87 int m_index = -1;
88 const SANE_Option_Descriptor *m_optDesc = nullptr; ///< This pointer is provided by sane
89 unsigned char *m_data = nullptr;
90 Option::OptionType m_optionType = Option::TypeDetectFail;
91};
92
93} // namespace KSaneCore
94
95#endif // KSANE_BASE_OPTION_H
96
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-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:52:23 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.