瀏覽代碼

Merge branch 'master' of http://git.gitorious.org/fb2edit/lintest

Kandrashin Denis 13 年之前
父節點
當前提交
87df214aa0
共有 3 個文件被更改,包括 34 次插入18 次删除
  1. 23 18
      source/fb2main.cpp
  2. 6 0
      source/fb2tree.cpp
  3. 5 0
      source/fb2tree.hpp

+ 23 - 18
source/fb2main.cpp

@@ -345,6 +345,10 @@ void FbMainWindow::createActions()
     menu->addAction(act);
     act->setEnabled(false);
 
+    actionAuthor = act = new QAction(tr("&Cite"), this);
+    menu->addAction(act);
+    act->setEnabled(false);
+
     actionPoem = act = new QAction(tr("&Poem"), this);
     menu->addAction(act);
 
@@ -681,33 +685,34 @@ void FbMainWindow::viewText()
     textFrame->view.setFocus();
     viewTree();
 
-    connect(textFrame->view.page()->undoStack(), SIGNAL(cleanChanged(bool)), SLOT(cleanChanged(bool)));
-    connect(textFrame->view.page()->undoStack(), SIGNAL(canUndoChanged(bool)), SLOT(canUndoChanged(bool)));
-    connect(textFrame->view.page()->undoStack(), SIGNAL(canRedoChanged(bool)), SLOT(canRedoChanged(bool)));
-    connect(textFrame->view.page(), SIGNAL(selectionChanged()), SLOT(selectionChanged()));
+    FbTextEdit * textEdit = &textFrame->view;
+    FbTextPage * textPage = textEdit->page();
+
+    connect(textPage->undoStack(), SIGNAL(cleanChanged(bool)), SLOT(cleanChanged(bool)));
+    connect(textPage->undoStack(), SIGNAL(canUndoChanged(bool)), SLOT(canUndoChanged(bool)));
+    connect(textPage->undoStack(), SIGNAL(canRedoChanged(bool)), SLOT(canRedoChanged(bool)));
+    connect(textPage, SIGNAL(selectionChanged()), SLOT(selectionChanged()));
 
-    connect(textFrame->view.pageAction(QWebPage::Undo), SIGNAL(changed()), SLOT(undoChanged()));
-    connect(textFrame->view.pageAction(QWebPage::Redo), SIGNAL(changed()), SLOT(redoChanged()));
-    connect(actionUndo, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::Undo), SIGNAL(triggered()));
-    connect(actionRedo, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::Redo), SIGNAL(triggered()));
+    connect(textEdit->pageAction(QWebPage::Undo), SIGNAL(changed()), SLOT(undoChanged()));
+    connect(textEdit->pageAction(QWebPage::Redo), SIGNAL(changed()), SLOT(redoChanged()));
+    connect(actionUndo, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Undo), SIGNAL(triggered()));
+    connect(actionRedo, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Redo), SIGNAL(triggered()));
 
-    connect(actionCut, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::Cut), SIGNAL(triggered()));
-    connect(actionCopy, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::Copy), SIGNAL(triggered()));
-    connect(actionPaste, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::Paste), SIGNAL(triggered()));
+    connect(actionCut, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Cut), SIGNAL(triggered()));
+    connect(actionCopy, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Copy), SIGNAL(triggered()));
+    connect(actionPaste, SIGNAL(triggered()), textEdit->pageAction(QWebPage::Paste), SIGNAL(triggered()));
 
-    connect(actionTextBold, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleBold), SIGNAL(triggered()));
-    connect(actionTextItalic, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleItalic), SIGNAL(triggered()));
-    connect(actionTextStrike, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleStrikethrough), SIGNAL(triggered()));
-    connect(actionTextSub, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleSubscript), SIGNAL(triggered()));
-    connect(actionTextSup, SIGNAL(triggered()), textFrame->view.pageAction(QWebPage::ToggleSuperscript), SIGNAL(triggered()));
+    connect(actionTextBold, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleBold), SIGNAL(triggered()));
+    connect(actionTextItalic, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleItalic), SIGNAL(triggered()));
+    connect(actionTextStrike, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleStrikethrough), SIGNAL(triggered()));
+    connect(actionTextSub, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleSubscript), SIGNAL(triggered()));
+    connect(actionTextSup, SIGNAL(triggered()), textEdit->pageAction(QWebPage::ToggleSuperscript), SIGNAL(triggered()));
 
-    FbTextEdit * textEdit = &(textFrame->view);
     connect(actionFind, SIGNAL(triggered()), textEdit, SLOT(find()));
     connect(actionImage, SIGNAL(triggered()), textEdit, SLOT(insertImage()));
     connect(actionNote, SIGNAL(triggered()), textEdit, SLOT(insertNote()));
     connect(actionLink, SIGNAL(triggered()), textEdit, SLOT(insertLink()));
 
-    FbTextPage * textPage = textEdit->page();
     connect(actionTitle, SIGNAL(triggered()), textPage, SLOT(insertTitle()));
     connect(actionSubtitle, SIGNAL(triggered()), textPage, SLOT(insertSubtitle()));
     connect(actionSection, SIGNAL(triggered()), textPage, SLOT(insertSection()));

+ 6 - 0
source/fb2tree.cpp

@@ -156,6 +156,12 @@ QModelIndex FbTreeModel::index(FbTreeItem *item, int column) const
     return parent ? createIndex(parent->index(item), column, (void*)item) : QModelIndex();
 }
 
+bool FbTreeModel::hasChildren(const QModelIndex &parent) const
+{
+    FbTreeItem *owner = item(parent);
+    return owner ? owner->hasChildren() : false;
+}
+
 QModelIndex FbTreeModel::index(int row, int column, const QModelIndex &parent) const
 {
     if (!m_root || row < 0 || column < 0) return QModelIndex();

+ 5 - 0
source/fb2tree.hpp

@@ -52,6 +52,10 @@ public:
         return m_list.takeAt(row);
     }
 
+    bool hasChildren() {
+        return m_list.size();
+    }
+
     int count() const {
         return m_list.size();
     }
@@ -110,6 +114,7 @@ public:
     void update();
 
 public:
+    virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
     virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
     virtual QModelIndex parent(const QModelIndex &child) const;
     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;