Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 4
0
    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))