コード例 #1
0
    def on_create_clicked(self):
        title = self.create_tab.title.text()
        if self.create_tab.plain_text_cb.checkState() == Qt.Checked:
            text = self.create_tab.text.toPlainText()
        else:
            # if this check is missing, text is sometimes saved as an empty paragraph
            if self.create_tab.text.document().isEmpty():
                text = ""
            else:
                text = self.create_tab.text.toHtml()

        source = self.create_tab.source.text()
        tags = self.create_tab.tag.text()
        queue_schedule = self.create_tab.queue_schedule

        # don't allow for completely empty fields
        if len(title.strip()) + len(text.strip()) == 0:
            return

        create_note(title, text, source, tags, None, "", queue_schedule)
        #aqt.dialogs.close("UserNoteEditor")
        self.reject()

        # if reading modal is open, we might have to update the bottom bar
        if self.read_note_id is not None:
            update_reading_bottom_bar(self.read_note_id)
 def cleanHighlights(self, text):
     """
     Clean linebreaks and some html entitíes from the highlights string.
     """
     text = text.replace("\n", " ").replace("\r\n", " ").strip()
     text = self.removeTags(text)
     return text.strip()
コード例 #3
0
    def _create_note(self):
        title = self.create_tab.title.text()
        title = utility.text.clean_user_note_title(title) 
        if self.create_tab.plain_text_cb.checkState() == Qt.Checked:
            text = self.create_tab.text.toPlainText()
        else:
            # if this check is missing, text is sometimes saved as an empty paragraph
            if self.create_tab.text.document().isEmpty():
                text = ""
            else:
                text = self.create_tab.text.toHtml()

        source              = self.create_tab.source.text()
        tags                = self.create_tab.tag.text()
        queue_schedule      = self.create_tab.slider.value()
        specific_schedule   = self.create_tab.slider.schedule()

        # if source is a pdf, title must be given
        if len(title.strip()) == 0 and source.lower().strip().endswith(".pdf"):
            tooltip("Title must be set if source is PDF.")
            return False

        if len(title.strip()) + len(text.strip()) == 0:
            tooltip("Either Text or Title have to be filled out.")
            return False
        
        if len(tags.strip()) == 0:
            default_tags = get_config_value_or_default("notes.editor.defaultTagsIfEmpty", "")
            if len(default_tags) > 0:
                tags = default_tags

        NoteEditor.last_tags = tags
        create_note(title, text, source, tags, None, specific_schedule, queue_schedule)
        return True
コード例 #4
0
    def _create_note(self):
        title = self.create_tab.title.text()
        title = utility.text.clean_user_note_title(title)

        # if this check is missing, text is sometimes saved as an empty paragraph
        if self.create_tab.text.document().isEmpty():
            text = ""
        else:
            # text = self.create_tab.text.toHtml()
            if self.create_tab.text.text_was_pasted:
                text = self.create_tab.text.toMarkdown()
            else:
                text = self.create_tab.text.toPlainText()
                # text = re.sub("(\r\n|\n|\r)^", "  \n", text, flags=re.M)
            # text = markdown(text)

        source = self.create_tab.source.text()
        tags = self.create_tab.tag.text()
        priority = self.create_tab.slider.value()
        specific_schedule = self.schedule_tab.scheduler.schedule()
        author = self.metadata_tab.author.text()
        url = self.metadata_tab.url.text()

        # if source is a pdf, title must be given
        if len(title.strip()) == 0 and source.lower().strip().endswith(".pdf"):
            tooltip("Title must be set if source is PDF.")
            return False

        if len(title.strip()) + len(text.strip()) == 0:
            tooltip("Either Text or Title have to be filled out.")
            return False

        if len(tags.strip()) == 0:
            default_tags = get_config_value_or_default(
                "notes.editor.defaultTagsIfEmpty", "")
            if len(default_tags) > 0:
                tags = default_tags

        NoteEditor.last_tags = tags
        create_note(title,
                    text,
                    source,
                    tags,
                    None,
                    specific_schedule,
                    priority,
                    author,
                    url=url)
        return True
コード例 #5
0
 def on_input(self, text):
     if text is None or len(text.strip()) == 0:
         self.fill_result_list(self.suggestions)
     else:
         notes = find_pdf_notes_by_title(text)
         self.fill_result_list(notes)
コード例 #6
0
 def on_input(self, text):
     if text is None or len(text.strip()) == 0:
         self.fill_result_list(self.suggestions)
     else:
         notes = find_notes(text)[:30]
         self.fill_result_list(notes)
コード例 #7
0
 def update_shortcut(self):
     text = self.shortcut_le.text()
     if text is None or len(text.strip()) == 0:
         return
     update_config("notes.editor.shortcut", text)