117
117
status = sane_control_option (m_handle, m_index, SANE_ACTION_SET_VALUE, data, &res);
118
118
if (status != SANE_STATUS_GOOD) {
119
kDebug(51004) << m_optDesc->name << "sane_control_option returned:" << sane_strstatus(status);
119
kDebug() << m_optDesc->name << "sane_control_option returned:" << sane_strstatus(status);
120
120
// write failed. re read the current setting
124
124
if ((res & SANE_INFO_INEXACT) && (m_frame != 0)) {
125
//kDebug(51004) << "write was inexact. Reload value just in case...";
125
//kDebug() << "write was inexact. Reload value just in case...";
159
159
data[3] = (from & 0xFF000000)>>24;
162
bool KSaneOption::getMinValue(float &) {return false;}
162
163
bool KSaneOption::getMaxValue(float &) {return false;}
163
164
bool KSaneOption::getValue(float &) {return false;}
164
165
bool KSaneOption::setValue(float) {return false;}
165
166
bool KSaneOption::getValue(QString &) {return false;}
166
167
bool KSaneOption::setValue(const QString &) {return false;}
168
int KSaneOption::getUnit() {return m_optDesc->unit;}
168
170
bool KSaneOption::storeCurrentData()
179
181
m_data = (unsigned char *)malloc(m_optDesc->size);
180
182
status = sane_control_option (m_handle, m_index, SANE_ACTION_GET_VALUE, m_data, &res);
181
183
if (status != SANE_STATUS_GOOD) {
182
kDebug(51004) << m_optDesc->name << "sane_control_option returned" << status;
184
kDebug() << m_optDesc->name << "sane_control_option returned" << status;
203
205
void KSaneOption::widgetSizeHints(int *, int *)
205
kDebug(51004) << m_optDesc->name << " : type not supported";
207
kDebug() << m_optDesc->name << " : type not supported";
208
210
void KSaneOption::setColumnWidths(int, int)
210
kDebug(51004) << m_optDesc->name << " : type not supported";
212
kDebug() << m_optDesc->name << " : type not supported";
213
215
KSaneOption::KSaneOptType KSaneOption::otpionType(const SANE_Option_Descriptor *optDesc)
222
224
return TYPE_CHECKBOX;
223
225
case SANE_TYPE_INT:
224
226
if (optDesc->size == sizeof(SANE_Word)) return TYPE_SLIDER;
225
kDebug(51004) << "Can not handle:"<< optDesc->title;
226
kDebug(51004) << "SANE_CONSTRAINT_NONE && SANE_TYPE_INT";
227
kDebug(51004) << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
227
kDebug() << "Can not handle:"<< optDesc->title;
228
kDebug() << "SANE_CONSTRAINT_NONE && SANE_TYPE_INT";
229
kDebug() << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
229
231
case SANE_TYPE_FIXED:
230
232
if (optDesc->size == sizeof(SANE_Word)) return TYPE_F_SLIDER;
231
kDebug(51004) << "Can not handle:"<< optDesc->title;
232
kDebug(51004) << "SANE_CONSTRAINT_NONE && SANE_TYPE_FIXED";
233
kDebug(51004) << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
233
kDebug() << "Can not handle:"<< optDesc->title;
234
kDebug() << "SANE_CONSTRAINT_NONE && SANE_TYPE_FIXED";
235
kDebug() << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
235
237
case SANE_TYPE_BUTTON:
236
238
return TYPE_BUTTON;
255
257
return TYPE_GAMMA;
257
kDebug(51004) << "Can not handle:"<< optDesc->title;
258
kDebug(51004) << "SANE_CONSTRAINT_RANGE && SANE_TYPE_INT && !SANE_NAME_GAMMA_VECTOR...";
259
kDebug(51004) << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
259
kDebug() << "Can not handle:"<< optDesc->title;
260
kDebug() << "SANE_CONSTRAINT_RANGE && SANE_TYPE_INT && !SANE_NAME_GAMMA_VECTOR...";
261
kDebug() << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
261
263
case SANE_TYPE_FIXED:
262
264
if (optDesc->size == sizeof(SANE_Word)) return TYPE_F_SLIDER;
263
kDebug(51004) << "Can not handle:"<< optDesc->title;
264
kDebug(51004) << "SANE_CONSTRAINT_RANGE && SANE_TYPE_FIXED";
265
kDebug(51004) << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
266
kDebug(51004) << "Analog Gamma vector?";
265
kDebug() << "Can not handle:"<< optDesc->title;
266
kDebug() << "SANE_CONSTRAINT_RANGE && SANE_TYPE_FIXED";
267
kDebug() << "size" << optDesc->size<< "!= sizeof(SANE_Word)";
268
kDebug() << "Analog Gamma vector?";
268
270
case SANE_TYPE_STRING:
269
kDebug(51004) << "Can not handle:" << optDesc->title;
270
kDebug(51004) << "SANE_CONSTRAINT_RANGE && SANE_TYPE_STRING";
271
kDebug() << "Can not handle:" << optDesc->title;
272
kDebug() << "SANE_CONSTRAINT_RANGE && SANE_TYPE_STRING";
271
273
return TYPE_DETECT_FAIL;
272
274
case SANE_TYPE_BUTTON:
273
275
return TYPE_BUTTON;
282
284
return TYPE_DETECT_FAIL;
285
QString KSaneOption::unitString()
287
KLocalizedString KSaneOption::unitString()
289
switch(m_optDesc->unit)
291
case SANE_UNIT_NONE: return KLocalizedString();
292
case SANE_UNIT_PIXEL: return ki18ncp("SpinBox parameter unit", " Pixel", " Pixels");
293
case SANE_UNIT_BIT: return ki18ncp("SpinBox parameter unit", " Bit", " Bits");
294
case SANE_UNIT_MM: return ki18nc("SpinBox parameter unit", " mm");
295
case SANE_UNIT_DPI: return ki18nc("SpinBox parameter unit", " DPI");
296
case SANE_UNIT_PERCENT: return ki18nc("SpinBox parameter unit", " %");
297
case SANE_UNIT_MICROSECOND: return ki18ncp("SpinBox parameter unit", " usec", " usecs");
299
return KLocalizedString();
302
QString KSaneOption::unitDoubleString()
287
304
switch(m_optDesc->unit)
289
306
case SANE_UNIT_NONE: return QString("");
290
case SANE_UNIT_PIXEL: return i18nc("SpinBox parameter unit"," Pixels");
291
case SANE_UNIT_BIT: return i18nc("SpinBox parameter unit"," Bits");
292
case SANE_UNIT_MM: return i18nc("SpinBox parameter unit"," mm");
293
case SANE_UNIT_DPI: return i18nc("SpinBox parameter unit"," DPI");
294
case SANE_UNIT_PERCENT: return i18nc("SpinBox parameter unit"," %");
295
case SANE_UNIT_MICROSECOND: return i18nc("SpinBox parameter unit"," usec");
307
case SANE_UNIT_PIXEL: return i18nc("Double numbers. SpinBox parameter unit", " Pixels");
308
case SANE_UNIT_BIT: return i18nc("Double numbers. SpinBox parameter unit", " Bits");
309
case SANE_UNIT_MM: return i18nc("Double numbers. SpinBox parameter unit", " mm");
310
case SANE_UNIT_DPI: return i18nc("Double numbers. SpinBox parameter unit", " DPI");
311
case SANE_UNIT_PERCENT: return i18nc("Double numbers. SpinBox parameter unit", " %");
312
case SANE_UNIT_MICROSECOND: return i18nc("Double numbers. SpinBox parameter unit", " usec");
297
314
return QString("");