Beispiel #1
0
    def __init__( self, parent = None ):
        QAbstractItemModel.__init__( self, parent )

        self.rootItem = FileItemRoot( [ "File name", "Full path" ] )
        self.count = 0
        self.__populateModel()
        return
Beispiel #2
0
	def __init__(self,
				parent=None,
				rootNode=None,
				horizontalHeaders=None,
				verticalHeaders=None,
				defaultNode=None):
		"""
		Initializes the class.

		:param parent: Object parent.
		:type parent: QObject
		:param rootNode: Root node.
		:type rootNode: AbstractCompositeNode or GraphModelNode
		:param horizontalHeaders: Headers.
		:type horizontalHeaders: OrderedDict
		:param verticalHeaders: Headers.
		:type verticalHeaders: OrderedDict
		:param defaultNode: Default node.
		:type defaultNode: AbstractCompositeNode or GraphModelNode
		"""

		LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__))

		QAbstractItemModel.__init__(self, parent)

		# --- Setting class attributes. ---
		self.__rootNode = None
		self.rootNode = rootNode or umbra.ui.nodes.DefaultNode(name="InvisibleRootNode")
		self.__horizontalHeaders = None
		self.horizontalHeaders = horizontalHeaders or OrderedDict([("Graph Model", "graphModel")])
		self.__verticalHeaders = None
		self.verticalHeaders = verticalHeaders or OrderedDict()
		self.__defaultNode = None
		self.defaultNode = defaultNode or umbra.ui.nodes.GraphModelNode
Beispiel #3
0
 def __init__(self, parentObject):
     QAbstractItemModel.__init__(self, parentObject )
     self._sortMode = core.config()["Workspace"]["FileSortMode"]
     self._workspace = parentObject.parent()
     self._workspace.documentOpened.connect(self._onDocumentOpened)
     self._workspace.documentClosed.connect(self._onDocumentClosed)
     self._workspace.modificationChanged.connect(self._onDocumentDataChanged)
Beispiel #4
0
 def __init__(self, library):
     QAbstractItemModel.__init__(self)
     self.file_icon = QIcon(auxilia.PIcon('audio-x-generic'))
     self.dir_icon = QIcon(auxilia.PIcon('folder-sound'))
     self.cache = {}
     self.library = library
     self.root = mpdlibrary.Dir('', self.library)
Beispiel #5
0
 def __init__(self, controller, distributed_objects, parent = None):
     """ Constructor <br>
         Create a VariableModel derived from an QAbstractItemModel to display the <br>
         GDB variables in a treeview.<br>
         Listens to the following Signals: SignalProxy::inferiorHasStopped(PyQt_PyObject) <br>
                                           SignalProxy::inferiorHasExited(PyQt_PyObject) and <br>
                                           SignalProxy::executableOpened()
     @param controller            controllers.WatchController, Reference to the WatchController
     @param distributedObjects    distributedobjects.DistributedObjects, the DistributedObjects-Instance
     @param parent                parent for the QAbstractItemModel-Constructor, can be None
     """
     
     QAbstractItemModel.__init__(self, parent)
     
     self.distributedObjects = distributed_objects    
     self.controller = controller
     
     ## @var root
     #  RootVarWrapper, root item of tree 
     self.root = RootVarWrapper()
     
     ## images: 
     self.imgStruct = QPixmap(":/icons/images/struct.png")
     self.imgFake = QPixmap(":/icons/images/fake_entry.png")
     self.imgVariable = QPixmap(":/icons/images/var.png")
     self.imgEdit = QPixmap(":/icons/images/edit.png")
     self.imgOutOfScope = QPixmap(":/icons/images/outofscope.png")
     #connects
     
     QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('inferiorHasStopped(PyQt_PyObject)'), self.update)
     QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('inferiorHasExited(PyQt_PyObject)'), self.clear)
     QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('executableOpened()'), self.clear)  
Beispiel #6
0
  def __init__(self, __parent = None):
    """
    Constructor.
    """
    QAbstractItemModel.__init__(self, __parent)

    # init root + some values
    self.rootItem = None
    self.__parent = __parent
    self.connect(self.__parent, SIGNAL("NewSearch"), self.clean)
    self.VFS = VFS.Get()
    self.map = {}
    self.imagesthumbnails = None
    self.connect(self, SIGNAL("dataImage"), self.setDataImage)
    self.translation()

    self.fetchedItems = 0
    self.thumbQueued = {}
    self.checkedNodes = set()

    # those list contains nodes' children of the currently selcted node.
    self.node_list = []

    # list of headers the user choosed to display.
    self.header_list = []
    self.type_list = []
    self.disp_module = 0
    self.del_sort = 0

    self.cacheAttr = (None, None)
Beispiel #7
0
 def __init__(self, ert):
     """
     @type ert: ert.enkf.EnKFMain
     """
     QAbstractItemModel.__init__(self)
     self.__ert = ert
     self.__icon = util.resourceIcon("ide/small/bullet_star")
Beispiel #8
0
    def __init__(self, parent ):
        """Constructor of SearchResultsModel class
        """
        QAbstractItemModel.__init__(self, parent )
        self._replaceMode = False

        self.fileResults = []  # list of FileResults
Beispiel #9
0
    def __init__(self, tree_instance):
        """ Inititalizes tree model and super class.
        """
        QAbstractItemModel.__init__(self)
        self._treeRoot = tree_instance

        self._treeRoot.signal_tree_data_changed.connect(self.fire_model_changed)
Beispiel #10
0
    def __init__( self, parent = None ):
        QAbstractItemModel.__init__( self, parent )

        self.rootItem = NameItem( None, None, "Name", "", "", "" )
        self.count = 0
        self.showTooltips = Settings().findNameTooltips
        self.__populateModel()
        return
    def __init__( self, headerData, parent = None ):
        QAbstractItemModel.__init__( self, parent )

        self.rootItem = TreeViewItem( None, headerData )
        self.globalData = GlobalData()
        self.projectTopLevelDirs = []
        self.showTooltips = True
        return
Beispiel #12
0
	def __init__(self, data, parent = None):
		QAbstractItemModel.__init__(self, parent)
		self._data = data
		self._table = []
		self._tableR = {}
		self._headers = ['file','confidence']
		self._headersR = { v:i for i,v in enumerate(self._headers) }
		self._update(self._data)
Beispiel #13
0
 def __init__(self, mpdclient, library):
     QAbstractItemModel.__init__(self)
     self.mpdclient = mpdclient
     self.library = library
     self._playlists = {}
     self._names = []
     self._dates = {}
     self.connect(self, SIGNAL("loadPlaylist"), self._loadPlaylist)
     self.connect(self, SIGNAL("updatePlaylist"), self._updatePlaylist)
Beispiel #14
0
  def setHeaderData(self, section, orientation, value, role):
    """
    \reimp

    Add a header data into the header. Emit a `layoutAboutToBeChanged` signal before adding the header
    and `layoutChanged` once it is done.
    """
    self.emit(SIGNAL("layoutAboutToBeChanged()"))
    QAbstractItemModel.setHeaderData(self, section, orientation, value, role)
    self.emit(SIGNAL("layoutChanged()"))
Beispiel #15
0
 def __init__(self, data, header, parent):
     QAbstractItemModel.__init__(self, parent)
     self._data = data
     self._dataDict = {}
     self._header = header
     self._roleData = {Qt.DisplayRole: self._data}
     self._roleData = partial(
         defaultdict,
         partial(defaultdict,
                 partial(defaultdict, lambda: None)))(self._roleData)
Beispiel #16
0
	def __init__(self, data, filename=None, parent = None ):
		QAbstractItemModel.__init__(self, parent)
		self._data = data
		self._file = filename
		self._hheaders = ['original', 'converted', 'encoder', 'decoder', 'chardet']
		self._hheadersR = { v:i for i,v in enumerate(self._hheaders) }
		self._table = []
		self._tableR = {}
		if filename:
			self._update()
Beispiel #17
0
 def __init__(self, annotations, parent=None):
     QAbstractItemModel.__init__(self, parent)
     start = time.time()
     self._annotations = annotations
     self._dirty = False
     self._root = RootModelItem(self, annotations)
     diff = time.time() - start
     LOG.info("Created AnnotationModel in %.2fs" % (diff,))
     self.dataChanged.connect(self.onDataChanged)
     self.rowsInserted.connect(self.onDataChanged)
     self.rowsRemoved.connect(self.onDataChanged)
Beispiel #18
0
    def __init__(self, parent=None):
        QAbstractItemModel.__init__(self, parent)
        self.treeView = parent
        self.header = [self.tr('Databases')]

        self.isImportVectorAvail = hasattr(qgis.core, 'QgsVectorLayerImport')
        if self.isImportVectorAvail:
            self.connect(self, SIGNAL("importVector"), self.importVector)

        self.rootItem = TreeItem(None, None)
        for dbtype in supportedDbTypes():
            dbpluginclass = createDbPlugin(dbtype)
            PluginItem(dbpluginclass, self.rootItem)
    def __init__(self, parent, topLevelOperator, roleIndex):
        """
        :param topLevelOperator: An instance of OpMultiLaneDataSelectionGroup
        """
        # super does not work here in Python 2.x, decorated class confuses it
        QAbstractItemModel.__init__(self, parent)
        self._op = topLevelOperator
        self._roleIndex = roleIndex

        def handleNewLane( multislot, laneIndex):
            assert multislot is self._op.DatasetGroup
            self.beginInsertRows( QModelIndex(), laneIndex, laneIndex )
            self.endInsertRows()

            def handleDatasetInfoChanged(slot):
                # Get the row of this slot
                laneSlot = slot.operator
                if laneSlot is None or laneSlot.operator is None: # This can happen during disconnect
                    return
                try:
                    laneIndex = laneSlot.operator.index( laneSlot )
                except ValueError:
                    # If the slot doesn't exist in the lane, 
                    #  then this dataset is in the process of being removed.
                    return
                firstIndex = self.createIndex(laneIndex, 0)
                lastIndex = self.createIndex(laneIndex, self.columnCount()-1)
                self.dataChanged.emit(firstIndex, lastIndex)
            
            def handleNewDatasetInserted(slot, index):
                if index == self._roleIndex:
                    datasetMultiSlot[self._roleIndex].notifyDirty( bind(handleDatasetInfoChanged) )
                    datasetMultiSlot[self._roleIndex].notifyDisconnect( bind(handleDatasetInfoChanged) )

            for laneIndex, datasetMultiSlot in enumerate( self._op.DatasetGroup ):
                datasetMultiSlot.notifyInserted( bind(handleNewDatasetInserted) )
                if self._roleIndex < len(datasetMultiSlot):
                    handleNewDatasetInserted(datasetMultiSlot, self._roleIndex)

        self._op.DatasetGroup.notifyInserted( bind(handleNewLane) )

        def handleLaneRemoved( multislot, laneIndex ):
            assert multislot is self._op.DatasetGroup
            self.beginRemoveRows( QModelIndex(), laneIndex, laneIndex )
            self.endRemoveRows()
        self._op.DatasetGroup.notifyRemoved( bind(handleLaneRemoved) )

        # Any lanes that already exist must be added now.        
        for laneIndex, slot in enumerate(self._op.DatasetGroup):
            handleNewLane( self._op.DatasetGroup, laneIndex )
Beispiel #20
0
    def __init__(self, header, header_types=None, key_column=None, parent=None):
        QAbstractItemModel.__init__(self, parent)

        self.header = header
        self.header_types = header_types
        self.key_column = key_column

        if not self.key_column:
            self.key_column = self.header[0]

        if not self.header_types:
            self.header_types = {}
            for column in self.header:
                self.header_types[column] = 'string'
Beispiel #21
0
 def __init__(self, selection):
   QAbstractItemModel.__init__(self)
   self.__list = []
   self.__rows = []
   self.__current_row = 0
   self.__row_selected = 0
   self.__thumb = True
   self.__visible_rows = 0
   self.__visible_cols = 0
   self.selection = selection
   self.setDefaultAttributes()
   self.connectSignals()
   self.thumbnailer = Thumbnailer()
   self.connect(self.thumbnailer, SIGNAL("ThumbnailUpdate"), self.thumbnailUpdate)
   self.headerorder = {0:0}
Beispiel #22
0
    def __init__(self, debugger, connector, parent=None):
        """ The constructor.
        @param debugger The debug controller.
        @param connector The GDB connector.
        @param parent The parent item.
        """

        QAbstractItemModel.__init__(self, parent)
        self.connector = connector
        self.debugController = debugger
        self.root = FileListItem(["Name", "Path"], None)
        self.sources = FileListItem(["Sources", ""], Icons.folder, self.root)
        self.headers = FileListItem(["Headers", ""], Icons.folder, self.root)
        self.others = FileListItem(["Others", ""], Icons.folder, self.root)

        self.debugController.executableOpened.connect(self.update)
Beispiel #23
0
 def createIndex(self, row, column, item):
     old = self.cache.get(item._value)
     if old is None:
         self.cache[item._value] = item
     else:
         item = old
     return QAbstractItemModel.createIndex(self, row, column, item)
Beispiel #24
0
    def __init__(self, debugger, connector, parent = None):
        """ The constructor.
        @param debugger The debug controller.
        @param connector The GDB connector.
        @param parent The parent item.
        """
 
        QAbstractItemModel.__init__(self, parent)
        self.connector = connector
        self.debug_controller = debugger
        self.imgs = [QPixmap(":/icons/images/folder.png"), QPixmap(":/icons/images/file.png")]
        self.root = FileListItem(["Name", "Path"], 0)
        self.sources = FileListItem(["Sources", ""], 0, self.root)
        self.headers = FileListItem(["Headers", ""], 0, self.root)
        self.others = FileListItem(["Others", ""], 0, self.root)
        
        QObject.connect(self.debug_controller, SIGNAL('executableOpened'), self.update)
Beispiel #25
0
    def __init__(self, framework, item_definition, parent = None):
        QAbstractItemModel.__init__(self, parent)
        self.framework = framework
        self.item_definition = item_definition

        self.rows = deque()
        self._sort_keys = None
        self._sort_column = 0
        self._sort_order = Qt.AscendingOrder

        self.column_offset = []
        self.db_offset = {}
        self.column_count = 0
        for item in self.item_definition:
            self.column_offset.append(item[1])
            self.db_offset[item[1]] = self.column_count
            self.column_count += 1
Beispiel #26
0
    def flags(self, index ):
        """See QAbstractItemModel docs
        """
        flags = QAbstractItemModel.flags( self, index )

        if self._replaceMode:
            flags |= Qt.ItemIsUserCheckable

        return flags
Beispiel #27
0
 def flags(self, index):
     """QAbstractItemModel required"""
     theFlags = QAbstractItemModel.flags(self,index)
     if index.isValid():
         theFlags |= Qt.ItemIsSelectable | Qt.ItemIsEnabled 
     if index.column() == NAME:
         theFlags |= Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
     # end if
     return theFlags
Beispiel #28
0
 def flags(self, index):
     defaultFlags = QAbstractItemModel.flags(self, index)
     if index.isValid():
         if index.column() == 0:
             return Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled | Qt.ItemIsEditable | defaultFlags
         else:
             return Qt.ItemIsDragEnabled | defaultFlags
     else:
         return Qt.ItemIsDropEnabled | defaultFlags
Beispiel #29
0
    def __init__( self, parent = None ):
        QAbstractItemModel.__init__( self, parent )

        self.watchpoints = []
        self.header = [
            QVariant( 'Condition' ),
            QVariant( 'Special' ),
            QVariant( 'Temporary' ),
            QVariant( 'Enabled' ),
            QVariant( 'Ignore Count' ),
                      ]
        self.alignments = [
            QVariant( Qt.Alignment( Qt.AlignLeft ) ),
            QVariant( Qt.Alignment( Qt.AlignLeft ) ),
            QVariant( Qt.Alignment( Qt.AlignHCenter ) ),
            QVariant( Qt.Alignment( Qt.AlignHCenter ) ),
            QVariant( Qt.Alignment( Qt.AlignRight ) ),
                          ]
        return
Beispiel #30
0
 def setData(self, index, value, role):
     if not index.isValid():
         return False
     item = index.internalPointer().node()
     if role == Qt.CheckStateRole:
         # a checkbox was modified
         progress, success = value.toInt()
         item.toElement().setAttribute("percentageComplete",str(progress*50))
         # check children
         numChildren = item.childNodes().count()
         if numChildren > 0 and progress == Qt.Checked:
             for i in xrange(0,numChildren):
                 self.setData(index.child(i,0),value,role)
             self.dataChanged.emit(index,index.child(numChildren-1,0))
         if progress == Qt.Unchecked:
             self.setData(index.parent(),value,role)
             self.dataChanged.emit(index.parent(),index)
         return True
         
     elif role == Qt.EditRole:
         if index.column() == 0:
             # task desc
             item.toElement().setAttribute("subject",
                                                 unicode(value.toString()))
             self.dataChanged.emit(index,index)
             return True
             
         elif index.column() == 1:
             # task progress
             item.toElement().setAttribute("percentageComplete",
                                                     str(value.toString())) 
             self.dataChanged.emit(index,index)
             
             progress, success = value.toInt()
             if progress == 100:                
                 # if task is now completed, update children
                 # FIXME: this doesn't work and I don't understand why :(
                 numChildren = item.childNodes().count()
                 if numChildren > 0:
                     for i in xrange(0,numChildren):
                         self.setData(index.child(i,1),value,role)
                     self.dataChanged.emit(index,index.child(numChildren-1,1))
                     return True
                     
             elif progress < 100:
                 # if task is now NOT complete and parent is, update parent.
                 # this works
                 if self.data(index.parent(),Qt.CheckStateRole) == Qt.Checked:
                     parentIndex = self.index(index.parent().row(),index.column(),index.parent().parent())
                     self.setData(parentIndex,value,role)
                     self.dataChanged.emit(index.parent(),index)
                 return True
             return True
     # for everything else, do the generic thing
     return QAbstractItemModel.setData(self,index,value,role)