Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
6b0ddf4c
Commit
6b0ddf4c
authored
Nov 10, 2020
by
Alexander A. Maly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Astyled DocBookViewer
parent
51f174af
Pipeline
#2579
failed with stages
in 2 minutes and 4 seconds
Changes
24
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1951 additions
and
2059 deletions
+1951
-2059
src/kumir2-libs/docbookviewer/contentview.cpp
src/kumir2-libs/docbookviewer/contentview.cpp
+0
-1
src/kumir2-libs/docbookviewer/contentview.h
src/kumir2-libs/docbookviewer/contentview.h
+0
-1
src/kumir2-libs/docbookviewer/docbookfactory.cpp
src/kumir2-libs/docbookviewer/docbookfactory.cpp
+589
-668
src/kumir2-libs/docbookviewer/docbookfactory.h
src/kumir2-libs/docbookviewer/docbookfactory.h
+57
-61
src/kumir2-libs/docbookviewer/docbookmodel.cpp
src/kumir2-libs/docbookviewer/docbookmodel.cpp
+103
-103
src/kumir2-libs/docbookviewer/docbookmodel.h
src/kumir2-libs/docbookviewer/docbookmodel.h
+0
-3
src/kumir2-libs/docbookviewer/docbookview.cpp
src/kumir2-libs/docbookviewer/docbookview.cpp
+53
-52
src/kumir2-libs/docbookviewer/docbookview.h
src/kumir2-libs/docbookviewer/docbookview.h
+34
-35
src/kumir2-libs/docbookviewer/docbookview_impl.cpp
src/kumir2-libs/docbookviewer/docbookview_impl.cpp
+227
-230
src/kumir2-libs/docbookviewer/docbookview_impl.h
src/kumir2-libs/docbookviewer/docbookview_impl.h
+55
-62
src/kumir2-libs/docbookviewer/document.cpp
src/kumir2-libs/docbookviewer/document.cpp
+7
-7
src/kumir2-libs/docbookviewer/document.h
src/kumir2-libs/docbookviewer/document.h
+12
-11
src/kumir2-libs/docbookviewer/main.cpp
src/kumir2-libs/docbookviewer/main.cpp
+10
-14
src/kumir2-libs/docbookviewer/mainwindow.cpp
src/kumir2-libs/docbookviewer/mainwindow.cpp
+34
-36
src/kumir2-libs/docbookviewer/mainwindow.h
src/kumir2-libs/docbookviewer/mainwindow.h
+11
-9
src/kumir2-libs/docbookviewer/mathmlrenderer.cpp
src/kumir2-libs/docbookviewer/mathmlrenderer.cpp
+214
-217
src/kumir2-libs/docbookviewer/mathmlrenderer.h
src/kumir2-libs/docbookviewer/mathmlrenderer.h
+20
-20
src/kumir2-libs/docbookviewer/modeltype.h
src/kumir2-libs/docbookviewer/modeltype.h
+67
-66
src/kumir2-libs/docbookviewer/printdialog.cpp
src/kumir2-libs/docbookviewer/printdialog.cpp
+41
-40
src/kumir2-libs/docbookviewer/printdialog.h
src/kumir2-libs/docbookviewer/printdialog.h
+20
-16
src/kumir2-libs/docbookviewer/printrenderer.cpp
src/kumir2-libs/docbookviewer/printrenderer.cpp
+1
-0
src/kumir2-libs/docbookviewer/printrenderer.h
src/kumir2-libs/docbookviewer/printrenderer.h
+1
-3
src/kumir2-libs/docbookviewer/sidepanel.cpp
src/kumir2-libs/docbookviewer/sidepanel.cpp
+343
-355
src/kumir2-libs/docbookviewer/sidepanel.h
src/kumir2-libs/docbookviewer/sidepanel.h
+52
-49
No files found.
src/kumir2-libs/docbookviewer/contentview.cpp
View file @
6b0ddf4c
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
#include <kumir2/editorinterface.h>
#include <kumir2/editorinterface.h>
#include <kumir2-libs/widgets/iconprovider.h>
#include <kumir2-libs/widgets/iconprovider.h>
#include <QUrl>
#include <QMenu>
#include <QMenu>
#include <QScrollBar>
#include <QScrollBar>
#include <QApplication>
#include <QApplication>
...
...
src/kumir2-libs/docbookviewer/contentview.h
View file @
6b0ddf4c
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include "contentrenderer.h"
#include "contentrenderer.h"
#include <QtGlobal>
#include <QTextBrowser>
#include <QTextBrowser>
class
QMenu
;
class
QMenu
;
...
...
src/kumir2-libs/docbookviewer/docbookfactory.cpp
View file @
6b0ddf4c
This diff is collapsed.
Click to expand it.
src/kumir2-libs/docbookviewer/docbookfactory.h
View file @
6b0ddf4c
#ifndef DOCBOOKFACTORY_H
#ifndef DOCBOOKFACTORY_H
#define DOCBOOKFACTORY_H
#define DOCBOOKFACTORY_H
#include "docbookview.h"
#include "document.h"
#include "document.h"
#include "docbookmodel.h"
#include "docbookmodel.h"
// Qt includes
#include <QXmlDefaultHandler>
#include <QXmlDefaultHandler>
#include <QXmlSimpleReader>
#include <QUrl>
#ifdef DOCBOOKVIEWER_LIBRARY
#ifdef DOCBOOKVIEWER_LIBRARY
...
@@ -17,76 +13,76 @@
...
@@ -17,76 +13,76 @@
#define EXTERN Q_DECL_IMPORT
#define EXTERN Q_DECL_IMPORT
#endif
#endif
namespace
DocBookViewer
{
namespace
DocBookViewer
{
class
EXTERN
DocBookFactory
class
EXTERN
DocBookFactory
:
public
QXmlDefaultHandler
:
public
QXmlDefaultHandler
{
{
public:
public:
static
DocBookFactory
*
self
();
static
DocBookFactory
*
self
();
Document
parseDocument
(
const
QMap
<
ModelType
,
QString
>
roleValues
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
Document
parseDocument
(
const
QMap
<
ModelType
,
QString
>
roleValues
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
static
ModelPtr
createListOfEntries
(
ModelPtr
root
,
static
ModelPtr
createListOfEntries
(
ModelPtr
root
,
ModelType
resType
,
ModelType
resType
,
ModelType
findType
ModelType
findType
);
);
static
QMap
<
QString
,
ModelPtr
>
&
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfAlgorithms
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
updateListOfAlgorithms
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
static
QMap
<
QString
,
ModelPtr
>
&
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfKeywords
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
updateListOfKeywords
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
Document
createNamedSet
(
const
QString
&
name
,
const
QList
<
Document
>
documents
)
const
;
Document
createNamedSet
(
const
QString
&
name
,
const
QList
<
Document
>
documents
)
const
;
void
setConfigurationName
(
const
QString
&
configurationName
);
void
setConfigurationName
(
const
QString
&
configurationName
);
private
/*methods*/
:
private
/*methods*/
:
ModelPtr
parseDocument
(
ModelPtr
parseDocument
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
const
QMap
<
ModelType
,
QString
>
&
roles
,
QIODevice
*
stream
,
QIODevice
*
stream
,
const
QUrl
&
url
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
QString
*
error
=
0
)
const
;
explicit
DocBookFactory
();
explicit
DocBookFactory
();
bool
startDocument
();
bool
startDocument
();
bool
startElement
(
const
QString
&
namespaceURI
,
bool
startElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
localName
,
const
QString
&
qName
,
const
QString
&
qName
,
const
QXmlAttributes
&
atts
);
const
QXmlAttributes
&
atts
);
bool
characters
(
const
QString
&
ch
);
bool
characters
(
const
QString
&
ch
);
bool
skippedEntity
(
const
QString
&
name
);
bool
skippedEntity
(
const
QString
&
name
);
bool
endElement
(
const
QString
&
namespaceURI
,
bool
endElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
localName
,
const
QString
&
qName
);
const
QString
&
qName
);
bool
error
(
const
QXmlParseException
&
exception
);
bool
error
(
const
QXmlParseException
&
exception
);
bool
fatalError
(
const
QXmlParseException
&
exception
);
bool
fatalError
(
const
QXmlParseException
&
exception
);
bool
warning
(
const
QXmlParseException
&
exception
);
bool
warning
(
const
QXmlParseException
&
exception
);
void
filterByOs
(
ModelPtr
root
)
const
;
void
filterByOs
(
ModelPtr
root
)
const
;
void
filterByRoles
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
void
filterByRoles
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
ModelPtr
root
)
const
;
ModelPtr
root
)
const
;
void
filterByConfiguration
(
ModelPtr
root
)
const
;
void
filterByConfiguration
(
ModelPtr
root
)
const
;
static
QList
<
ModelPtr
>
findEntriesOfType
(
ModelPtr
root
,
static
QList
<
ModelPtr
>
findEntriesOfType
(
ModelPtr
root
,
ModelType
findType
ModelType
findType
);
);
static
QByteArray
loadAndPreprocessSvg
(
const
QString
&
fileName
);
static
QByteArray
loadAndPreprocessSvg
(
const
QString
&
fileName
);
static
QImage
loadAndPreprocessPng
(
const
QString
&
fileName
);
static
QImage
loadAndPreprocessPng
(
const
QString
&
fileName
);
private
/*fields*/
:
private
/*fields*/
:
mutable
QXmlSimpleReader
*
reader_
;
mutable
QXmlSimpleReader
*
reader_
;
mutable
ModelPtr
doc_
;
mutable
ModelPtr
doc_
;
mutable
QUrl
url_
;
mutable
QUrl
url_
;
mutable
QMap
<
ModelType
,
QString
>
roles_
;
mutable
QMap
<
ModelType
,
QString
>
roles_
;
ModelPtr
root_
;
ModelPtr
root_
;
QString
buffer_
;
QString
buffer_
;
QString
configurationName_
;
QString
configurationName_
;
};
};
...
...
src/kumir2-libs/docbookviewer/docbookmodel.cpp
View file @
6b0ddf4c
#include "docbookmodel.h"
#include "docbookmodel.h"
#include "contentrenderer.h"
#include <QImage>
#include <QPainter>
#include <QPainter>
namespace
DocBookViewer
{
namespace
DocBookViewer
{
DocBookModel
::
DocBookModel
(
ModelPtr
parent
,
const
ModelType
modelType
)
DocBookModel
::
DocBookModel
(
ModelPtr
parent
,
const
ModelType
modelType
)
:
parent_
(
parent
)
:
parent_
(
parent
)
,
modelType_
(
modelType
)
,
modelType_
(
modelType
)
,
sectionLevel_
(
0
)
,
sectionLevel_
(
0
)
{
{
updateSectionLevel
();
updateSectionLevel
();
}
}
quint8
DocBookModel
::
sectionLevel
()
const
quint8
DocBookModel
::
sectionLevel
()
const
{
{
return
sectionLevel_
;
return
sectionLevel_
;
}
}
ModelType
DocBookModel
::
modelType
()
const
ModelType
DocBookModel
::
modelType
()
const
{
{
return
modelType_
;
return
modelType_
;
}
}
const
QString
&
DocBookModel
::
id
()
const
const
QString
&
DocBookModel
::
id
()
const
{
{
return
id_
;
return
id_
;
}
}
const
QString
&
DocBookModel
::
title
()
const
const
QString
&
DocBookModel
::
title
()
const
{
{
return
title_
;
return
title_
;
}
}
QString
DocBookModel
::
titleAbbrev
()
const
QString
DocBookModel
::
titleAbbrev
()
const
{
{
if
(
titleAbbrev_
.
isEmpty
())
if
(
titleAbbrev_
.
isEmpty
())
{
return
title_
;
return
title_
;
else
}
else
{
return
titleAbbrev_
;
return
titleAbbrev_
;
}
}
}
const
QString
&
DocBookModel
::
subtitle
()
const
const
QString
&
DocBookModel
::
subtitle
()
const
{
{
return
subtitle_
;
return
subtitle_
;
}
}
const
QString
&
DocBookModel
::
text
()
const
const
QString
&
DocBookModel
::
text
()
const
{
{
return
text_
;
return
text_
;
}
}
const
QString
&
DocBookModel
::
role
()
const
const
QString
&
DocBookModel
::
role
()
const
{
{
return
role_
;
return
role_
;
}
}
const
QString
&
DocBookModel
::
xrefLinkEnd
()
const
const
QString
&
DocBookModel
::
xrefLinkEnd
()
const
{
{
return
xrefLinkEnd_
;
return
xrefLinkEnd_
;
}
}
const
QString
&
DocBookModel
::
xrefEndTerm
()
const
const
QString
&
DocBookModel
::
xrefEndTerm
()
const
{
{
return
xrefEndTerm_
;
return
xrefEndTerm_
;
}
}
const
QString
DocBookModel
::
format
()
const
const
QString
DocBookModel
::
format
()
const
{
{
return
format_
.
toLower
().
trimmed
();
return
format_
.
toLower
().
trimmed
();
}
}
const
QUrl
&
DocBookModel
::
href
()
const
const
QUrl
&
DocBookModel
::
href
()
const
{
{
return
href_
;
return
href_
;
}
}
ModelPtr
DocBookModel
::
parent
()
const
ModelPtr
DocBookModel
::
parent
()
const
{
{
return
parent_
;
return
parent_
;
}
}
ModelPtr
DocBookModel
::
indexParent
()
const
ModelPtr
DocBookModel
::
indexParent
()
const
{
{
return
indexParent_
;
return
indexParent_
;
}
}
ModelPtr
DocBookModel
::
findChildrenOfType
(
const
ModelType
modelType
)
const
ModelPtr
DocBookModel
::
findChildrenOfType
(
const
ModelType
modelType
)
const
{
{
ModelPtr
result
;
ModelPtr
result
;
foreach
(
ModelPtr
child
,
children_
)
{
foreach
(
ModelPtr
child
,
children_
)
{
if
(
modelType
==
child
->
modelType
())
{
if
(
modelType
==
child
->
modelType
())
{
result
=
child
;
result
=
child
;
}
}
else
{
else
{
result
=
child
->
findChildrenOfType
(
modelType
);
result
=
child
->
findChildrenOfType
(
modelType
);
}
}
if
(
result
)
{
if
(
result
)
break
;
break
;
}
}
return
result
;
}
return
result
;
}
}
const
QList
<
ModelPtr
>
&
DocBookModel
::
children
()
const
const
QList
<
ModelPtr
>
&
DocBookModel
::
children
()
const
{
{
return
children_
;
return
children_
;
}
}
ModelPtr
DocBookModel
::
self
()
const
ModelPtr
DocBookModel
::
self
()
const
{
{
ModelPtr
result
;
ModelPtr
result
;
if
(
parent
())
{
if
(
parent
())
{
foreach
(
ModelPtr
child
,
parent
()
->
children
())
{
foreach
(
ModelPtr
child
,
parent
()
->
children
())
{
if
(
child
.
data
()
==
this
)
{
if
(
child
.
data
()
==
this
)
{
result
=
child
;
result
=
child
;
break
;
break
;
}
}
}
}
}
}
if
(
!
result
)
foreach
(
ModelPtr
child
,
children
())
{
if
(
!
result
)
if
(
child
->
parent
().
data
()
==
this
)
{
foreach
(
ModelPtr
child
,
children
())
{
result
=
child
->
parent
();
if
(
child
->
parent
().
data
()
==
this
)
{
break
;
result
=
child
->
parent
();
}
break
;
}
}
return
result
;
}
return
result
;
}
}
bool
DocBookModel
::
isSectioningNode
()
const
bool
DocBookModel
::
isSectioningNode
()
const
{
{
if
(
title_
.
length
()
==
0
)
{
if
(
title_
.
length
()
==
0
)
{
return
false
;
return
false
;
}
}
else
if
(
modelType_
==
Section
)
{
else
if
(
modelType_
==
Section
)
{
return
sectionLevel_
<=
MAX_SECTION_LEVEL_IN_TOC
;
return
sectionLevel_
<=
MAX_SECTION_LEVEL_IN_TOC
;
}
else
{
}
return
else
{
modelType_
==
Book
||
return
modelType_
==
Book
||
modelType_
==
Article
||
modelType_
==
Article
||
modelType_
==
Set
||
modelType_
==
Set
||
modelType_
==
Chapter
||
modelType_
==
Chapter
||
modelType_
==
Preface
||
modelType_
==
Preface
||
modelType_
==
Reference
||
modelType_
==
Reference
||
modelType_
==
Abstract
;
modelType_
==
Abstract
;
}
}
}
}
void
DocBookModel
::
updateSectionLevel
()
void
DocBookModel
::
updateSectionLevel
()
{
{
if
(
modelType_
!=
Section
)
{
if
(
modelType_
!=
Section
)
{
sectionLevel_
=
0u
;
sectionLevel_
=
0u
;
}
}
else
{
else
{
ModelPtr
p
=
parent_
;
ModelPtr
p
=
parent_
;
sectionLevel_
=
1u
;
sectionLevel_
=
1u
;
while
(
p
&&
p
->
modelType_
==
Section
)
{
while
(
p
&&
p
->
modelType_
==
Section
)
{
p
=
p
->
parent
();
p
=
p
->
parent
();
sectionLevel_
++
;
sectionLevel_
++
;
}
}
}
}
foreach
(
ModelPtr
child
,
children_
)
{
foreach
(
ModelPtr
child
,
children_
)
{
child
->
updateSectionLevel
();
child
->
updateSectionLevel
();
}
}
}
}
const
QImage
&
DocBookModel
::
imageData
()
const
const
QImage
&
DocBookModel
::
imageData
()
const
{
{
if
(
svgRenderer_
&&
cachedImage_
.
isNull
())
{
if
(
svgRenderer_
&&
cachedImage_
.
isNull
())
{
const
QSize
size
=
svgRenderer_
->
defaultSize
();
const
QSize
size
=
svgRenderer_
->
defaultSize
();
QImage
img
(
size
,
QImage
::
Format_ARGB32
);
QImage
img
(
size
,
QImage
::
Format_ARGB32
);
img
.
fill
(
0
);
img
.
fill
(
0
);
QPainter
painter
(
&
img
);
QPainter
painter
(
&
img
);
svgRenderer_
->
render
(
&
painter
);
svgRenderer_
->
render
(
&
painter
);
cachedImage_
=
img
;
cachedImage_
=
img
;
}
}
return
cachedImage_
;
return
cachedImage_
;
}
}
}
}
src/kumir2-libs/docbookviewer/docbookmodel.h
View file @
6b0ddf4c
...
@@ -5,10 +5,7 @@
...
@@ -5,10 +5,7 @@
#include "modeltype.h"
#include "modeltype.h"
// Qt includes
// Qt includes
#include <QtGlobal>
#include <QString>
#include <QUrl>
#include <QUrl>
#include <QObject>
#include <QSharedPointer>
#include <QSharedPointer>
#include <QSvgRenderer>
#include <QSvgRenderer>
#include <QImage>
#include <QImage>
...
...
src/kumir2-libs/docbookviewer/docbookview.cpp
View file @
6b0ddf4c
...
@@ -4,144 +4,145 @@
...
@@ -4,144 +4,145 @@
#include <QResizeEvent>
#include <QResizeEvent>
#include <QDebug>
#include <QDebug>
namespace
DocBookViewer
{
namespace
DocBookViewer
{
DocBookView
::
DocBookView
(
QWidget
*
parent
)
DocBookView
::
DocBookView
(
QWidget
*
parent
)
:
QWidget
(
parent
)
:
QWidget
(
parent
)
,
pImpl_
(
new
DocBookViewImpl
(
this
))
,
pImpl_
(
new
DocBookViewImpl
(
this
))
{
{
}
}
void
DocBookView
::
updateSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QString
&
prefix
)
void
DocBookView
::
updateSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QString
&
prefix
)
{
{
pImpl_
->
updateSettings
(
settings
,
prefix
);
pImpl_
->
updateSettings
(
settings
,
prefix
);
}
}
void
DocBookView
::
closeEvent
(
QCloseEvent
*
event
)
void
DocBookView
::
closeEvent
(
QCloseEvent
*
event
)
{
{
if
(
pImpl_
->
settings_
)
{
if
(
pImpl_
->
settings_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
}
QWidget
::
closeEvent
(
event
);
QWidget
::
closeEvent
(
event
);
}
}
void
DocBookView
::
hideEvent
(
QHideEvent
*
event
)
void
DocBookView
::
hideEvent
(
QHideEvent
*
event
)
{
{
if
(
pImpl_
->
settings_
)
{
if
(
pImpl_
->
settings_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}