コード例 #1
0
ファイル: treemodel.py プロジェクト: yxsyxs/QMusic
    def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()

        child_item = index.internalPointer()
        parent_item = child_item.parent()

        if parent_item is None or parent_item == self.root_item:
            return QtCore.QModelIndex()

        return self.createIndex(parent_item.row(), 0, parent_item)
コード例 #2
0
ファイル: treemodel.py プロジェクト: yxsyxs/QMusic
    def index(self, row, column, parent=None):

        if parent is None:
            parent = QtCore.QModelIndex()

        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

        parentItem = self.treeItem(parent)
        childItem = parentItem.child(row)
        if childItem:
            return self.createIndex(row, column, childItem)
        else:
            return QtCore.QModelIndex()
コード例 #3
0
 def _readModelSettings(self,
                        reset=False,
                        show_routine_attributes=None,
                        show_special_attributes=None):
     """ Reads the persistent model settings .
         The persistent settings (show_routine_attributes, show_special_attributes) can be \
         overridden by giving it a True or False value.
         If reset is True and the setting is None, True is used as default.
     """
     default_sra = True
     default_ssa = True
     if reset:
         logger.debug("Resetting persistent model settings")
         if show_routine_attributes is None:
             show_routine_attributes = default_sra
         if show_special_attributes is None:
             show_special_attributes = default_ssa
     else:
         logger.debug("Reading model settings for window: {:d}".format(
             self._instance_nr))
         settings = QtCore.QSettings()
         settings.beginGroup(self._settings_group_name('model'))
         if show_routine_attributes is None:
             show_routine_attributes = setting_str_to_bool(
                 settings.value("show_routine_attributes", default_sra))
         if show_special_attributes is None:
             show_special_attributes = setting_str_to_bool(
                 settings.value("show_special_attributes", default_ssa))
         settings.endGroup()
         logger.debug("read show_routine_attributes: {!r}".format(
             show_routine_attributes))
         logger.debug("read show_special_attributes: {!r}".format(
             show_special_attributes))
     return (show_routine_attributes, show_special_attributes)
コード例 #4
0
    def _readViewSettings(self, reset=False):
        """ Reads the persistent program settings
        
            :param reset: If True, the program resets to its default settings
        """
        pos = QtCore.QPoint(20 * self._instance_nr, 20 * self._instance_nr)
        window_size = QtCore.QSize(1024, 700)
        details_button_idx = 0

        header = self.obj_tree.header()
        header_restored = False

        if reset:
            logger.debug("Resetting persistent view settings")
        else:
            logger.debug("Reading view settings for window: {:d}".format(
                self._instance_nr))
            settings = QtCore.QSettings()
            settings.beginGroup(self._settings_group_name('view'))
            pos = settings.value("main_window/pos", pos)
            window_size = settings.value("main_window/size", window_size)
            details_button_idx = int(
                settings.value("details_button_idx", details_button_idx))
            self.central_splitter.restoreState(
                settings.value("central_splitter/state"))
            header_restored = self.obj_tree.read_view_settings(
                'table/header_state', settings, reset)
            settings.endGroup()

        if not header_restored:
            column_sizes = [col.width for col in self._attr_cols]
            column_visible = [col.col_visible for col in self._attr_cols]

            for idx, size in enumerate(column_sizes):
                if size > 0:  # Just in case
                    header.resizeSection(idx, size)

            for idx, visible in enumerate(column_visible):
                self.obj_tree.toggle_column_actions_group.actions(
                )[idx].setChecked(visible)

        self.resize(window_size)
        self.move(pos)
        button = self.button_group.button(details_button_idx)
        if button is not None:
            button.setChecked(True)
コード例 #5
0
ファイル: toggle_column_mixin.py プロジェクト: yxsyxs/QMusic
    def write_view_settings(self, key, settings=None):
        """ Writes the view settings to the persistent store
        """
        logger.debug("Writing view settings for: {}".format(key))

        if settings is None:
            settings = QtCore.QSettings()
        settings.setValue(key, self._horizontal_header().saveState())
コード例 #6
0
 def _writeModelSettings(self):
     """ Writes the model settings to the persistent store
     """         
     logger.debug("Writing model settings for window: {:d}".format(self._instance_nr))
     
     settings = QtCore.QSettings()
     settings.beginGroup(self._settings_group_name('model'))
     logger.debug("writing show_routine_attributes: {!r}".format(self._tree_model.getShowCallables()))
     logger.debug("wrting show_special_attributes: {!r}".format(self._tree_model.getShowSpecialAttributes()))
     settings.setValue("show_routine_attributes", self._tree_model.getShowCallables())
     settings.setValue("show_special_attributes", self._tree_model.getShowSpecialAttributes())
     settings.endGroup()
コード例 #7
0
 def _writeViewSettings(self):
     """ Writes the view settings to the persistent store
     """         
     logger.debug("Writing view settings for window: {:d}".format(self._instance_nr))
     
     settings = QtCore.QSettings()
     settings.beginGroup(self._settings_group_name('view'))
     self.obj_tree.write_view_settings("table/header_state", settings)
     settings.setValue("central_splitter/state", self.central_splitter.saveState())
     settings.setValue("details_button_idx", self.button_group.checkedId())
     settings.setValue("main_window/pos", self.pos())
     settings.setValue("main_window/size", self.size())
     settings.endGroup()
コード例 #8
0
 def refreshcontent(self):
     markdownpageinstance = getattr(self.parent, 'MarkdownPage')
     frame = markdownpageinstance.view.page().mainFrame()
     mdhtml = unicode(frame.evaluateJavaScript("$('#preview').html()"))
     if not os.path.exists(os.sep.join([os.getcwd(), 'doc'])):
         os.mkdir(os.sep.join([os.getcwd(), 'doc']))
     htmlfile = os.sep.join([os.getcwd(), 'doc', 'preview.html'])
     self.theme = "evernote"
     self.html = mdhtmlcomplete(
         mdhtml, windowsoptions['markdownthemes']['theme%s' % self.theme],
         htmlfile, 'templateDef_evernote')
     url = QtCore.QUrl('file:///' + htmlfile)
     self.view.load(url)
コード例 #9
0
ファイル: effect.py プロジェクト: zhangxin8105/QMarkdowner
    def __init__(self, parent=None):
        super(FaderWidget, self).__init__(parent)

        if parent:
            self.startColor = parent.palette().window().color()
        else:
            self.startColor = QtCore.Qt.white

        self.currentAlpha = 0
        self.duration = 1000

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.update)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.resize(parent.size())
コード例 #10
0
    def __init__(self, text, bg, parent=None):


        super(DynamicTextWidget, self).__init__(parent)

        self.bg = bg
        self.text = text

        newFont = self.font()
        newFont.setPointSize(newFont.pointSize() + 10)
        self.setFont(newFont)

        self.painter = QtGui.QPainter()

        self.timer = QtCore.QBasicTimer()

        self.step = 0
        self.timer.start(60, self)
コード例 #11
0
 def settheme(self):
     theme = self.sender().objectName()[5:-6]
     self.theme = theme
     markdownpageinstance = getattr(self.parent, 'MarkdownPage')
     frame = markdownpageinstance.view.page().mainFrame()
     mdhtml = unicode(frame.evaluateJavaScript("$('#preview').html()"))
     if theme == "evernote":
         self.html = mdhtmlcomplete(
             mdhtml,
             windowsoptions['markdownthemes']['themeevernote'],
             template='templateDef_evernote')
     elif theme == "jeklyy":
         self.html = mdhtmlcomplete(
             mdhtml,
             windowsoptions['markdownthemes']['themejeklyy'],
             template='templateDef_jeklyy')
     else:
         self.html = mdhtmlcomplete(
             mdhtml, windowsoptions['markdownthemes']['theme%s' % theme])
     self.view.setHtml(self.html, QtCore.QUrl(os.getcwd()))
コード例 #12
0
ファイル: toggle_column_mixin.py プロジェクト: yxsyxs/QMusic
    def read_view_settings(self, key, settings=None, reset=False):
        """ Reads the persistent program settings
        
            :param reset: If True, the program resets to its default settings
            :returns: True if the header state was restored, otherwise returns False
        """
        logger.debug("Reading view settings for: {}".format(key))
        header_restored = False
        if not reset:
            if settings is None:
                settings = QtCore.QSettings()
            horizontal_header = self._horizontal_header()
            header_restored = horizontal_header.restoreState(
                settings.value(key))

            # update actions
            for col, action in enumerate(horizontal_header.actions()):
                is_checked = not horizontal_header.isSectionHidden(col)
                action.setChecked(is_checked)

        return header_restored
コード例 #13
0
 def loadfromlocal(self):
     html = self.auto_html(templateDef_absolute)
     url = QtCore.QUrl('file:///' + os.sep.join(
         [os.getcwd(), 'webjscss', 'MaDeEditor', 'MaDeEditor.html']))
     self.view.load(url)
     self.view.setFocus()
コード例 #14
0
ファイル: aboutpage.py プロジェクト: zhangxin8105/QMarkdowner
 def loadfromlocal(self):
     html = self.auto_html(templateDef_absolute)
     self.view.setHtml(html, QtCore.QUrl(os.getcwd()))