Commit a6ec5ea9 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Fix parsing of lilypond URLs

parent 3bcfb63d
......@@ -59,33 +59,40 @@ int SourceReference::column() const
bool Okular::extractLilyPondSourceReference( const QUrl &url, QString *file, int *row, int *col )
{
// Example URL is: textedit:///home/foo/bar.ly:42:42:42
// The three numbers are apparently: line:beginning of column:end of column
if ( url.scheme() != QStringLiteral("textedit") )
return false;
#pragma message("KF5 fix LilyPond references")
return false;
// *row = 0;
// *col = 0;
// int lilyChar = 0;
// typedef int *IntPtr;
// const IntPtr int_data[] = { row, &lilyChar, col };
// int int_index = sizeof( int_data ) / sizeof( int* ) - 1;
// int index_last = -1;
// int index = url.lastIndexOf( QLatin1Char( ':' ), index_last );
// while ( index != -1 && int_index >= 0 )
// {
// // read the current "chunk"
// const QStringRef ref = url.midRef( index + 1, index_last - index - 1 );
// *int_data[ int_index ] = QString::fromRawData( ref.data(), ref.count() ).toInt();
// // find the previous "chunk"
// index_last = index;
// index = url.lastIndexOf( QLatin1Char( ':' ), index_last - 1 );
// --int_index;
// }
// // NOTE: 11 is the length of "textedit://"
// *file = QUrl::fromPercentEncoding( url.mid( 11, index_last != -1 ? index_last - 11 : -1 ).toUtf8() );
// return true;
// There can be more, in case the filename contains :
if (url.fileName().count(':') < 3) {
return false;
}
QStringList parts(url.path().split(':'));
bool ok;
// Take out the things we need
int columnEnd = parts.takeLast().toInt(&ok); // apparently we don't use this
Q_UNUSED(columnEnd);
if (!ok) {
return false;
}
*col = parts.takeLast().toInt(&ok);
if (!ok) {
return false;
}
*row = parts.takeLast().toInt(&ok);
if (!ok) {
return false;
}
// In case the path itself contains :, we need to reconstruct it after removing all the numbers
*file = parts.join(':');
return (!file->isEmpty());
}
QString Okular::sourceReferenceToolTip( const QString &source, int row, int col )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment