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 @@
#include <kumir2/editorinterface.h>
#include <kumir2-libs/widgets/iconprovider.h>
#include <QUrl>
#include <QMenu>
#include <QScrollBar>
#include <QApplication>
...
...
src/kumir2-libs/docbookviewer/contentview.h
View file @
6b0ddf4c
...
...
@@ -3,7 +3,6 @@
#include "contentrenderer.h"
#include <QtGlobal>
#include <QTextBrowser>
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
#define DOCBOOKFACTORY_H
#include "docbookview.h"
#include "document.h"
#include "docbookmodel.h"
// Qt includes
#include <QXmlDefaultHandler>
#include <QXmlSimpleReader>
#include <QUrl>
#ifdef DOCBOOKVIEWER_LIBRARY
...
...
@@ -17,76 +13,76 @@
#define EXTERN Q_DECL_IMPORT
#endif
namespace
DocBookViewer
{
namespace
DocBookViewer
{
class
EXTERN
DocBookFactory
:
public
QXmlDefaultHandler
class
EXTERN
DocBookFactory
:
public
QXmlDefaultHandler
{
public:
static
DocBookFactory
*
self
();
Document
parseDocument
(
const
QMap
<
ModelType
,
QString
>
roleValues
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
static
ModelPtr
createListOfEntries
(
ModelPtr
root
,
ModelType
resType
,
ModelType
findType
);
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfAlgorithms
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
static
DocBookFactory
*
self
();
Document
parseDocument
(
const
QMap
<
ModelType
,
QString
>
roleValues
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
static
ModelPtr
createListOfEntries
(
ModelPtr
root
,
ModelType
resType
,
ModelType
findType
);
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfAlgorithms
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfKeywords
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
static
QMap
<
QString
,
ModelPtr
>
&
updateListOfKeywords
(
ModelPtr
root
,
QMap
<
QString
,
ModelPtr
>
&
result
);
Document
createNamedSet
(
const
QString
&
name
,
const
QList
<
Document
>
documents
)
const
;
void
setConfigurationName
(
const
QString
&
configurationName
);
Document
createNamedSet
(
const
QString
&
name
,
const
QList
<
Document
>
documents
)
const
;
void
setConfigurationName
(
const
QString
&
configurationName
);
private
/*methods*/
:
ModelPtr
parseDocument
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
QIODevice
*
stream
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
explicit
DocBookFactory
();
bool
startDocument
();
bool
startElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
qName
,
const
QXmlAttributes
&
atts
);
bool
characters
(
const
QString
&
ch
);
bool
skippedEntity
(
const
QString
&
name
);
bool
endElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
qName
);
bool
error
(
const
QXmlParseException
&
exception
);
bool
fatalError
(
const
QXmlParseException
&
exception
);
bool
warning
(
const
QXmlParseException
&
exception
);
void
filterByOs
(
ModelPtr
root
)
const
;
void
filterByRoles
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
ModelPtr
root
)
const
;
void
filterByConfiguration
(
ModelPtr
root
)
const
;
static
QList
<
ModelPtr
>
findEntriesOfType
(
ModelPtr
root
,
ModelType
findType
);
static
QByteArray
loadAndPreprocessSvg
(
const
QString
&
fileName
);
static
QImage
loadAndPreprocessPng
(
const
QString
&
fileName
);
ModelPtr
parseDocument
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
QIODevice
*
stream
,
const
QUrl
&
url
,
QString
*
error
=
0
)
const
;
explicit
DocBookFactory
();
bool
startDocument
();
bool
startElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
qName
,
const
QXmlAttributes
&
atts
);
bool
characters
(
const
QString
&
ch
);
bool
skippedEntity
(
const
QString
&
name
);
bool
endElement
(
const
QString
&
namespaceURI
,
const
QString
&
localName
,
const
QString
&
qName
);
bool
error
(
const
QXmlParseException
&
exception
);
bool
fatalError
(
const
QXmlParseException
&
exception
);
bool
warning
(
const
QXmlParseException
&
exception
);
void
filterByOs
(
ModelPtr
root
)
const
;
void
filterByRoles
(
const
QMap
<
ModelType
,
QString
>
&
roles
,
ModelPtr
root
)
const
;
void
filterByConfiguration
(
ModelPtr
root
)
const
;
static
QList
<
ModelPtr
>
findEntriesOfType
(
ModelPtr
root
,
ModelType
findType
);
static
QByteArray
loadAndPreprocessSvg
(
const
QString
&
fileName
);
static
QImage
loadAndPreprocessPng
(
const
QString
&
fileName
);
private
/*fields*/
:
mutable
QXmlSimpleReader
*
reader_
;
mutable
ModelPtr
doc_
;
mutable
QUrl
url_
;
mutable
QMap
<
ModelType
,
QString
>
roles_
;
ModelPtr
root_
;
QString
buffer_
;
QString
configurationName_
;
mutable
QXmlSimpleReader
*
reader_
;
mutable
ModelPtr
doc_
;
mutable
QUrl
url_
;
mutable
QMap
<
ModelType
,
QString
>
roles_
;
ModelPtr
root_
;
QString
buffer_
;
QString
configurationName_
;
};
...
...
src/kumir2-libs/docbookviewer/docbookmodel.cpp
View file @
6b0ddf4c
#include "docbookmodel.h"
#include "contentrenderer.h"
#include <QImage>
#include <QPainter>
namespace
DocBookViewer
{
namespace
DocBookViewer
{
DocBookModel
::
DocBookModel
(
ModelPtr
parent
,
const
ModelType
modelType
)
:
parent_
(
parent
)
,
modelType_
(
modelType
)
,
sectionLevel_
(
0
)
:
parent_
(
parent
)
,
modelType_
(
modelType
)
,
sectionLevel_
(
0
)
{
updateSectionLevel
();
updateSectionLevel
();
}
quint8
DocBookModel
::
sectionLevel
()
const
{
return
sectionLevel_
;
return
sectionLevel_
;
}
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
{
if
(
titleAbbrev_
.
isEmpty
())
return
title_
;
else
return
titleAbbrev_
;
if
(
titleAbbrev_
.
isEmpty
())
{
return
title_
;
}
else
{
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
{
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
{
return
parent_
;
return
parent_
;
}
ModelPtr
DocBookModel
::
indexParent
()
const
{
return
indexParent_
;
return
indexParent_
;
}
ModelPtr
DocBookModel
::
findChildrenOfType
(
const
ModelType
modelType
)
const
{
ModelPtr
result
;
foreach
(
ModelPtr
child
,
children_
)
{
if
(
modelType
==
child
->
modelType
())
{
result
=
child
;
}
else
{
result
=
child
->
findChildrenOfType
(
modelType
);
}
if
(
result
)
break
;
}
return
result
;
ModelPtr
result
;
foreach
(
ModelPtr
child
,
children_
)
{
if
(
modelType
==
child
->
modelType
())
{
result
=
child
;
}
else
{
result
=
child
->
findChildrenOfType
(
modelType
);
}
if
(
result
)
{
break
;
}
}
return
result
;
}
const
QList
<
ModelPtr
>
&
DocBookModel
::
children
()
const
const
QList
<
ModelPtr
>
&
DocBookModel
::
children
()
const
{
return
children_
;
return
children_
;
}
ModelPtr
DocBookModel
::
self
()
const
{
ModelPtr
result
;
if
(
parent
())
{
foreach
(
ModelPtr
child
,
parent
()
->
children
())
{
if
(
child
.
data
()
==
this
)
{
result
=
child
;
break
;
}
}
}
if
(
!
result
)
foreach
(
ModelPtr
child
,
children
())
{
if
(
child
->
parent
().
data
()
==
this
)
{
result
=
child
->
parent
();
break
;
}
}
return
result
;
ModelPtr
result
;
if
(
parent
())
{
foreach
(
ModelPtr
child
,
parent
()
->
children
())
{
if
(
child
.
data
()
==
this
)
{
result
=
child
;
break
;
}
}
}
if
(
!
result
)
foreach
(
ModelPtr
child
,
children
())
{
if
(
child
->
parent
().
data
()
==
this
)
{
result
=
child
->
parent
();
break
;
}
}
return
result
;
}
bool
DocBookModel
::
isSectioningNode
()
const
{
if
(
title_
.
length
()
==
0
)
{
return
false
;
}
else
if
(
modelType_
==
Section
)
{
return
sectionLevel_
<=
MAX_SECTION_LEVEL_IN_TOC
;
}
else
{
return
modelType_
==
Book
||
modelType_
==
Article
||
modelType_
==
Set
||
modelType_
==
Chapter
||
modelType_
==
Preface
||
modelType_
==
Reference
||
modelType_
==
Abstract
;
}
if
(
title_
.
length
()
==
0
)
{
return
false
;
}
else
if
(
modelType_
==
Section
)
{
return
sectionLevel_
<=
MAX_SECTION_LEVEL_IN_TOC
;
}
else
{
return
modelType_
==
Book
||
modelType_
==
Article
||
modelType_
==
Set
||
modelType_
==
Chapter
||
modelType_
==
Preface
||
modelType_
==
Reference
||
modelType_
==
Abstract
;
}
}
void
DocBookModel
::
updateSectionLevel
()
{
if
(
modelType_
!=
Section
)
{
sectionLevel_
=
0u
;
}
else
{
ModelPtr
p
=
parent_
;
sectionLevel_
=
1u
;
while
(
p
&&
p
->
modelType_
==
Section
)
{
p
=
p
->
parent
();
sectionLevel_
++
;
}
}
foreach
(
ModelPtr
child
,
children_
)
{
child
->
updateSectionLevel
();
}
}
const
QImage
&
DocBookModel
::
imageData
()
const
{
if
(
svgRenderer_
&&
cachedImage_
.
isNull
())
{
const
QSize
size
=
svgRenderer_
->
defaultSize
();
QImage
img
(
size
,
QImage
::
Format_ARGB32
);
img
.
fill
(
0
);
QPainter
painter
(
&
img
);
svgRenderer_
->
render
(
&
painter
);
cachedImage_
=
img
;
}
return
cachedImage_
;
if
(
modelType_
!=
Section
)
{
sectionLevel_
=
0u
;
}
else
{
ModelPtr
p
=
parent_
;
sectionLevel_
=
1u
;
while
(
p
&&
p
->
modelType_
==
Section
)
{
p
=
p
->
parent
();
sectionLevel_
++
;
}
}
foreach
(
ModelPtr
child
,
children_
)
{
child
->
updateSectionLevel
();
}
}
const
QImage
&
DocBookModel
::
imageData
()
const
{
if
(
svgRenderer_
&&
cachedImage_
.
isNull
())
{
const
QSize
size
=
svgRenderer_
->
defaultSize
();
QImage
img
(
size
,
QImage
::
Format_ARGB32
);
img
.
fill
(
0
);
QPainter
painter
(
&
img
);
svgRenderer_
->
render
(
&
painter
);
cachedImage_
=
img
;
}
return
cachedImage_
;
}
}
src/kumir2-libs/docbookviewer/docbookmodel.h
View file @
6b0ddf4c
...
...
@@ -5,10 +5,7 @@
#include "modeltype.h"
// Qt includes
#include <QtGlobal>
#include <QString>
#include <QUrl>
#include <QObject>
#include <QSharedPointer>
#include <QSvgRenderer>
#include <QImage>
...
...
src/kumir2-libs/docbookviewer/docbookview.cpp
View file @
6b0ddf4c
...
...
@@ -4,144 +4,145 @@
#include <QResizeEvent>
#include <QDebug>
namespace
DocBookViewer
{
namespace
DocBookViewer
{
DocBookView
::
DocBookView
(
QWidget
*
parent
)
:
QWidget
(
parent
)
,
pImpl_
(
new
DocBookViewImpl
(
this
))
:
QWidget
(
parent
)
,
pImpl_
(
new
DocBookViewImpl
(
this
))
{
}
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_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
closeEvent
(
event
);
if
(
pImpl_
->
settings_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
closeEvent
(
event
);
}
void
DocBookView
::
hideEvent
(
QHideEvent
*
event
)
void
DocBookView
::
hideEvent
(
QHideEvent
*
event
)
{
if
(
pImpl_
->
settings_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
hideEvent
(
event
);
if
(
pImpl_
->
settings_
)
{
pImpl_
->
saveState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
hideEvent
(
event
);
}
void
DocBookView
::
showEvent
(
QShowEvent
*
event
)
void
DocBookView
::
showEvent
(
QShowEvent
*
event
)
{
if
(
pImpl_
->
settings_
)
{
pImpl_
->
restoreState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
showEvent
(
event
);
if
(
pImpl_
->
settings_
)
{
pImpl_
->
restoreState
(
pImpl_
->
settings_
,
pImpl_
->
settingsPrefix_
);
}
QWidget
::
showEvent
(
event
);
}
void
DocBookView
::
resizeEvent
(
QResizeEvent
*
event
)
void
DocBookView
::
resizeEvent
(
QResizeEvent
*
event
)
{
if
(
event
->
size
().
width
()
<
minimumWidth
()
||
event
->
size
().
height
()
<
minimumHeight
())
{
event
->
ignore
();
}
else
{
event
->
accept
();
pImpl_
->
setSize
(
event
->
size
());
}
if
(
event
->
size
().
width
()
<
minimumWidth
()
||
event
->
size
().
height
()
<
minimumHeight
())
{
event
->
ignore
();
}
else
{
event
->
accept
();
pImpl_
->
setSize
(
event
->
size
());
}
}
DocBookView
::~
DocBookView
()
{
delete
pImpl_
;
delete
pImpl_
;
}
QAction
*
DocBookView
::
viewerAction
(
const
DocBookViewAction
type
)
const
QAction
*
DocBookView
::
viewerAction
(
const
DocBookViewAction
type
)
const
{
return
pImpl_
->
viewerAction
(
type
);
return
pImpl_
->
viewerAction
(
type
);
}
Document
DocBookView
::
addDocument
(
const
QUrl
&
url
,
QString
*
error
)
{
return
pImpl_
->
addDocument
(
url
,
error
);
return
pImpl_
->
addDocument
(
url
,
error
);
}
Document
DocBookView
::
addDocuments
(
const
QString
&
groupName
,
const
QList
<
QUrl
>
&
urls
,
QString
*
error
)
{
return
pImpl_
->
addDocuments
(
groupName
,
urls
,
error
);
return
pImpl_
->
addDocuments
(
groupName
,
urls
,
error
);
}
void
DocBookView
::
removeDocument
(
const
Document
&
existingDocument
)
void
DocBookView
::
removeDocument
(
const
Document
&
existingDocument
)
{
pImpl_
->
removeDocument
(
existingDocument
);
pImpl_
->
removeDocument
(
existingDocument
);
}
QSize
DocBookView
::
minimumSizeHint
()
const
{
return
pImpl_
->
minimumSizeHint
();
return
pImpl_
->
minimumSizeHint
();
}
QSize
DocBookView
::
sizeHint
()
const
{
return
pImpl_
->
sizeHint
();
return
pImpl_
->
sizeHint
();