Commits

Benjamin Wohlwend committed 5fa6742

Synchronization between the views should finally work without errors

  • Participants
  • Parent commits c5426c8

Comments (0)

Files changed (2)

File src/undercover/gui/mainwindow.py

                                self.set_view_mode)
         QtCore.QObject.connect(self.ui.show_flowview, QtCore.SIGNAL('clicked()'),
                                self.set_view_mode)
-        QtCore.QObject.connect(self.ui.icon_view, QtCore.SIGNAL('currentIndexChanged(QModelIndex)'), 
+        QtCore.QObject.connect(self.ui.icon_view, QtCore.SIGNAL('currentChanged(QModelIndex, QModelIndex)'), 
                                self.cover_index_changed)
-        QtCore.QObject.connect(self.ui.flow_view, QtCore.SIGNAL('currentIndexChanged(QModelIndex)'), 
+        QtCore.QObject.connect(self.ui.flow_view, QtCore.SIGNAL('currentChanged(QModelIndex, QModelIndex)'), 
                                self.cover_index_changed)
                                
     def setup_actions(self):
         if self.current_covers_index == index:
             return
         self.current_covers_index = index
-        if self.ui.flow_view.isVisible():
-            self.ui.icon_view.setCurrentIndex(index)
-        else:
-            self.ui.flow_view.setCurrentIndex(index)
         self.set_cover_info(index)
     
     def set_cover_info(self, current=None):

File src/undercover/gui/widgets/views.py

     def position_label(self, label, rect):
         label.move(rect.x() +rect.width()/2 - label.width()/2,
                    rect.y() + 2*rect.height()/3)
-    
-    def currentChanged(self, current, old):
-        self.emit(QtCore.SIGNAL('currentIndexChanged(QModelIndex)'), current)
         
     def setModel(self, model):
         if not model:
         else:
             self.__has_model = True
         QtGui.QListView.setModel(self, model)
-        
+
+    def setCurrentIndex(self, index):
+        QtGui.QListView.setCurrentIndex(self, index)
+            
     def keyPressEvent(self, event):
         if event.key() in (QtCore.Qt.Key_Delete,):
             if self.currentIndex().isValid():
         self.info_label = AlbumInfoLabel(self)
         self.info_label.hide(animate=False)
         self.setSlideSize(QtCore.QSize(150,150))
-        QtCore.QObject.connect(self, QtCore.SIGNAL('currentIndexChanged(QModelIndex)'), self.fill_label)
+        QtCore.QObject.connect(self, QtCore.SIGNAL('currentIndexChanged(QModelIndex)'), self.current_changed)
         self.set_background_image()
 
     def set_background_image(self):
             painter = QtGui.QPainter(self)
             painter.drawPixmap(event.rect(), self.__bg_pixmap, event.rect())
             painter.end()
-        
-    def currentIndex(self):
-        i = QxtFlowView.currentIndex(self)
-        return i
+ 
+    def setCurrentIndex(self, index):
+        prev = self.currentIndex()
+        QxtFlowView.setCurrentIndex(self, index)
+        QtCore.QObject.emit(self, QtCore.SIGNAL('currentChanged(QModelIndex, QModelIndex)'), index, prev)
+
+    def current_changed(self, index):
+        self.fill_label(index)
+        QtCore.QObject.emit(self, QtCore.SIGNAL('currentChanged(QModelIndex, QModelIndex)'), index, QtCore.QModelIndex())
 
     def resizeEvent(self, event):
         QxtFlowView.resizeEvent(self, event)