Commit c847e2e7 authored by Alexander A. Maly's avatar Alexander A. Maly

Cleaning warnings

parent e0871f48
Pipeline #2514 failed with stages
in 2 minutes and 8 seconds
#include <QtCore>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QDateTime>
#include <QDebug>
#include <QMessageBox>
#include <QTranslator>
#include <QDir>
#include <QIcon>
#include <QPainter>
#include <QSplashScreen>
#include <QApplication>
#include <kumir2-libs/extensionsystem/pluginmanager.h>
#include <kumir2-libs/extensionsystem/logger.h>
......@@ -126,7 +129,7 @@ QList<QDir> translationsDirs()
class Application : QObject
{
public:
inline explicit Application(int &argc, char **argv, bool gui)
explicit Application(int &argc, char **argv, bool gui)
: QObject()
, _qApp(0)
, _timerId(-1)
......@@ -141,14 +144,14 @@ public:
_qApp->installEventFilter(this);
}
inline void setSplashScreen(QSplashScreen *s)
void setSplashScreen(QSplashScreen *s)
{
_splashScreen = s;
}
inline void initialize()
void initialize()
{
const QStringList arguments = _qApp->arguments();
QStringList arguments = _qApp->arguments();
qDebug() << "Arguments: " << arguments;
bool mustShowHelpAndExit = false;
bool mustShowVersionAndExit = false;
......@@ -284,7 +287,7 @@ public:
}
}
inline bool eventFilter(QObject *obj, QEvent *event)
bool eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Timer && obj == _qApp && !_started) {
_started = true;
......@@ -298,7 +301,7 @@ public:
}
}
inline int main()
int main()
{
_timerId = _qApp->startTimer(250);
int ret = _qApp->exec();
......@@ -433,7 +436,10 @@ int main(int argc, char **argv)
}
}
const bool customAppAndVendorInformation = setup_custom_vendor_information(qobject_cast<QCoreApplication *>(qApp));
bool customAppAndVendorInformation = setup_custom_vendor_information(qobject_cast<QCoreApplication *>(qApp));
Q_UNUSED(mustShowHelpAndExit);
Q_UNUSED(mustShowVersionAndExit);
Q_UNUSED(customAppAndVendorInformation);
#ifdef SPLASHSCREEN
......
......@@ -3,16 +3,18 @@
#include <QSharedPointer>
namespace DocBookViewer {
namespace DocBookViewer
{
typedef QSharedPointer<class DocBookModel> ModelPtr;
class DocBookModel;
typedef QSharedPointer<DocBookModel> ModelPtr;
class ContentRenderer
{
public:
virtual bool isEmpty() const = 0;
virtual void reset() = 0;
virtual void renderData(ModelPtr data) = 0;
virtual bool isEmpty() const = 0;
virtual void reset() = 0;
virtual void renderData(ModelPtr data) = 0;
};
}
......
......@@ -5,154 +5,151 @@
#include <QtGlobal>
#include <QTextBrowser>
#include <QSharedPointer>
#include <QResizeEvent>
#include <QWheelEvent>
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
namespace DocBookViewer {
class QMenu;
class QAction;
class QResizeEvent;
class QWheelEvent;
class QContextMenuEvent;
namespace DocBookViewer
{
typedef QSharedPointer<class DocBookModel> ModelPtr;
class ContentView
: public QTextBrowser
, public ContentRenderer
class ContentView :
public QTextBrowser,
public ContentRenderer
{
Q_OBJECT
Q_OBJECT
public:
explicit ContentView(QWidget * parent);
bool isEmpty() const;
void reset();
void renderData(ModelPtr data);
QSize minimumSizeHint() const;
explicit ContentView(QWidget *parent);
bool isEmpty() const;
void reset();
void renderData(ModelPtr data);
QSize minimumSizeHint() const;
signals:
void itemRequest(ModelPtr model);
void itemRequest(ModelPtr model);
private:
void resizeEvent(QResizeEvent *e);
void wheelEvent(QWheelEvent *e);
void contextMenuEvent(QContextMenuEvent *e);
QString codeFontSize() const;
QString codeFontFamily() const;
QString wrapHTML(const QString & body) const;
QString renderModel(ModelPtr data) const;
QString renderElement(ModelPtr data) const;
QString renderSet(ModelPtr data) const;
QString renderChapter(ModelPtr data) const;
QString renderArticle(ModelPtr data) const;
QString renderAbstract(ModelPtr data, bool wrapInDivClassAbstract) const;
QString renderTOC(ModelPtr data) const;
QString renderTOCElement(ModelPtr data, quint8 level, bool enumerate) const;
QString renderPlainPage(ModelPtr data) const;
QString renderOrderedList(ModelPtr data) const;
QString renderItemizedList(ModelPtr data) const;
QString renderListItem(ModelPtr data) const;
QString renderParagraph(ModelPtr data) const;
QString renderEmphasis(ModelPtr data) const;
QString renderText(ModelPtr data) const;
QString normalizeText(QString text) const;
QString renderExample(ModelPtr data) const;
QString renderChilds(ModelPtr data) const;
QString renderSection(ModelPtr data) const;
QString renderXref(ModelPtr data) const;
QString renderProgramListing(ModelPtr data) const;
QString renderCode(ModelPtr data) const;
QString renderKeyCombo(ModelPtr data) const;
QString renderKeySym(ModelPtr data) const;
QString renderGuiMenu(ModelPtr data) const;
QString renderGuiMenuItem(ModelPtr data) const;
QString renderGuiButton(ModelPtr data) const;
QString renderSubscript(ModelPtr data) const;
QString renderSuperscript(ModelPtr data) const;
static QString& wrapInlineElement(ModelPtr data, QString & result,
bool left, bool right);
QString renderInformalTable(ModelPtr data) const;
QString renderTable(ModelPtr data) const;
QString renderTableContent(ModelPtr data) const;
QString renderTHead(ModelPtr data) const;
QString renderTBody(ModelPtr data) const;
QString renderRow(ModelPtr data) const;
QString renderEntry(ModelPtr data) const;
QString renderCaption(ModelPtr data, const QString &captionPrefix) const;
QString renderMediaObject(ModelPtr data) const;
QString renderInlineMediaObject(ModelPtr data) const;
QString renderImageObject(ModelPtr data) const;
QString renderFuncSynopsys(ModelPtr data) const;
QString renderFuncSynopsysInfo(ModelPtr data) const;
QString renderFuncPrototype(ModelPtr data) const;
QString renderFuncDef(ModelPtr data) const;
QString renderFunction(ModelPtr data) const;
QString renderParamDef(ModelPtr data) const;
QString renderParameter(ModelPtr data) const;
QString renderType(ModelPtr data) const;
QString renderListOfExamples(ModelPtr data) const;
QString renderListOfFunctions(ModelPtr data) const;
QString renderListOfTables(ModelPtr data) const;
QString renderMathML(ModelPtr data) const;
bool isPlainPage(ModelPtr data) const;
ModelPtr topLevelModel(ModelPtr data) const;
ModelPtr onePageParentModel(ModelPtr data) const;
ModelPtr findModelById(ModelPtr top, const QString & modelId) const;
ModelPtr findImageData(ModelPtr parent) const;
QString modelToLink(ModelPtr data) const;
ModelPtr findModelByRawPtr(quintptr raw) const;
ModelPtr findModelByRawPtr(ModelPtr root, quintptr raw) const;
QString renderItemContextLink(ModelPtr data) const;
static quint16 chapterNumber(ModelPtr data);
static quint16 elementNumber(ModelPtr data);
static quint16 indexInParent(ModelPtr data);
static quint16 countOfElements(ModelPtr root, ModelPtr until, bool &stop);
static QString sectionNumber(ModelPtr data);
bool hasModelOnThisPage(ModelPtr data) const;
bool hasChild(ModelPtr who, ModelPtr child) const;
static QString formatProgramSourceText(
const QString &source,
const QStringList &keywords,
const QString & inlineCommentSymbol,
const QString & multilineCommentStartSymbol,
const QString & multilineCommentEndSymbol
);
static QString programTextForLanguage(const QString &source,
const QString &language);
QVariant loadResource(int type, const QUrl &name);
void resizeEvent(QResizeEvent *e);
void wheelEvent(QWheelEvent *e);
void contextMenuEvent(QContextMenuEvent *e);
QString codeFontSize() const;
QString codeFontFamily() const;
QString wrapHTML(const QString &body) const;
QString renderModel(ModelPtr data) const;
QString renderElement(ModelPtr data) const;
QString renderSet(ModelPtr data) const;
QString renderChapter(ModelPtr data) const;
QString renderArticle(ModelPtr data) const;
QString renderAbstract(ModelPtr data, bool wrapInDivClassAbstract) const;
QString renderTOC(ModelPtr data) const;
QString renderTOCElement(ModelPtr data, quint8 level, bool enumerate) const;
QString renderPlainPage(ModelPtr data) const;
QString renderOrderedList(ModelPtr data) const;
QString renderItemizedList(ModelPtr data) const;
QString renderListItem(ModelPtr data) const;
QString renderParagraph(ModelPtr data) const;
QString renderEmphasis(ModelPtr data) const;
QString renderText(ModelPtr data) const;
QString normalizeText(QString text) const;
QString renderExample(ModelPtr data) const;
QString renderChilds(ModelPtr data) const;
QString renderSection(ModelPtr data) const;
QString renderXref(ModelPtr data) const;
QString renderProgramListing(ModelPtr data) const;
QString renderCode(ModelPtr data) const;
QString renderKeyCombo(ModelPtr data) const;
QString renderKeySym(ModelPtr data) const;
QString renderGuiMenu(ModelPtr data) const;
QString renderGuiMenuItem(ModelPtr data) const;
QString renderGuiButton(ModelPtr data) const;
QString renderSubscript(ModelPtr data) const;
QString renderSuperscript(ModelPtr data) const;
static QString &wrapInlineElement(
ModelPtr data, QString &result,
bool left, bool right
);
QString renderInformalTable(ModelPtr data) const;
QString renderTable(ModelPtr data) const;
QString renderTableContent(ModelPtr data) const;
QString renderTHead(ModelPtr data) const;
QString renderTBody(ModelPtr data) const;
QString renderRow(ModelPtr data) const;
QString renderEntry(ModelPtr data) const;
QString renderCaption(ModelPtr data, const QString &captionPrefix) const;
QString renderMediaObject(ModelPtr data) const;
QString renderInlineMediaObject(ModelPtr data) const;
QString renderImageObject(ModelPtr data) const;
QString renderFuncSynopsys(ModelPtr data) const;
QString renderFuncSynopsysInfo(ModelPtr data) const;
QString renderFuncPrototype(ModelPtr data) const;
QString renderFuncDef(ModelPtr data) const;
QString renderFunction(ModelPtr data) const;
QString renderParamDef(ModelPtr data) const;
QString renderParameter(ModelPtr data) const;
QString renderType(ModelPtr data) const;
QString renderListOfExamples(ModelPtr data) const;
QString renderListOfFunctions(ModelPtr data) const;
QString renderListOfTables(ModelPtr data) const;
QString renderMathML(ModelPtr data) const;
bool isPlainPage(ModelPtr data) const;
ModelPtr topLevelModel(ModelPtr data) const;
ModelPtr onePageParentModel(ModelPtr data) const;
ModelPtr findModelById(ModelPtr top, const QString &modelId) const;
ModelPtr findImageData(ModelPtr parent) const;
QString modelToLink(ModelPtr data) const;
ModelPtr findModelByRawPtr(quintptr raw) const;
ModelPtr findModelByRawPtr(ModelPtr root, quintptr raw) const;
QString renderItemContextLink(ModelPtr data) const;
static quint16 chapterNumber(ModelPtr data);
static quint16 elementNumber(ModelPtr data);
static quint16 indexInParent(ModelPtr data);
static quint16 countOfElements(ModelPtr root, ModelPtr until, bool &stop);
static QString sectionNumber(ModelPtr data);
bool hasModelOnThisPage(ModelPtr data) const;
bool hasChild(ModelPtr who, ModelPtr child) const;
static QString formatProgramSourceText(
const QString &source,
const QStringList &keywords,
const QString &inlineCommentSymbol,
const QString &multilineCommentStartSymbol,
const QString &multilineCommentEndSymbol
);
static QString programTextForLanguage(const QString &source,
const QString &language);
QVariant loadResource(int type, const QUrl &name);
private /*fields*/:
ModelPtr loadedModel_;
QUrl lastAnchorUrl_;
bool ignoreClearAnchorUrl_;
ModelPtr loadedModel_;
QUrl lastAnchorUrl_;
bool ignoreClearAnchorUrl_;
static bool ExtraFontsLoaded_;
QMenu * contextMenu_;
QAction * actionCopyToClipboard_;
static bool ExtraFontsLoaded_;
QMenu *contextMenu_;
QAction *actionCopyToClipboard_;
private slots:
void clearLastAnchorUrl();
void handleInternalLink(const QUrl & url);
void clearLastAnchorUrl();
void handleInternalLink(const QUrl &url);
};
}
} // namespace DocBookViewer
#endif
......@@ -19,7 +19,8 @@
#define EXTERN Q_DECL_IMPORT
#endif
namespace DocBookViewer {
namespace DocBookViewer
{
static const quint8 MAX_SECTION_LEVEL_IN_TOC = 2u;
typedef QSharedPointer<class DocBookModel> ModelPtr;
......@@ -28,72 +29,72 @@ typedef QSharedPointer<QSvgRenderer> SvgRendererPtr;
class EXTERN DocBookModel
{
friend class DocBookFactory;
friend class MathMLRenderer;
public:
quint8 sectionLevel() const;
ModelType modelType() const;
const QString & id() const;
const QString & title() const;
QString titleAbbrev() const;
const QString & subtitle() const;
const QString & text() const;
const QString & role() const;
const QString & xrefLinkEnd() const;
const QString & xrefEndTerm() const;
const QUrl & href() const;
const QString format() const;
ModelPtr parent() const;
ModelPtr indexParent() const;
const QList<ModelPtr>& children() const;
bool isSectioningNode() const;
const QImage& imageData() const;
ModelPtr self() const;
ModelPtr findChildrenOfType(const ModelType modelType) const;
friend class DocBookFactory;
friend class MathMLRenderer;
public:
quint8 sectionLevel() const;
ModelType modelType() const;
const QString &id() const;
const QString &title() const;
QString titleAbbrev() const;
const QString &subtitle() const;
const QString &text() const;
const QString &role() const;
const QString &xrefLinkEnd() const;
const QString &xrefEndTerm() const;
const QUrl &href() const;
const QString format() const;
ModelPtr parent() const;
ModelPtr indexParent() const;
const QList<ModelPtr> &children() const;
bool isSectioningNode() const;
const QImage &imageData() const;
ModelPtr self() const;
ModelPtr findChildrenOfType(const ModelType modelType) const;
protected /*methods*/:
explicit DocBookModel(ModelPtr parent, const ModelType modelType);
void updateSectionLevel();
explicit DocBookModel(ModelPtr parent, const ModelType modelType);
void updateSectionLevel();
protected /*fields*/:
ModelPtr parent_;
ModelPtr indexParent_;
QList<ModelPtr> children_;
ModelType modelType_;
unsigned short sectionLevel_;
QString title_;
QString titleAbbrev_;
QString subtitle_;
QString text_;
QString id_;
QString os_;
QString configuration_;
QString xrefLinkEnd_;
QString xrefEndTerm_;
QString role_;
QUrl href_;
QString format_;
mutable SvgRendererPtr svgRenderer_;
mutable QImage cachedImage_;
ModelPtr parent_;
ModelPtr indexParent_;
QList<ModelPtr> children_;
ModelType modelType_;
unsigned short sectionLevel_;
QString title_;
QString titleAbbrev_;
QString subtitle_;
QString text_;
QString id_;
QString os_;
QString configuration_;
QString xrefLinkEnd_;
QString xrefEndTerm_;
QString role_;
QUrl href_;
QString format_;
mutable SvgRendererPtr svgRenderer_;
mutable QImage cachedImage_;
};
}
inline bool operator==(const DocBookViewer::ModelPtr & model,
DocBookViewer::ModelType type)
inline bool operator==(const DocBookViewer::ModelPtr &model,
DocBookViewer::ModelType type)
{
return model && model->modelType() == type;
return model && model->modelType() == type;
}
inline bool operator!=(const DocBookViewer::ModelPtr & model,
DocBookViewer::ModelType type)
inline bool operator!=(const DocBookViewer::ModelPtr &model,
DocBookViewer::ModelType type)
{
return ! (model && model->modelType() == type);
return !(model && model->modelType() == type);
}
#endif
......@@ -1975,24 +1975,25 @@ void KumirVM::do_specialcall(uint16_t alg)
String source = second.value().toString();
String ch = first.value().toString();
error_ = Kumir::Core::getError();
if (error_.length() == 0) {
if (end < start && start == 0) {
source = ch + source;
Variable r(source);
valuesStack_.push(r);
} else if (start > (int)source.length()) {
} else if (start > (int) source.length()) {
error_ = Kumir::Core::fromUtf8("Левая граница вырезки за пределами строки");
} else if (end < start && start > 0) {
source.insert(start, ch);
Variable r(source);
valuesStack_.push(r);
} else if (start == source.length() + 1 && end <= start) {
} else if (start == (int) source.length() + 1 && end <= start) {
source.append(ch);
Variable r(source);
valuesStack_.push(r);
} else if (end < 1 || end > (int)source.length()) {
} else if (end < 1 || end > (int) source.length()) {
error_ = Kumir::Core::fromUtf8("Правая граница вырезки за пределами строки");
} else if (start < 1 || start > (int)source.length()) {
} else if (start < 1 || start > (int) source.length()) {
error_ = Kumir::Core::fromUtf8("Левая граница вырезки за пределами строки");
} else if (end < start) {
error_ = Kumir::Core::fromUtf8("Ошибка в границах вырезки");
......@@ -2002,6 +2003,7 @@ void KumirVM::do_specialcall(uint16_t alg)
valuesStack_.push(r);
}
}
if (stacksMutex_) {
stacksMutex_->unlock();
}
......
......@@ -1814,18 +1814,8 @@ void Generator::LOOP(
const AST::StatementPtr st,
QList<Bytecode::Instruction> &result
) {
Bytecode::Instruction ctlOn;
ctlOn.module = 0x00;
ctlOn.arg = 0x0001;
Bytecode::Instruction ctlOff;
ctlOff.module = 0x00;
ctlOff.arg = 0x0000;
ctlOn.type = ctlOff.type = Bytecode::CTL;
if (st->beginBlockError.size() > 0) {
const QString error = ErrorMessages::message("KumirAnalizer", QLocale::Russian, st->beginBlockError);
QString error = ErrorMessages::message("KumirAnalizer", QLocale::Russian, st->beginBlockError);
result += makeLineInstructions(st->lexems);