~ubuntu-branches/ubuntu/maverick/digikam/maverick

« back to all changes in this revision

Viewing changes to utilities/advancedrename/parser/options/directorynameoption.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2009-12-22 21:38:14 UTC
  • mfrom: (1.2.26 upstream)
  • Revision ID: james.westby@ubuntu.com-20091222213814-dtgz0u1068y5rql7
Tags: 2:1.0.0-1ubuntu1
* 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 liblqr-1-0-dev: now in main (LP: #493508)

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    setRegExp(reg);
51
51
}
52
52
 
53
 
void DirectoryNameOption::parseOperation(const QString& parseString, ParseSettings& settings, ParseResults& results)
 
53
QString DirectoryNameOption::parseOperation(ParseSettings& settings)
54
54
{
55
55
    QFileInfo fi(settings.fileUrl.toLocalFile());
56
56
    QStringList folders = fi.absolutePath().split('/', QString::SkipEmptyParts);
57
 
 
58
 
    QRegExp reg     = regExp();
59
 
    int folderCount = folders.count();
60
 
 
61
 
    // --------------------------------------------------------
62
 
 
63
 
    QString tmp;
64
 
    PARSE_LOOP_START(parseString, reg)
65
 
    {
66
 
        int matchedLength = reg.cap(1).length();
67
 
 
68
 
        if (matchedLength == 0)
69
 
        {
70
 
            tmp = folders.last();
71
 
        }
72
 
        else if (matchedLength > (folderCount - 1))
73
 
        {
74
 
            tmp.clear();
75
 
        }
76
 
        else
77
 
        {
78
 
            tmp = folders[folderCount - matchedLength - 1];
79
 
        }
80
 
    }
81
 
    PARSE_LOOP_END(parseString, reg, tmp, results)
 
57
    int folderCount     = folders.count();
 
58
    const QRegExp& reg  = regExp();
 
59
 
 
60
    QString result;
 
61
    int matchedLength = reg.cap(1).length();
 
62
 
 
63
    if (matchedLength == 0)
 
64
    {
 
65
        result = folders.last();
 
66
    }
 
67
    else if (matchedLength > (folderCount - 1))
 
68
    {
 
69
        result.clear();
 
70
    }
 
71
    else
 
72
    {
 
73
        result = folders[folderCount - matchedLength - 1];
 
74
    }
 
75
 
 
76
    return result;
82
77
}
83
78
 
84
79
} // namespace Digikam