~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kspread/dialogs/ConditionalDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include "Cell.h"
28
28
#include "Map.h"
29
 
#include "Selection.h"
 
29
#include "ui/Selection.h"
30
30
#include "Sheet.h"
31
 
#include "Style.h"
32
31
#include "StyleManager.h"
 
32
#include "ValueConverter.h"
 
33
#include "ValueParser.h"
33
34
 
34
35
// commands
35
36
#include "commands/ConditionCommand.h"
299
300
                found = false;
300
301
                for (it2 = otherList.begin(); !found && it2 != otherList.end(); ++it2) {
301
302
                    kDebug() << "Found:" << found;
302
 
                    found = ((*it1).val1 == (*it2).val1 &&
303
 
                             (*it1).val2 == (*it2).val2 &&
 
303
                    found = ((*it1).value1 == (*it2).value1 &&
 
304
                             (*it1).value2 == (*it2).value2 &&
304
305
                             (*it1).cond == (*it2).cond);
305
306
 
306
 
                    if ((*it1).strVal1 && !(*it2).strVal1)
307
 
                        found = false;
308
 
                    if (!(*it1).strVal1 && (*it2).strVal1)
309
 
                        found = false;
310
 
                    if ((*it1).strVal1 && (*it2).strVal1
311
 
                            && (*(*it1).strVal1 != *(*it2).strVal1))
312
 
                        found = false;
313
 
                    if (!found)
314
 
                        continue;
315
 
 
316
 
                    if ((*it1).strVal2 && !(*it2).strVal2)
317
 
                        found = false;
318
 
                    if (!(*it1).strVal2 && (*it2).strVal2)
319
 
                        found = false;
320
 
                    if ((*it1).strVal2 && (*it2).strVal2
321
 
                            && (*(*it1).strVal2 != *(*it2).strVal2))
322
 
                        found = false;
323
 
                    if (!found)
324
 
                        continue;
325
 
 
326
 
                    if ((*it1).colorcond && !(*it2).colorcond)
327
 
                        found = false;
328
 
                    if (!(*it1).colorcond && (*it2).colorcond)
329
 
                        found = false;
330
 
                    if ((*it1).colorcond && (*it2).colorcond
331
 
                            && (*(*it1).colorcond != *(*it2).colorcond))
332
 
                        found = false;
333
 
                    if (!found)
334
 
                        continue;
335
 
 
336
 
                    if ((*it1).fontcond && !(*it2).fontcond)
337
 
                        found = false;
338
 
                    if (!(*it1).fontcond && (*it2).fontcond)
339
 
                        found = false;
340
 
                    if ((*it1).fontcond && (*it2).fontcond
341
 
                            && (*(*it1).fontcond != *(*it2).fontcond))
342
 
                        found = false;
343
 
                    if (!found)
344
 
                        continue;
345
 
 
346
 
                    if ((*it1).styleName && !(*it2).styleName)
347
 
                        found = false;
348
 
                    if (!(*it1).styleName && (*it2).styleName)
349
 
                        found = false;
350
 
                    if ((*it1).styleName && (*it2).styleName
351
 
                            && (*(*it1).styleName != *(*it2).styleName))
 
307
                    if (!found)
 
308
                        continue;
 
309
 
 
310
                    if ((*it1).styleName != (*it2).styleName)
352
311
                        found = false;
353
312
                }
354
313
 
386
345
    KLineEdit * kl1 = 0;
387
346
    KLineEdit * kl2 = 0;
388
347
    QString value;
 
348
    Map *const map = m_selection->activeSheet()->map();
 
349
    ValueConverter *const converter = map->converter();
389
350
 
390
351
    switch (numCondition) {
391
352
    case 0:
410
371
        return;
411
372
    }
412
373
 
413
 
    if (tmp.styleName) {
414
 
        sb->setCurrentIndex(sb->findText(*tmp.styleName));
 
374
    if (!tmp.styleName.isEmpty()) {
 
375
        sb->setCurrentIndex(sb->findText(tmp.styleName));
415
376
        sb->setEnabled(true);
416
377
    }
417
378
 
441
402
 
442
403
    case Conditional::Between :
443
404
        cb->setCurrentIndex(6);
444
 
 
445
 
        if (tmp.strVal2)
446
 
            kl2->setText(*tmp.strVal2);
447
 
        else {
448
 
            value = value.setNum(tmp.val2);
449
 
            kl2->setText(value);
450
 
        }
 
405
        kl2->setText(converter->asString(tmp.value2).asString());
451
406
        break;
452
407
 
453
408
    case Conditional::Different :
454
409
        cb->setCurrentIndex(7);
455
 
        if (tmp.strVal2)
456
 
            kl2->setText(*tmp.strVal2);
457
 
        else {
458
 
            value = value.setNum(tmp.val2);
459
 
            kl2->setText(value);
460
 
        }
 
410
        kl2->setText(converter->asString(tmp.value2).asString());
461
411
        break;
462
412
    case Conditional::DifferentTo :
463
413
        cb->setCurrentIndex(8);
466
416
 
467
417
    if (tmp.cond != Conditional::None) {
468
418
        kl1->setEnabled(true);
469
 
 
470
 
        if (tmp.strVal1)
471
 
            kl1->setText(*tmp.strVal1);
472
 
        else {
473
 
            value = value.setNum(tmp.val1);
474
 
            kl1->setText(value);
475
 
        }
 
419
        kl1->setText(converter->asString(tmp.value1).asString());
476
420
    }
477
421
}
478
422
 
561
505
    if (newCondition.cond == Conditional::None)
562
506
        return false;
563
507
 
564
 
    bool ok = false;
565
 
    double d1 = edit1->text().toDouble(&ok);
566
 
    double d2 = 0.0;
567
 
    QString * s1 = 0;
568
 
    QString * s2 = 0;
569
 
    QString * sn = 0;
570
 
 
571
 
    if (ok) {
572
 
        if (edit2->isEnabled())
573
 
            d2 = edit2->text().toDouble(&ok);
574
 
        // values are already checked...
575
 
    } else {
576
 
        d1 = 0.0;
577
 
        s1 = new QString(edit1->text());
578
 
 
579
 
        if (edit2->isEnabled())
580
 
            s2 = new QString(edit2->text());
581
 
    }
582
 
    sn = new QString(sb->currentText());
583
 
 
584
 
    newCondition.val1      = d1;
585
 
    newCondition.val2      = d2;
586
 
    newCondition.strVal1   = s1;
587
 
    newCondition.strVal2   = s2;
588
 
    newCondition.fontcond  = 0;
589
 
    newCondition.colorcond = 0;
590
 
    newCondition.styleName = sn;
 
508
    Map *const map = m_selection->activeSheet()->map();
 
509
    ValueParser *const parser = map->parser();
 
510
 
 
511
    newCondition.value1 = parser->parse(edit1->text());
 
512
    newCondition.value2 = parser->parse(edit2->text());
 
513
    newCondition.styleName = sb->currentText();
591
514
 
592
515
    return true;
593
516
}
601
524
 
602
525
    kDebug() << "Input data is valid";
603
526
 
604
 
    //StyleManager * manager = m_selection->activeSheet()->map()->styleManager();
605
 
 
606
527
    QLinkedList<Conditional> newList;
607
528
 
608
529
    Conditional newCondition;