Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lintest/fb2edit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-11-10 01:27:27 +0400
committerKandrashin Denis <mail@lintest.ru>2012-11-10 01:27:27 +0400
commitb7cd1e55211a41929c19fb1aaf5d560a76ccfa43 (patch)
tree2eed3a177aff11c140f7a16c583f7a517cb5cf74
parentf4312cc08d79f57ea611727e09fdf67b197e4e45 (diff)
Small changes for export
-rw-r--r--source/fb2app.cpp2
-rw-r--r--source/fb2dock.cpp4
-rw-r--r--source/fb2main.cpp14
-rw-r--r--source/fb2main.hpp4
-rw-r--r--source/fb2page.hpp4
-rw-r--r--source/fb2read.cpp4
-rw-r--r--source/fb2save.cpp12
-rw-r--r--source/fb2save.hpp8
-rw-r--r--source/fb2xml.cpp6
-rw-r--r--source/fb2xml.hpp4
-rw-r--r--source/js/export.js5
11 files changed, 55 insertions, 12 deletions
diff --git a/source/fb2app.cpp b/source/fb2app.cpp
index fc2dbca..df6d716 100644
--- a/source/fb2app.cpp
+++ b/source/fb2app.cpp
@@ -68,7 +68,5 @@ int main(int argc, char *argv[])
qInstallMsgHandler(fb2MessageHandler);
- qRegisterMetaType<QXmlParseException>("QXmlParseException");
-
return app.exec();
}
diff --git a/source/fb2dock.cpp b/source/fb2dock.cpp
index 9bbcede..d11bc99 100644
--- a/source/fb2dock.cpp
+++ b/source/fb2dock.cpp
@@ -54,7 +54,9 @@ FbMainDock::FbMainDock(QWidget *parent)
addWidget(m_head);
addWidget(m_code);
- connect(m_text->page(), SIGNAL(log(QXmlParseException)), parent, SLOT(log(QXmlParseException)));
+ connect(m_text->page(), SIGNAL(warning(int,int,QString)), parent, SLOT(warning(int,int,QString)));
+ connect(m_text->page(), SIGNAL(error(int,int,QString)), parent, SLOT(error(int,int,QString)));
+ connect(m_text->page(), SIGNAL(fatal(int,int,QString)), parent, SLOT(fatal(int,int,QString)));
connect(m_text->page(), SIGNAL(status(QString)), parent, SLOT(status(QString)));
connect(m_head, SIGNAL(status(QString)), parent, SLOT(status(QString)));
connect(m_code, SIGNAL(status(QString)), parent, SLOT(status(QString)));
diff --git a/source/fb2main.cpp b/source/fb2main.cpp
index e8dd0fd..9f9595d 100644
--- a/source/fb2main.cpp
+++ b/source/fb2main.cpp
@@ -46,9 +46,19 @@ FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode)
mainDock->load(filepath);
}
-void FbMainWindow::log(const QXmlParseException &exception)
+void FbMainWindow::warning(int row, int col, const QString &msg)
{
- logMessage(exception.message().simplified());
+ logMessage(msg.simplified());
+}
+
+void FbMainWindow::error(int row, int col, const QString &msg)
+{
+ logMessage(msg.simplified());
+}
+
+void FbMainWindow::fatal(int row, int col, const QString &msg)
+{
+ logMessage(msg.simplified());
}
void FbMainWindow::logMessage(const QString &message)
diff --git a/source/fb2main.hpp b/source/fb2main.hpp
index cb64143..95ea80e 100644
--- a/source/fb2main.hpp
+++ b/source/fb2main.hpp
@@ -49,7 +49,9 @@ signals:
void showInspectorChecked(bool);
public slots:
- void log(const QXmlParseException &exception);
+ void warning(int row, int col, const QString &msg);
+ void error(int row, int col, const QString &msg);
+ void fatal(int row, int col, const QString &msg);
void logMessage(const QString &message);
void status(const QString &text);
diff --git a/source/fb2page.hpp b/source/fb2page.hpp
index f94c4a3..b769454 100644
--- a/source/fb2page.hpp
+++ b/source/fb2page.hpp
@@ -47,7 +47,9 @@ public:
static QUrl createUrl();
signals:
- void log(const QXmlParseException &exception);
+ void warning(int row, int col, const QString &msg);
+ void error(int row, int col, const QString &msg);
+ void fatal(int row, int col, const QString &msg);
void status(const QString &text);
public slots:
diff --git a/source/fb2read.cpp b/source/fb2read.cpp
index 8602a37..89a3ba3 100644
--- a/source/fb2read.cpp
+++ b/source/fb2read.cpp
@@ -46,7 +46,9 @@ bool FbReadThread::parse()
FbReadHandler handler(writer);
connect(&handler, SIGNAL(binary(QString,QByteArray)), m_store, SLOT(binary(QString,QByteArray)));
- connect(&handler, SIGNAL(log(QXmlParseException)), parent(), SIGNAL(log(QXmlParseException)));
+ connect(&handler, SIGNAL(warning(int,int,QString)), parent(), SIGNAL(warning(int,int,QString)));
+ connect(&handler, SIGNAL(error(int,int,QString)), parent(), SIGNAL(error(int,int,QString)));
+ connect(&handler, SIGNAL(fatal(int,int,QString)), parent(), SIGNAL(fatal(int,int,QString)));
#ifdef FB2_USE_LIBXML2
XML2::XmlReader reader;
diff --git a/source/fb2save.cpp b/source/fb2save.cpp
index 7dc8129..b0a86b1 100644
--- a/source/fb2save.cpp
+++ b/source/fb2save.cpp
@@ -495,6 +495,8 @@ void FbSaveHandler::ParagHandler::start()
FbSaveHandler::FbSaveHandler(FbSaveWriter &writer)
: FbHtmlHandler()
, m_writer(writer)
+ , m_anchor(-1)
+ , m_focus(-1)
{
}
@@ -504,6 +506,16 @@ bool FbSaveHandler::comment(const QString& ch)
return true;
}
+void FbSaveHandler::onAnchor(int offset)
+{
+ m_anchor = offset;
+}
+
+void FbSaveHandler::onFocus(int offset)
+{
+ m_focus = offset;
+}
+
FbXmlHandler::NodeHandler * FbSaveHandler::CreateRoot(const QString &name, const QXmlAttributes &atts)
{
Q_UNUSED(atts);
diff --git a/source/fb2save.hpp b/source/fb2save.hpp
index c375ece..bde4eea 100644
--- a/source/fb2save.hpp
+++ b/source/fb2save.hpp
@@ -89,11 +89,17 @@ private:
class FbSaveHandler : public FbHtmlHandler
{
+ Q_OBJECT
+
public:
explicit FbSaveHandler(FbSaveWriter &writer);
virtual bool comment(const QString& ch);
bool save();
+public slots:
+ void onAnchor(int offset);
+ void onFocus(int offset);
+
private:
class TextHandler : public NodeHandler
{
@@ -180,6 +186,8 @@ private:
private:
FbSaveWriter & m_writer;
+ int m_anchor;
+ int m_focus;
};
#endif // FB2SAVE_H
diff --git a/source/fb2xml.cpp b/source/fb2xml.cpp
index 60541bf..9682c43 100644
--- a/source/fb2xml.cpp
+++ b/source/fb2xml.cpp
@@ -101,19 +101,19 @@ bool FbXmlHandler::endElement(const QString & namespaceURI, const QString & loca
bool FbXmlHandler::warning(const QXmlParseException& exception)
{
- emit log(exception);
+ emit warning(exception.lineNumber(), exception.columnNumber(), exception.message());
return true;
}
bool FbXmlHandler::error(const QXmlParseException& exception)
{
- emit log(exception);
+ emit error(exception.lineNumber(), exception.columnNumber(), exception.message());
return false;
}
bool FbXmlHandler::fatalError(const QXmlParseException &exception)
{
- emit log(exception);
+ emit fatal(exception.lineNumber(), exception.columnNumber(), exception.message());
return false;
}
diff --git a/source/fb2xml.hpp b/source/fb2xml.hpp
index 0db74a2..b7543a9 100644
--- a/source/fb2xml.hpp
+++ b/source/fb2xml.hpp
@@ -43,7 +43,9 @@ public:
QString errorString() const;
signals:
- void log(const QXmlParseException &exception);
+ void warning(int row, int col, const QString &msg);
+ void error(int row, int col, const QString &msg);
+ void fatal(int row, int col, const QString &msg);
protected:
class NodeHandler
diff --git a/source/js/export.js b/source/js/export.js
index 11c0894..a23b22d 100644
--- a/source/js/export.js
+++ b/source/js/export.js
@@ -1,5 +1,10 @@
+var selection = document.getSelection();
+var anchorNode = selection.anchorNode;
+var focusNode = selection.baseNode;
(f = function(node) {
if (node.nodeName === "#text") {
+ if (anchorNode === node) handler.onAnchor(selection.anchorOffset);
+ if (focusNode === node) handler.onFocus(selection.focusOffset);
handler.onTxt(node.data);
} else if (node.nodeName === "#comment") {
handler.onCom(node.data);