~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to libs/libksane/libksane/options/ksane_option.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
 
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
121
121
        readValue();
122
122
        return false;
123
123
    }
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...";
126
126
        readValue();
127
127
    }
128
128
 
159
159
    data[3] = (from & 0xFF000000)>>24;
160
160
}
161
161
 
 
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;}
167
169
 
168
170
bool KSaneOption::storeCurrentData()
169
171
{
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;
183
185
        return false;
184
186
    }
185
187
    return true;
202
204
 
203
205
void KSaneOption::widgetSizeHints(int *, int *)
204
206
{
205
 
    kDebug(51004) << m_optDesc->name << " : type not supported";
 
207
    kDebug() << m_optDesc->name << " : type not supported";
206
208
}
207
209
 
208
210
void KSaneOption::setColumnWidths(int, int)
209
211
{
210
 
    kDebug(51004) << m_optDesc->name << " : type not supported";
 
212
    kDebug() << m_optDesc->name << " : type not supported";
211
213
}
212
214
 
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)";
228
230
                    break;
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)";
234
236
                    break;
235
237
                case SANE_TYPE_BUTTON:
236
238
                    return TYPE_BUTTON;
254
256
                    {
255
257
                        return TYPE_GAMMA;
256
258
                    }
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)";
260
262
                    break;
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?";
267
269
                    break;
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;
283
285
}
284
286
 
285
 
QString KSaneOption::unitString()
 
287
KLocalizedString KSaneOption::unitString()
 
288
{
 
289
    switch(m_optDesc->unit)
 
290
    {
 
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");
 
298
    }
 
299
    return KLocalizedString();
 
300
}
 
301
 
 
302
QString KSaneOption::unitDoubleString()
286
303
{
287
304
    switch(m_optDesc->unit)
288
305
    {
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");
296
313
    }
297
314
    return QString("");
298
315
}