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

kjots

  • sources
  • kde-4.12
  • kdepim
  • kjots
kjotsbrowser.cpp
Go to the documentation of this file.
1 //
2 // kjots
3 //
4 // Copyright (C) 1997 Christoph Neerfeld <Christoph.Neerfeld@home.ivm.de>
5 // Copyright (C) 2002, 2003 Aaron J. Seigo <aseigo@kde.org>
6 // Copyright (C) 2003 Stanislav Kljuhhin <crz@hot.ee>
7 // Copyright (C) 2005-2006 Jaison Lee <lee.jaison@gmail.com>
8 //
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 
24 //Own Header
25 #include "kjotsbrowser.h"
26 
27 #include <QTextDocument>
28 #include <QStackedWidget>
29 #include <QItemSelectionModel>
30 
31 #include <krun.h>
32 #include <kdebug.h>
33 #include <Akonadi/EntityTreeModel>
34 
35 KJotsBrowser::KJotsBrowser ( QItemSelectionModel *selectionModel, QWidget *parent )
36  : QTextBrowser(parent), m_itemSelectionModel( selectionModel )
37 {
38  setWordWrapMode(QTextOption::WordWrap);
39 }
40 
41 KJotsBrowser::~KJotsBrowser()
42 {
43 }
44 
45 void KJotsBrowser::delayedInitialization ()
46 {
47  connect(this, SIGNAL(anchorClicked(QUrl)), SLOT(linkClicked(QUrl)));
48 }
49 
53 void KJotsBrowser::linkClicked(const QUrl& link)
54 {
55  //Stop QTextBrowser from being stupid by giving it an invalid url.
56  QUrl url;
57  setSource(url);
58 
59  QString anchor = link.fragment();
60 
61  if ( link.toString().startsWith(QLatin1String("#")) && (anchor.startsWith( QLatin1String( "book_" ) )
62  || anchor.startsWith( QLatin1String( "page_" ) ) ) ) {
63  scrollToAnchor(anchor);
64  return;
65  }
66 
67  if ( link.scheme() == QLatin1String("kjots") ) {
68  const quint64 targetId = link.path().mid(1).toULongLong();
69  if (link.host().endsWith(QLatin1String("book"))) {
70  const QModelIndex colIndex = Akonadi::EntityTreeModel::modelIndexForCollection(m_itemSelectionModel->model(), Akonadi::Collection(targetId));
71  if (!colIndex.isValid())
72  return;
73  m_itemSelectionModel->select(colIndex, QItemSelectionModel::ClearAndSelect);
74  } else {
75  Q_ASSERT(link.host().endsWith(QLatin1String("page")));
76  const QModelIndexList itemIndexes = Akonadi::EntityTreeModel::modelIndexesForItem(m_itemSelectionModel->model(), Akonadi::Item(targetId));
77  if (itemIndexes.size() != 1)
78  return;
79  m_itemSelectionModel->select(itemIndexes.first(), QItemSelectionModel::ClearAndSelect);
80  }
81  } else {
82  new KRun ( link, this );
83  }
84 }
85 
86 #include "kjotsbrowser.moc"
87 /* ex: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab: */
88 /* kate: tab-indents off; replace-tabs on; tab-width 4; remove-trailing-space on; encoding utf-8;*/
KJotsBrowser::linkClicked
void linkClicked(const QUrl &)
Handle link clicks.
Definition: kjotsbrowser.cpp:53
QWidget
KJotsBrowser::~KJotsBrowser
virtual ~KJotsBrowser()
Definition: kjotsbrowser.cpp:41
KJotsBrowser::KJotsBrowser
KJotsBrowser(QItemSelectionModel *selectionModel, QWidget *)
Definition: kjotsbrowser.cpp:35
kjotsbrowser.h
QTextBrowser
KJotsBrowser::delayedInitialization
void delayedInitialization()
Definition: kjotsbrowser.cpp:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjots

Skip menu "kjots"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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