Beispiel #1
0
    def on_get_relations(self, relations):
        self.on_get_proc_nodes(relations.get('Proc', []))
        self.on_get_many_infos(relations.get('Many', []))
        self.on_get_one_infos(relations.get('One', []))
        self.on_get_child_nodes(relations.get('Child', []))
        self.scene.setSceneRect(QtCore.QRectF())

        self.liner.lineup()
Beispiel #2
0
    def mimeData(self, items):
        # I store the created mime data because of a pyside bug:
        #commit 59c882566be0d58c256f715ce675f10f3181ccc3
        #Author: Hugo Parente Lima <*****@*****.**>
        #Date:   Fri Feb 4 17:42:38 2011 -0200
        #
        #    Fix bug 660 - "QMimeData type deleted prematurely when overriding mime-type in QStandardItemModel drag and drop"

        # Also, giving a string in second param of setData() result
        # in a QtCore.QByteArray('') !?!
        # After lots of empiric tries, constructing a QtCore.QByteArray seem to work.

        if not items:
            return None
        self._md = QtCore.QMimeData()
        self._md.setData('kabaret/ids',
                         QtCore.QByteArray('\n'.join(i.text() for i in items)))
        return self._md
Beispiel #3
0
    def __init__(self, parent, index, node_view):
        super(Item, self).__init__(parent)

        self.index = index
        self.infos = None
        self._is_hidden = False

        self.node_view = node_view

        self._create_widget()

        self._state_machine = QtCore.QStateMachine(self)
        self.anims = QtCore.QSequentialAnimationGroup()
        self.anims.addPause(30 * (self.index - 1))
        grp = QtCore.QParallelAnimationGroup()
        opanim = QtCore.QPropertyAnimation(self, "opacity")
        opanim.setDuration(100)
        grp.addAnimation(opanim)
        scaleanim = QtCore.QPropertyAnimation(self, "scale")
        scaleanim.setDuration(100)
        grp.addAnimation(scaleanim)
        self.anims.addAnimation(grp)

        self.hidden = QtCore.QState(self._state_machine)
        self.hidden.assignProperty(self, 'opacity', .1)
        self.hidden.assignProperty(self, 'scale', 0.1)

        self.hidden_done = QtCore.QState(self._state_machine)
        self.hidden_done.entered.connect(self._on_hidden_done)

        self.shown = QtCore.QState(self._state_machine)
        self.shown.assignProperty(self, 'opacity', 1)
        self.shown.assignProperty(self, 'scale', 1)
        self.shown.entered.connect(self._on_shown_start)

        self.hidden.addTransition(self.hidden.propertiesAssigned,
                                  self.hidden_done)

        tr = self.hidden_done.addTransition(self.to_shown, self.shown)
        tr.addAnimation(self.anims)

        tr = self.shown.addTransition(self.to_hidden, self.hidden)
        tr.addAnimation(self.anims)

        self._state_machine.setInitialState(self.hidden_done)
        self._state_machine.start()
Beispiel #4
0
class Item(QtGui.QGraphicsProxyWidget):
    try:
        to_shown = QtCore.Signal()
        to_hidden = QtCore.Signal()
    except AttributeError:
        to_shown = QtCore.pyqtSignal()
        to_hidden = QtCore.pyqtSignal()

    def __init__(self, parent, index, node_view):
        super(Item, self).__init__(parent)

        self.index = index
        self.infos = None
        self._is_hidden = False

        self.node_view = node_view

        self._create_widget()

        self._state_machine = QtCore.QStateMachine(self)
        self.anims = QtCore.QSequentialAnimationGroup()
        self.anims.addPause(30 * (self.index - 1))
        grp = QtCore.QParallelAnimationGroup()
        opanim = QtCore.QPropertyAnimation(self, "opacity")
        opanim.setDuration(100)
        grp.addAnimation(opanim)
        scaleanim = QtCore.QPropertyAnimation(self, "scale")
        scaleanim.setDuration(100)
        grp.addAnimation(scaleanim)
        self.anims.addAnimation(grp)

        self.hidden = QtCore.QState(self._state_machine)
        self.hidden.assignProperty(self, 'opacity', .1)
        self.hidden.assignProperty(self, 'scale', 0.1)

        self.hidden_done = QtCore.QState(self._state_machine)
        self.hidden_done.entered.connect(self._on_hidden_done)

        self.shown = QtCore.QState(self._state_machine)
        self.shown.assignProperty(self, 'opacity', 1)
        self.shown.assignProperty(self, 'scale', 1)
        self.shown.entered.connect(self._on_shown_start)

        self.hidden.addTransition(self.hidden.propertiesAssigned,
                                  self.hidden_done)

        tr = self.hidden_done.addTransition(self.to_shown, self.shown)
        tr.addAnimation(self.anims)

        tr = self.shown.addTransition(self.to_hidden, self.hidden)
        tr.addAnimation(self.anims)

        self._state_machine.setInitialState(self.hidden_done)
        self._state_machine.start()

    def _create_widget(self):
        raise NotImplementedError

    def _on_hidden_done(self):
        self._is_hidden = True
        self._update_widget()
        self.parentItem().lineup()

    def _update_widget(self):
        raise NotImplementedError

    def _on_shown_start(self):
        self._is_hidden = False

    def set_infos(self, node_infos):
        self.infos = node_infos
        if not self._is_hidden:
            self.to_hidden.emit()
        else:
            self._on_hidden_done()
Beispiel #5
0
 def columnCount(self, index=QtCore.QModelIndex()):
     return len(self.column_names)
Beispiel #6
0
 def rowCount(self, index=QtCore.QModelIndex()):
     return len(self._data)
Beispiel #7
0
class VersionsTable(QtGui.QTableView):
    try:
        status_changed = QtCore.pyqtSignal(str)
        load_finished = QtCore.pyqtSignal()
    except AttributeError:
        # PySide style
        status_changed = QtCore.Signal(str)
        load_finished = QtCore.Signal()
        
        
    def __init__(self, client, parent):
        super(VersionsTable, self).__init__(parent)
        
        self.filename = None
        self.client = client
        self._text_status = 'Initializing'
        
        self._show_versions_only = True

        self._model = VersionsModel()
        
        self.setHorizontalScrollMode(self.ScrollPerPixel)
        #self.setVerticalScrollMode(self.ScrollPerPixel)
        #self.setSortingEnabled(False)
        self.verticalHeader().setVisible(False)
        self.setSelectionMode(self.SingleSelection)
        self.setSelectionBehavior(self.SelectRows)

        self.setModel(self._model)
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._on_table_menu)

    def _on_table_menu(self, pos):
        menu = QtGui.QMenu(self)
        menu.addAction('Refresh', self.refresh)        
        menu.exec_(self.mapToGlobal(pos))
        
    def on_disconnect(self):
        self._model._clear()
        self.resizeColumnsToContents()

    def on_connect(self):
        self.refresh()
    
    def set_filename(self, filename):
        if filename == self.filename:
            self.load_finished.emit()
            return
        self.filename = filename
        self.refresh()
        
    def show_versions_only(self, b):
        if b == self._show_versions_only:
            return
        self._show_versions_only = b
        self.refresh()

    def refresh(self):
        if not self.client.connected():
            self.set_status('Not Connected.')
            self.load_finished.emit()
            return
        
        if self.filename is None:
            self._model._clear()
            self.resizeColumnsToContents()
            self.set_status('No filename.')
            self.load_finished.emit()
            return
        
        with self.client.result_to(self._history_data_ready):
            self.set_status('Loading...')
            self.client.apps.VERSIONS.cmds.GetHistory(
                self.filename,
                get_user_name(),
                self._show_versions_only
            )
                
    def _history_data_ready(self, data):
        if data is None:
            self._model._clear()
            self.resizeColumnsToContents()
            self.set_status('Not under version control.')
            return
        self.set_status('')
        self._model._reset(data)
        self.resizeColumnsToContents()
        self.load_finished.emit()
        
    def set_status(self, message):
        self._text_status = message
        self.status_changed.emit(self._text_status)
        
    def text_status(self):
        return self._text_status