aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qmmpui/metadataformatter.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/qmmpui/metadataformatter.cpp b/src/qmmpui/metadataformatter.cpp
index 957ae9f84..75d0fd0c9 100644
--- a/src/qmmpui/metadataformatter.cpp
+++ b/src/qmmpui/metadataformatter.cpp
@@ -45,14 +45,15 @@ Syntax:
%{decoder} - decoder name,
%{filesize} - file size,
%if(A,B,C) or %if(A&B&C,D,E) - condition,
-%dir(n) - Name of the directory located on n levels above.
+%dir(n) - name of the directory located on n levels above,
+%dir - full path of the parent directory.
*/
#include <QStringList>
#include <QUrl>
#include "metadataformatter.h"
-//#define DUMP_NODES
+#define DUMP_NODES
MetaDataFormatter::MetaDataFormatter(const QString &pattern)
{
@@ -335,7 +336,7 @@ bool MetaDataFormatter::parseIf(QList<MetaDataFormatter::Node> *nodes, QString::
bool MetaDataFormatter::parseDir(QList<MetaDataFormatter::Node> *nodes, QString::const_iterator *i, QString::const_iterator end)
{
- if((*i) + 1 == end || (*i) + 2 == end || (*i) + 3 == end)
+ if((*i) + 1 == end || (*i) + 2 == end)
return false;
if((**i) != QChar('d') || *((*i)+1) != QChar('i') || *((*i)+2) != QChar('r'))
@@ -343,11 +344,16 @@ bool MetaDataFormatter::parseDir(QList<MetaDataFormatter::Node> *nodes, QString:
(*i)+=3;
- if((**i) != QChar('('))
- return false;
-
Node node;
node.command = Node::DIR_FUNCTION;
+
+ if((**i) == end || (**i) != QChar('(')) // %dir without params
+ {
+ (*i)--;
+ nodes->append(node);
+ return true;
+ }
+
QString var;
enum {
@@ -486,7 +492,10 @@ QString MetaDataFormatter::evalute(const QList<Node> *nodes, const TrackInfo *in
}
else if(node.command == Node::DIR_FUNCTION)
{
- out.append(info->path().section('/', -node.params[0].number - 2, -node.params[0].number - 2));
+ if(node.params.isEmpty())
+ out.append(info->path().mid(0, info->path().lastIndexOf('/')));
+ else
+ out.append(info->path().section('/', -node.params[0].number - 2, -node.params[0].number - 2));
}
}
return out;
@@ -574,6 +583,8 @@ QString MetaDataFormatter::dumpNode(MetaDataFormatter::Node node) const
str += "AND_OPERATOR";
else if(node.command == Node::OR_OPERATOR)
str += "OR_OPERATOR";
+ else if(node.command == Node::DIR_FUNCTION)
+ str += "DIR_FUNCTION";
str += "(";
for(const Param &p : qAsConst(node.params))
{
aluser02@90c681e8-e032-0410-971d-27865f9a5e38> 2010-01-31 21:57:58 +0000 optimized settings dialog' href='/qmmp/commit/src/ui/visualmenu.cpp?id=dbe1c2bb4eda63205b744411ddcaf12d5d6436fb'>dbe1c2bb4
86aac72c6








d9d22bf78
86aac72c6
d9d22bf78
86aac72c6

dbe1c2bb4



013ee07b5
dbe1c2bb4








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            


                                                                             

                               

                       
                                                                            
 
                                     
                                         
     

                                                            








                                
                                                       
     
                                                                               

     



                                                                     
                        








                                                               
/***************************************************************************
 *   Copyright (C) 2007-2012 by Ilya Kotov                                 *