Răsfoiți Sursa

New class: FbTextScheme

Kandrashin Denis 13 ani în urmă
părinte
comite
592c9ffeea
2 a modificat fișierele cu 74 adăugiri și 0 ștergeri
  1. 47 0
      source/fb2html.cpp
  2. 27 0
      source/fb2html.h

+ 47 - 0
source/fb2html.cpp

@@ -2,6 +2,53 @@
 #include "fb2utils.h"
 #include "fb2text.hpp"
 
+//---------------------------------------------------------------------------
+//  FbTextScheme
+//---------------------------------------------------------------------------
+
+FbTextScheme::FbTextScheme()
+{
+    m_types["body"]
+            << Type("image")
+            << Type("title")
+            << Type("epigraph", 0, 0)
+            << Type()
+    ;
+
+    m_types["section"]
+            << Type("title")
+            << Type("epigraph", 0, 0)
+            << Type("image")
+            << Type("annotation")
+            << Type()
+    ;
+
+    m_types["poem"]
+            << Type("title")
+            << Type("epigraph", 0, 0)
+            << Type("stanza", 1, 0)
+            << Type()
+            << Type("text-author", 0, 0)
+            << Type("date")
+    ;
+
+    m_types["stanza"]
+            << Type("title")
+            << Type("subtitle")
+            << Type()
+    ;
+
+    m_types["epigraph"]
+            << Type()
+            << Type("text-author", 0, 0)
+    ;
+
+    m_types["cite"]
+            << Type()
+            << Type("text-author", 0, 0)
+    ;
+}
+
 //---------------------------------------------------------------------------
 //  FbTextElement
 //---------------------------------------------------------------------------

+ 27 - 0
source/fb2html.h

@@ -10,6 +10,33 @@ class FbTextElement;
 
 typedef QList<FbTextElement> FbElementList;
 
+class FbTextScheme
+{
+public:
+    explicit FbTextScheme();
+
+    class Type
+    {
+    public:
+        Type(const QString &name = QString(), int min=0, int max=1): m_name(name), m_min(min), m_max(max) {}
+        Type(const Type &t): m_name(t.m_name), m_min(t.m_min), m_max(t.m_max) {}
+        const QString & name() const { return m_name; }
+        int min() { return m_min; }
+        int max() { return m_max; }
+    private:
+        const QString m_name;
+        const int m_min;
+        const int m_max;
+    };
+
+    typedef QList<Type> TypeList;
+
+    typedef QMap<QString, TypeList> TypeMap;
+
+private:
+    TypeMap m_types;
+};
+
 class FbTextElement : public QWebElement
 {
 public: