Explorar o código

Scroll text to footnote

Kandrashin Denis %!s(int64=12) %!d(string=hai) anos
pai
achega
03f3b9f008
Modificáronse 5 ficheiros con 125 adicións e 45 borrados
  1. 16 3
      source/fb2note.cpp
  2. 5 3
      source/fb2note.hpp
  3. 1 8
      source/fb2page.cpp
  4. BIN=BIN
      source/ts/ru.qm
  5. 103 31
      source/ts/ru.ts

+ 16 - 3
source/fb2note.cpp

@@ -101,6 +101,13 @@ FbNotesModel::FbNotesModel(FbTextPage *page, QObject *parent)
 {
 }
 
+FbTextElement FbNotesModel::at(const QModelIndex &index) const
+{
+    int row = index.row();
+    if (row < 0 || row >= collection.count()) return QWebElement();
+    return collection.at(row);
+}
+
 int FbNotesModel::columnCount(const QModelIndex &parent) const
 {
     Q_UNUSED(parent);
@@ -129,9 +136,7 @@ QVariant FbNotesModel::data(const QModelIndex &index, int role) const
     if (index.isValid()) {
         switch (role) {
             case Qt::DisplayRole: {
-                int row = index.row();
-                if (row < 0 || row >= collection.count()) return QVariant();
-                QWebElement element = collection[row];
+                QWebElement element = at(index);
                 switch (index.column()) {
                     case 1: return element.toPlainText();
                     case 2: return element.attribute("type");
@@ -178,9 +183,17 @@ FbNotesWidget::FbNotesWidget(FbTextEdit *text, QWidget* parent)
 
     connect(m_text, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
     connect(m_list, SIGNAL(showCurrent(QString)), SLOT(showCurrent(QString)));
+    connect(m_list, SIGNAL(activated(QModelIndex)), SLOT(activated(QModelIndex)));
     loadFinished();
 }
 
+void FbNotesWidget::activated(const QModelIndex &index)
+{
+    if (FbNotesModel *m = qobject_cast<FbNotesModel*>(m_list->model())) {
+        m->at(index).select();
+    }
+}
+
 void FbNotesWidget::loadFinished()
 {
     if (QAbstractItemModel *m = m_list->model()) m->deleteLater();

+ 5 - 3
source/fb2note.hpp

@@ -19,6 +19,8 @@ class FbTextPage;
 class FbTextBase;
 class FbTextEdit;
 
+#include "fb2html.h"
+
 class FbNoteDlg : public QDialog
 {
     Q_OBJECT
@@ -42,6 +44,7 @@ class FbNotesModel : public QAbstractListModel
 
 public:
     explicit FbNotesModel(FbTextPage *page, QObject *parent = 0);
+    FbTextElement at(const QModelIndex &index) const;
 
 public:
     int rowCount(const QModelIndex &parent = QModelIndex()) const;
@@ -62,10 +65,9 @@ public:
     explicit FbNotesWidget(FbTextEdit *text, QWidget* parent = 0);
     QSize sizeHint() const { return QSize(200,200); }
 
-public slots:
-    void showCurrent(const QString &name);
-
 private slots:
+    void activated(const QModelIndex &index);
+    void showCurrent(const QString &name);
     void loadFinished();
 
 private:

+ 1 - 8
source/fb2page.cpp

@@ -390,16 +390,9 @@ void FbTextPage::showStatus()
 void FbTextPage::loadFinished()
 {
     mainFrame()->addToJavaScriptWindowObject("logger", &m_logger);
-    FbTextElement element = body().findFirst("fb\\:section");
-    if (element.isNull()) element = body().findFirst("fb\\:body");
-    if (element.isNull()) element = body();
-    FbTextElement child = element.firstChild();
-    if (child.isTitle()) child = child.nextSibling();
-    if (!child.isNull()) element = child;
-    element.select();
-
     QString style = "p:after{display:inline;content:'\\A0\\B6';color:gray;}";
     mainFrame()->findFirstElement("html>head>style#inline").setInnerXml(style);
+    body().select();
 }
 
 void FbTextPage::fixContents()

BIN=BIN
source/ts/ru.qm


+ 103 - 31
source/ts/ru.ts

@@ -32,6 +32,17 @@
         <translation>Эл. почта</translation>
     </message>
 </context>
+<context>
+    <name>FbCodeEdit</name>
+    <message>
+        <source>Schema is not valid: </source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Validation successful</source>
+        <translation>Проверка выполнена успешно </translation>
+    </message>
+</context>
 <context>
     <name>FbCodeFindDlg</name>
     <message>
@@ -230,19 +241,77 @@
         <translation type="obsolete">&amp;Удалить</translation>
     </message>
 </context>
+<context>
+    <name>FbImageDlg</name>
+    <message>
+        <source>File name:</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Insert picture</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Select file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>From collection</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Common Graphics (*.png *.jpg *.jpeg *.gif)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Portable Network Graphics (PNG) (*.png)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>JPEG (*.jpg *.jpeg)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Graphics Interchange Format (*.gif)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>All Files (*)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Insert image...</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>FbImgsModel</name>
+    <message>
+        <source>File name</source>
+        <translation type="unfinished">Имя файла</translation>
+    </message>
+    <message>
+        <source>Type</source>
+        <translation type="unfinished">Тип</translation>
+    </message>
+    <message>
+        <source>Size</source>
+        <translation type="unfinished">Размер</translation>
+    </message>
+</context>
 <context>
     <name>FbListModel</name>
     <message>
         <source>File name</source>
-        <translation>Имя файла</translation>
+        <translation type="obsolete">Имя файла</translation>
     </message>
     <message>
         <source>Size</source>
-        <translation>Размер</translation>
+        <translation type="obsolete">Размер</translation>
     </message>
     <message>
         <source>Type</source>
-        <translation>Тип</translation>
+        <translation type="obsolete">Тип</translation>
     </message>
 </context>
 <context>
@@ -335,10 +404,6 @@
         <source>Show the application&apos;s About box</source>
         <translation></translation>
     </message>
-    <message>
-        <source>The &lt;b&gt;fb2edit&lt;/b&gt; is application for editing FB2-files.</source>
-        <translation></translation>
-    </message>
     <message>
         <source>&amp;About</source>
         <translation>&amp;О программе...</translation>
@@ -605,6 +670,18 @@
         <source>&amp;HTML</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>&lt;b&gt;fb2edit&lt;/b&gt; is an application for creating and editing FB2-files.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>&amp;Check...</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>&amp;Footnotes</source>
+        <translation>&amp;Сноски</translation>
+    </message>
 </context>
 <context>
     <name>FbNodeDlg</name>
@@ -662,6 +739,21 @@
         <translation>Заголовок:</translation>
     </message>
 </context>
+<context>
+    <name>FbNotesModel</name>
+    <message>
+        <source>Title</source>
+        <translation>Заголовок</translation>
+    </message>
+    <message>
+        <source>Type</source>
+        <translation>Тип</translation>
+    </message>
+    <message>
+        <source>Link</source>
+        <translation>Ссылка</translation>
+    </message>
+</context>
 <context>
     <name>FbSaveDialog</name>
     <message>
@@ -702,30 +794,6 @@
 </context>
 <context>
     <name>FbTextEdit</name>
-    <message>
-        <source>Common Graphics (*.png *.jpg *.jpeg *.gif);;</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <source>Portable Network Graphics (PNG) (*.png);;</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <source>JPEG (*.jpg *.jpeg);;</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <source>Graphics Interchange Format (*.gif);;</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <source>All Files (*)</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <source>Insert image...</source>
-        <translation type="unfinished"></translation>
-    </message>
     <message>
         <source>Insert hyperlink</source>
         <translation type="unfinished"></translation>
@@ -750,6 +818,10 @@
         <source>Web inspector</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>Footnotes</source>
+        <translation>Сноски</translation>
+    </message>
 </context>
 <context>
     <name>FbTextPage</name>