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
path: root/source
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-11-02 12:08:24 +0400
committerKandrashin Denis <mail@lintest.ru>2012-11-02 12:08:24 +0400
commit43b3116f7f57799b09ee6eea306f1d3d33b9de7f (patch)
tree96ce577882e87616cd3f9c2772911f5e97980314 /source
parentd86d1516d2887dcb62c951ca7e7d0b08b08e2cb8 (diff)
Show status and switch HTML
Diffstat (limited to 'source')
-rw-r--r--source/fb2dock.cpp18
-rw-r--r--source/fb2main.hpp2
-rw-r--r--source/fb2page.cpp8
-rw-r--r--source/fb2page.hpp5
4 files changed, 21 insertions, 12 deletions
diff --git a/source/fb2dock.cpp b/source/fb2dock.cpp
index 7ae779d..71418ce 100644
--- a/source/fb2dock.cpp
+++ b/source/fb2dock.cpp
@@ -44,28 +44,32 @@ FbMainDock::FbMainDock(QWidget *parent)
addWidget(textFrame);
addWidget(m_head);
addWidget(m_code);
+
+ connect(m_text->page(), SIGNAL(status(QString)), parent, SLOT(status(QString)));
}
void FbMainDock::switchMode(Fb::Mode mode)
{
- QString xml;
+ if (mode == m_mode) return;
if (currentWidget() == m_code) {
- switch (mode) {
- case Fb::Text:
- case Fb::Head:
+ QString xml = m_code->toPlainText();
+ switch (m_mode) {
+ case Fb::Code: m_text->page()->read(xml); break;
+ case Fb::Html: m_text->setHtml(xml, m_text->url()); break;
default: ;
}
} else {
+ QString xml;
switch (mode) {
case Fb::Code: m_text->save(&xml); break;
case Fb::Html: xml = m_text->toHtml(); break;
default: ;
}
+ if (!xml.isEmpty()) {
+ m_code->setPlainText(xml);
+ }
}
setMode(mode);
- if (!xml.isEmpty()) {
- m_code->setPlainText(xml);
- }
}
void FbMainDock::setMode(Fb::Mode mode)
diff --git a/source/fb2main.hpp b/source/fb2main.hpp
index babf57a..0e7bf75 100644
--- a/source/fb2main.hpp
+++ b/source/fb2main.hpp
@@ -47,6 +47,7 @@ signals:
public slots:
void logMessage(const QString &message);
+ void status(const QString &text);
private slots:
void fileNew();
@@ -59,7 +60,6 @@ private slots:
void logDestroyed();
void logShowed();
- void status(const QString &text);
void openSettings();
private:
diff --git a/source/fb2page.cpp b/source/fb2page.cpp
index 8996bd2..e2b0f63 100644
--- a/source/fb2page.cpp
+++ b/source/fb2page.cpp
@@ -46,6 +46,7 @@ FbTextPage::FbTextPage(QObject *parent)
connect(this, SIGNAL(linkHovered(QString,QString,QString)), parent, SLOT(linkHovered(QString,QString,QString)));
connect(this, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
connect(this, SIGNAL(contentsChanged()), SLOT(fixContents()));
+ connect(this, SIGNAL(selectionChanged()), SLOT(showStatus()));
QFile *file = new QFile(":blank.fb2");
if (file->open(QFile::ReadOnly | QFile::Text)) {
@@ -392,11 +393,12 @@ QString FbTextPage::location()
return mainFrame()->evaluateJavaScript(javascript).toString();
}
-QString FbTextPage::status()
+void FbTextPage::showStatus()
{
QString javascript = jScript("get_status.js");
- QString status = mainFrame()->evaluateJavaScript(javascript).toString();
- return status.replace("FB:", "");
+ QString text = mainFrame()->evaluateJavaScript(javascript).toString();
+ text.replace("FB:", "");
+ emit status(text);
}
void FbTextPage::loadFinished()
diff --git a/source/fb2page.hpp b/source/fb2page.hpp
index 814242c..066b4aa 100644
--- a/source/fb2page.hpp
+++ b/source/fb2page.hpp
@@ -35,7 +35,6 @@ public:
FbTextElement element(const QString &location);
FbTextElement current();
QString location();
- QString status();
FbTextElement body();
FbTextElement doc();
@@ -45,6 +44,9 @@ public:
FbTextElement appendText(const FbTextElement &parent);
static QUrl createUrl();
+signals:
+ void status(const QString &text);
+
public slots:
void html(QObject *temp, const QString &html);
void insertBody();
@@ -75,6 +77,7 @@ protected:
private slots:
void loadFinished();
void fixContents();
+ void showStatus();
private:
FbActionMap m_actions;