~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to utilities/advancedrename/parser/modifiers/rangemodifier.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2010-02-04 07:46:57 UTC
  • mfrom: (3.2.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100204074657-hqzwjn4timlfw265
Tags: 2:1.1.0-1ubuntu1
* New upstream release:
  - Rename in BQM fails with multi dot names (LP: #501135)
  - Add collection with similar name fails (LP: #500581)
  - Add SMB folder error message (LP: #350280)
  - Zoom indicators indicate wrong magnification (LP: #510346)
* Merge with Debian, remaining changes:
  - Export .pot name and copy to plugins in debian/rules
  - Build-depend on libkipi7-dev, libkexiv2-8-dev and 
    libkdcraw8-dev (KDE 4.3 -> 4.4)
  - Build-depend on libmarble-dev (was disabled temporarily 
    in Debian due to 4.3.4 regression)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <klocale.h>
36
36
#include <knuminput.h>
37
37
 
 
38
// Local includes
 
39
 
 
40
#include "ui_rangemodifierdialogwidget.h"
 
41
 
38
42
namespace Digikam
39
43
{
40
44
 
41
45
RangeDialog::RangeDialog(ParseObject* parent)
42
 
             : ParseObjectDialog(parent),
43
 
               startInput(0), stopInput(0), toTheEndCheckBox(0)
 
46
           : ParseObjectDialog(parent), ui(new Ui::RangeModifierDialogWidget())
44
47
{
45
 
    const int minRange = 1;
46
 
    const int maxRange = 999999;
47
 
 
48
 
    startInput = new KIntNumInput(this);
49
 
    startInput->setMinimum(minRange);
50
 
    startInput->setMaximum(maxRange);
51
 
    startInput->setLabel(i18nc("Beginning of the text range", "From:"));
52
 
 
53
 
    stopInput = new KIntNumInput(this);
54
 
    stopInput->setMinimum(minRange);
55
 
    stopInput->setMaximum(maxRange);
56
 
    stopInput->setLabel(i18nc("end of the text range", "To:"));
57
 
 
58
 
    toTheEndCheckBox = new QCheckBox(i18nc("range is specified until the end of the string", "to the end"));
59
 
    toTheEndCheckBox->setChecked(true);
 
48
    QWidget* mainWidget = new QWidget(this);
 
49
    ui->setupUi(mainWidget);
 
50
    setSettingsWidget(mainWidget);
 
51
    ui->startInput->setFocus();
 
52
 
60
53
    slotToTheEndChecked(true);
61
54
 
62
 
    // --------------------------------------------------------
63
 
 
64
 
    QWidget*     mainWidget = new QWidget(this);
65
 
    QGridLayout* mainLayout = new QGridLayout(this);
66
 
    mainLayout->addWidget(startInput,          0, 0);
67
 
    mainLayout->addWidget(toTheEndCheckBox,    1, 0);
68
 
    mainLayout->addWidget(stopInput,           2, 0);
69
 
    mainLayout->setSpacing(KDialog::spacingHint());
70
 
    mainLayout->setMargin(KDialog::spacingHint());
71
 
    mainLayout->setRowStretch(3, 10);
72
 
    mainWidget->setLayout(mainLayout);
73
 
 
74
 
    setSettingsWidget(mainWidget);
75
 
 
76
 
    // --------------------------------------------------------
77
 
 
78
 
    startInput->setFocus();
79
 
 
80
 
    connect(toTheEndCheckBox, SIGNAL(toggled(bool)),
 
55
    connect(ui->toTheEndCheckBox, SIGNAL(toggled(bool)),
81
56
            this, SLOT(slotToTheEndChecked(bool)));
82
57
}
83
58
 
84
59
RangeDialog::~RangeDialog()
85
60
{
 
61
    delete ui;
86
62
}
87
63
 
88
64
void RangeDialog::slotToTheEndChecked(bool checked)
89
65
{
90
 
    stopInput->setEnabled(!checked);
 
66
    ui->stopInput->setEnabled(!checked);
91
67
}
92
68
 
93
69
// --------------------------------------------------------
96
72
             : Modifier(i18n("Range..."), i18n("Add only a specific range of a renaming option"),
97
73
                        SmallIcon("measure"))
98
74
{
99
 
    addToken("{|from| - |to|}", i18n("Extract a specific range (if omitted, '|to|' = end of string)"));
 
75
    addToken("{||from|| - ||to||}", i18n("Extract a specific range (if omitted, '||to||' = end of string)"));
100
76
 
101
77
    QRegExp reg("\\{(\\d+)(-((-1|\\d+))?)?\\}");
102
78
    reg.setMinimal(true);
112
88
    QPointer<RangeDialog> dlg = new RangeDialog(this);
113
89
    if (dlg->exec() == KDialog::Accepted)
114
90
    {
115
 
        int start = dlg->startInput->value();
116
 
        int stop  = dlg->stopInput->value();
 
91
        int start = dlg->ui->startInput->value();
 
92
        int stop  = dlg->ui->stopInput->value();
117
93
 
118
 
        if (dlg->toTheEndCheckBox->isChecked())
 
94
        if (dlg->ui->toTheEndCheckBox->isChecked())
119
95
        {
120
96
            result = QString("{%1-}").arg(QString::number(start));
121
97
        }
122
98
        else
123
99
        {
124
100
            result = QString("{%1-%2}").arg(QString::number(start))
125
 
                                    .arg(QString::number(stop));
 
101
                                       .arg(QString::number(stop));
126
102
        }
127
103
    }
128
104
    delete dlg;