Wednesday 19 March 2014

KDE upgrade on Gentoo: 4.11 to 4.12.3

Recently I have noticed that while many of my kde packages are Upgradable (Blue highlighted "U" in emerge's output), they were not getting upgraded.
After browsing some forums and attempting to explicitly install a kde 4.12.3 package and having it failed, it appears I may have found the solution.

It may seem like a simple solution, but I am using layman to manage all my kde packages so I assumed that when I ran layman -S or layman -f, it would have updated my kde keyword to reflect the latest packages.

This was not the case, so I created this file in the path: /etc/portage/package.accept_keywords/kde-4.12.3 and inside it, placed all the packages the output listed that had dependencies. Since it was a bit of effort to find, copy and paste into the file, I'm listing it here for those interested.

=kde-base/kcmshell-4.12.3 ~amd64
=kde-base/kiconfinder-4.12.3 ~amd64
=kde-base/kwrite-4.12.3 ~amd64
=kde-base/oxygen-icons-4.12.3 ~amd64
=kde-base/khelpcenter-4.12.3 ~amd64
=kde-base/kdnssd-4.12.3 ~amd64
=kde-base/knetattach-4.12.3 ~amd64
=kde-base/kdontchangethehostname-4.12.3 ~amd64
=kde-base/kstart-4.12.3 ~amd64
=kde-base/keditfiletype-4.12.3 ~amd64
=kde-base/kmimetypefinder-4.12.3 ~amd64
=kde-base/kurifilter-plugins-4.12.3 ~amd64
=kde-base/kdepasswd-4.12.3 ~amd64
=kde-base/ktraderclient-4.12.3 ~amd64
=kde-base/kdebase-menu-4.12.3 ~amd64
=kde-base/kdesu-4.12.3 ~amd64
=kde-base/dolphin-4.12.3 ~amd64
=app-office/akonadi-server-1.11.0 ~amd64
=kde-base/nsplugins-4.12.3 ~amd64
=kde-base/kde-base-artwork-4.12.3 ~amd64
=kde-base/kuiserver-4.12.3 ~amd64
=kde-base/svgpart-4.12.3 ~amd64
=kde-base/konsole-4.12.3 ~amd64
=kde-base/kdebase-runtime-meta-4.12.3 ~amd64
=kde-base/kdebase-desktoptheme-4.12.3 ~amd64
=kde-base/katepart-4.12.3-r1 ~amd64
=kde-base/nepomuk-widgets-4.12.3 ~amd64
=kde-base/kquitapp-4.12.3 ~amd64
=kde-base/keditbookmarks-4.12.3 ~amd64
=kde-base/drkonqi-4.12.3 ~amd64
=kde-base/kglobalaccel-4.12.3 ~amd64
=kde-base/kfind-4.12.3 ~amd64
=kde-base/kdebugdialog-4.12.3 ~amd64
=kde-base/kde-env-4.12.3 ~amd64
=kde-base/kfile-4.12.3 ~amd64
=kde-base/ktimezoned-4.12.3 ~amd64
=kde-base/solid-runtime-4.12.3 ~amd64
=kde-base/kwalletd-4.12.3 ~amd64
=kde-base/kdebase-menu-icons-4.12.3 ~amd64
=kde-base/nepomuk-4.12.3 ~amd64
=kde-base/kactivities-4.12.3 ~amd64
=kde-base/kdebase-meta-4.12.3 ~amd64
=kde-base/konq-plugins-4.12.3 ~amd64
=kde-base/kdebase-kioslaves-4.12.3 ~amd64
=kde-base/attica-4.12.3 ~amd64
=kde-base/kdelibs-4.12.3 ~amd64
=kde-base/plasma-runtime-4.12.3 ~amd64
=kde-base/kcontrol-4.12.3 ~amd64
=kde-base/kpasswdserver-4.12.3 ~amd64
=kde-base/kdepimlibs-4.12.3 ~amd64
=kde-base/phonon-kde-4.12.3 ~amd64
=kde-base/kwalletmanager-4.12.3 ~amd64
=kde-base/kfmclient-4.12.3 ~amd64
=kde-base/konqueror-4.12.3 ~amd64
=kde-base/kimgio-4.12.3 ~amd64
=kde-base/nepomuk-core-4.12.3 ~amd64
=kde-base/plasma-apps-4.12.3 ~amd64
=kde-base/kdebase-data-4.12.3 ~amd64
=kde-base/kdialog-4.12.3 ~amd64
=kde-base/renamedlg-plugins-4.12.3 ~amd64
=kde-base/knewstuff-4.12.3 ~amd64
=kde-base/libkonq-4.12.3 ~amd64
=kde-base/kioclient-4.12.3 ~amd64

Now you must know that this will require updating when new packages are released, so this isn't a proper solution. However, since the maintainers at Gentoo and KDE are working on plasma2 and KDE Frameworks 5, it is likely that there will be a proper upgrade path and all that will be required is the deletion of this file and a simple upgrade world.

I don't guarantee anything will work, these are just my thoughts and solutions.

Cheers.

Tuesday 11 March 2014

Excellent QT Drag and Drop Tutorial

This link is what got me started in understanding how QT works with drag and drop. I will post a link to the file in my github account that will use the results of this tutorial (although it is subject to change over time), but with code samples in-page.

http://rowinggolfer.blogspot.ca/2010/04/pyqt4-modelview-drag-drop-example.html

Here is my github source file with drag and drop classes in them:
https://github.com/NucleaPeon/QTCIDE/blob/master/src/view/main/widget.py

Note the following sections:

class Droppable(QtGui.QLabel):
    
    def __init__(self):
        super(Droppable, self).__init__()
        self.mime = QtCore.QMimeData()
        # ... more

    def mousePressEvent(self, event):
        mime = QtCore.QMimeData()
        mime.setText(self.mime.text())
        hotSpot = event.pos()
        mime.setData("application/x-hotspot", str(hotSpot.x()))
        
        # Create a pixmap of size of self
        pixmap = QtGui.QPixmap(self.size())
        self.render(pixmap)
        drag = QtGui.QDrag(self)
        drag.setMimeData(mime)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)
        
        dropAction = drag.exec_(QtCore.Qt.CopyAction|QtCore.Qt.MoveAction, QtCore.Qt.CopyAction)
Important things to note is that droppable object is a QtGui object, therefore has a visual place in the UI, has methods such as mousePressEvent in them.

Another odd thing you may notice, is that __init__ has a variable named self.mime, whereas mousePressEvent has just mime. Through trial and error, I found that the mousePressEvent method requires an instantiation *each* time the mouse is pressed, otherwise it fails to work. I set a variable in __init__ so that I only have one copy of the data and don't need to keep setting it (hardcoding == bad) in the method itself; changing the constructor variable will change the behaviour of the entire class easily.

class DropCanvas(QtGui.QGraphicsView):
    
    def __init__(self):
        super(DropCanvas, self).__init__()
        self.setAcceptDrops(True)
        self.scene = model.scene.ProjectScene()
        
    def dropEvent(self, event):
        # Here is where you put actions you want when the drop is done
        
        
    def dragEnterEvent(self, event):
        event.accept()

This class is the QtGui droppable object. I have it set to QGraphicsView, but it can be anything, such as a different view or a dock or panel, provided it inherits QWidget (I think).

Personally, I have an object that is set up specifically upon a drop event. The code here won't work with a QGraphicsView, but it used to be a QListView so it did work.

class CanvasItem(QtGui.QStandardItem):
    
    def __init__(self, *args, **kwargs):
        super(CanvasItem, self).__init__(*args)
        self.setEditable(False)


The item inherits a standard item and disables editing of itself.


Put all of the classes together and you can drag and drop!