浏览代码

Description tree

Kandrashin Denis 13 年之前
父节点
当前提交
9f83b8c296
共有 4 个文件被更改,包括 127 次插入68 次删除
  1. 22 1
      source/fb2head.cpp
  2. 8 0
      source/fb2head.h
  3. 二进制
      source/ts/ru.qm
  4. 97 67
      source/ts/ru.ts

+ 22 - 1
source/fb2head.cpp

@@ -6,6 +6,11 @@
 #include <QWebView>
 #include <QTreeView>
 
+FB2_BEGIN_KEYHASH(Fb2HeadItem)
+    FB2_KEY( Image  , "img"       );
+    FB2_KEY( Seqn   , "sequence"  );
+FB2_END_KEYHASH
+
 Fb2HeadItem::Fb2HeadItem(QWebElement &element, Fb2HeadItem *parent)
     : QObject(parent)
     , m_element(element)
@@ -62,11 +67,27 @@ QString Fb2HeadItem::text(int col) const
 {
     switch (col) {
         case 0: return QString("<%1>").arg(m_name);
-        case 2: if (m_list.count() == 0) return m_element.toPlainText().simplified();
+        case 2: if (m_list.count() == 0) return value();
     }
     return QString();
 }
 
+QString Fb2HeadItem::value() const
+{
+    switch (toKeyword(m_name)) {
+        case Image : {
+            return m_element.attribute("alt");
+        } break;
+        case Seqn : {
+            QString text = m_element.attribute("fb2:name");
+            QString numb = m_element.attribute("fb2:number");
+            if (numb.isEmpty() || numb == "0") return text;
+            return text + ", " + tr("#") + numb;
+        } break;
+    }
+    return m_element.toPlainText().simplified();
+}
+
 //---------------------------------------------------------------------------
 //  Fb2HeadModel
 //---------------------------------------------------------------------------

+ 8 - 0
source/fb2head.h

@@ -9,10 +9,17 @@ QT_BEGIN_NAMESPACE
 class QTreeView;
 QT_END_NAMESPACE
 
+#include "fb2xml.h"
+
 class Fb2HeadItem: public QObject
 {
     Q_OBJECT
 
+    FB2_BEGIN_KEYLIST
+        Image,
+        Seqn,
+    FB2_END_KEYLIST
+
 public:
     explicit Fb2HeadItem(QWebElement &element, Fb2HeadItem *parent = 0);
 
@@ -46,6 +53,7 @@ public:
 
 private:
     void addChildren(QWebElement &parent);
+    QString value() const;
 
 private:
     QList<Fb2HeadItem*> m_list;

二进制
source/ts/ru.qm


+ 97 - 67
source/ts/ru.ts

@@ -1,265 +1,300 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
 <TS version="2.0">
+<context>
+    <name>Fb2HeadItem</name>
+    <message>
+        <location filename="../fb2head.cpp" line="85"/>
+        <source>#</source>
+        <translation>№</translation>
+    </message>
+</context>
+<context>
+    <name>Fb2HeadModel</name>
+    <message>
+        <location filename="../fb2head.cpp" line="178"/>
+        <source>Tag</source>
+        <translation>Ключ</translation>
+    </message>
+    <message>
+        <location filename="../fb2head.cpp" line="179"/>
+        <source>Description</source>
+        <translation>Описание</translation>
+    </message>
+    <message>
+        <location filename="../fb2head.cpp" line="180"/>
+        <source>Value</source>
+        <translation>Значение</translation>
+    </message>
+</context>
 <context>
     <name>Fb2MainWindow</name>
     <message>
-        <location filename="../fb2main.cpp" line="66"/>
+        <location filename="../fb2main.cpp" line="69"/>
         <source>Message log</source>
         <translation>Информационные сообщения</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="173"/>
+        <location filename="../fb2main.cpp" line="133"/>
+        <source>Open file</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../fb2main.cpp" line="176"/>
         <source>Save As...</source>
         <translation>Сохранить как...</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="180"/>
+        <location filename="../fb2main.cpp" line="183"/>
         <source>About fb2edit</source>
         <translation>О программе...</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="181"/>
+        <location filename="../fb2main.cpp" line="184"/>
         <source>The &lt;b&gt;fb2edit&lt;/b&gt; is application for editing FB2-files.</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="210"/>
+        <location filename="../fb2main.cpp" line="213"/>
         <source>&amp;File</source>
         <translation>&amp;Файл</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="211"/>
+        <location filename="../fb2main.cpp" line="214"/>
         <source>File</source>
         <translation>Файл</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="213"/>
+        <location filename="../fb2main.cpp" line="217"/>
         <source>&amp;New</source>
         <translation>&amp;Новый</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="216"/>
+        <location filename="../fb2main.cpp" line="220"/>
         <source>Create a new file</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="221"/>
+        <location filename="../fb2main.cpp" line="225"/>
         <source>&amp;Open...</source>
         <translation>&amp;Открыть...</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="223"/>
+        <location filename="../fb2main.cpp" line="227"/>
         <source>Open an existing file</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="228"/>
+        <location filename="../fb2main.cpp" line="232"/>
         <source>&amp;Save</source>
         <translation>&amp;Сохранить</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="230"/>
+        <location filename="../fb2main.cpp" line="234"/>
         <source>Save the document to disk</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="235"/>
+        <location filename="../fb2main.cpp" line="239"/>
         <source>Save &amp;As...</source>
         <translation>Сохрать &amp;как...</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="237"/>
+        <location filename="../fb2main.cpp" line="241"/>
         <source>Save the document under a new name</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="243"/>
+        <location filename="../fb2main.cpp" line="247"/>
         <source>&amp;Close</source>
         <translation>&amp;Закрыть</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="245"/>
+        <location filename="../fb2main.cpp" line="249"/>
         <source>Close this window</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="249"/>
+        <location filename="../fb2main.cpp" line="253"/>
         <source>E&amp;xit</source>
         <translation>&amp;Выход</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="251"/>
+        <location filename="../fb2main.cpp" line="255"/>
         <source>Exit the application</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="255"/>
+        <location filename="../fb2main.cpp" line="259"/>
         <source>&amp;Edit</source>
         <translation>&amp;Правка</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="256"/>
+        <location filename="../fb2main.cpp" line="260"/>
         <source>Edit</source>
         <translation>Правка</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="260"/>
+        <location filename="../fb2main.cpp" line="266"/>
         <source>&amp;Undo</source>
         <translation>&amp;Отменить</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="267"/>
+        <location filename="../fb2main.cpp" line="273"/>
         <source>&amp;Redo</source>
         <translation>&amp;Повторить</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="277"/>
+        <location filename="../fb2main.cpp" line="283"/>
         <source>Cu&amp;t</source>
         <translation>Вы&amp;резать</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="280"/>
+        <location filename="../fb2main.cpp" line="286"/>
         <source>Cut the current selection&apos;s contents to the clipboard</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="285"/>
+        <location filename="../fb2main.cpp" line="291"/>
         <source>&amp;Copy</source>
         <translation>&amp;Копировать</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="288"/>
+        <location filename="../fb2main.cpp" line="294"/>
         <source>Copy the current selection&apos;s contents to the clipboard</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="293"/>
+        <location filename="../fb2main.cpp" line="299"/>
         <source>&amp;Paste</source>
         <translation>&amp;Вставить</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="296"/>
+        <location filename="../fb2main.cpp" line="302"/>
         <source>Paste the clipboard&apos;s contents into the current selection</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="301"/>
+        <location filename="../fb2main.cpp" line="307"/>
         <source>Fo&amp;rmat</source>
         <translation>Фо&amp;рмат</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="302"/>
+        <location filename="../fb2main.cpp" line="379"/>
+        <source>&amp;Contents</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../fb2main.cpp" line="383"/>
+        <source>&amp;Web inspector</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <source>Format</source>
-        <translation>Формат</translation>
+        <translation type="obsolete">Формат</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="304"/>
+        <location filename="../fb2main.cpp" line="310"/>
         <source>Bold</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="310"/>
+        <location filename="../fb2main.cpp" line="316"/>
         <source>Italic</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="316"/>
+        <location filename="../fb2main.cpp" line="322"/>
         <source>Strikethrough</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="321"/>
+        <location filename="../fb2main.cpp" line="327"/>
         <source>Superscript</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="326"/>
+        <location filename="../fb2main.cpp" line="332"/>
         <source>Subscript</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="331"/>
+        <location filename="../fb2main.cpp" line="337"/>
         <source>&amp;View</source>
         <translation>&amp;Вид</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="333"/>
+        <location filename="../fb2main.cpp" line="342"/>
         <source>&amp;Text</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="337"/>
-        <source>&amp;XML</source>
-        <translation></translation>
+        <location filename="../fb2main.cpp" line="349"/>
+        <source>&amp;Head</source>
+        <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="350"/>
-        <source>Zoom</source>
+        <location filename="../fb2main.cpp" line="355"/>
+        <source>&amp;XML</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="352"/>
+        <location filename="../fb2main.cpp" line="363"/>
         <source>Zoom in</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="357"/>
+        <location filename="../fb2main.cpp" line="368"/>
         <source>Zoom out</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="362"/>
+        <location filename="../fb2main.cpp" line="373"/>
         <source>Zoom original</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="368"/>
-        <source>Web inspector</source>
-        <translation></translation>
-    </message>
-    <message>
-        <location filename="../fb2main.cpp" line="374"/>
+        <location filename="../fb2main.cpp" line="389"/>
         <source>&amp;Help</source>
         <translation>&amp;?</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="376"/>
+        <location filename="../fb2main.cpp" line="391"/>
         <source>&amp;About</source>
         <translation>&amp;О программа...</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="377"/>
+        <location filename="../fb2main.cpp" line="392"/>
         <source>Show the application&apos;s About box</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="381"/>
+        <location filename="../fb2main.cpp" line="396"/>
         <source>About &amp;Qt</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="382"/>
+        <location filename="../fb2main.cpp" line="397"/>
         <source>Show the Qt library&apos;s About box</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="394"/>
+        <location filename="../fb2main.cpp" line="409"/>
         <source>Contents</source>
         <translation>Содержание</translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="519"/>
+        <location filename="../fb2main.cpp" line="552"/>
         <source>Ready</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="543"/>
+        <location filename="../fb2main.cpp" line="576"/>
         <source>The document has been modified. Do you want to save your changes?</source>
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2main.cpp" line="558"/>
+        <location filename="../fb2main.cpp" line="591"/>
         <source>Cannot write file %1: %2.</source>
         <translation></translation>
     </message>
@@ -272,7 +307,7 @@
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2read.cpp" line="378"/>
+        <location filename="../fb2read.cpp" line="377"/>
         <source>The file is not an FB2 file.</source>
         <translation></translation>
     </message>
@@ -284,14 +319,9 @@
         <translation></translation>
     </message>
     <message>
-        <location filename="../fb2save.cpp" line="198"/>
+        <location filename="../fb2save.cpp" line="275"/>
         <source>The tag &lt;body&gt; was not found.</source>
         <translation type="unfinished"></translation>
     </message>
-    <message>
-        <location filename="../fb2view.cpp" line="105"/>
-        <source>Cannot write file %1: %2.</source>
-        <translation type="unfinished"></translation>
-    </message>
 </context>
 </TS>