Exemplo n.º 1
0
 def __init__(self,parent=None):
     super(Content_Treeview,self).__init__(parent)
     
     self.overlay_painter = Progress_Overlay_Painter() 
     self.overlay_painter.set_paint_device(self)
     
     #self.overlay_painter.show()
     self.setAlternatingRowColors(True)
     scale = .045
     self.setIconSize(QSize(1920*scale,1080*scale))
     
     self.setDragEnabled(True)
     self.setSelectionMode(QAbstractItemView.ExtendedSelection)
     #self.setSortingEnabled(True)
     
     #self.setModel(Content_Model())
     self.connect(self, SIGNAL("collapsed (const QModelIndex&)"),self.stop_loading)
     self.connect(self, SIGNAL("expanded (const QModelIndex&)"),self.start_loading)
     
     self.connect(self, SIGNAL("doubleClicked (const QModelIndex&)"),self.double_clicked)
     self.auto_size()
Exemplo n.º 2
0
class Content_Treeview(QTreeView):
    def __init__(self,parent=None):
        super(Content_Treeview,self).__init__(parent)
        
        self.overlay_painter = Progress_Overlay_Painter() 
        self.overlay_painter.set_paint_device(self)
        
        #self.overlay_painter.show()
        self.setAlternatingRowColors(True)
        scale = .045
        self.setIconSize(QSize(1920*scale,1080*scale))
        
        self.setDragEnabled(True)
        self.setSelectionMode(QAbstractItemView.ExtendedSelection)
        #self.setSortingEnabled(True)
        
        #self.setModel(Content_Model())
        self.connect(self, SIGNAL("collapsed (const QModelIndex&)"),self.stop_loading)
        self.connect(self, SIGNAL("expanded (const QModelIndex&)"),self.start_loading)
        
        self.connect(self, SIGNAL("doubleClicked (const QModelIndex&)"),self.double_clicked)
        self.auto_size()
    def stop_loading(self,index):
        
        self.model().remove_data_request(index)
        
        
    def start_loading(self,index):
        
        self.model().request_children_data_loaded(index)

    def double_clicked(self,index):
        
        item_data = index.internalPointer()
        
        if not isinstance(item_data.content, content_types.FileSequence):
            
            url = item_data.content.url()
            QDesktopServices.openUrl(QUrl(url))
        
    def auto_size(self):
        for i in [0,1,2,3,4]:
            self.resizeColumnToContents(i)
            
        #self.setColumnWidth(0,200)
            
    def currentChanged(self,current,previous):
        
        self.emit(SIGNAL('current_changed'),current,previous)
        
        QTreeView.currentChanged(self,current,previous)

        
        self.model().set_current_item(current.internalPointer())
        if current:
            self.model().priority_data_request(current)
            
    def dataChanged(self,topLeft,bottomRight):
        
        QTreeView.dataChanged(self,topLeft,bottomRight)
        
        #for i in [1,2,3,4]:
            #self.resizeColumnToContents(i)
            
            
    def get_selected_items(self):
        

        selected_items = []
        #print self.selectedIndexes()
        
        selection_model = self.selectionModel()
        
        #print selection_model.selectedRows()
        for index in selection_model.selectedRows():
            
            item_data = index.internalPointer()
            
            selected_items.append(item_data)
            
        return selected_items
        
    def sizeHint(self):
        return QSize(800,400)
    
    def setModel(self,model):
        
        QTreeView.setModel(self,model)
        self.setSortingEnabled(True)
        self.start_loading(None)
        
    def keyPressEvent(self,event):
        
        if event == QKeySequence.Copy:
            items = self.get_selected_items()
            
            paths = []
            for item in items:
                paths.append(item.content.path())
                
            app = QApplication.instance()
            
            app.clipboard().setText("\n".join(paths))
            print paths
            event.accept()
        else:
            QTreeView.keyPressEvent(self,event)
        
    def paintEvent(self,event):
        
        QTreeView.paintEvent(self,event)
        self.overlay_painter.paint_overlay()