1
0
Эх сурвалжийг харах

Small changes in text editor

Kandrashin Denis 12 жил өмнө
parent
commit
c9deefc769

+ 2 - 3
source/fb2code.hpp

@@ -2,9 +2,8 @@
 #define FB2CODE_H
 
 #include <QByteArray>
-#include <QList>
-#include <QPlainTextEdit>
 #include <QObject>
+#include <QPlainTextEdit>
 #include <QSyntaxHighlighter>
 #include <QTextCharFormat>
 #include <QColor>
@@ -133,7 +132,7 @@ private:
     void setZoomRatio(qreal ratio);
 
 private:
-    FbHighlighter * highlighter;
+    FbHighlighter *highlighter;
     QWidget *lineNumberArea;
     FbActionMap m_actions;
     qreal zoomRatio;

+ 1 - 0
source/fb2dock.cpp

@@ -64,6 +64,7 @@ void FbMainDock::setModeText()
     m_head->disconnectActions();
     m_code->disconnectActions();
     m_text->connectActions(m_tool);
+    m_text->viewContents(true);
 }
 
 void FbMainDock::setModeHead()

+ 1 - 0
source/fb2head.cpp

@@ -597,6 +597,7 @@ void FbHeadEdit::setAction(Fb::Actions index, QAction *action)
 
 void FbHeadEdit::connectActions(QToolBar *tool)
 {
+    tool->clear();
 }
 
 void FbHeadEdit::disconnectActions()

+ 0 - 18
source/fb2page.cpp

@@ -74,24 +74,6 @@ bool FbTextPage::load(const QString &filename, const QString &xml)
     return ok;
 }
 
-QAction * FbTextPage::act(Fb::Actions index) const
-{
-    return m_actions[index];
-}
-
-void FbTextPage::setAction(Fb::Actions index, QAction *action)
-{
-    m_actions[index] = action;
-}
-
-void FbTextPage::connectActions()
-{
-}
-
-void FbTextPage::disconnectActions()
-{
-}
-
 void FbTextPage::onTimer()
 {
     static int number = 0;

+ 0 - 5
source/fb2page.hpp

@@ -36,11 +36,6 @@ public:
     QString location();
     QString status();
 
-    QAction * act(Fb::Actions index) const;
-    void setAction(Fb::Actions index, QAction *action);
-    void connectActions();
-    void disconnectActions();
-
     FbTextElement body();
     FbTextElement doc();
 

+ 51 - 58
source/fb2text.cpp

@@ -1,20 +1,12 @@
 #include "fb2text.hpp"
 
-#include <QAction>
 #include <QBoxLayout>
 #include <QDockWidget>
 #include <QFileDialog>
 #include <QInputDialog>
 #include <QMainWindow>
 #include <QMenu>
-#include <QNetworkRequest>
-#include <QStyle>
-#include <QStyleOptionFrame>
 #include <QToolBar>
-#include <QToolTip>
-#include <QUndoCommand>
-#include <QUndoStack>
-#include <QWebElement>
 #include <QWebInspector>
 #include <QWebFrame>
 #include <QWebPage>
@@ -26,6 +18,57 @@
 #include "fb2tree.hpp"
 #include "fb2utils.h"
 
+//---------------------------------------------------------------------------
+//  FbTextAction
+//---------------------------------------------------------------------------
+
+FbTextAction::FbTextAction(const QString &text, QWebPage::WebAction action, FbTextEdit *parent)
+    : QAction(text, parent)
+    , m_action(action)
+    , m_parent(parent)
+{
+}
+
+FbTextAction::FbTextAction(const QIcon &icon, const QString &text, QWebPage::WebAction action, FbTextEdit* parent)
+    : QAction(icon, text, parent)
+    , m_action(action)
+    , m_parent(parent)
+{
+}
+
+QAction * FbTextAction::action(QWebPage::WebAction action)
+{
+    return m_parent->pageAction(m_action);
+}
+
+void FbTextAction::updateAction()
+{
+    if (QAction * act = action(m_action)) {
+        if (isCheckable()) setChecked(act->isChecked());
+        setEnabled(act->isEnabled());
+    }
+}
+
+void FbTextAction::connectAction()
+{
+    if (QAction * act = action(m_action)) {
+        connect(this, SIGNAL(triggered(bool)), act, SIGNAL(triggered(bool)));
+        connect(act, SIGNAL(changed()), this, SLOT(updateAction()));
+        if (isCheckable()) setChecked(act->isChecked());
+        setEnabled(act->isEnabled());
+    } else {
+        if (isCheckable()) setChecked(false);
+        setEnabled(false);
+    }
+}
+
+void FbTextAction::disconnectAction()
+{
+    QAction * act = action(m_action);
+    disconnect(act, 0, this, 0);
+    disconnect(this, 0, act, 0);
+}
+
 //---------------------------------------------------------------------------
 //  FbDockWidget
 //---------------------------------------------------------------------------
@@ -610,53 +653,3 @@ FbTextFrame::FbTextFrame(QWidget *parent)
     setLayout(layout);
 }
 
-//---------------------------------------------------------------------------
-//  FbTextAction
-//---------------------------------------------------------------------------
-
-FbTextAction::FbTextAction(const QString &text, QWebPage::WebAction action, FbTextEdit *parent)
-    : QAction(text, parent)
-    , m_action(action)
-    , m_parent(parent)
-{
-}
-
-FbTextAction::FbTextAction(const QIcon &icon, const QString &text, QWebPage::WebAction action, FbTextEdit* parent)
-    : QAction(icon, text, parent)
-    , m_action(action)
-    , m_parent(parent)
-{
-}
-
-QAction * FbTextAction::action(QWebPage::WebAction action)
-{
-    return m_parent->pageAction(m_action);
-}
-
-void FbTextAction::updateAction()
-{
-    if (QAction * act = action(m_action)) {
-        if (isCheckable()) setChecked(act->isChecked());
-        setEnabled(act->isEnabled());
-    }
-}
-
-void FbTextAction::connectAction()
-{
-    if (QAction * act = action(m_action)) {
-        connect(this, SIGNAL(triggered(bool)), act, SIGNAL(triggered(bool)));
-        connect(act, SIGNAL(changed()), this, SLOT(updateAction()));
-        if (isCheckable()) setChecked(act->isChecked());
-        setEnabled(act->isEnabled());
-    } else {
-        if (isCheckable()) setChecked(false);
-        setEnabled(false);
-    }
-}
-
-void FbTextAction::disconnectAction()
-{
-    QAction * act = action(m_action);
-    disconnect(act, 0, this, 0);
-    disconnect(this, 0, act, 0);
-}

+ 4 - 6
source/fb2text.hpp

@@ -4,10 +4,8 @@
 #include <QAction>
 #include <QDockWidget>
 #include <QFrame>
-#include <QMainWindow>
 #include <QResizeEvent>
 #include <QTimer>
-#include <QThread>
 #include <QWebElement>
 #include <QWebView>
 
@@ -15,8 +13,8 @@
 #include "fb2temp.hpp"
 
 QT_BEGIN_NAMESPACE
+class QMainWindow;
 class QToolBar;
-class QWebInspector;
 QT_END_NAMESPACE
 
 class FbNoteView;
@@ -101,6 +99,9 @@ protected:
 public slots:
     void html(QString html);
     void data(QString name, QByteArray data);
+    void viewContents(bool show);
+    void viewPictures(bool show);
+    void viewInspector(bool show);
     void insertImage();
     void insertNote();
     void insertLink();
@@ -111,9 +112,6 @@ private slots:
     void contextMenu(const QPoint &pos);
     void treeDestroyed();
     void imgsDestroyed();
-    void viewContents(bool show);
-    void viewPictures(bool show);
-    void viewInspector(bool show);
     void zoomIn();
     void zoomOut();
     void zoomReset();