Example #1
0
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        WindowStateReader.__init__(self)
        WindowStateWriter.__init__(self)

        if not QtSql.QSqlDatabase.drivers().contains("QSQLITE"):
            raise Exception, "Fatal error: QSQLITE database driver is not found!"

        self.userConfigDir = QtCore.QDir.homePath() + QtCore.QDir.separator() + \
                             '.pyhomelib';
        if not QtCore.QFileInfo(self.userConfigDir).isDir():
            QtCore.QDir.home().mkdir('.pyhomelib')
        self.uiSettingsFile = self.userConfigDir + QtCore.QDir.separator() + \
                              'ui.xml'
        self.programSettings = MySettings(self.userConfigDir +
                                          QtCore.QDir.separator() +
                                          'pyhomelib.conf')

        if len(sys.argv) < 2:
            dbname = self.userConfigDir + QtCore.QDir.separator() + \
                     'default.sqlite'
        else:
            dbname = sys.argv[1]

        QtSql.QSqlDatabase.addDatabase("QSQLITE")

        genreModel = GenreTreeModelReader('genres.xml')

        info = QtCore.QFileInfo(dbname)
        if info.exists() and info.size() > 0:
            openDb(dbname)
        else:
            QtGui.QMessageBox.information(self, self.tr("Information"),
                QtCore.QString(self.tr("Database doesn't exists, recreating: %1"))
                .arg(dbname))
            createDb(dbname, 'Default', '', genreModel.list(),
                     [self.tr('Favorites')])

        self.setupUi(self)
        self.appTitle = self.windowTitle()
        self.appendToTitle(getDbProperty('name').toString())
        self.actionRuLetterA.setText(u"А")
        self.actionRuLetterB.setText(u"Б")
        self.actionRuLetterV.setText(u"В")
        self.actionRuLetterG.setText(u"Г")
        self.actionRuLetterD.setText(u"Д")
        self.actionRuLetterE.setText(u"Е")
        self.actionRuLetterYo.setText(u"Ё")
        self.actionRuLetterZh.setText(u"Ж")
        self.actionRuLetterZ.setText(u"З")
        self.actionRuLetterI.setText(u"И")
        self.actionRuLetterY.setText(u"Й")
        self.actionRuLetterK.setText(u"К")
        self.actionRuLetterL.setText(u"Л")
        self.actionRuLetterM.setText(u"М")
        self.actionRuLetterN.setText(u"Н")
        self.actionRuLetterO.setText(u"О")
        self.actionRuLetterP.setText(u"П")
        self.actionRuLetterR.setText(u"Р")
        self.actionRuLetterS.setText(u"С")
        self.actionRuLetterT.setText(u"Т")
        self.actionRuLetterU.setText(u"У")
        self.actionRuLetterF.setText(u"Ф")
        self.actionRuLetterH.setText(u"Х")
        self.actionRuLetterTs.setText(u"Ц")
        self.actionRuLetterCh.setText(u"Ч")
        self.actionRuLetterSh.setText(u"Ш")
        self.actionRuLetterSch.setText(u"Щ")
        self.actionRuLetterYy.setText(u"Ы")
        self.actionRuLetterEe.setText(u"Э")
        self.actionRuLetterYu.setText(u"Ю")
        self.actionRuLetterYa.setText(u"Я")

        self.lettersGroup = QtGui.QActionGroup(self)
        for a in self.findChildren(QtGui.QAction):
            if a.objectName().startsWith('actionRuLetter') or \
               a.objectName().startsWith('actionEnLetter'):
                self.lettersGroup.addAction(a)

        self.authorsModel = SqlQueryModelEx(self, "authorid, lastname, firstname",
                                                  "libauthorname",
                                                  None,
                                                  "lastname, firstname")
        self.authorsView.setModel(self.authorsModel)
        self.setTableAuthorsModelQuery()
        self.authorsView.hideColumn(0)
        self.authorsView.model().setHeaderData(1, QtCore.Qt.Horizontal, self.tr("Last name"))
        self.authorsView.model().setHeaderData(2, QtCore.Qt.Horizontal, self.tr("First name"))

        self.sequencesModel = SqlQueryModelEx(self, "seqid, seqname",
                                                    "libseqname",
                                                    None,
                                                    "seqname")
        self.sequencesView.setModel(self.sequencesModel)
        self.sequencesModel.select()
        self.sequencesView.hideColumn(0)
        self.sequencesView.model().setHeaderData(1, QtCore.Qt.Horizontal, self.tr("Sequence"))

        self.genresTree.setModel(genreModel)
        self.genresTree.hideColumn(1)


        self.bookSearchModel = SqlQueryModelEx(self, "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
                                                     "libbook b LEFT JOIN libsequence s ON b.bookid = s.bookid LEFT JOIN libseqname sn ON s.seqid = sn.seqid LEFT JOIN libauthor a ON b.bookid = a.bookid LEFT JOIN libauthorname an ON a.authorid = an.authorid LEFT JOIN libgenre g ON b.bookid = g.bookid LEFT JOIN libgenrelist gl ON g.genreid = gl.genreid",
                                                     "b.bookid = 0",
                                                     None,
                                                     "1")
        self.bookSearchView.setModel(self.bookSearchModel)
        self.bookSearchModel.select()
        self.bookSearchView.hideColumn(0)
        self.bookSearchModel.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("First name"))
        self.bookSearchModel.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("Last name"))
        self.bookSearchModel.setHeaderData(3, QtCore.Qt.Horizontal, self.tr("Book Title"))
        self.bookSearchModel.setHeaderData(4, QtCore.Qt.Horizontal, self.tr("Sequence"))
        self.bookSearchModel.setHeaderData(5, QtCore.Qt.Horizontal, self.tr("Genre"))
        self.bookSearchModel.setHeaderData(6, QtCore.Qt.Horizontal, self.tr("Lang"))
        self.bookSearchModel.setHeaderData(7, QtCore.Qt.Horizontal, self.tr("Year"))

        self.groupsModel = SqlQueryModelEx(self, "groupid, groupname",
                                                 "libgrouplist",
                                                 None,
                                                 "groupname")
        self.groupsView.setModel(self.groupsModel)
        self.groupsModel.select()
        self.groupsView.hideColumn(0)
        self.groupsView.model().setHeaderData(1, QtCore.Qt.Horizontal, self.tr("Group"))

        self.booksByAuthorModel = SqlQueryModelEx(self, "bookid, title, seqname, genredesc, lang, year",
                                                        "libauthor a INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
                                                        "a.authorid = ?")
        self.booksByAuthorView.setModel(self.booksByAuthorModel)
        self.booksByAuthorModel.addBindValue(0)
        self.booksByAuthorModel.select()
        self.booksByAuthorView.hideColumn(0)
        self.booksByAuthorModel.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("Book Title"))
        self.booksByAuthorModel.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("Sequence"))
        self.booksByAuthorModel.setHeaderData(3, QtCore.Qt.Horizontal, self.tr("Genre"))
        self.booksByAuthorModel.setHeaderData(4, QtCore.Qt.Horizontal, self.tr("Lang"))
        self.booksByAuthorModel.setHeaderData(5, QtCore.Qt.Horizontal, self.tr("Year"))

        self.booksBySeqModel = SqlQueryModelEx(self, "bookid, firstname, lastname, title, genredesc, lang, year",
                                                     "libsequence s INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
                                                     "s.seqid = ?")
        self.booksBySeqView.setModel(self.booksBySeqModel)
        self.booksBySeqModel.addBindValue(0)
        self.booksBySeqModel.select()
        self.booksBySeqView.hideColumn(0)
        self.booksBySeqModel.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("First name"))
        self.booksBySeqModel.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("Last name"))
        self.booksBySeqModel.setHeaderData(3, QtCore.Qt.Horizontal, self.tr("Book Title"))
        self.booksBySeqModel.setHeaderData(4, QtCore.Qt.Horizontal, self.tr("Genre"))
        self.booksBySeqModel.setHeaderData(5, QtCore.Qt.Horizontal, self.tr("Lang"))
        self.booksBySeqModel.setHeaderData(6, QtCore.Qt.Horizontal, self.tr("Year"))

        self.booksByGenreModel = SqlQueryModelEx(self, "bookid, firstname, lastname, title, seqname, lang, year",
                                                       "libgenre g INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libseqname s ON b.seqid = s.seqid",
                                                       "g.genreid = ?")
        self.booksByGenreView.setModel(self.booksByGenreModel)
        self.booksByGenreModel.addBindValue(0)
        self.booksByGenreModel.select()
        self.booksByGenreView.hideColumn(0)
        self.booksByGenreModel.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("First name"))
        self.booksByGenreModel.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("Last name"))
        self.booksByGenreModel.setHeaderData(3, QtCore.Qt.Horizontal, self.tr("Book Title"))
        self.booksByGenreModel.setHeaderData(4, QtCore.Qt.Horizontal, self.tr("Sequence"))
        self.booksByGenreModel.setHeaderData(5, QtCore.Qt.Horizontal, self.tr("Lang"))
        self.booksByGenreModel.setHeaderData(6, QtCore.Qt.Horizontal, self.tr("Year"))

        self.booksByGroupModel = SqlQueryModelEx(self, "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
                                                       "libgroup g INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist gl ON b.genreid = gl.genreid",
                                                       "g.groupid = ?")
        self.booksByGroupView.setModel(self.booksByGroupModel)
        self.booksByGroupModel.addBindValue(0)
        self.booksByGroupModel.select()
        self.booksByGroupView.hideColumn(0)
        self.booksByGroupModel.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("First name"))
        self.booksByGroupModel.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("Last name"))
        self.booksByGroupModel.setHeaderData(3, QtCore.Qt.Horizontal, self.tr("Book Title"))
        self.booksByGroupModel.setHeaderData(4, QtCore.Qt.Horizontal, self.tr("Sequence"))
        self.booksByGroupModel.setHeaderData(5, QtCore.Qt.Horizontal, self.tr("Genre"))
        self.booksByGroupModel.setHeaderData(6, QtCore.Qt.Horizontal, self.tr("Lang"))
        self.booksByGroupModel.setHeaderData(7, QtCore.Qt.Horizontal, self.tr("Year"))

        self.readStateFrom(self.uiSettingsFile)
        self.actionRussianAlphabet.setChecked(self.ruLettersToolbar.isVisibleTo(self))
        self.actionEnglishAlphabet.setChecked(self.enLettersToolbar.isVisibleTo(self))

        self.parserThread = FB2BookParserThread()
        self.parserThread.bookParsed.connect(self.bookParsed)
        self.parserThread.start()
Example #2
0
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        WindowStateReader.__init__(self)
        WindowStateWriter.__init__(self)
        self._db = BookDbLayer()

        self.userConfigDir = QtCore.QDir.homePath() + QtCore.QDir.separator() + \
                             '.pyhomelib';
        if not QtCore.QFileInfo(self.userConfigDir).isDir():
            QtCore.QDir.home().mkdir('.pyhomelib')
        self.uiSettingsFile = self.userConfigDir + QtCore.QDir.separator() + \
                              'ui.xml'
        self.programSettings = MySettings(self.userConfigDir +
                                          QtCore.QDir.separator() +
                                          'pyhomelib.conf')

        if len(sys.argv) < 2:
            dbname = self.userConfigDir + QtCore.QDir.separator() + \
                     'default.sqlite'
        else:
            dbname = QtCore.QString.fromUtf8(sys.argv[1])

        genreModel = GenreTreeModelReader('genres.xml')

        info = QtCore.QFileInfo(dbname)
        if info.exists() and info.size() > 0:
            self._db.open(dbname)
        else:
            QtGui.QMessageBox.information(self, self.tr("Information"),
                QtCore.QString(self.tr("Database doesn't exists, recreating: %1"))
                .arg(dbname))
            self._db.create(dbname, 'Default', '', genreModel.list(),
                     [self.tr('Favorites')])

        try:
            import sqlite3ext
            handle = db().driver().handle()
            sqlite3ext.load_icu(handle.data().ascobject())
        except ImportError:
            pass

        self.setupUi(self)
        QtGui.qApp.setStyleSheet(QtCore.QResource(":resources/pyhomelib.css").data())
        self.appTitle = self.windowTitle()
        self.prependToTitle(self._db.getDbProperty('name').toString())
        self.actionRuLetterA.setText(u"А")
        self.actionRuLetterB.setText(u"Б")
        self.actionRuLetterV.setText(u"В")
        self.actionRuLetterG.setText(u"Г")
        self.actionRuLetterD.setText(u"Д")
        self.actionRuLetterE.setText(u"Е")
        self.actionRuLetterYo.setText(u"Ё")
        self.actionRuLetterZh.setText(u"Ж")
        self.actionRuLetterZ.setText(u"З")
        self.actionRuLetterI.setText(u"И")
        self.actionRuLetterY.setText(u"Й")
        self.actionRuLetterK.setText(u"К")
        self.actionRuLetterL.setText(u"Л")
        self.actionRuLetterM.setText(u"М")
        self.actionRuLetterN.setText(u"Н")
        self.actionRuLetterO.setText(u"О")
        self.actionRuLetterP.setText(u"П")
        self.actionRuLetterR.setText(u"Р")
        self.actionRuLetterS.setText(u"С")
        self.actionRuLetterT.setText(u"Т")
        self.actionRuLetterU.setText(u"У")
        self.actionRuLetterF.setText(u"Ф")
        self.actionRuLetterH.setText(u"Х")
        self.actionRuLetterTs.setText(u"Ц")
        self.actionRuLetterCh.setText(u"Ч")
        self.actionRuLetterSh.setText(u"Ш")
        self.actionRuLetterSch.setText(u"Щ")
        self.actionRuLetterYy.setText(u"Ы")
        self.actionRuLetterEe.setText(u"Э")
        self.actionRuLetterYu.setText(u"Ю")
        self.actionRuLetterYa.setText(u"Я")

        self.lettersGroup = QtGui.QActionGroup(self)
        for a in self.findChildren(QtGui.QAction):
            if a.objectName().startsWith('actionRuLetter') or \
               a.objectName().startsWith('actionEnLetter'):
                self.lettersGroup.addAction(a)

        self.authorsModel = SqlQueryModel(self, self._db, "authorid, lastname, firstname",
                                                          "libauthorname",
                                                          None,
                                                          "lastname, firstname")
        self.authorsView.setModel(self.authorsModel)
        self.setTableAuthorsModelQuery()
        self.authorsView.hideColumn(0)
        for index, name in enumerate([self.tr("authorid"),
                                      self.tr("Last name"),
                                      self.tr("First name")]):
            self.authorsView.model().setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.sequencesModel = SqlQueryModel(self, self._db, "seqid, seqname",
                                                            "libseqname",
                                                            None,
                                                            "seqname")
        self.sequencesView.setModel(self.sequencesModel)
        self.sequencesModel.select()
        self.sequencesView.hideColumn(0)
        for index, name in enumerate([self.tr("seqid"),
                                      self.tr("Sequence")]):
            self.sequencesView.model().setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.genresTree.setModel(genreModel)
        self.genresTree.hideColumn(1)


        self.bookSearchModel = SqlQueryModel(self, self._db, "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
                                                             "libbook b LEFT JOIN libsequence s ON b.bookid = s.bookid LEFT JOIN libseqname sn ON s.seqid = sn.seqid LEFT JOIN libauthor a ON b.bookid = a.bookid LEFT JOIN libauthorname an ON a.authorid = an.authorid LEFT JOIN libgenre g ON b.bookid = g.bookid LEFT JOIN libgenrelist gl ON g.genreid = gl.genreid",
                                                             "b.bookid = 0",
                                                             None,
                                                             "1")
        self.bookSearchView.setModel(self.bookSearchModel)
        self.bookSearchModel.select()
        self.bookSearchView.hideColumn(0)
        for index, name in enumerate([self.tr("bookid"),
                                      self.tr("First name"),
                                      self.tr("Last name"),
                                      self.tr("Book Title"),
                                      self.tr("Sequence"),
                                      self.tr("Genre"),
                                      self.tr("Lang"),
                                      self.tr("Year")]):
            self.bookSearchModel.setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.groupsModel = SqlQueryModel(self, self._db, "groupid, groupname",
                                                         "libgrouplist",
                                                         None,
                                                         "groupname")
        self.groupsView.setModel(self.groupsModel)
        self.groupsModel.select()
        self.groupsView.hideColumn(0)
        for index, name in enumerate([self.tr("groupid"),
                                      self.tr("Group")]):
            self.groupsView.model().setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.booksByAuthorModel = SqlQueryModel(self, self._db, "bookid, title, seqname, genredesc, lang, year",
                                                                "libauthor a INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
                                                                "a.authorid = ?")
        self.booksByAuthorView.setModel(self.booksByAuthorModel)
        self.booksByAuthorModel.addBindValue(0)
        self.booksByAuthorModel.select()
        self.booksByAuthorView.hideColumn(0)
        for index, name in enumerate([self.tr("bookid"),
                                      self.tr("Book Title"),
                                      self.tr("Sequence"),
                                      self.tr("Genre"),
                                      self.tr("Lang"),
                                      self.tr("Year")]):
            self.booksByAuthorModel.setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.booksBySeqModel = SqlQueryModel(self, self._db, "bookid, firstname, lastname, title, genredesc, lang, year",
                                                             "libsequence s INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
                                                             "s.seqid = ?")
        self.booksBySeqView.setModel(self.booksBySeqModel)
        self.booksBySeqModel.addBindValue(0)
        self.booksBySeqModel.select()
        self.booksBySeqView.hideColumn(0)
        for index, name in enumerate([self.tr("bookid"),
                                      self.tr("First name"),
                                      self.tr("Last name"),
                                      self.tr("Book Title"),
                                      self.tr("Genre"),
                                      self.tr("Lang"),
                                      self.tr("Year")]):
            self.booksBySeqModel.setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.booksByGenreModel = SqlQueryModel(self, self._db, "bookid, firstname, lastname, title, seqname, lang, year",
                                                               "libgenre g INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libseqname s ON b.seqid = s.seqid",
                                                               "g.genreid = ?")
        self.booksByGenreView.setModel(self.booksByGenreModel)
        self.booksByGenreModel.addBindValue(0)
        self.booksByGenreModel.select()
        self.booksByGenreView.hideColumn(0)
        for index, name in enumerate([self.tr("bookid"),
                                      self.tr("First name"),
                                      self.tr("Last name"),
                                      self.tr("Book Title"),
                                      self.tr("Sequence"),
                                      self.tr("Lang"),
                                      self.tr("Year")]):
            self.booksByGenreModel.setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.booksByGroupModel = SqlQueryModel(self, self._db, "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
                                                               "libgroup g INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist gl ON b.genreid = gl.genreid",
                                                               "g.groupid = ?")
        self.booksByGroupView.setModel(self.booksByGroupModel)
        self.booksByGroupModel.addBindValue(0)
        self.booksByGroupModel.select()
        self.booksByGroupView.hideColumn(0)
        for index, name in enumerate([self.tr("bookid"),
                                      self.tr("First name"),
                                      self.tr("Last name"),
                                      self.tr("Book Title"),
                                      self.tr("Sequence"),
                                      self.tr("Genre"),
                                      self.tr("Lang"),
                                      self.tr("Year")]):
            self.booksByGroupModel.setHeaderData(index, QtCore.Qt.Horizontal, name)

        self.readStateFrom(self.uiSettingsFile)
        self.actionRussianAlphabet.setChecked(self.ruLettersToolbar.isVisibleTo(self))
        self.actionEnglishAlphabet.setChecked(self.enLettersToolbar.isVisibleTo(self))

        if not self.programSettings.getRowHeight():
            self.programSettings.writeRowHeight(self.authorsView.verticalHeader().defaultSectionSize())
        else:
            self.setRowHeight(self.programSettings.getRowHeight())

        for key in ('/', 'Ctrl+F'):
            QtGui.QShortcut(key, self).activated.connect(self.on_quickFindShortcut_activated)

        self.parserThread = FB2BookParserThread()
        self.parserThread.bookParsed.connect(self.bookParsed)
        self.parserThread.start()
Example #3
0
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        WindowStateReader.__init__(self)
        WindowStateWriter.__init__(self)
        self._db = BookDbLayer()

        self.userConfigDir = QtCore.QDir.homePath() + QtCore.QDir.separator() + \
                             '.pyhomelib'
        if not QtCore.QFileInfo(self.userConfigDir).isDir():
            QtCore.QDir.home().mkdir('.pyhomelib')
        self.uiSettingsFile = self.userConfigDir + QtCore.QDir.separator() + \
                              'ui.xml'
        self.programSettings = MySettings(self.userConfigDir +
                                          QtCore.QDir.separator() +
                                          'pyhomelib.conf')

        if len(sys.argv) < 2:
            dbname = self.userConfigDir + QtCore.QDir.separator() + \
                     'default.sqlite'
        else:
            dbname = QtCore.QString.fromUtf8(sys.argv[1])

        genreModel = GenreTreeModelReader('genres.xml')

        info = QtCore.QFileInfo(dbname)
        if info.exists() and info.size() > 0:
            self._db.open(dbname)
        else:
            QtGui.QMessageBox.information(
                self, self.tr("Information"),
                QtCore.QString(
                    self.tr("Database doesn't exists, recreating: %1")).arg(
                        dbname))
            self._db.create(dbname, 'Default', '', genreModel.list(),
                            [self.tr('Favorites')])

        try:
            import sqlite3ext
            handle = db().driver().handle()
            sqlite3ext.load_icu(handle.data().ascobject())
        except ImportError:
            pass

        self.setupUi(self)
        QtGui.qApp.setStyleSheet(
            QtCore.QResource(":resources/pyhomelib.css").data())
        self.appTitle = self.windowTitle()
        self.prependToTitle(self._db.getDbProperty('name').toString())
        self.actionRuLetterA.setText(u"А")
        self.actionRuLetterB.setText(u"Б")
        self.actionRuLetterV.setText(u"В")
        self.actionRuLetterG.setText(u"Г")
        self.actionRuLetterD.setText(u"Д")
        self.actionRuLetterE.setText(u"Е")
        self.actionRuLetterYo.setText(u"Ё")
        self.actionRuLetterZh.setText(u"Ж")
        self.actionRuLetterZ.setText(u"З")
        self.actionRuLetterI.setText(u"И")
        self.actionRuLetterY.setText(u"Й")
        self.actionRuLetterK.setText(u"К")
        self.actionRuLetterL.setText(u"Л")
        self.actionRuLetterM.setText(u"М")
        self.actionRuLetterN.setText(u"Н")
        self.actionRuLetterO.setText(u"О")
        self.actionRuLetterP.setText(u"П")
        self.actionRuLetterR.setText(u"Р")
        self.actionRuLetterS.setText(u"С")
        self.actionRuLetterT.setText(u"Т")
        self.actionRuLetterU.setText(u"У")
        self.actionRuLetterF.setText(u"Ф")
        self.actionRuLetterH.setText(u"Х")
        self.actionRuLetterTs.setText(u"Ц")
        self.actionRuLetterCh.setText(u"Ч")
        self.actionRuLetterSh.setText(u"Ш")
        self.actionRuLetterSch.setText(u"Щ")
        self.actionRuLetterYy.setText(u"Ы")
        self.actionRuLetterEe.setText(u"Э")
        self.actionRuLetterYu.setText(u"Ю")
        self.actionRuLetterYa.setText(u"Я")

        self.lettersGroup = QtGui.QActionGroup(self)
        for a in self.findChildren(QtGui.QAction):
            if a.objectName().startsWith('actionRuLetter') or \
               a.objectName().startsWith('actionEnLetter'):
                self.lettersGroup.addAction(a)

        self.authorsModel = SqlQueryModel(self, self._db,
                                          "authorid, lastname, firstname",
                                          "libauthorname", None,
                                          "lastname, firstname")
        self.authorsView.setModel(self.authorsModel)
        self.setTableAuthorsModelQuery()
        self.authorsView.hideColumn(0)
        for index, name in enumerate(
            [self.tr("authorid"),
             self.tr("Last name"),
             self.tr("First name")]):
            self.authorsView.model().setHeaderData(index, QtCore.Qt.Horizontal,
                                                   name)

        self.sequencesModel = SqlQueryModel(self, self._db, "seqid, seqname",
                                            "libseqname", None, "seqname")
        self.sequencesView.setModel(self.sequencesModel)
        self.sequencesModel.select()
        self.sequencesView.hideColumn(0)
        for index, name in enumerate([self.tr("seqid"), self.tr("Sequence")]):
            self.sequencesView.model().setHeaderData(index,
                                                     QtCore.Qt.Horizontal,
                                                     name)

        self.genresTree.setModel(genreModel)
        self.genresTree.hideColumn(1)

        self.bookSearchModel = SqlQueryModel(
            self, self._db,
            "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
            "libbook b LEFT JOIN libsequence s ON b.bookid = s.bookid LEFT JOIN libseqname sn ON s.seqid = sn.seqid LEFT JOIN libauthor a ON b.bookid = a.bookid LEFT JOIN libauthorname an ON a.authorid = an.authorid LEFT JOIN libgenre g ON b.bookid = g.bookid LEFT JOIN libgenrelist gl ON g.genreid = gl.genreid",
            "b.bookid = 0", None, "1")
        self.bookSearchView.setModel(self.bookSearchModel)
        self.bookSearchModel.select()
        self.bookSearchView.hideColumn(0)
        for index, name in enumerate([
                self.tr("bookid"),
                self.tr("First name"),
                self.tr("Last name"),
                self.tr("Book Title"),
                self.tr("Sequence"),
                self.tr("Genre"),
                self.tr("Lang"),
                self.tr("Year")
        ]):
            self.bookSearchModel.setHeaderData(index, QtCore.Qt.Horizontal,
                                               name)

        self.groupsModel = SqlQueryModel(self, self._db, "groupid, groupname",
                                         "libgrouplist", None, "groupname")
        self.groupsView.setModel(self.groupsModel)
        self.groupsModel.select()
        self.groupsView.hideColumn(0)
        for index, name in enumerate([self.tr("groupid"), self.tr("Group")]):
            self.groupsView.model().setHeaderData(index, QtCore.Qt.Horizontal,
                                                  name)

        self.booksByAuthorModel = SqlQueryModel(
            self, self._db, "bookid, title, seqname, genredesc, lang, year",
            "libauthor a INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
            "a.authorid = ?")
        self.booksByAuthorView.setModel(self.booksByAuthorModel)
        self.booksByAuthorModel.addBindValue(0)
        self.booksByAuthorModel.select()
        self.booksByAuthorView.hideColumn(0)
        for index, name in enumerate([
                self.tr("bookid"),
                self.tr("Book Title"),
                self.tr("Sequence"),
                self.tr("Genre"),
                self.tr("Lang"),
                self.tr("Year")
        ]):
            self.booksByAuthorModel.setHeaderData(index, QtCore.Qt.Horizontal,
                                                  name)

        self.booksBySeqModel = SqlQueryModel(
            self, self._db,
            "bookid, firstname, lastname, title, genredesc, lang, year",
            "libsequence s INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist g ON b.genreid = g.genreid",
            "s.seqid = ?")
        self.booksBySeqView.setModel(self.booksBySeqModel)
        self.booksBySeqModel.addBindValue(0)
        self.booksBySeqModel.select()
        self.booksBySeqView.hideColumn(0)
        for index, name in enumerate([
                self.tr("bookid"),
                self.tr("First name"),
                self.tr("Last name"),
                self.tr("Book Title"),
                self.tr("Genre"),
                self.tr("Lang"),
                self.tr("Year")
        ]):
            self.booksBySeqModel.setHeaderData(index, QtCore.Qt.Horizontal,
                                               name)

        self.booksByGenreModel = SqlQueryModel(
            self, self._db,
            "bookid, firstname, lastname, title, seqname, lang, year",
            "libgenre g INNER JOIN libbook b USING(bookid) LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libseqname s ON b.seqid = s.seqid",
            "g.genreid = ?")
        self.booksByGenreView.setModel(self.booksByGenreModel)
        self.booksByGenreModel.addBindValue(0)
        self.booksByGenreModel.select()
        self.booksByGenreView.hideColumn(0)
        for index, name in enumerate([
                self.tr("bookid"),
                self.tr("First name"),
                self.tr("Last name"),
                self.tr("Book Title"),
                self.tr("Sequence"),
                self.tr("Lang"),
                self.tr("Year")
        ]):
            self.booksByGenreModel.setHeaderData(index, QtCore.Qt.Horizontal,
                                                 name)

        self.booksByGroupModel = SqlQueryModel(
            self, self._db,
            "b.bookid, firstname, lastname, title, seqname, genredesc, lang, year",
            "libgroup g INNER JOIN libbook b USING(bookid) LEFT JOIN libseqname s ON b.seqid = s.seqid LEFT JOIN libauthorname a ON b.authorid = a.authorid LEFT JOIN libgenrelist gl ON b.genreid = gl.genreid",
            "g.groupid = ?")
        self.booksByGroupView.setModel(self.booksByGroupModel)
        self.booksByGroupModel.addBindValue(0)
        self.booksByGroupModel.select()
        self.booksByGroupView.hideColumn(0)
        for index, name in enumerate([
                self.tr("bookid"),
                self.tr("First name"),
                self.tr("Last name"),
                self.tr("Book Title"),
                self.tr("Sequence"),
                self.tr("Genre"),
                self.tr("Lang"),
                self.tr("Year")
        ]):
            self.booksByGroupModel.setHeaderData(index, QtCore.Qt.Horizontal,
                                                 name)

        self.readStateFrom(self.uiSettingsFile)
        self.actionRussianAlphabet.setChecked(
            self.ruLettersToolbar.isVisibleTo(self))
        self.actionEnglishAlphabet.setChecked(
            self.enLettersToolbar.isVisibleTo(self))

        if not self.programSettings.getRowHeight():
            self.programSettings.writeRowHeight(
                self.authorsView.verticalHeader().defaultSectionSize())
        else:
            self.setRowHeight(self.programSettings.getRowHeight())

        for key in ('/', 'Ctrl+F'):
            QtGui.QShortcut(key, self).activated.connect(
                self.on_quickFindShortcut_activated)

        self.parserThread = FB2BookParserThread()
        self.parserThread.bookParsed.connect(self.bookParsed)
        self.parserThread.start()