示例#1
0
    def _del_article(self):
        items = self.selectedItems()
        if not items:
            return

        article = items[0].article
        msg = 'Delete "%s"?' % article.title
        btn = QMessageBox.question(self, 'Delete article', msg, QMessageBox.Yes | QMessageBox.No)
        if btn == QMessageBox.No:
            return

        s = get_session()
        s.delete(Article.find_by_id(s, article.id))
        s.commit()
        self.update_articles()
示例#2
0
    def _rename_article(self):
        items = self.selectedItems()
        if not items:
            return

        article = items[0].article
        text, result = QInputDialog.getText(self, 'Rename article', 'New article title:', text=article.title)
        if not result:
            return

        text = str(text)
        if not text or text == article.title:
            return

        s = get_session()
        a = Article.find_by_id(s, article.id)
        a.title = text
        s.commit()
        self.update_articles()
示例#3
0
 def _refresh(self):
     article = Article.find_by_id(get_session(), self.article_id)
     self.new_words = list(article.new_words)
     self.highlight.rehighlight()
     self.onArticleLoaded.emit(self.article_id)
示例#4
0
文件: MainWindow.py 项目: Alex-ZL/ljn
    def open_article(self, window, article_id):
        from ljn.Model import Article
        from ljn.Repository import get_session

        window.article_browser.setFocus()
        window.article_browser.set_article(Article.find_by_id(get_session(), article_id))