~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to utilities/advancedrename/common/parser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
// --------------------------------------------------------
67
67
 
68
68
Parser::Parser()
69
 
      : d(new ParserPriv)
 
69
    : d(new ParserPriv)
70
70
{
71
71
    registerOption(new FilePropertiesOption());
72
72
    registerOption(new DirectoryNameOption());
223
223
    }
224
224
 
225
225
    QString newName;
 
226
 
226
227
    if (settings.applyModifiers)
227
228
    {
228
229
        settings.invalidModifiers = applyModifiers(settings.parseString, results);
229
230
        newName                   = results.replaceTokens(settings.parseString);
230
231
    }
 
232
 
231
233
    settings.results = results;
232
234
 
233
235
    // remove invalid modifiers from the new name
284
286
    {
285
287
        found = true;
286
288
    }
 
289
 
287
290
    return found;
288
291
}
289
292
 
310
313
    {
311
314
        QRegExp regExp = modifier->regExp();
312
315
        int pos = 0;
 
316
 
313
317
        while (pos > -1)
314
318
        {
315
319
            pos = regExp.indexIn(parseString, pos);
 
320
 
316
321
            if (pos > -1)
317
322
            {
318
323
                ParseResults::ResultsKey   k(pos, regExp.matchedLength());
331
336
    // We need to create a second ParseResults object with modified keys, otherwise the final parsing step will not
332
337
    // remove the modifier tokens from the result.
333
338
 
334
 
    foreach (const ParseResults::ResultsKey &key, results.keys())
 
339
    foreach (const ParseResults::ResultsKey& key, results.keys())
335
340
    {
336
341
        int off  = results.offset(key);
337
342
        int diff = 0;
 
343
 
338
344
        for (int pos = off; pos < parseString.count();)
339
345
        {
340
346
            if (modifierResults.hasKeyAtPosition(pos))
347
353
                QString str2Modify            = results.result(key);
348
354
 
349
355
                QString modResult;
 
356
 
350
357
                if (mod)
351
358
                {
352
359
                    settings.parseString       = modToken;
353
360
                    settings.currentResultsKey = key;
354
361
                    settings.str2Modify        = str2Modify;
355
362
                    ParseResults modResults    = mod->parse(settings);
 
363
 
356
364
                    if (!modResults.isEmpty() && modResults.values().length() == 1)
357
365
                    {
358
366
                        modResult = modResults.result(modResults.keys().first());