• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
sourcereference.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007,2008 by Pino Toscano <pino@kde.org> *
3  * *
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  ***************************************************************************/
9 
10 #include "sourcereference.h"
11 #include "sourcereference_p.h"
12 
13 #include <QtCore/QString>
14 #include <QtCore/QUrl>
15 #include <klocale.h>
16 
17 using namespace Okular;
18 
19 class SourceReference::Private
20 {
21  public:
22  Private()
23  : row( 0 ), column( 0 )
24  {
25  }
26 
27  QString filename;
28  int row;
29  int column;
30 };
31 
32 SourceReference::SourceReference( const QString &fileName, int row, int column )
33  : d( new Private )
34 {
35  d->filename = fileName;
36  d->row = row;
37  d->column = column;
38 }
39 
40 SourceReference::~SourceReference()
41 {
42  delete d;
43 }
44 
45 QString SourceReference::fileName() const
46 {
47  return d->filename;
48 }
49 
50 int SourceReference::row() const
51 {
52  return d->row;
53 }
54 
55 int SourceReference::column() const
56 {
57  return d->column;
58 }
59 
60 bool Okular::extractLilyPondSourceReference( const QString &url, QString *file, int *row, int *col )
61 {
62  if ( !url.startsWith( QLatin1String( "textedit://" ) ) )
63  return false;
64 
65  *row = 0;
66  *col = 0;
67  int lilyChar = 0;
68  typedef int *IntPtr;
69  const IntPtr int_data[] = { row, &lilyChar, col };
70  int int_index = sizeof( int_data ) / sizeof( int* ) - 1;
71  int index_last = -1;
72  int index = url.lastIndexOf( QLatin1Char( ':' ), index_last );
73  while ( index != -1 && int_index >= 0 )
74  {
75  // read the current "chunk"
76  const QStringRef ref = url.midRef( index + 1, index_last - index - 1 );
77  *int_data[ int_index ] = QString::fromRawData( ref.data(), ref.count() ).toInt();
78  // find the previous "chunk"
79  index_last = index;
80  index = url.lastIndexOf( QLatin1Char( ':' ), index_last - 1 );
81  --int_index;
82  }
83  // NOTE: 11 is the length of "textedit://"
84  *file = QUrl::fromPercentEncoding( url.mid( 11, index_last != -1 ? index_last - 11 : -1 ).toUtf8() );
85  return true;
86 }
87 
88 QString Okular::sourceReferenceToolTip( const QString &source, int row, int col )
89 {
90  Q_UNUSED( row );
91  Q_UNUSED( col );
92  return i18nc( "'source' is a source file", "Source: %1", source );
93 }
Okular::SourceReference::~SourceReference
~SourceReference()
Destroys the source reference.
Definition: sourcereference.cpp:40
Okular::SourceReference::SourceReference
SourceReference(const QString &fileName, int row, int column=0)
Creates a reference to the row row and column column of the source fileName.
Definition: sourcereference.cpp:32
Okular::SourceReference::column
int column() const
Returns the column of the position in the source file.
Definition: sourcereference.cpp:55
Okular::sourceReferenceToolTip
QString sourceReferenceToolTip(const QString &source, int row, int col)
Definition: sourcereference.cpp:88
Okular::SourceReference::fileName
QString fileName() const
Returns the filename of the source.
Definition: sourcereference.cpp:45
sourcereference.h
Okular::extractLilyPondSourceReference
bool extractLilyPondSourceReference(const QString &url, QString *file, int *row, int *col)
Definition: sourcereference.cpp:60
sourcereference_p.h
Okular::SourceReference::row
int row() const
Returns the row of the position in the source file.
Definition: sourcereference.cpp:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal