示例#1
0
def forumItemSelected(om_gui):
    '''
    user has selected an item in the forum
    '''
    item = om_gui.ui.forum_treeWidget.currentItem()

    datetext = item.data(4,
                         QtCore.Qt.DisplayRole).toDateTime().toString("ddd d MMM h:mm")

    heading = "<b>Subject:\t%s<br />" % item.text(0)
    heading += "From:\t%s<br />" % item.text(2)
    heading += "To:\t%s<br />" % item.text(3)
    heading += "Date:\t%s</b>" % datetext
    message = item.text(5)
    om_gui.ui.forum_label.setText(heading)
    om_gui.ui.forum_textBrowser.setPlainText(message)
    om_gui.ui.forumDelete_pushButton.setEnabled(True)
    om_gui.ui.forumReply_pushButton.setEnabled(True)
    om_gui.ui.forumParent_pushButton.setEnabled(True)

    if om_gui.forum_parenting_mode[0]:
        parentix = int(item.text(1))
        forum.setParent(om_gui.forum_parenting_mode[1], parentix)
        om_gui.forum_parenting_mode = (False, None)
        om_gui.ui.forumParent_pushButton.setStyleSheet("")
        loadForum(om_gui)
示例#2
0
    def forumItemSelected(self):
        '''
        user has selected an item in the forum
        '''
        self.clear_browser()
        n_selected = len(self.tree_widget.selectionModel().selectedRows())
        if n_selected > 0:
            self.archive_button.setEnabled(True)
            self.all_read_button.setEnabled(True)
        if n_selected != 1:
            return
        item = self.tree_widget.currentItem()
        post = item.data(0, QtCore.Qt.UserRole)
        LOGGER.debug("forum post selected %s", post)
        self.topic_label.setText("%s:\t<b>%s</b>" % (_("Subject"), post.topic))
        heading = "%s:\t%s<br />" % (_("From"), post.inits)
        heading += "%s:\t%s<br />" % (_("To"), post.recipient)
        heading += "%s:\t%s" % (_("Post Date"),
                                localsettings.readableDateTime(post.date))
        self.header_label.setText(heading)
        self.browser.setPlainText(post.comment)
        self.reply_button.setEnabled(True)
        if post.important:
            self.important_button.setStyleSheet("color: red")
            self.important_button.setText(_("Remove importance"))
        else:
            self.important_button.setStyleSheet("")
            self.important_button.setText(_("Mark as important"))

        self.important_button.setEnabled(True)
        self.parent_button.setEnabled(True)

        if self.parenting_mode[0]:
            try:
                if self.parenting_mode[1] < post.ix:
                    self.advise(
                        _("Parent topic is newer, operation not allowed"))
                else:
                    forum.setParent(self.parenting_mode[1], post.ix)
            except Exception as exc:
                raise exc
            finally:
                self.cancel_parenting_mode()
                self.loadForum()
        else:
            QtCore.QTimer.singleShot(3000, partial(self.mark_as_read, post.ix))
示例#3
0
    def forumItemSelected(self):
        """
        user has selected an item in the forum
        """
        self.clear_browser()
        n_selected = len(self.tree_widget.selectionModel().selectedRows())
        if n_selected > 0:
            self.archive_button.setEnabled(True)
            self.all_read_button.setEnabled(True)
        if n_selected != 1:
            return
        item = self.tree_widget.currentItem()
        post = item.data(0, QtCore.Qt.UserRole)
        LOGGER.debug("forum post selected %s", post)
        self.topic_label.setText("%s:\t<b>%s</b>" % (_("Subject"), post.topic))
        heading = "%s:\t%s<br />" % (_("From"), post.inits)
        heading += "%s:\t%s<br />" % (_("To"), post.recipient)
        heading += "%s:\t%s" % (_("Post Date"), localsettings.readableDateTime(post.date))
        self.header_label.setText(heading)
        self.browser.setPlainText(post.comment)
        self.reply_button.setEnabled(True)
        if post.important:
            self.important_button.setStyleSheet("color: red")
            self.important_button.setText(_("Remove importance"))
        else:
            self.important_button.setStyleSheet("")
            self.important_button.setText(_("Mark as important"))

        self.important_button.setEnabled(True)
        self.parent_button.setEnabled(True)

        if self.parenting_mode[0]:
            try:
                if self.parenting_mode[1] < post.ix:
                    self.advise(_("Parent topic is newer, operation not allowed"))
                else:
                    forum.setParent(self.parenting_mode[1], post.ix)
            except Exception as exc:
                raise exc
            finally:
                self.cancel_parenting_mode()
                self.loadForum()
        else:
            QtCore.QTimer.singleShot(3000, partial(self.mark_as_read, post.ix))