'Ensure the view has a current item if one is available.'

def ensureCurrent(self):

    model = self.__view.model()
    curr = self.__view.currentIndex()
    if (not curr.isValid()):
        for i in range(model.rowCount()):
            index = model.index(i, 0)
            if (index.flags() & Qt.ItemIsEnabled):
                self.__view.setCurrentIndex(index)
                break
