29 #include "ksane_option.moc"
41 :
QObject(), m_handle(handle), m_index(index)
96 if (((
m_optDesc->cap & SANE_CAP_SOFT_DETECT) == 0) ||
102 else if ((
m_optDesc->cap & SANE_CAP_SOFT_SELECT) == 0) {
112 if ((
m_optDesc->cap & SANE_CAP_SOFT_DETECT) && !(
m_optDesc->cap & SANE_CAP_SOFT_SELECT)) {
135 status = sane_control_option (
m_handle,
m_index, SANE_ACTION_SET_VALUE, data, &res);
136 if (status != SANE_STATUS_GOOD) {
137 kDebug() <<
m_optDesc->name <<
"sane_control_option returned:" << sane_strstatus(status);
142 if ((res & SANE_INFO_INEXACT) && (
m_widget != 0)) {
147 if (res & SANE_INFO_RELOAD_OPTIONS) {
151 else if (res & SANE_INFO_RELOAD_PARAMS) {
166 #if __BYTE_ORDER == __LITTLE_ENDIAN
167 tmp = (data[0]&0xff);
168 tmp += ((SANE_Word)(data[1]&0xff))<<8;
169 tmp += ((SANE_Word)(data[2]&0xff))<<16;
170 tmp += ((SANE_Word)(data[3]&0xff))<<24;
172 tmp = (data[3]&0xff);
173 tmp += ((SANE_Word)(data[2]&0xff))<<8;
174 tmp += ((SANE_Word)(data[1]&0xff))<<16;
175 tmp += ((SANE_Word)(data[0]&0xff))<<24;
183 #if __BYTE_ORDER == __LITTLE_ENDIAN
184 data[0] = (from & 0x000000FF);
185 data[1] = (from & 0x0000FF00)>>8;
186 data[2] = (from & 0x00FF0000)>>16;
187 data[3] = (from & 0xFF000000)>>24;
189 data[3] = (from & 0x000000FF);
190 data[2] = (from & 0x0000FF00)>>8;
191 data[1] = (from & 0x00FF0000)>>16;
192 data[0] = (from & 0xFF000000)>>24;
210 if (!
hasGui())
return false;
217 if (status != SANE_STATUS_GOOD) {
218 kDebug() <<
m_optDesc->name <<
"sane_control_option returned" << status;
227 if (
m_data == 0)
return false;
230 if (!
hasGui())
return false;
243 switch (optDesc->constraint_type) {
244 case SANE_CONSTRAINT_NONE:
245 switch(optDesc->type)
250 if (optDesc->size ==
sizeof(SANE_Word))
return TYPE_SLIDER;
251 kDebug() <<
"Can not handle:"<< optDesc->title;
252 kDebug() <<
"SANE_CONSTRAINT_NONE && SANE_TYPE_INT";
253 kDebug() <<
"size" << optDesc->size<<
"!= sizeof(SANE_Word)";
255 case SANE_TYPE_FIXED:
256 if (optDesc->size ==
sizeof(SANE_Word))
return TYPE_F_SLIDER;
257 kDebug() <<
"Can not handle:"<< optDesc->title;
258 kDebug() <<
"SANE_CONSTRAINT_NONE && SANE_TYPE_FIXED";
259 kDebug() <<
"size" << optDesc->size<<
"!= sizeof(SANE_Word)";
261 case SANE_TYPE_BUTTON:
263 case SANE_TYPE_STRING:
265 case SANE_TYPE_GROUP:
269 case SANE_CONSTRAINT_RANGE:
270 switch(optDesc->type) {
274 if (optDesc->size ==
sizeof(SANE_Word))
return TYPE_SLIDER;
276 if ((strcmp(optDesc->name, SANE_NAME_GAMMA_VECTOR) == 0) ||
277 (strcmp(optDesc->name, SANE_NAME_GAMMA_VECTOR_R) == 0) ||
278 (strcmp(optDesc->name, SANE_NAME_GAMMA_VECTOR_G) == 0) ||
279 (strcmp(optDesc->name, SANE_NAME_GAMMA_VECTOR_B) == 0))
283 kDebug() <<
"Can not handle:"<< optDesc->title;
284 kDebug() <<
"SANE_CONSTRAINT_RANGE && SANE_TYPE_INT && !SANE_NAME_GAMMA_VECTOR...";
285 kDebug() <<
"size" << optDesc->size<<
"!= sizeof(SANE_Word)";
287 case SANE_TYPE_FIXED:
288 if (optDesc->size ==
sizeof(SANE_Word))
return TYPE_F_SLIDER;
289 kDebug() <<
"Can not handle:"<< optDesc->title;
290 kDebug() <<
"SANE_CONSTRAINT_RANGE && SANE_TYPE_FIXED";
291 kDebug() <<
"size" << optDesc->size<<
"!= sizeof(SANE_Word)";
292 kDebug() <<
"Analog Gamma vector?";
294 case SANE_TYPE_STRING:
295 kDebug() <<
"Can not handle:" << optDesc->title;
296 kDebug() <<
"SANE_CONSTRAINT_RANGE && SANE_TYPE_STRING";
298 case SANE_TYPE_BUTTON:
300 case SANE_TYPE_GROUP:
304 case SANE_CONSTRAINT_WORD_LIST:
305 case SANE_CONSTRAINT_STRING_LIST:
315 case SANE_UNIT_NONE:
return KLocalizedString();
316 case SANE_UNIT_PIXEL:
return ki18ncp(
"SpinBox parameter unit",
" Pixel",
" Pixels");
317 case SANE_UNIT_BIT:
return ki18ncp(
"SpinBox parameter unit",
" Bit",
" Bits");
318 case SANE_UNIT_MM:
return ki18nc(
"SpinBox parameter unit (Millimeter)",
" mm");
319 case SANE_UNIT_DPI:
return ki18nc(
"SpinBox parameter unit (Dots Per Inch)",
" DPI");
320 case SANE_UNIT_PERCENT:
return ki18nc(
"SpinBox parameter unit (Percentage)",
" %");
321 case SANE_UNIT_MICROSECOND:
return ki18nc(
"SpinBox parameter unit (Microseconds)",
" µs");
323 return KLocalizedString();
330 case SANE_UNIT_NONE:
return QString(
"");
331 case SANE_UNIT_PIXEL:
return i18nc(
"Double numbers. SpinBox parameter unit",
" Pixels");
332 case SANE_UNIT_BIT:
return i18nc(
"Double numbers. SpinBox parameter unit",
" Bits");
333 case SANE_UNIT_MM:
return i18nc(
"Double numbers. SpinBox parameter unit (Millimeter)",
" mm");
334 case SANE_UNIT_DPI:
return i18nc(
"Double numbers. SpinBox parameter unit (Dots Per Inch)",
" DPI");
335 case SANE_UNIT_PERCENT:
return i18nc(
"Double numbers. SpinBox parameter unit (Percentage)",
" %");
336 case SANE_UNIT_MICROSECOND:
return i18nc(
"Double numbers. SpinBox parameter unit (Microseconds)",
" µs");
static KSaneOptType optionType(const SANE_Option_Descriptor *optDesc)
virtual void createWidget(QWidget *parent)
void fromSANE_Word(unsigned char *data, SANE_Word from)
SANE_Word toSANE_Word(unsigned char *data)
const SANE_Option_Descriptor * m_optDesc
This pointer is provided by sane.
virtual bool setValue(float val)
virtual bool getMaxValue(float &max)
virtual bool getMinValue(float &max)
bool writeData(void *data)
virtual void readOption()
KSaneOption(const SANE_Handle handle, const int index)
KSaneOptionWidget * m_widget
QString unitDoubleString()
KLocalizedString unitString()
virtual bool getValue(float &val)