Example #1
0
 def __init__(self, *args):
     QtGui.QWidget.__init__(self, None)
     self.ui = Ui_userFilesWidget()
     self.ui.setupUi(self)
     print "os.getenv(\"HOME\"):%s" % os.getenv("HOME")
     self.ui.destination.setText(os.getenv("HOME"))
     self.connect(self.ui.copy, SIGNAL("toggled(bool)"),
                  self.slotRadiosClicked)
     self.connect(self.ui.nothing, SIGNAL("toggled(bool checked)"),
                  self.slotRadiosClicked)
     self.connect(self.ui.link, SIGNAL("toggled(bool checked)"),
                  self.slotRadiosClicked)
     self.connect(self.ui.dirview,
                  SIGNAL("itemCollapsed(QTreeWidgetItem *)"), self.collapse)
     self.connect(self.ui.dirview,
                  SIGNAL("itemExpanded(QTreeWidgetItem *)"), self.expand)
Example #2
0
 def __init__(self, *args):
     QtGui.QWidget.__init__(self,None)
     self.ui = Ui_userFilesWidget()
     self.ui.setupUi(self)
     self.ui.destination.setText(os.getenv("HOME"))
     self.connect(self.ui.copy, SIGNAL("toggled(bool)"), self.slotRadiosClicked)
     self.connect(self.ui.nothing, SIGNAL("toggled(bool checked)"), self.slotRadiosClicked)
     self.connect(self.ui.link, SIGNAL("toggled(bool checked)"), self.slotRadiosClicked)
     self.connect(self.ui.dirview, SIGNAL("itemCollapsed(QTreeWidgetItem *)"), self.collapse)
     self.connect(self.ui.dirview, SIGNAL("itemExpanded(QTreeWidgetItem *)"), self.expand)
Example #3
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = i18n("Selecting Files")
    desc = i18n("Welcome to Migration Tool Wizard :)")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_userFilesWidget()
        self.ui.setupUi(self)
        self.ui.destination.setText(os.getenv("HOME"))
        self.connect(self.ui.copy, SIGNAL("toggled(bool)"), self.slotRadiosClicked)
        self.connect(self.ui.nothing, SIGNAL("toggled(bool checked)"), self.slotRadiosClicked)
        self.connect(self.ui.link, SIGNAL("toggled(bool checked)"), self.slotRadiosClicked)
        self.connect(self.ui.dirview, SIGNAL("itemCollapsed(QTreeWidgetItem *)"), self.collapse)
        self.connect(self.ui.dirview, SIGNAL("itemExpanded(QTreeWidgetItem *)"), self.expand)

    def collapse(self, item):
        item.collapse()

    def expand(self, item):
        item.expand()

    def slotRadiosClicked(self):
        if self.ui.copy.isChecked():
            self.ui.destination.setEnabled(True)
            self.ui.dirview.setEnabled(True)
        elif self.ui.nothing.isChecked():
            self.ui.destination.setEnabled(False)
            self.ui.dirview.setEnabled(False)
        elif self.ui.link.isChecked():
            self.ui.destination.setEnabled(False)
            self.ui.dirview.setEnabled(False)

    def creator(self, sources):
        # Add folders:
        folders = []
        acceptList = [("Personal Path", "My Documents", i18n("My Documents")),
                      ("Desktop Path", "Desktop", i18n("Desktop")),
                      ("My Music Path", "My Music", i18n("My Music")),
                      ("My Pictures Path", "My Pictures", i18n("My Pictures")),
                      ("My Video Path", "My Video", i18n("My Video"))]

        for key, name, localname in acceptList:
            if sources.has_key(key):
                path = sources[key]
                folders.append((path, name, unicode(localname)))

        # Check if one dir includes another:
        for index, (path, name, localname) in enumerate(folders):
            unique = True
            for index2, (path2, name2, localname2) in enumerate(folders):
                # If this is a child, skip
                if path.find(path2) == 0 and index != index2:
                    unique = False
                    break
            if unique:
                DirectoryViewRoot(self.ui.dirview, path, name, localname)

    def getOptions(self):
        options = {}
        if self.ui.link.isChecked():
            links = []
            for index in xrange(self.ui.dirview.topLevelItemCount()):
                child = self.ui.dirview.topLevelItem(index)
                if child.isChecked():
                    child.setHidden(False)
                    links.append({"path":child.path, "name":child.name, "localname":child.localname})

            if links:
                options["links"] = links

        elif self.ui.copy.isChecked():
            folders = []
            for index in xrange(self.ui.dirview.topLevelItemCount()):
                child = self.ui.dirview.topLevelItem(index)
                if child.isChecked():
                    child.setHidden(False)
                    files = child.selectedFiles()
                    folders.append({"name":child.name, "localname":child.localname, "source":child.path, "files":files})
            if folders:
                options["folders"] = folders
                options["copy destination"] = unicode(self.ui.destination.text())
        return options

    def shown(self):
        if ctx.sources:
            self.creator(ctx.sources)
        else:
            QMessageBox.critical(self,"Warning", "There isn't any Windows User Sources to migrate! Check your Windows Partition...")

    def execute(self):
        if self.getOptions():
            ctx.filesOptions = self.getOptions()
            return (True, None)
        else:
            return (False, None)
Example #4
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = i18n("Selecting Files")
    desc = i18n("Welcome to Migration Tool Wizard :)")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_userFilesWidget()
        self.ui.setupUi(self)
        print "os.getenv(\"HOME\"):%s" % os.getenv("HOME")
        self.ui.destination.setText(os.getenv("HOME"))
        self.connect(self.ui.copy, SIGNAL("toggled(bool)"),
                     self.slotRadiosClicked)
        self.connect(self.ui.nothing, SIGNAL("toggled(bool checked)"),
                     self.slotRadiosClicked)
        self.connect(self.ui.link, SIGNAL("toggled(bool checked)"),
                     self.slotRadiosClicked)
        self.connect(self.ui.dirview,
                     SIGNAL("itemCollapsed(QTreeWidgetItem *)"), self.collapse)
        self.connect(self.ui.dirview,
                     SIGNAL("itemExpanded(QTreeWidgetItem *)"), self.expand)

    def collapse(self, item):
        item.collapse()

    def expand(self, item):
        item.expand()

    def slotRadiosClicked(self):
        if self.ui.copy.isChecked():
            self.ui.destination.setEnabled(True)
            self.ui.dirview.setEnabled(True)
        elif self.ui.nothing.isChecked():
            self.ui.destination.setEnabled(False)
            self.ui.dirview.setEnabled(False)
        elif self.ui.link.isChecked():
            self.ui.destination.setEnabled(False)
            self.ui.dirview.setEnabled(False)

    def creator(self, sources):
        # Add folders:
        folders = []
        acceptList = [("Personal Path", "My Documents", i18n("My Documents")),
                      ("Desktop Path", "Desktop", i18n("Desktop")),
                      ("My Music Path", "My Music", i18n("My Music")),
                      ("My Pictures Path", "My Pictures", i18n("My Pictures")),
                      ("My Video Path", "My Video", i18n("My Video"))]

        for key, name, localname in acceptList:
            if sources.has_key(key):
                path = sources[key]
                folders.append((path, name, unicode(localname)))

        # Check if one dir includes another:
        for index, (path, name, localname) in enumerate(folders):
            unique = True
            for index2, (path2, name2, localname2) in enumerate(folders):
                # If this is a child, skip
                if path.find(path2) == 0 and index != index2:
                    unique = False
                    break
            if unique:
                DirectoryViewRoot(self.ui.dirview, path, name, localname)

    def getOptions(self):
        options = {}
        if self.ui.link.isChecked():
            links = []
            for index in xrange(self.ui.dirview.topLevelItemCount()):
                child = self.ui.dirview.topLevelItem(index)
                if child.isChecked():
                    child.setHidden(False)
                    links.append({
                        "path": child.path,
                        "name": child.name,
                        "localname": child.localname
                    })

            if links:
                options["links"] = links

        elif self.ui.copy.isChecked():
            folders = []
            for index in xrange(self.ui.dirview.topLevelItemCount()):
                child = self.ui.dirview.topLevelItem(index)
                if child.isChecked():
                    child.setHidden(False)
                    files = child.selectedFiles()
                    folders.append({
                        "name": child.name,
                        "localname": child.localname,
                        "source": child.path,
                        "files": files
                    })
            if folders:
                options["folders"] = folders
                options["copy destination"] = unicode(
                    self.ui.destination.text())
        return options

    def shown(self):
        if ctx.sources:
            self.creator(ctx.sources)
        else:
            KMessageBox.error(
                self,
                "There isn't any Windows User Sources to migrate! Check your Windows Partition..."
            )

    def execute(self):
        if self.getOptions():
            ctx.filesOptions = self.getOptions()
            return (True, None)
        else:
            return (False, None)