1 /***************************************************************************
2 * Copyright (C) 2007,2008 by Pino Toscano <pino@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "sourcereference.h"
11 #include "sourcereference_p.h"
13 #include <QtCore/QString>
16 using namespace Okular
;
18 class SourceReference::Private
22 : row( 0 ), column( 0 )
31 SourceReference::SourceReference( const QString
&fileName
, int row
, int column
)
34 d
->filename
= fileName
;
39 SourceReference::~SourceReference()
44 QString
SourceReference::fileName() const
49 int SourceReference::row() const
54 int SourceReference::column() const
59 bool Okular::extractLilyPondSourceReference( const QString
&url
, QString
*file
, int *row
, int *col
)
61 if ( !url
.startsWith( QLatin1String( "textedit://" ) ) )
68 const IntPtr int_data
[] = { row
, &lilyChar
, col
};
69 int int_index
= sizeof( int_data
) / sizeof( int* ) - 1;
71 int index
= url
.lastIndexOf( QLatin1Char( ':' ), index_last
);
72 while ( index
!= -1 && int_index
>= 0 )
74 // read the current "chunk"
75 const QStringRef ref
= url
.midRef( index
+ 1, index_last
- index
- 1 );
76 *int_data
[ int_index
] = QString::fromRawData( ref
.data(), ref
.count() ).toInt();
77 // find the previous "chunk"
79 index
= url
.lastIndexOf( QLatin1Char( ':' ), index_last
- 1 );
82 // NOTE: 11 is the length of "textedit://"
83 *file
= url
.mid( 11, index_last
!= -1 ? index_last
- 11 : -1 );
87 QString
Okular::sourceReferenceToolTip( const QString
&source
, int row
, int col
)
91 return i18nc( "'source' is a source file", "Source: %1", source
);