File tree 1 file changed +39
-7
lines changed
1 file changed +39
-7
lines changed Original file line number Diff line number Diff line change 12
12
* (at your option) any later version. *
13
13
* *
14
14
***************************************************************************/
15
+ #include < QStringList>
16
+
15
17
#include " qgsmimedatautils.h"
16
18
17
19
#include " qgsdataitem.h"
@@ -39,20 +41,50 @@ QgsMimeDataUtils::Uri::Uri( QgsLayerItem* layerItem )
39
41
40
42
QgsMimeDataUtils::Uri::Uri ( QString& encData )
41
43
{
42
- QRegExp rx ( " ^([^:]+):([^:]+):([^:]+):(.+)" );
43
- if ( rx.indexIn ( encData ) != -1 )
44
+ QStringList parts;
45
+ QChar split = ' :' ;
46
+ QChar escape = ' \\ ' ;
47
+ QString part;
48
+ bool inEscape = false ;
49
+ for (int i = 0 ; i < encData.length (); ++i)
50
+ {
51
+ if (encData.at (i) == escape && !inEscape)
52
+ {
53
+ inEscape = true ;
54
+ }
55
+ else if (encData.at (i) == split && !inEscape)
56
+ {
57
+ parts << part;
58
+ part = " " ;
59
+ }
60
+ else
61
+ {
62
+ part += encData.at (i);
63
+ inEscape = false ;
64
+ }
65
+ }
66
+ if (!part.isEmpty ())
67
+ {
68
+ parts << part;
69
+ }
70
+
71
+ if ( parts.size () == 4 )
44
72
{
45
- layerType = rx. cap ( 1 ) ;
46
- providerKey = rx. cap ( 2 ) ;
47
- name = rx. cap ( 3 ) ;
48
- uri = rx. cap ( 4 ) ;
73
+ layerType = parts[ 0 ] ;
74
+ providerKey = parts[ 1 ] ;
75
+ name = parts[ 2 ] ;
76
+ uri = parts[ 3 ] ;
49
77
QgsDebugMsg ( " type: " + layerType + " key: " + providerKey + " name: " + name + " uri: " + uri );
50
78
}
51
79
}
52
80
53
81
QString QgsMimeDataUtils::Uri::data () const
54
82
{
55
- return layerType + " :" + providerKey + " :" + name + " :" + uri;
83
+ QString escapedName = name;
84
+ QString escapeUri = uri;
85
+ escapedName.replace (" :" , " \\ :" );
86
+ escapeUri.replace (" :" , " \\ :" );
87
+ return layerType + " :" + providerKey + " :" + escapedName + " :" + escapeUri;
56
88
}
57
89
58
90
// -----
You can’t perform that action at this time.
0 commit comments