Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lintest/myrulib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-10-19 18:01:13 +0400
committerKandrashin Denis <mail@lintest.ru>2012-10-19 18:01:13 +0400
commit489fa3e15fccf42d1656c393c1725aa54dde6d54 (patch)
treebd1a31a99f8093507bcb596971f9cbc07916d91d
parent646929764daaac869b109ccfc0612657bcd36554 (diff)
Read annotation when import books
-rw-r--r--sources/MyRuLib/FbDatabase.cpp8
-rw-r--r--sources/MyRuLib/FbImportReader.cpp22
-rw-r--r--sources/MyRuLib/FbImportReader.h11
-rw-r--r--sources/MyRuLib/FbUpdateThread.cpp4
-rw-r--r--sources/MyRuLib/controls/FbSearchCtrl.cpp2
-rw-r--r--sources/MyRuLib/controls/FbSearchCtrl.h4
6 files changed, 45 insertions, 6 deletions
diff --git a/sources/MyRuLib/FbDatabase.cpp b/sources/MyRuLib/FbDatabase.cpp
index 8209b575..b31dddfa 100644
--- a/sources/MyRuLib/FbDatabase.cpp
+++ b/sources/MyRuLib/FbDatabase.cpp
@@ -706,7 +706,13 @@ void FbMainDatabase::CreateTableFTS(const wxString & name, const wxString & tabl
sql << wxT("(tokenize=porter)");
#endif
ExecuteUpdate(sql);
- sql = wxString::Format(wxT("INSERT INTO fts_%s(docid,content)SELECT DISTINCT id,LOW(%s)FROM %s"), name.c_str(), field.c_str(), table.c_str());
+
+ if (name == wxT("book")) {
+ ExecuteUpdate(fbT("ALTER TABLE fts_book ADD dscr TEXT"));
+ sql = wxString::Format(wxT("INSERT INTO fts_%s(docid,content,dscr)SELECT DISTINCT id,LOW(%s),LOW(description)FROM %s"), name.c_str(), field.c_str(), table.c_str());
+ } else {
+ sql = wxString::Format(wxT("INSERT INTO fts_%s(docid,content)SELECT DISTINCT id,LOW(%s)FROM %s"), name.c_str(), field.c_str(), table.c_str());
+ }
ExecuteUpdate(sql);
}
diff --git a/sources/MyRuLib/FbImportReader.cpp b/sources/MyRuLib/FbImportReader.cpp
index 14fa11e4..65449731 100644
--- a/sources/MyRuLib/FbImportReader.cpp
+++ b/sources/MyRuLib/FbImportReader.cpp
@@ -187,6 +187,7 @@ FbHandlerXML * FbImportReaderFB2::DscrHandler::NewNode(const wxString &name, con
FB2_BEGIN_KEYHASH(FbImportReaderFB2::TitleHandler)
KEY( "book-title" , Title );
KEY( "author" , Author );
+ KEY( "annotation" , Annot );
KEY( "sequence" , Sequence );
KEY( "genre" , Genre );
KEY( "lang" , Lang );
@@ -197,6 +198,7 @@ FbHandlerXML * FbImportReaderFB2::TitleHandler::NewNode(const wxString &name, co
switch (toKeyword(name)) {
case Author : return new AuthorHandler(m_reader, name);
case Title : return new TextHandler(name, m_reader.m_title);
+ case Annot : return new AnnotHandler(m_reader, name);
case Sequence : return new SeqnHandler(m_reader, name, atts);
case Genre : return new GenrHandler(m_reader, name);
case Lang : return new TextHandler(name, m_reader.m_lang);
@@ -232,6 +234,26 @@ FbHandlerXML * FbImportReaderFB2::AuthorHandler::NewNode(const wxString &name, c
}
//-----------------------------------------------------------------------------
+// FbImportReaderFB2::AnnotHandler
+//-----------------------------------------------------------------------------
+
+FbHandlerXML * FbImportReaderFB2::AnnotHandler::NewNode(const wxString &name, const FbStringHash &atts)
+{
+ if (name == wxT('p')) m_reader.m_dscr << wxT('<') << name << wxT('>');
+ return new AnnotHandler(*this, name);
+}
+
+void FbImportReaderFB2::AnnotHandler::TxtNode(const wxString &text)
+{
+ m_reader.m_dscr << text;
+}
+
+void FbImportReaderFB2::AnnotHandler::EndNode(const wxString &name)
+{
+ if (name == wxT('p')) m_reader.m_dscr << wxT('<') << wxT('/') << name << wxT('>');
+}
+
+//-----------------------------------------------------------------------------
// FbImportReaderFB2::SeqnHandler
//-----------------------------------------------------------------------------
diff --git a/sources/MyRuLib/FbImportReader.h b/sources/MyRuLib/FbImportReader.h
index 5270c890..99807c87 100644
--- a/sources/MyRuLib/FbImportReader.h
+++ b/sources/MyRuLib/FbImportReader.h
@@ -127,6 +127,7 @@ private:
FB2_BEGIN_KEYLIST
Author,
Title,
+ Annot,
Sequence,
Genre,
Lang,
@@ -151,6 +152,16 @@ private:
AuthorItem * m_author;
};
+ class AnnotHandler : public BookHandler
+ {
+ public:
+ explicit AnnotHandler(FbImportReader &reader, const wxString &name) : BookHandler(reader, name) {}
+ explicit AnnotHandler(AnnotHandler &parent, const wxString &name) : BookHandler(parent.m_reader, name) {}
+ virtual FbHandlerXML * NewNode(const wxString &name, const FbStringHash &atts);
+ virtual void TxtNode(const wxString &text);
+ virtual void EndNode(const wxString &name);
+ };
+
class SeqnHandler : public FbHandlerXML
{
public:
diff --git a/sources/MyRuLib/FbUpdateThread.cpp b/sources/MyRuLib/FbUpdateThread.cpp
index 37ef2542..b097ad15 100644
--- a/sources/MyRuLib/FbUpdateThread.cpp
+++ b/sources/MyRuLib/FbUpdateThread.cpp
@@ -210,8 +210,8 @@ void FbUpdateItem::ExecInsert()
wxT("authors"), wxT("id,LOW(AUTH(last_name,first_name,middle_name))"),
},
{
- wxT("fts_book"), wxT("docid,content"),
- wxT("books"), wxT("id,LOW(title)"),
+ wxT("fts_book"), wxT("docid,content,dscr"),
+ wxT("books"), wxT("id,LOW(title),LOW(description)"),
},
{
wxT("fts_seqn"), wxT("docid,content"),
diff --git a/sources/MyRuLib/controls/FbSearchCtrl.cpp b/sources/MyRuLib/controls/FbSearchCtrl.cpp
index 91259a2f..fb3e2342 100644
--- a/sources/MyRuLib/controls/FbSearchCtrl.cpp
+++ b/sources/MyRuLib/controls/FbSearchCtrl.cpp
@@ -106,7 +106,7 @@ static int GetMultiplier()
IMPLEMENT_CLASS(FbSearchCtrl, wxOwnerDrawnComboBox)
BEGIN_EVENT_TABLE(FbSearchCtrl, wxOwnerDrawnComboBox)
- EVT_MENU(wxID_SELECTALL, FbSearchTextCtrl::OnSelectAll)
+ EVT_MENU(wxID_SELECTALL, FbSearchCtrl::OnSelectAll)
END_EVENT_TABLE()
FbSearchCtrl::FbSearchCtrl()
diff --git a/sources/MyRuLib/controls/FbSearchCtrl.h b/sources/MyRuLib/controls/FbSearchCtrl.h
index a4642776..cc7bcd69 100644
--- a/sources/MyRuLib/controls/FbSearchCtrl.h
+++ b/sources/MyRuLib/controls/FbSearchCtrl.h
@@ -64,8 +64,8 @@ public:
protected:
virtual wxBitmap RenderCancelBitmap( int x, int y );
-private
- void OnSelectAll(wxCommandEvent& event) {}
+private:
+ void OnSelectAll(wxCommandEvent& event) {
GetTextCtrl()->SelectAll();
}