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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-06-18 21:58:46 UTC
  • mfrom: (1.2.29 upstream) (3.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100618215846-c95bk5aoysmu786d
Tags: 2:1.3.0-0ubuntu1
* Merge with Debian unstable, remaining changes:
  - Export .pot name and copy to plugins in debian/rules
  - Enable Nepomuk support in Digikam
    - Add shared-desktop-ontologies to build depends
* New upstream release:
  - Remove digikam-1.2.0-kde232628.patch fixed by upstream
  - Add mysql-server-5.1 to buil-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Date        : 2009-08-08
7
7
 * Description : an option to provide file information to the parser
8
8
 *
9
 
 * Copyright (C) 2009 by Andi Clemens <andi dot clemens at gmx dot net>
 
9
 * Copyright (C) 2009-2010 by Andi Clemens <andi dot clemens at gmx dot net>
10
10
 *
11
11
 * This program is free software; you can redistribute it
12
12
 * and/or modify it under the terms of the GNU General
32
32
#include <kiconloader.h>
33
33
#include <klocale.h>
34
34
 
 
35
static const QString KEY_FILE("[file]");
 
36
static const QString KEY_EXT("[ext]");
 
37
static const QString KEY_USER("[user]");
 
38
static const QString KEY_GROUP("[group]");
 
39
 
35
40
namespace Digikam
36
41
{
37
42
 
40
45
{
41
46
    setUseTokenMenu(true);
42
47
 
43
 
    addToken("[file]", i18n("Filename"),
 
48
    addToken(KEY_FILE, i18n("Filename"),
44
49
             i18nc("File name", "Name"));
45
50
 
46
 
    addToken("[ext]", i18n("File extension, prepend with a '.' character, to modify the real file extension"),
 
51
    addToken(KEY_EXT, i18n("File extension, prepend with a '.' character, to modify the real file extension"),
47
52
             i18nc("File extension", "Extension"));
48
53
 
49
 
    addToken("[user]", i18n("Owner of the file"),
 
54
    addToken(KEY_USER, i18n("Owner of the file"),
50
55
             i18nc("Owner of the file", "Owner"));
51
56
 
52
 
    addToken("[group]", i18n("Group of the file"),
 
57
    addToken(KEY_GROUP, i18n("Group of the file"),
53
58
             i18nc("Group of the file", "Group"));
54
59
 
55
60
    QString regExpStr;
56
61
    regExpStr.append('(');
57
 
    regExpStr.append(escapeToken("[file]")).append('|');
58
 
    regExpStr.append(escapeToken("[user]")).append('|');
59
 
    regExpStr.append(escapeToken("[group]")).append('|');
60
 
    regExpStr.append("(\\.?)").append(escapeToken("[ext]"));
 
62
    regExpStr.append(escapeToken(KEY_FILE)).append('|');
 
63
    regExpStr.append(escapeToken(KEY_USER)).append('|');
 
64
    regExpStr.append(escapeToken(KEY_GROUP)).append('|');
 
65
    regExpStr.append("(\\.?)").append(escapeToken(KEY_EXT));
61
66
    regExpStr.append(')');
62
67
 
63
68
    QRegExp reg(regExpStr);
70
75
    QString result;
71
76
    QFileInfo fi(settings.fileUrl.toLocalFile());
72
77
 
73
 
    if (!fi.exists())
74
 
    {
75
 
        return result;
76
 
    }
77
 
 
78
78
    const QRegExp& reg   = regExp();
79
79
    const QString& token = reg.cap(1);
80
80
 
81
 
    if (token == QString("[file]"))
 
81
    if (token == KEY_FILE)
82
82
    {
83
83
        result = fi.completeBaseName();
84
84
    }
85
 
    else if (token == QString("[user]"))
 
85
    else if (token == KEY_USER)
86
86
    {
87
87
        result = fi.owner();
88
88
    }
89
 
    else if (token == QString("[group]"))
 
89
    else if (token == KEY_GROUP)
90
90
    {
91
91
        result = fi.group();
92
92
    }
93
 
    else if (token == QString("[ext]"))
 
93
    else if (token == KEY_EXT)
94
94
    {
95
95
        result = fi.suffix();
96
96
    }
97
 
    else if (token == QString(".[ext]"))
 
97
    else if (token == QString("." + KEY_EXT))
98
98
    {
99
99
        result = '.' + fi.suffix();
100
100
        settings.useOriginalFileExtension = false;