15 #include <QStringList>
25 : providerKey( layerItem->providerKey() )
26 , name( layerItem->layerName() )
27 , uri( layerItem->uri() )
28 , supportedCrs( layerItem->supportedCRS() )
29 , supportedFormats( layerItem->supportedFormats() )
48 QStringList decoded = decode( encData );
49 if ( decoded.size() < 4 )
52 layerType = decoded[0];
53 providerKey = decoded[1];
57 if ( layerType ==
"raster" && decoded.size() == 6 )
59 supportedCrs = decode( decoded[4] );
60 supportedFormats = decode( decoded[5] );
65 supportedFormats.clear();
68 QgsDebugMsg( QString(
"type:%1 key:%2 name:%3 uri:%4 supportedCRS:%5 supportedFormats:%6" )
69 .arg( layerType ).arg( providerKey ).arg( name ).arg( uri )
70 .arg( supportedCrs.join(
", " ) )
71 .arg( supportedFormats.join(
", " ) ) );
76 return encode( QStringList() << layerType << providerKey << name << uri << encode( supportedCrs ) << encode( supportedFormats ) );
88 QMimeData *mimeData =
new QMimeData();
89 QByteArray encodedData;
91 QDataStream stream( &encodedData, QIODevice::WriteOnly );
92 foreach (
const Uri& u, layers )
105 QDataStream stream( &encodedData, QIODevice::ReadOnly );
108 while ( !stream.atEnd() )
112 list.append(
Uri( xUri ) );
117 QString QgsMimeDataUtils::encode(
const QStringList& items )
120 foreach (
const QString& item, items )
123 str.replace(
"\\",
"\\\\" );
124 str.replace(
":",
"\\:" );
125 encoded += str +
":";
127 return encoded.left( encoded.length() - 1 );
130 QStringList QgsMimeDataUtils::decode(
const QString& encoded )
134 bool inEscape =
false;
135 foreach (
const QChar& c, encoded )
137 if ( c ==
'\\' && inEscape )
141 else if ( c ==
'\\' )
145 else if ( c ==
':' && !inEscape )
147 items.append( item );
156 items.append( item );