Exemplo n.º 1
0
 def changeFile(self, _filePath, _isNew=False):
     self.fileValues = fu.readTextFile(_filePath, uni.MySettings["fileSystemEncoding"])
     self.setWindowTitle(str(fu.getBaseName(self.fileValues["path"])))
     if self.pnlClearable is not None:
         clearAllChildren(self.pnlClearable, True)
     self.pnlClearable = MWidget()
     self.vblMain.insertWidget(0, self.pnlClearable, 20)
     vblClearable = MVBoxLayout(self.pnlClearable)
     self.infoLabels["path"] = MLabel(self.labels[0])
     self.infoLabels["content"] = MLabel(self.labels[1])
     dirPath = fu.getDirName(self.fileValues["path"])
     baseName = fu.getBaseName(self.fileValues["path"])
     self.infoValues["path"] = MLineEdit(str(fu.joinPath(dirPath, Organizer.emend(baseName, "file"))))
     self.infoValues["content"] = MPlainTextEdit(
         str(Organizer.emend(self.fileValues["content"], "text", False, True)))
     self.infoValues["content"].setLineWrapMode(MPlainTextEdit.NoWrap)
     self.sourceCharSet = MComboBox()
     self.sourceCharSet.addItems(uni.getCharSets())
     self.sourceCharSet.setCurrentIndex(self.sourceCharSet.findText(uni.MySettings["fileSystemEncoding"]))
     MObject.connect(self.sourceCharSet, SIGNAL("currentIndexChanged(int)"), self.sourceCharSetChanged)
     HBOXs = []
     HBOXs.append(MHBoxLayout())
     HBOXs[-1].addWidget(self.infoLabels["path"])
     HBOXs[-1].addWidget(self.infoValues["path"])
     HBOXs[-1].addWidget(self.sourceCharSet)
     for hbox in HBOXs:
         vblClearable.addLayout(hbox)
     vblClearable.addWidget(self.infoLabels["content"])
     vblClearable.addWidget(self.infoValues["content"])
Exemplo n.º 2
0
 def emendDirectoryWithContents(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             if uni.getBoolValue("isShowQuickMakeWindow"):
                 newEmendedName = str(self.leNewValue.text())
             else:
                 newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
             fu.activateSmartCheckIcon()
             oldFileName = _path
             newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
             if newDirName != oldFileName:
                 fileAndDirectoryNames = fu.readDirectory(newDirName, "fileAndDirectory")
                 for fileAndDirs in fileAndDirectoryNames:
                     objectType = fu.getObjectType(fu.joinPath(newDirName, fileAndDirs))
                     fu.moveOrChange(fu.joinPath(newDirName, fileAndDirs),
                                     fu.joinPath(newDirName, Organizer.emend(fileAndDirs, objectType)), objectType)
                 if uni.isActiveDirectoryCover and uni.getBoolValue(
                     "isActiveAutoMakeIconToDirectory") and uni.getBoolValue(
                     "isAutoMakeIconToDirectoryWhenFileMove"):
                     fu.checkIcon(newDirName)
                 if fu.isDir(newDirName):
                     fu.completeSmartCheckIcon()
                 Dialogs.show(translate("QuickMake", "Directory And Contents Emended"),
                              str(translate("QuickMake",
                                            "\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
                              (Organizer.getLink(_path), Organizer.getLink(newDirName)))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 3
0
 def correctTable(self):
     for rowNo in range(self.rowCount()):
         for coloumKey in self.getWritableColumnKeys():
             coloumNo = self.getColumnNoFromKey(coloumKey)
             if self.isChangeableItem(rowNo, coloumKey):
                 if coloumKey == "baseNameOfDirectory":
                     newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()), "directory")
                 else:
                     newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()), "file")
                 self.item(rowNo, coloumNo).setText(str(newString))
Exemplo n.º 4
0
 def apply(self):
     self.checkCompleters()
     self.reFillCompleters()
     getMainTable().createHistoryPoint()
     getMainTable().isAskShowHiddenColumn = True
     selectedColumnKey = self.columns.currentData()
     if selectedColumnKey == "all":
         columnKeys = getMainTable().getWritableColumnKeys()
     else:
         columnKeys = [selectedColumnKey]
     for columnKey in columnKeys:
         columnNo = getMainTable().getColumnNoFromKey(columnKey)
         if getMainTable().checkReadOnlyColumn(columnKey) is False:
             continue
         if getMainTable().checkHiddenColumn(columnKey, False) is False:
             continue
         for rowNo in range(getMainTable().rowCount()):
             if getMainTable().isChangeableItem(rowNo, columnKey):
                 newString = str(getMainTable().item(rowNo, columnNo).text())
                 newString = uni.trDecode(newString, "utf-8")
                 informationSectionX = self.specialTools.cbInformationSectionX.value()
                 informationSectionY = self.specialTools.cbInformationSectionY.value()
                 isCaseInsensitive = self.cckbCaseInsensitive.isChecked()
                 oldString = str(self.leClear.text())
                 cbClearType = self.cbClearType.currentText()
                 isRegExp = self.cckbRegExp.isChecked()
                 myString = None
                 if self.specialTools.cbInformationSection.currentIndex() == 0:
                     myString = Organizer.clear(cbClearType, newString,
                                                oldString, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 1:
                     myString = Organizer.clear(cbClearType, newString[:informationSectionX],
                                                oldString, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 2:
                     myString = newString[:informationSectionX]
                     myString += Organizer.clear(cbClearType, newString[informationSectionX:],
                                                 oldString, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 3:
                     myString = Organizer.clear(cbClearType, newString[:-informationSectionX],
                                                oldString, isCaseInsensitive, isRegExp)
                     myString += newString[-informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 4:
                     myString = newString[:-informationSectionX]
                     myString += Organizer.clear(cbClearType, newString[-informationSectionX:],
                                                 oldString, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 5:
                     myString = newString[:informationSectionX]
                     myString += Organizer.clear(cbClearType, newString[informationSectionX:informationSectionY],
                                                 oldString, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionY:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 6:
                     myString = Organizer.clear(cbClearType, newString[:informationSectionX],
                                                oldString, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionX:informationSectionY]
                     myString += Organizer.clear(cbClearType, newString[informationSectionY:],
                                                 oldString, isCaseInsensitive, isRegExp)
                 getMainTable().item(rowNo, columnNo).setText(str(myString))
Exemplo n.º 5
0
def readMusicFile(_filePath, _isAlertWhenNotAvailable=True):
    _directoryPath = fu.getDirName(_filePath)
    isCanNoncompatible = False
    if fu.isReadableFileOrDir(_filePath):
        tagger = Taggers.getTagger()
        try:
            tagger.loadFile(_filePath)
        except:
            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                              str(translate("FileUtils/Musics",
                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                              ) % Organizer.getLink(_filePath))
        if tagger.isAvailableFile() is False:
            isCanNoncompatible = True
        content = {}
        content["path"] = _filePath
        content["baseNameOfDirectory"] = fu.getBaseName(_directoryPath)
        content["baseName"] = fu.getBaseName(_filePath)
        content["artist"] = tagger.getArtist()
        content["title"] = tagger.getTitle()
        content["album"] = tagger.getAlbum()
        content["albumArtist"] = tagger.getAlbumArtist()
        content["trackNum"] = tagger.getTrackNum()
        content["year"] = tagger.getYear()
        content["genre"] = tagger.getGenre()
        content["firstComment"] = tagger.getFirstComment()
        content["firstLyrics"] = tagger.getFirstLyrics()
        content["images"] = tagger.getImages()
        if isCanNoncompatible and _isAlertWhenNotAvailable:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
        return content
Exemplo n.º 6
0
 def addImage(self):
     try:
         if self.isActiveAddImage is False:
             self.isActiveAddImage = True
             self.pbtnAddImage.setText(translate("MusicDetails", "OK"))
             self.pbtnSelectImage.show()
             self.leImagePath.show()
             self.lblImagePath.show()
             self.lblImageType.show()
             self.cbImageType.show()
             self.pbtnCancelAddImage.show()
             self.pbtnDeleteImage.hide()
             self.pbtnSaveAsImage.hide()
         else:
             if fu.isFile(self.leImagePath.text()):
                 imageType = Taggers.getTagger().getImageTypesNo()[self.cbImageType.currentIndex()]
                 description = str(imageType)
                 Musics.writeMusicFile(self.musicValues, None, True, imageType, str(self.leImagePath.text()),
                                       description)
                 self.changeFile(self.musicFile)
                 self.cancelAddImage()
             else:
                 Dialogs.showError(translate("MusicDetails", "Image Does Not Exist"),
                                   str(translate("MusicDetails", "\"%s\" does not exist.")
                                   ) % Organizer.getLink(str(self.leImagePath.text())))
     except:
         ReportBug.ReportBug()
Exemplo n.º 7
0
def changeDirectoryPath(_oldPath, _newPath):
    _oldPath, _newPath = str(_oldPath), str(_newPath)
    withOutDevicePointValues, withOutDeviceValues = [], []
    for devicePoint in getDevices():
        if devicePoint[1] + "/" == _oldPath[:len(devicePoint[1]) + 1]:
            if devicePoint[1] + "/" == _newPath[:len(devicePoint[1]) + 1]:
                withOutDevicePointValues.append({"id": devicePoint[0],
                                                 "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                                 "newPath": Databases.correctForSql(_newPath[len(devicePoint[1]):])
                })
            else:
                withOutDeviceValues.append({"id": devicePoint[0],
                                            "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                            "newPath": Databases.correctForSql(_newPath)
                })
    _oldPath, _newPath = Databases.correctForSql(_oldPath), Databases.correctForSql(_newPath)
    _oldPathUrl, _newPathUrl = Databases.correctForSql(Organizer.quote(_oldPath)), Databases.correctForSql(Organizer.quote(_newPath))
    db = Amarok.checkAndGetDB()
    db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/')" % (_oldPath, _newPath))
    db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/')" % (_oldPath, _newPath))
    for withOutDevice in withOutDeviceValues:
        db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/'), deviceid = -1 WHERE deviceid = %s " % (
            withOutDevice["oldPath"], withOutDevice["newPath"], withOutDevice["id"]))
        db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/'), deviceid = -1 WHERE deviceid = %s " % (
            withOutDevice["oldPath"], withOutDevice["newPath"], withOutDevice["id"]))
    for withOutDevicePoint in withOutDevicePointValues:
        db.query("UPDATE directories SET dir=REPLACE(dir, '.%s/', '.%s/') WHERE deviceid = %s " % (
            withOutDevicePoint["oldPath"], withOutDevicePoint["newPath"], withOutDevicePoint["id"]))
        db.query("UPDATE urls SET rpath=REPLACE(rpath, '.%s/', '.%s/') WHERE deviceid = %s " % (
            withOutDevicePoint["oldPath"], withOutDevicePoint["newPath"], withOutDevicePoint["id"]))
    db.query("UPDATE images SET path=REPLACE(path, '%s/', '%s/')" % (_oldPath, _newPath))
    db.query("UPDATE statistics_permanent SET url=REPLACE(url, '%s/', '%s/')" % (_oldPathUrl, _newPathUrl))
    db.commit()
    return True
Exemplo n.º 8
0
    def getFromAmarok(self):
        try:
            import Amarok

            Dialogs.showState(translate("CoverTable", "Checking For Amarok..."), 0, 1)
            if Amarok.checkAmarok():
                from Amarok import Operations

                directoriesAndValues = Operations.getDirectoriesAndValues()
                Dialogs.showState(translate("CoverTable", "Values Are Being Processed"), 1, 1)
                if directoriesAndValues is not None:
                    for rowNo in range(self.rowCount()):
                        if (getMainWindow().checkHiddenColumn("sourceCover") and
                                getMainWindow().checkHiddenColumn("destinationCover")):
                            if self.isChangeableItem(rowNo, "sourceCover"):
                                directoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text()))
                                if directoryPath in directoriesAndValues:
                                    directoryAndValues = directoriesAndValues[directoryPath]
                                    self.item(rowNo, 3).setText(
                                        directoryAndValues["coverPath"][0].replace(directoryPath, "."))
                                    self.item(rowNo, 4).setText("./" + Organizer.getIconName(
                                        directoryAndValues["artist"][0],
                                        directoryAndValues["album"][0],
                                        directoryAndValues["genre"][0],
                                        directoryAndValues["year"][0]))
        except:
            ReportBug.ReportBug()
Exemplo n.º 9
0
def changeFilePath(_oldPath, _newPath):
    _oldPath, _newPath = str(_oldPath), str(_newPath)
    withOutDevicePointValues, withOutDeviceValues = [], []
    for devicePoint in getDevices():
        if devicePoint[1] + "/" == _oldPath[:len(devicePoint[1]) + 1]:
            if devicePoint[1] + "/" == _newPath[:len(devicePoint[1]) + 1]:
                withOutDevicePointValues.append({"id": devicePoint[0],
                                                 "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                                 "newPath": Databases.correctForSql(_newPath[len(devicePoint[1]):])
                })
            else:
                withOutDeviceValues.append({"id": devicePoint[0],
                                            "oldPath": Databases.correctForSql(_oldPath[len(devicePoint[1]):]),
                                            "newPath": Databases.correctForSql(_newPath)
                })
    _oldPath, _newPath = Databases.correctForSql(_oldPath), Databases.correctForSql(_newPath)
    _oldPathUrl, _newPathUrl = Databases.correctForSql(Organizer.quote(_oldPath)), Databases.correctForSql(Organizer.quote(_newPath))
    db = Amarok.checkAndGetDB()
    db.query("UPDATE urls SET rpath='.%s' WHERE rpath='.%s'" % (_newPath, _oldPath))
    for withOutDevice in withOutDeviceValues:
        directoryID = getOrInsertDirectory(fu.getDirName(withOutDevice["newPath"]), "-1")
        db.query("UPDATE urls SET rpath='.%s', directory=%s, deviceid = -1 WHERE deviceid = %s and rpath = '.%s' " % (
            withOutDevice["newPath"], directoryID, withOutDevice["id"], withOutDevice["oldPath"]))
    for withOutDevicePoint in withOutDevicePointValues:
        directoryID = getOrInsertDirectory(fu.getDirName(withOutDevicePoint["newPath"]), withOutDevicePoint["id"])
        db.query("UPDATE urls SET rpath='.%s', directory=%s WHERE deviceid = %s and rpath = '.%s'" % (
            withOutDevicePoint["newPath"], directoryID, withOutDevicePoint["id"], withOutDevicePoint["oldPath"]))
    db.query("UPDATE images SET path='%s' WHERE path='%s'" % (_newPath, _oldPath))
    db.query("UPDATE lyrics SET url='.%s' WHERE url='.%s'" % (_newPath, _oldPath))
    db.query("UPDATE statistics_permanent SET url='file://%s' WHERE url='file://%s'" % (_newPathUrl, _oldPathUrl))
    db.commit()
    return True
Exemplo n.º 10
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     global currentDialogs
     _filePath = fu.checkSource(_filePath, "file")
     if _filePath is not None:
         if _isOpenDetailsOnNewWindow is False:
             isHasOpenedDialog = False
             for dialog in currentDialogs:
                 if dialog.isVisible():
                     isHasOpenedDialog = True
                     dialog.changeFile(_filePath)
                     dialog.activateWindow()
                     dialog.raise_()
                     break
             if isHasOpenedDialog is False:
                 _isOpenDetailsOnNewWindow = True
         if _isOpenDetailsOnNewWindow:
             currentDialogs.append(self)
             MDialog.__init__(self, MApplication.activeWindow())
             if isActivePyKDE4:
                 self.setButtons(MDialog.NoDefault)
             self.charSet = MComboBox()
             self.charSet.addItems(uni.getCharSets())
             self.charSet.setCurrentIndex(self.charSet.findText(uni.MySettings["fileSystemEncoding"]))
             self.infoLabels = {}
             self.infoValues = {}
             self.fileValues = {}
             pbtnClose = MPushButton(translate("TextDetails", "Close"))
             pbtnSave = MPushButton(translate("TextDetails", "Save Changes"))
             pbtnSave.setIcon(MIcon("Images:save.png"))
             MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
             MObject.connect(pbtnSave, SIGNAL("clicked()"), self.save)
             self.labels = [translate("TextDetails", "File Path : "),
                            translate("TextDetails", "Content : ")]
             self.pnlMain = MWidget()
             self.vblMain = MVBoxLayout(self.pnlMain)
             self.pnlClearable = None
             self.changeFile(_filePath, True)
             HBOXs, VBOXs = [], []
             VBOXs.append(MVBoxLayout())
             HBOXs.append(MHBoxLayout())
             HBOXs[-1].addWidget(self.charSet, 1)
             HBOXs[-1].addWidget(pbtnSave, 4)
             VBOXs[0].addLayout(HBOXs[-1])
             VBOXs[0].addWidget(pbtnClose)
             self.vblMain.addLayout(VBOXs[0], 1)
             if isActivePyKDE4:
                 self.setMainWidget(self.pnlMain)
             else:
                 self.setLayout(self.vblMain)
             self.show()
             self.setMinimumWidth(700)
             self.setMinimumHeight(500)
     else:
         Dialogs.showError(translate("TextDetails", "File Does Not Exist"),
                           str(translate("TextDetails",
                                         "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                           ) % Organizer.getLink(str(_filePath)))
         if hasattr(getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Exemplo n.º 11
0
 def emendDirectory(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             if uni.getBoolValue("isShowQuickMakeWindow"):
                 newEmendedName = str(self.leNewValue.text())
             else:
                 newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
             oldFileName = _path
             newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
             if newDirName != oldFileName:
                 Dialogs.show(translate("QuickMake", "Directory Emended"),
                              str(translate("QuickMake",
                                            "\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
                              (Organizer.getLink(_path), Organizer.getLink(newDirName)))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 12
0
 def cellDoubleClickedTable(self, _row, _column):
     try:
         if uni.getBoolValue("isRunOnDoubleClick"):
             self.showTableDetails(_row, _column)
     except:
         Dialogs.showError(translate("SubFolderTable", "Cannot Open File"),
                           str(translate("SubFolderTable",
                                         "\"%s\" : cannot be opened. Please make sure that you selected a text file.")
                           ) % Organizer.getLink(self.values[_row]["path"]))
Exemplo n.º 13
0
 def sendAndClose(self):
     try:
         uni.isCanBeShowOnMainWindow = False
         self.namMain = MNetworkAccessManager(self)
         self.connect(self.namMain, SIGNAL("finished (QNetworkReply *)"), self.sendFinished)
         self.nrqPost = MNetworkRequest(MUrl("http://hamsiapps.com/ForMyProjects/SuggestIdea.php"))
         self.nrpBack = self.namMain.post(self.nrqPost,
                                          "p=HamsiManager&l=" + str(uni.MySettings["language"]) + "&v=" + str(
                                              uni.intversion) +
                                          "&thankYouMessages=new style" +
                                          "&userNotes=" + Organizer.quote(str(self.teIdea.toHtml())) +
                                          "&nameAndSurname=" + Organizer.quote(str(self.leName.text())) +
                                          "&mail=" + Organizer.quote(str(self.leEMailAddress.text()))
         )
         self.connect(self.nrpBack, SIGNAL("downloadProgress (qint64,qint64)"), self.sending)
         Dialogs.showState(translate("SuggestIdea", "Sending Your Idea"), 0, 100, True, self.cancelSending)
     except:
         ReportBug.ReportBug()
Exemplo n.º 14
0
 def correctTable(self):
     for rowNo in range(self.rowCount()):
         for coloumKey in self.getWritableColumnKeys():
             coloumNo = self.getColumnNoFromKey(coloumKey)
             if self.isChangeableItem(rowNo, coloumKey):
                 newString = None
                 if coloumKey == "correctedArtist":
                     newString = Organizer.emend(str(self.item(rowNo, coloumNo).text()))
                 self.item(rowNo, coloumNo).setText(str(newString))
Exemplo n.º 15
0
    def createWindow(self, _actionName, _makeThisAction, _isShowEmendWidgets):
        from Options import OptionsForm

        newOrChangedKeys = uni.newSettingsKeys + uni.changedDefaultValuesKeys
        wOptionsPanel = OptionsForm.OptionsForm(None, QuickMakeParameters[0], None, newOrChangedKeys)
        if MyDialogType == "MDialog":
            if isActivePyKDE4:
                self.setButtons(MyDialog.NoDefault)
        elif MyDialogType == "MMainWindow":
            self.setObjectName("Packager")
            setMainWindow(self)
        self.setWindowTitle(_actionName)
        pnlMain = MWidget(self)
        vblMain = MVBoxLayout(pnlMain)
        pnlInfo = MWidget()
        vblInfo = MVBoxLayout(pnlInfo)
        vblInfo.addStretch(3)
        if _isShowEmendWidgets:
            lblOldValue = MLabel(translate("QuickMake", "Old Value : "))
            lblNewValue = MLabel(translate("QuickMake", "New Value : "))
            leOldValue = MLineEdit(str(fu.getRealPath(QuickMakeParameters[1])))
            leOldValue.setEnabled(False)
            self.leNewValue = MLineEdit(str(Organizer.emend(fu.getRealPath(QuickMakeParameters[1]),
                                                            fu.getObjectType(fu.getRealPath(QuickMakeParameters[1])))))
            vblInfo.addWidget(lblOldValue)
            vblInfo.addWidget(leOldValue)
            vblInfo.addWidget(lblNewValue)
            vblInfo.addWidget(self.leNewValue)
        else:
            lblValue = MLabel(translate("QuickMake", "Value : "))
            leValue = MLineEdit(str(fu.getRealPath(QuickMakeParameters[1])))
            leValue.setEnabled(False)
            vblInfo.addWidget(lblValue)
            vblInfo.addWidget(leValue)
        vblInfo.addStretch(3)
        pbtnApply = MPushButton(_actionName)
        pbtnClose = MPushButton(translate("QuickMake", "Cancel"))
        MObject.connect(pbtnApply, SIGNAL("clicked()"), _makeThisAction)
        MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
        tabwTabs = MTabWidget()
        tabwTabs.addTab(pnlInfo, translate("QuickMake", "Quick Make"))
        tabwTabs.addTab(wOptionsPanel, translate("QuickMake", "Quick Make Options"))
        vblMain.addWidget(tabwTabs)
        hblBox = MHBoxLayout()
        hblBox.addWidget(pbtnClose, 2)
        hblBox.addWidget(pbtnApply, 3)
        vblInfo.addLayout(hblBox)
        if MyDialogType == "MDialog":
            if isActivePyKDE4:
                self.setMainWidget(pnlMain)
            else:
                self.setLayout(vblMain)
        elif MyDialogType == "MMainWindow":
            self.setCentralWidget(pnlMain)
            moveToCenter(self)
        self.setMinimumSize(450, 350)
Exemplo n.º 16
0
 def fillValues(self):
     filePath = str(self.leFilePath.text())
     if fu.isFile(filePath) and fu.isReadableFileOrDir(filePath):
         self.fileValues = fu.readTextFile(filePath, str(self.sourceCharSet.currentText()))
         self.pteFileContent.setPlainText(str(Organizer.emend(self.fileValues["content"], "text", False, True)))
         self.isChangeSourceCharSetChanged = True
         self.pbtnSave.setEnabled(True)
     else:
         self.isChangeSourceCharSetChanged = False
         self.pbtnSave.setEnabled(False)
Exemplo n.º 17
0
 def sourceCharSetChanged(self):
     try:
         self.fileValues = fu.readTextFile(self.fileValues["path"], str(self.sourceCharSet.currentText()))
         self.infoValues["content"].setPlainText(
             str(Organizer.emend(self.fileValues["content"], "text", False, True)))
     except:
         Dialogs.showError(translate("TextDetails", "Incorrect File Encoding"),
                           str(translate("TextDetails",
                                         "File can not decode by \"%s\" codec.<br>Please select another file encoding type.")
                           ) % str(self.sourceCharSet.currentText()))
Exemplo n.º 18
0
    def refreshTable(self, _path):
        self.values = []
        fileAndDirectoryNames = fu.readDirectory(_path, "fileAndDirectory",
                                                 uni.getBoolValue("isShowHiddensInFolderTable"))
        allItemNumber = len(fileAndDirectoryNames)
        uni.startThreadAction()
        baseNameOfDirectory = fu.getBaseName(_path)
        rowNo = 0
        self.setRowCount(allItemNumber)
        for baseName in fileAndDirectoryNames:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
                        details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
                        content = {}
                        content["path"] = fu.joinPath(_path, baseName)
                        content["baseNameOfDirectory"] = baseNameOfDirectory
                        content["baseName"] = baseName
                        content.update(details)
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        content["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(content["baseName"], fu.getObjectType(self.values[rowNo]["path"]))
                        self.createItem(rowNo, "baseName", newBaseName, content["baseName"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

                        self.createItem(rowNo, "lastMetadataChanged",
                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                        if not uni.isWindows:
                            self.createItem(rowNo, "accessRights", content["accessRights"])

                            self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"])

                            self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"])

                            self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"])

                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 19
0
 def Clear(self):
     try:
         uni.isCanBeShowOnMainWindow = False
         answer = Dialogs.ask(translate("Cleaner", "Your Files Will Be Removed"),
                              str(translate("Cleaner",
                                            "The files in the \"%s\" folder will be cleared according to the criteria you set.<br>" +
                                            "This action will delete the files completely, without any chance to recover.<br>" +
                                            "Are you sure you want to perform the action?")) % Organizer.getLink(
                                  Organizer.getLink(str(self.lePathOfProject.text()))))
         if answer == Dialogs.Yes:
             if fu.isWritableFileOrDir(str(self.lePathOfProject.text())):
                 if fu.clearCleaningDirectory(str(self.lePathOfProject.text()), True, True):
                     Dialogs.show(translate("Cleaner", "Directory Is Cleared"),
                                  str(translate("Cleaner",
                                                "This directory is cleared : \"%s\"")) % Organizer.getLink(
                                      str(self.lePathOfProject.text())))
         uni.isCanBeShowOnMainWindow = True
     except:
         ReportBug.ReportBug()
Exemplo n.º 20
0
    def refreshTable(self, _path):
        self.values = []
        uni.startThreadAction()
        Dialogs.showState(translate("AmarokArtistTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                artistValues = Operations.getAllArtistsValues(uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokArtistTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if artistValues is not None:
                        allItemNumber = len(artistValues)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in artistValues:
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    content = {}
                                    content["id"] = musicFileRow["id"]
                                    content["currentArtist"] = musicFileRow["name"]
                                    content["correctedArtist"] = musicFileRow["name"]
                                    self.values.append(content)

                                    currentName = content["currentArtist"]
                                    self.createItem(rowNo, "currentArtist", currentName, currentName, True)

                                    newName = Organizer.emend(content["correctedArtist"])
                                    isReadOnlyNewName = (content["correctedArtist"].strip() == "")
                                    self.createItem(rowNo, "correctedArtist", newName, content["currentArtist"],
                                                    isReadOnlyNewName)
                                    rowNo += 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 21
0
    def save(self):
        try:
            filePath = str(self.leFilePath.text())
            if self.fileValues is not None:
                from Core import Records

                Records.setTitle(translate("TextCorrector", "Text File"))
                newFileValues = {}
                newFileValues["path"] = filePath
                newFileValues["content"] = str(self.pteFileContent.toPlainText())
                newPath = fu.writeTextFile(self.fileValues, newFileValues, str(self.charSet.currentText()))
                if newPath != self.fileValues["path"]:
                    self.changeFile(newPath)
                if hasattr(getMainWindow(),
                           "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
                Records.saveAllRecords()
            else:
                Dialogs.showError(translate("TextCorrector", "File Does Not Exist"),
                                  str(translate("TextDetails",
                                                "\"%s\" does not exist.<br>Please select an exist file and try again.")
                                  ) % Organizer.getLink(str(filePath)))
        except:
            ReportBug.ReportBug()
Exemplo n.º 22
0
 def triggered(self, _action):
     try:
         if _action.objectName() == "Edit Bookmarks":
             getMainWindow().FileManager.bookmarks.makeRefresh()
             getMainWindow().FileManager.bookmarks.show()
             return
         for info in BookmarksOfDirectories.fetchAll():
             if info[1] == str(_action.objectName()):
                 if fu.isDir(str(info[2])):
                     getMainWindow().FileManager.goTo(str(info[2]))
                     return
                 else:
                     answer = Dialogs.ask(translate("BookmarksMenu", "Cannot Find Folder"),
                                 str(translate("BookmarksMenu",
                                     "\"%s\" cannot be found.<br>Delete this folder from the bookmarks?")) %
                                 Organizer.getLink(info[1]))
                     if answer == Dialogs.Yes:
                         BookmarksOfDirectories.delete(str(info[0]))
                         self.makeRefresh()
                         getMainWindow().FileManager.bookmarks.makeRefresh()
         getMainWindow().FileManager.makeRefreshOnlyFileList()
         getMainWindow().FileManager.makeRefreshOnlyFileListByTree()
     except:
         ReportBug.ReportBug()
Exemplo n.º 23
0
    def downloadAndInstall(self):
        try:
            if uni.isBuilt() is False:
                if fu.isWritableFileOrDir(fu.HamsiManagerDirectory,
                                          True) is False:
                    from Core import Organizer

                    Dialogs.showError(
                        translate("UpdateControl", "Access Denied"),
                        str(
                            translate(
                                "UpdateControl",
                                "\"%s\" : you do not have the necessary permissions to change this directory.<br />Please check your access controls and retry. <br />Note: You can run Hamsi Manager as root and try again."
                            )) % Organizer.getLink(fu.HamsiManagerDirectory))
            self.setFixedHeight(130)
            self.isDownloading = True
            self.prgbState.setVisible(True)
            self.lblInfo.setVisible(False)
            self.setWindowTitle(
                translate("UpdateControl", "Downloading Latest Release..."))
            self.request = MNetworkRequest(MUrl(self.updateInformations[1]))
            self.willDownload(self.request)
        except:
            ReportBug.ReportBug()
Exemplo n.º 24
0
    def refreshTable(self, _path):
        self.values = []
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                directoriesAndValues = Operations.getDirectoriesAndValues(uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if directoriesAndValues is not None:
                        allItemNumber = len(directoriesAndValues)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for dirPath, dirRow in directoriesAndValues.items():
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    if fu.isReadableFileOrDir(dirPath, False, True) and fu.isReadableFileOrDir(
                                        fu.joinPath(dirPath, ".directory"), False, True):
                                        content = {}
                                        content["path"] = dirPath
                                        content["pathOfParentDirectory"] = fu.getDirName(dirPath)
                                        content["baseName"] = fu.getBaseName(dirPath)
                                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(dirPath)
                                        if currentCover is None:
                                            currentCover = ""
                                        content["currentCover"] = (currentCover)
                                        content["sourceCover"] = (dirRow["coverPath"][0].replace(dirPath, "."))
                                        content["destinationCover"] = ("./" + Organizer.getIconName(
                                            dirRow["artist"][0],
                                            dirRow["album"][0],
                                            dirRow["genre"][0],
                                            dirRow["year"][0]))
                                        content["flagColor"] = {}
                                        if isCorrectedFileContent is False:
                                            content["flagColor"]["currentCover"] = 255, 163, 163
                                        if fu.isFile(content["sourceCover"]) is False:
                                            content["flagColor"]["sourceCover"] = 255, 163, 163
                                        self.values.append(content)

                                        newPathOfParentDirectory = Organizer.emend(
                                            self.values[rowNo]["pathOfParentDirectory"], "directory")
                                        self.createItem(rowNo, "pathOfParentDirectory", newPathOfParentDirectory,
                                                        self.values[rowNo]["pathOfParentDirectory"])

                                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "directory")
                                        self.createItem(rowNo, "pathOfParentDirectory", newBaseName,
                                                        self.values[rowNo]["baseName"])

                                        newCurrentCover = fu.getShortPath(self.values[rowNo]["currentCover"],
                                                                          self.values[rowNo]["path"])
                                        itemCurrentCover = self.createItem(rowNo, "currentCover", newCurrentCover,
                                                                           newCurrentCover, True)
                                        self.setItemColor(itemCurrentCover, rowNo, 2, "currentCover")

                                        newSourceCover = fu.getShortPath(self.values[rowNo]["sourceCover"],
                                                                         self.values[rowNo]["path"])
                                        itemSourceCover = self.createItem(rowNo, "sourceCover", newSourceCover,
                                                                          fu.getShortPath(
                                                                              self.values[rowNo]["currentCover"],
                                                                              self.values[rowNo]["path"]))
                                        self.setItemColor(itemSourceCover, rowNo, 3, "sourceCover")

                                        newDestinationCover = Organizer.emend(
                                            fu.getShortPath(self.values[rowNo]["destinationCover"],
                                                            self.values[rowNo]["path"]), "file")
                                        itemDestinationCover = self.createItem(rowNo, "destinationCover",
                                                                               newDestinationCover,
                                                                               fu.getShortPath(
                                                                                   self.values[rowNo]["currentCover"],
                                                                                   self.values[rowNo]["path"]))
                                        self.setItemColor(itemDestinationCover, rowNo, 4, "destinationCover")
                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 25
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(translate("MenuBar", "Open State Of Hamsi Manager"),
                                        fu.userDirectoryPath,
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(translate("MenuBar", "Save State Of Hamsi Manager"),
                                        fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                                        translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(translate("MenuBar", "Current State Saved"),
                             translate("MenuBar",
                                       "Current state saved with preferences.<br>You can continue where you left off."))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(translate("MenuBar", "Can Not Run As Root"),
                                  translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree",
                               "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree",
                               "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText",
                               "fileTree", "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

            OptionsForm.OptionsForm(getMainWindow())
        elif actionName == "My Plugins":
            import MyPlugins

            MyPlugins.MyPlugins()
        elif actionName == "Reconfigure":
            from Tools import Configurator

            Configurator.Configurator("configurePage")
        elif actionName == "My Plugins (System)":
            Execute.execute(["--qm", "--plugins", "--runAsRoot"], "HamsiManager")
        elif actionName == "Reconfigure (System)":
            Execute.execute(["--qm", "--configurator", "--runAsRoot"], "HamsiManager")
        elif actionName == "Update":
            from Core import UpdateControl

            UpdateControl.UpdateControl(getMainWindow())
        elif actionName == "Report Bug":
            ReportBug.ReportBug(True)
        elif actionName == "Suggest Idea":
            from Core import SuggestIdea

            SuggestIdea.SuggestIdea()
        elif actionName == "About Hamsi Manager":
            if isActivePyKDE4 is False:
                MMessageBox.about(getMainWindow(), translate("MenuBar", "About Hamsi Manager"),
                                  uni.aboutOfHamsiManager)
        elif actionName == translate("ToolsBar", "Check Icon"):
            getMainWindow().setEnabled(False)
            fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath())
            Dialogs.show(translate("ToolsBar", "Directory Icon Checked"),
                         translate("ToolsBar",
                                   "Current directory icon checked.<br>The default action based on the data is executed."))
            getMainWindow().setEnabled(True)
        elif actionName == "Clear Empty Directories":
            if getMainTable().checkUnSavedValues() is False:
                _action.setChecked(False)
                return False
            answer = Dialogs.ask(translate("ToolsBar", "Empty Directories Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                currentDirPath = getMainWindow().FileManager.getCurrentDirectoryPath()
                if fu.isWritableFileOrDir(currentDirPath):
                    fu.checkEmptyDirectories(currentDirPath, True, True, True, True)
                    Dialogs.show(translate("ToolsBar", "Directory Cleaned"),
                                 translate("ToolsBar",
                                           "The current directory is cleaned based on the criteria you set."))
                getMainWindow().setEnabled(True)
                getMainWindow().FileManager.makeRefresh()
        elif actionName == "Pack":
            from Tools import Packager

            Packager.Packager(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Hash":
            from Tools import Hasher

            Hasher.Hasher(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Clear":
            from Tools import Cleaner

            Cleaner.Cleaner(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Text Corrector":
            from Tools import TextCorrector

            TextCorrector.TextCorrector(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "File Tree":
            from Tools import FileTreeBuilder

            FileTreeBuilder.FileTreeBuilder(getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Search":
            from Tools import Searcher

            Searcher.Searcher([getMainWindow().FileManager.getCurrentDirectoryPath()])
        elif actionName == "Script Manager":
            from Tools import ScriptManager

            if ScriptManager.ScriptManager.checkScriptManager():
                ScriptManager.ScriptManager(getMainWindow())
        elif actionName == "Show Last Actions":
            from Core import RecordsForm

            RecordsForm.RecordsForm(getMainWindow())
        elif actionName == "Remove Sub Files":
            answer = Dialogs.ask(translate("ToolsBar", "All Files Will Be Removed"),
                                 str(translate("ToolsBar",
                                               "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                     getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                fu.removeOnlySubFiles(getMainWindow().FileManager.getCurrentDirectoryPath())
                getMainWindow().setEnabled(True)
                Dialogs.show(translate("ToolsBar", "Removed Only All Files"),
                             str(translate("ToolsBar",
                                           "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                 getMainWindow().FileManager.getCurrentDirectoryPath()))
        elif actionName == "Amarok Embedded Database Configurator":
            import Amarok

            if Amarok.checkAmarok():
                Amarok.openEmbeddedDBConfigurator()
        elif _action.parent().objectName() == "Table Types":
            changeTableType(_action)
        elif _action.parent().objectName() == "File Renamer Types":
            changeReNamerType(_action)
        elif _action.parent().objectName() == "Scripts":
            from Core import Scripts

            Scripts.runScriptFile(fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 26
0
 def clearIgnoreds(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             fu.clearIgnoreds(_path)
             Dialogs.show(translate("QuickMake", "Directory Cleaned"),
                          str(translate("QuickMake",
                                        "\"%s\" is cleaned based on the criteria you set.")) % Organizer.getLink(
                              _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 27
0
 def apply(self):
     self.checkCompleters()
     self.reFillCompleters()
     getMainTable().createHistoryPoint()
     getMainTable().isAskShowHiddenColumn = True
     searchStrings = str(self.leSearch.text()).split(";")
     selectedColumnKey = self.columns.currentData()
     if selectedColumnKey == "all":
         columnKeys = getMainTable().getWritableColumnKeys()
     else:
         columnKeys = [selectedColumnKey]
     for columnKey in columnKeys:
         columnNo = getMainTable().getColumnNoFromKey(columnKey)
         if getMainTable().checkReadOnlyColumn(columnKey) is False:
             continue
         if getMainTable().checkHiddenColumn(columnKey, False) is False:
             continue
         for rowNo in range(getMainTable().rowCount()):
             if getMainTable().isChangeableItem(rowNo, columnKey):
                 newString = uni.trUnicode(getMainTable().item(rowNo, columnNo).text())
                 myString = ""
                 informationSectionX = self.specialTools.cbInformationSectionX.value()
                 informationSectionY = self.specialTools.cbInformationSectionY.value()
                 cbCharacterType = uni.validSentenceStructureKeys[self.cbCharacterType.currentIndex()]
                 isCaseInsensitive = self.cckbCaseInsensitive.isChecked()
                 isRegExp = self.cckbRegExp.isChecked()
                 isCorrectText = self.cckbCorrectText.isChecked()
                 if self.specialTools.cbInformationSection.currentIndex() == 0:
                     myString = Organizer.correctCaseSensitive(newString, cbCharacterType, isCorrectText,
                                                               searchStrings, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 1:
                     myString = Organizer.correctCaseSensitive(newString[:informationSectionX], cbCharacterType,
                                                               isCorrectText, searchStrings, isCaseInsensitive,
                                                               isRegExp)
                     myString += newString[informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 2:
                     myString = newString[:informationSectionX]
                     myString += Organizer.correctCaseSensitive(newString[informationSectionX:], cbCharacterType,
                                                                isCorrectText, searchStrings, isCaseInsensitive,
                                                                isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 3:
                     myString = Organizer.correctCaseSensitive(newString[:-informationSectionX], cbCharacterType,
                                                               isCorrectText, searchStrings, isCaseInsensitive,
                                                               isRegExp)
                     myString += newString[-informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 4:
                     myString = newString[:-informationSectionX]
                     myString += Organizer.correctCaseSensitive(newString[-informationSectionX:], cbCharacterType,
                                                                isCorrectText, searchStrings, isCaseInsensitive,
                                                                isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 5:
                     myString = newString[:informationSectionX]
                     myString += Organizer.correctCaseSensitive(newString[informationSectionX:informationSectionY],
                                                                cbCharacterType, isCorrectText, searchStrings,
                                                                isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionY:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 6:
                     myString = Organizer.correctCaseSensitive(newString[:informationSectionX], cbCharacterType,
                                                               isCorrectText, searchStrings, isCaseInsensitive,
                                                               isRegExp)
                     myString += newString[informationSectionX:informationSectionY]
                     myString += Organizer.correctCaseSensitive(newString[informationSectionY:], cbCharacterType,
                                                                isCorrectText, searchStrings, isCaseInsensitive,
                                                                isRegExp)
                 getMainTable().item(rowNo, columnNo).setText(str(myString))
Exemplo n.º 28
0
 def changeArtist(self, _artistId, _isNew=False):
     self.artistId = _artistId
     self.songTableContentValues = None
     uni.startThreadAction()
     Dialogs.showState(translate("AmarokArtistDetails", "Getting Values From Amarok"), 0, 1)
     if Amarok.checkAmarok():
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             self.artistName = Commands.getArtistName(self.artistId)
             self.songTableContentValues = Operations.getAllMusicFileValuesWithNames("", self.artistId)
             Dialogs.showState(translate("MusicDetails", "Values Are Being Processed"), 1, 1)
     uni.finishThreadAction()
     if self.songTableContentValues is None:
         self.close()
     self.setWindowTitle(str(self.artistName))
     if self.pnlClearable is not None:
         clearAllChildren(self.pnlClearable, True)
     self.pnlClearable = MWidget()
     self.vblMain.insertWidget(0, self.pnlClearable, 20)
     vblClearable = MVBoxLayout(self.pnlClearable)
     self.infoLabels["currentArtist"] = MLabel(self.labels[0])
     self.infoLabels["correctedArtist"] = MLabel(self.labels[1])
     self.infoValues["currentArtist"] = MLineEdit(str(self.artistName))
     self.infoValues["correctedArtist"] = MLineEdit(str(Organizer.emend(self.artistName)))
     self.twSongs = MTableWidget()
     self.twSongs.clear()
     self.twSongs.setColumnCount(len(self.songTableColumns))
     self.twSongs.setHorizontalHeaderLabels(self.songTableColumns)
     self.twSongs.setRowCount(len(self.songTableContentValues))
     for rowNo in range(self.twSongs.rowCount()):
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["filePath"]))
         self.twSongs.setItem(rowNo, 0, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["artist"]))
         self.twSongs.setItem(rowNo, 1, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["title"]))
         self.twSongs.setItem(rowNo, 2, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["album"]))
         self.twSongs.setItem(rowNo, 3, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["albumArtist"]))
         self.twSongs.setItem(rowNo, 4, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["trackNumber"]))
         self.twSongs.setItem(rowNo, 5, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["year"]))
         self.twSongs.setItem(rowNo, 6, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["genre"]))
         self.twSongs.setItem(rowNo, 7, item)
         item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["comment"]))
         self.twSongs.setItem(rowNo, 8, item)
         for x in range(self.twSongs.columnCount()):
             self.twSongs.item(rowNo, x).setFlags(Mt.ItemIsSelectable | Mt.ItemIsEnabled)
     HBOXs = []
     HBOXs.append(MHBoxLayout())
     HBOXs[-1].addWidget(self.infoLabels["currentArtist"])
     HBOXs[-1].addWidget(self.infoValues["currentArtist"])
     HBOXs.append(MHBoxLayout())
     HBOXs[-1].addWidget(self.infoLabels["correctedArtist"])
     HBOXs[-1].addWidget(self.infoValues["correctedArtist"])
     vblInfos = MVBoxLayout()
     for hbox in HBOXs:
         vblInfos.addLayout(hbox)
     vblInfos.addWidget(self.twSongs)
     vblClearable.addLayout(vblInfos)
Exemplo n.º 29
0
 def exportValues(self,
                  _actionType="return",
                  _formatType="html",
                  _extInfo="no"):
     info = ""
     if _formatType == "html":
         if _extInfo == "no":
             pass
         elif _extInfo == "title":
             info += " \n<h3>%s : </h3>" % (str(
                 translate("Tables", "Table Contents")))
         info += " \n<table border=1> \n<tr> \n<td>*</td> \n"
         for columnNo in range(self.columnCount()):
             if self.isColumnHidden(columnNo) is False:
                 info += "<td><b>"
                 info += str(self.tableColumns[columnNo])
                 info += "</b></td> \n"
         info += "</tr> \n"
         for rowNo in range(self.rowCount()):
             if self.isRowHidden(rowNo) is False:
                 info += " \n<tr> \n<td>" + str(rowNo + 1) + "</td> \n"
                 for columnNo in range(self.columnCount()):
                     if self.isColumnHidden(columnNo) is False:
                         info += "<td>"
                         info += str(str(self.item(rowNo, columnNo).text()))
                         info += "</td> \n"
                 info += "</tr> \n"
         info += "</table> \n"
     elif _formatType == "plainText":
         if _extInfo == "no":
             pass
         elif _extInfo == "title":
             info += " %s : \n" % (str(translate("Tables",
                                                 "Table Contents")))
         info += "*\t"
         for columnNo in range(self.columnCount()):
             if self.isColumnHidden(columnNo) is False:
                 info += str(self.tableColumns[columnNo])
                 info += "\t"
         info += "\n"
         for rowNo in range(self.rowCount()):
             info += str(rowNo + 1) + "\t"
             if self.isRowHidden(rowNo) is False:
                 for columnNo in range(self.columnCount()):
                     if self.isColumnHidden(columnNo) is False:
                         info += str(str(self.item(rowNo, columnNo).text()))
                         info += "\t"
                 info += "\n"
     if _actionType == "return":
         return info
     elif _actionType == "file":
         fileExt = None
         formatTypeName = None
         if _formatType == "html":
             if _extInfo != "no":
                 strHeader = (
                     "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n"
                     +
                     "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> \n"
                     +
                     "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"tr\" lang=\"tr\" dir=\"ltr\"> \n"
                     +
                     "<head> \n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> \n</head> \n<body> \n"
                 )
                 strFooter = " \n</body> \n</html>"
                 info = strHeader + info + strFooter
             formatTypeName = translate("Tables", "HTML")
             fileExt = "html"
         elif _formatType == "plainText":
             formatTypeName = translate("Tables", "Plain Text")
             fileExt = "txt"
         filePath = Dialogs.getSaveFileName(
             translate("Tables", "Save As"),
             fu.joinPath(
                 fu.userDirectoryPath,
                 fu.getBaseName(self.currentDirectoryPath) + "." + fileExt),
             formatTypeName + " (*." + fileExt + ")", 2)
         if filePath is not None:
             if _formatType == "html" and filePath[-5:] != ".html":
                 filePath += ".html"
             elif _formatType == "plainText" and filePath[-4:] != ".txt":
                 filePath += ".txt"
             fu.writeToFile(filePath, info)
             Dialogs.show(
                 translate("Tables", "Table Exported"),
                 str(
                     translate(
                         "Tables",
                         "Table contents are exported to file: \"%s\".")) %
                 Organizer.getLink(filePath))
     elif _actionType == "dialog":
         dDialog = MDialog(getMainWindow())
         if isActivePyKDE4:
             dDialog.setButtons(MDialog.NoDefault)
         dDialog.setWindowTitle(translate("Tables", "Table Contents"))
         mainPanel = MWidget(dDialog)
         vblMain = MVBoxLayout(mainPanel)
         if _formatType == "html":
             QtWebKit = getMyObject("QtWebKit")
             wvWeb = QtWebKit.QWebView()
             wvWeb.setHtml(str(info))
             vblMain.addWidget(wvWeb)
         elif _formatType == "plainText":
             teContent = MTextEdit()
             teContent.setPlainText(str(info))
             vblMain.addWidget(teContent)
         pbtnClose = MPushButton(translate("Tables", "OK"))
         MObject.connect(pbtnClose, SIGNAL("clicked()"), dDialog.close)
         vblMain.addWidget(pbtnClose)
         if isActivePyKDE4:
             dDialog.setMainWidget(mainPanel)
         else:
             dDialog.setLayout(vblMain)
         dDialog.setMinimumWidth(600)
         dDialog.setMinimumHeight(400)
         dDialog.show()
     elif _actionType == "clipboard":
         MApplication.clipboard().setText(str(info))
Exemplo n.º 30
0
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath,
                                           dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails",
                                                       "Close"))
                self.pbtnSave = MPushButton(
                    translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"),
                                self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [
                    translate("MusicDetails", "Directory: "),
                    translate("MusicDetails", "File Name: "),
                    translate("MusicDetails", "Artist: "),
                    translate("MusicDetails", "Title: "),
                    translate("MusicDetails", "Album: "),
                    translate("MusicDetails", "Album Artist: "),
                    translate("MusicDetails", "Track: "),
                    translate("MusicDetails", "Year: "),
                    translate("MusicDetails", "Genre: ")
                ]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(
                translate("MusicDetails", "File Does Not Exist"),
                str(
                    translate(
                        "MusicDetails",
                        "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry."
                    )) % Organizer.getLink(str(_filePath)))
            if hasattr(
                    getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None:
                getMainWindow().FileManager.makeRefresh()
Exemplo n.º 31
0
    def changeFile(self, _filePath, _readFrom="tag"):
        self.musicFile = _filePath
        self.musicValues = None
        self.isPlayNow = MToolButton()
        self.isPlayNow.setToolTip(
            translate("MusicDetails", "Play Suddenly Music When Open"))
        self.isPlayNow.setText(translate("MusicDetails", "Play When Open"))
        self.isPlayNow.setCheckable(True)
        self.isPlayNow.setChecked(uni.getBoolValue("isPlayNow"))
        self.isGetFromAmarok = MToolButton()
        self.isGetFromAmarok.setToolTip(
            translate("MusicDetails", "Get Values From Amarok"))
        self.isGetFromAmarok.setText(
            translate("MusicDetails", "Get From Amarok"))
        self.isGetFromAmarok.setCheckable(True)
        if _readFrom.count("Amarok") > 0:
            import Amarok

            uni.startThreadAction()
            Dialogs.showState(
                translate("MusicDetails", "Getting Values From Amarok"), 0, 1)
            if Amarok.checkAmarok():
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    from Amarok import Operations

                    musicFileRows = Operations.getAllMusicFileValuesWithNames(
                        "filename:\"" + _filePath + "\"")
                    Dialogs.showState(
                        translate("MusicDetails",
                                  "Values Are Being Processed"), 1, 1)
                    if len(musicFileRows) > 0:
                        musicFileRow = musicFileRows[0]
                        content = {}
                        content["path"] = musicFileRow["filePath"]
                        content["baseNameOfDirectory"] = fu.getBaseName(
                            fu.getDirName(musicFileRow["filePath"]))
                        content["baseName"] = fu.getBaseName(
                            musicFileRow["filePath"])
                        content["artist"] = musicFileRow["artist"]
                        content["title"] = musicFileRow["title"]
                        content["album"] = musicFileRow["album"]
                        content["albumArtist"] = musicFileRow["albumArtist"]
                        content["trackNum"] = musicFileRow["trackNumber"]
                        content["year"] = musicFileRow["year"]
                        content["genre"] = musicFileRow["genre"]
                        content["firstComment"] = musicFileRow["comment"]
                        content["firstLyrics"] = musicFileRow["lyrics"]
                        content["images"] = []
                        if _readFrom == "Amarok (Smart)":
                            tagger = Taggers.getTagger()
                            try:
                                tagger.loadFile(musicFileRow["filePath"])
                            except:
                                pass
                            else:
                                if content["artist"].strip() == "":
                                    content["artist"] = tagger.getArtist()
                                if content["title"].strip() == "":
                                    content["title"] = tagger.getTitle()
                                if content["album"].strip() == "":
                                    content["album"] = tagger.getAlbum()
                                if content["albumArtist"].strip() == "":
                                    content[
                                        "albumArtist"] = tagger.getAlbumArtist(
                                        )
                                if str(content["trackNum"]).strip() == "":
                                    content["trackNum"] = tagger.getTrackNum()
                                if str(content["year"]).strip() == "":
                                    content["year"] = tagger.getYear()
                                if content["genre"].strip() == "":
                                    content["genre"] = tagger.getGenre()
                                if content["firstComment"].strip() == "":
                                    content[
                                        "firstComment"] = tagger.getFirstComment(
                                        )
                                if content["firstLyrics"].strip() == "":
                                    content[
                                        "firstLyrics"] = tagger.getFirstLyrics(
                                        )
                                content["images"] = tagger.getImages()
                        self.isGetFromAmarok.setChecked(True)
                        self.musicValues = content
                    else:
                        Dialogs.show(
                            translate("MusicDetails", "Not Exist In Amarok"),
                            translate(
                                "MusicDetails",
                                "This music file not exist in Amarok DB."))
            uni.finishThreadAction()
        if self.musicValues is None:
            self.isGetFromAmarok.setChecked(False)
            self.musicValues = Musics.readMusicFile(self.musicFile)
        self.setWindowTitle(str(fu.getBaseName(self.musicFile)))
        if self.pnlClearable is not None:
            clearAllChildren(self.pnlClearable, True)
        self.pnlClearable = MWidget()
        self.vblMain.insertWidget(0, self.pnlClearable, 20)
        vblClearable = MVBoxLayout(self.pnlClearable)
        self.player = MusicPlayer.MusicPlayer(self, "dialog", _filePath)
        self.infoLabels["baseNameOfDirectory"] = MLabel(self.labels[0])
        self.infoLabels["baseName"] = MLabel(self.labels[1])
        self.infoLabels["artist"] = MLabel(self.labels[2])
        self.infoLabels["title"] = MLabel(self.labels[3])
        self.infoLabels["album"] = MLabel(self.labels[4])
        self.infoLabels["albumArtist"] = MLabel(self.labels[5])
        self.infoLabels["trackNum"] = MLabel(self.labels[6])
        self.infoLabels["year"] = MLabel(self.labels[7])
        self.infoLabels["genre"] = MLabel(self.labels[8])
        self.infoValues["baseNameOfDirectory"] = MLineEdit(
            str(
                Organizer.emend(self.musicValues["baseNameOfDirectory"],
                                "directory", False)))
        self.infoValues["baseName"] = MLineEdit(
            str(Organizer.emend(self.musicValues["baseName"], "file")))
        self.infoValues["artist"] = MLineEdit(
            str(Organizer.emend(self.musicValues["artist"])))
        self.infoValues["title"] = MLineEdit(
            str(Organizer.emend(self.musicValues["title"])))
        self.infoValues["album"] = MLineEdit(
            str(Organizer.emend(self.musicValues["album"])))
        self.infoValues["albumArtist"] = MLineEdit(
            str(Organizer.emend(self.musicValues["albumArtist"])))
        self.infoValues["trackNum"] = MLineEdit(
            str(Organizer.emend(self.musicValues["trackNum"])))
        self.infoValues["year"] = MLineEdit(
            str(Organizer.emend(self.musicValues["year"])))
        self.infoValues["genre"] = MLineEdit(
            str(Organizer.emend(self.musicValues["genre"])))
        self.infoValues["firstComment"] = MPlainTextEdit(
            str(Organizer.emend(self.musicValues["firstComment"])))
        self.infoValues["firstLyrics"] = MPlainTextEdit(
            str(Organizer.emend(self.musicValues["firstLyrics"])))
        self.infoValues["firstComment"].setLineWrapMode(MPlainTextEdit.NoWrap)
        self.infoValues["firstLyrics"].setLineWrapMode(MPlainTextEdit.NoWrap)

        if Taggers.getTagger().isSupportImages:
            self.isOpenImageDetailsOnNewWindow = MCheckBox(
                translate("MusicDetails", "Show Images In New Window"))
            self.pbtnAddImage = MPushButton(translate("MusicDetails",
                                                      "Append"))
            self.pbtnDeleteImage = MPushButton(
                translate("MusicDetails", "Delete"))
            self.pbtnSaveAsImage = MPushButton(
                translate("MusicDetails", "Save As ..."))
            self.pbtnCancelAddImage = MPushButton(
                translate("MusicDetails", "Cancel"))
            self.pbtnSelectImage = MPushButton(
                translate("MusicDetails", "Choose Image"))
            MObject.connect(self.pbtnAddImage, SIGNAL("clicked()"),
                            self.addImage)
            MObject.connect(self.pbtnDeleteImage, SIGNAL("clicked()"),
                            self.deleteImage)
            MObject.connect(self.pbtnSaveAsImage, SIGNAL("clicked()"),
                            self.saveAsImage)
            MObject.connect(self.pbtnCancelAddImage, SIGNAL("clicked()"),
                            self.cancelAddImage)
            MObject.connect(self.pbtnSelectImage, SIGNAL("clicked()"),
                            self.selectImage)
            self.leImagePath = MLineEdit("")
            self.lblImagePath = MLabel(
                translate("MusicDetails", "Image Path: "))
            self.cbImageType = MComboBox()
            self.cbImageType.addItems(Taggers.getTagger().getImageTypes())
            self.lblImageType = MLabel(
                translate("MusicDetails", "Image Type: "))

            self.lstwImages = MListWidget()
            self.lstwImages.setGridSize(MSize(350, 100))
            self.lstwImages.setIconSize(MSize(98, 98))
            MObject.connect(self.lstwImages,
                            SIGNAL("doubleClicked(QModelIndex)"),
                            self.openImageDetails)
            MObject.connect(self.isGetFromAmarok, SIGNAL("toggled(bool)"),
                            self.isGetFromAmarokTiggered)
            self.lstwImages.clear()
            for image in self.musicValues["images"]:
                if len(image) == 5:
                    pixmImage = MPixmap()
                    pixmImage.loadFromData(image[3])
                    icnImage = QIcon(pixmImage)
                    icnImage.actualSize(MSize(98, 98))
                    item = MListWidgetItem(icnImage,
                                           image[1] + "\n(" + image[2] + ")")
                    item.setSizeHint(MSize(1, 100))
                    self.lstwImages.addItem(item)
        HBOXs = []
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["baseNameOfDirectory"])
        HBOXs[-1].addWidget(self.infoValues["baseNameOfDirectory"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["baseName"])
        HBOXs[-1].addWidget(self.infoValues["baseName"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["artist"])
        HBOXs[-1].addWidget(self.infoValues["artist"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["title"])
        HBOXs[-1].addWidget(self.infoValues["title"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["album"])
        HBOXs[-1].addWidget(self.infoValues["album"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["albumArtist"])
        HBOXs[-1].addWidget(self.infoValues["albumArtist"])
        HBOXs.append(MHBoxLayout())
        HBOXs[-1].addWidget(self.infoLabels["trackNum"])
        HBOXs[-1].addWidget(self.infoValues["trackNum"])
        HBOXs[-1].addWidget(self.infoLabels["year"])
        HBOXs[-1].addWidget(self.infoValues["year"])
        HBOXs[-1].addWidget(self.infoLabels["genre"])
        HBOXs[-1].addWidget(self.infoValues["genre"])
        vblInfos = MVBoxLayout()
        for hbox in HBOXs:
            vblInfos.addLayout(hbox)
        if Taggers.getTagger().isSupportImages:
            imageBoxs = []
            imageBoxs.append(MHBoxLayout())
            imageBoxs[0].addWidget(self.leImagePath)
            imageBoxs[0].addWidget(self.pbtnSelectImage)
            imageBoxs.append(MHBoxLayout())
            imageBoxs[1].addWidget(self.lblImageType)
            imageBoxs[1].addWidget(self.cbImageType)
            imageBoxs.append(MHBoxLayout())
            imageBoxs[2].addWidget(self.pbtnAddImage)
            imageBoxs[2].addWidget(self.pbtnDeleteImage)
            imageBoxs[2].addWidget(self.pbtnSaveAsImage)
            imageBoxs[2].addWidget(self.pbtnCancelAddImage)
            vblImages = MVBoxLayout()
            vblImages.addWidget(self.lstwImages)
            vblImages.addWidget(self.isOpenImageDetailsOnNewWindow)
            vblImages.addWidget(self.lblImagePath)
            vblImages.addLayout(imageBoxs[0])
            vblImages.addLayout(imageBoxs[1])
            vblImages.addLayout(imageBoxs[2])
        vblComments = MVBoxLayout()
        vblComments.addWidget(self.infoValues["firstComment"])
        vblLyrics = MVBoxLayout()
        vblLyrics.addWidget(self.infoValues["firstLyrics"])
        self.tabwTabs = MTabWidget(self.pnlMain)
        self.pnlComments = MWidget(self.tabwTabs)
        self.pnlComments.setLayout(vblComments)
        self.tabwTabs.addTab(self.pnlComments,
                             translate("MusicDetails", "Comments"))
        self.pnlLyrics = MWidget(self.tabwTabs)
        self.pnlLyrics.setLayout(vblLyrics)
        self.tabwTabs.addTab(self.pnlLyrics, translate("MusicDetails",
                                                       "Lyrics"))
        if Taggers.getTagger().isSupportImages:
            self.pnlImages = MWidget(self.tabwTabs)
            self.pnlImages.setLayout(vblImages)
            self.tabwTabs.addTab(self.pnlImages,
                                 translate("MusicDetails", "Images"))
            self.pbtnSelectImage.hide()
            self.leImagePath.hide()
            self.lblImagePath.hide()
            self.lblImageType.hide()
            self.cbImageType.hide()
            self.pbtnCancelAddImage.hide()
        hblPlayer = MHBoxLayout()
        vblExtraButtons = MVBoxLayout()
        hblPlayer.addWidget(self.player)
        vblExtraButtons.addWidget(self.isPlayNow)
        vblExtraButtons.addWidget(self.isGetFromAmarok)
        hblPlayer.addLayout(vblExtraButtons)
        vblClearable.addLayout(hblPlayer)
        vblClearable.addLayout(vblInfos)
        vblClearable.addWidget(self.tabwTabs)
Exemplo n.º 32
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        musicFileNames = fu.readDirectory(_path, "music", uni.getBoolValue("isShowHiddensInMusicTable"))
        isCanNoncompatible = False
        allItemNumber = len(musicFileNames)
        uni.startThreadAction()
        baseNameOfDirectory = fu.getBaseName(_path)
        rowNo = 0
        self.setRowCount(allItemNumber)
        for baseName in musicFileNames:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
                        tagger = Taggers.getTagger()
                        try:
                            tagger.loadFile(fu.joinPath(_path, baseName))
                        except:
                            Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                              str(translate("FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags.")
                                              ) % Organizer.getLink(fu.joinPath(_path, baseName)))
                        if tagger.isAvailableFile() is False:
                            isCanNoncompatible = True
                        details = fu.getDetails(fu.joinPath(_path, baseName))
                        content = {}
                        content["path"] = fu.joinPath(_path, baseName)
                        content["baseNameOfDirectory"] = baseNameOfDirectory
                        content["baseName"] = baseName
                        content["artist"] = tagger.getArtist()
                        content["title"] = tagger.getTitle()
                        content["album"] = tagger.getAlbum()
                        content["albumArtist"] = tagger.getAlbumArtist()
                        content["trackNum"] = tagger.getTrackNum()
                        content["year"] = tagger.getYear()
                        content["genre"] = tagger.getGenre()
                        content["firstComment"] = tagger.getFirstComment()
                        content["firstLyrics"] = tagger.getFirstLyrics()
                        if tagger.isSupportInfo:
                            content["length"] = tagger.getLength()
                            content["bitrate"] = tagger.getBitrate()
                            content["sampleRate"] = tagger.getSampleRate()
                            content["mode"] = tagger.getMode()
                        content["size"] = details[stat.ST_SIZE]
                        content["lastAccessed"] = details[stat.ST_ATIME]
                        content["lastModified"] = details[stat.ST_MTIME]
                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                        self.values.append(content)
                        newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                        self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"])

                        newTrackNum = str(self.values[rowNo]["trackNum"])
                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                        newYear = Organizer.emend(self.values[rowNo]["year"])
                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                        self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"])

                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                        self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"])

                        if tagger.isSupportInfo:
                            self.createItem(rowNo, "length", content["length"])
                            self.createItem(rowNo, "bitrate", content["bitrate"])
                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                            self.createItem(rowNo, "mode", content["mode"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

                        self.createItem(rowNo, "lastMetadataChanged",
                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
        if isCanNoncompatible:
            Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"),
                         translate("FileUtils/Musics",
                                   "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
Exemplo n.º 33
0
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"),
                          0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(
                            self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory",
                                                 baseNameOfDirectory):
                            baseNameOfDirectory = str(
                                self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName,
                                                 False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()),
                                        baseNameOfDirectory, baseName))
                        if fu.isFile(self.values[rowNo]
                                     ["path"]) and fu.isReadableFileOrDir(
                                         self.values[rowNo]["path"], False,
                                         True):
                            if fu.isWritableFileOrDir(newFilePath, False,
                                                      True):
                                newFilePathCopied = fu.copyOrChange(
                                    self.values[rowNo]["path"], newFilePath)
                                if self.values[rowNo][
                                        "path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(
                                                rowNo, "artist"):
                                            value = str(
                                                self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Artist")),
                                                str(self.values[rowNo]
                                                    ["artist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "title"):
                                            value = str(
                                                self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Title")),
                                                str(self.values[rowNo]
                                                    ["title"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "album"):
                                            value = str(
                                                self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album")),
                                                str(self.values[rowNo]
                                                    ["album"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "albumArtist"):
                                            value = str(
                                                self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Album Artist")),
                                                str(self.values[rowNo]
                                                    ["albumArtist"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "trackNum"):
                                            value = str(
                                                self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Track No")),
                                                str(self.values[rowNo]
                                                    ["trackNum"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "year"):
                                            value = str(
                                                self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable", "Year")),
                                                str(self.values[rowNo]
                                                    ["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "genre"):
                                            value = str(
                                                self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Genre")),
                                                str(self.values[rowNo]
                                                    ["genre"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstComment"):
                                            value = str(
                                                self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Comment")),
                                                str(self.values[rowNo]
                                                    ["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(
                                                rowNo, "firstLyrics"):
                                            value = str(
                                                self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(
                                                str(
                                                    translate(
                                                        "MusicTable",
                                                        "Lyrics")),
                                                str(self.values[rowNo]
                                                    ["firstLyrics"]), value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(
                                            translate("MusicTable",
                                                      "Tags Cannot Changed"),
                                            str(
                                                translate(
                                                    "MusicTable",
                                                    "\"%s\" : cannot be changed tags."
                                                )) %
                                            Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(
                translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1,
                allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Exemplo n.º 34
0
    def refreshTable(self, _path):
        self.values = []
        allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(_path,
                                                                          int(uni.MySettings["subDirectoryDeep"]),
                                                                          "file", uni.getBoolValue(
                "isShowHiddensInSubFolderTable"))
        allItemNumber = len(allFilesAndDirectories)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for baseName in allFilesAndDirectories:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(baseName, False, True):
                        details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
                        content = {}
                        content["path"] = baseName
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) + str(fu.getDirName(baseName)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(baseName)
                        content.update(details)
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory")
                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                        content["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(content["baseName"], "file")
                        self.createItem(rowNo, "baseName", newBaseName, content["baseName"])

                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                        self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))

                        self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))

                        self.createItem(rowNo, "lastMetadataChanged",
                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                        if not uni.isWindows:
                            self.createItem(rowNo, "accessRights", content["accessRights"])

                            self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"])

                            self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"])

                            self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"])

                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 35
0
 def checkIcon(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             fu.checkIcon(_path)
             Dialogs.show(translate("QuickMake", "Directory Icon Checked"),
                          str(translate("QuickMake",
                                        "\"%s\"`s icon checked.<br>The default action based on the data is executed.")) % Organizer.getLink(
                              _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 36
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     startRowNo, rowStep = 0, 1
     uni.startThreadAction()
     allItemNumber = len(self.values)
     Dialogs.showState(
         translate("FileUtils/Covers", "Writing Cover Informations"), 0,
         allItemNumber, True)
     for rowNo in range(startRowNo, self.rowCount(), rowStep):
         isContinueThreadAction = uni.isContinueThreadAction()
         if isContinueThreadAction:
             try:
                 if fu.isWritableFileOrDir(self.values[rowNo]["path"],
                                           False, True):
                     if self.isRowHidden(rowNo):
                         fu.removeFileOrDir(self.values[rowNo]["path"])
                         self.changedValueNumber += 1
                     else:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         baseName = str(self.values[rowNo]["baseName"])
                         if (self.isChangeableItem(rowNo, "sourceCover")
                                 or self.isChangeableItem(
                                     rowNo, "destinationCover")):
                             sourcePath = self.values[rowNo]["sourceCover"]
                             destinationPath = self.values[rowNo][
                                 "destinationCover"]
                             if self.isChangeableItem(rowNo, "sourceCover"):
                                 sourcePath = str(
                                     self.item(rowNo, 3).text()).strip()
                             if self.isChangeableItem(
                                     rowNo, "destinationCover"):
                                 destinationPath = str(
                                     self.item(rowNo, 4).text()).strip()
                             if (str(self.item(rowNo,
                                               2).text()) != sourcePath
                                     or sourcePath != destinationPath
                                     or str(self.item(rowNo, 2).text()) !=
                                     destinationPath
                                 ) or (str(self.item(rowNo, 2).text()) !=
                                       self.values[rowNo]["currentCover"]
                                       and
                                       (str(self.item(rowNo, 2).text()) !=
                                        sourcePath
                                        and str(self.item(rowNo, 2).text())
                                        != destinationPath)):
                                 if str(self.item(rowNo,
                                                  3).text()).strip() != "":
                                     sourcePath = fu.getRealPath(
                                         sourcePath,
                                         self.values[rowNo]["path"])
                                     sourcePath = fu.checkSource(
                                         sourcePath, "file")
                                     if sourcePath is not None:
                                         if destinationPath != "":
                                             destinationPath = fu.getRealPath(
                                                 destinationPath,
                                                 self.values[rowNo]["path"])
                                             if sourcePath != destinationPath:
                                                 destinationPath = fu.moveOrChange(
                                                     sourcePath,
                                                     destinationPath)
                                         else:
                                             destinationPath = sourcePath
                                         fu.setIconToDirectory(
                                             self.values[rowNo]["path"],
                                             destinationPath)
                                         self.changedValueNumber += 1
                                 else:
                                     fu.setIconToDirectory(
                                         self.values[rowNo]["path"], "")
                                     self.changedValueNumber += 1
                         if self.isChangeableItem(rowNo,
                                                  "baseNameOfDirectory",
                                                  baseNameOfDirectory):
                             baseNameOfDirectory = str(
                                 self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(
                                     fu.getDirName(
                                         self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(
                                         rowNo - 1,
                                         0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName",
                                                  baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(
                                 fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, baseName)
                         oldFilePath = fu.getRealPath(
                             self.values[rowNo]["path"])
                         newFilePath = fu.getRealPath(newFilePath)
                         if oldFilePath != newFilePath:
                             oldAndNewPaths = {}
                             oldAndNewPaths["oldPath"] = oldFilePath
                             oldAndNewPaths["newPath"] = fu.moveOrChange(
                                 oldFilePath, newFilePath, "directory")
                             if oldFilePath != oldAndNewPaths["newPath"]:
                                 oldAndNewPathValues.append(oldAndNewPaths)
                                 oldDirName = fu.getDirName(oldFilePath)
                                 if uni.getBoolValue(
                                         "isClearEmptyDirectoriesWhenFileMove"
                                 ):
                                     fu.checkEmptyDirectories(
                                         oldDirName, True, True,
                                         uni.getBoolValue(
                                             "isAutoCleanSubFolderWhenFileMove"
                                         ))
             except:
                 ReportBug.ReportBug()
         else:
             allItemNumber = rowNo + 1
         Dialogs.showState(
             translate("FileUtils/Covers", "Writing Cover Informations"),
             rowNo + 1, allItemNumber, True)
         if isContinueThreadAction is False:
             break
     uni.finishThreadAction()
     if self.rowCount() == len(
             oldAndNewPathValues
     ) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath,
                                           "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(
                 translate("FileUtils/Musics", "There Are More Files"),
                 str(
                     translate(
                         "FileUtils/Musics",
                         "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\""
                     )) % (Organizer.getLink(currentDirectoryPath),
                           Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(
                                 fu.joinPath(currentDirectoryPath,
                                             fileName))
                             newFilePath = fu.getRealPath(
                                 fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths[
                                     "newPath"] = fu.moveOrChange(
                                         oldFilePath, newFilePath,
                                         fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(
                                         oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(
                         translate(
                             "FileUtils/Covers",
                             "Writing Directory And File Informations"),
                         rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(
                         currentDirectoryPath, True, True,
                         uni.getBoolValue(
                             "isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and
                         uni.getBoolValue("isActiveAutoMakeIconToDirectory")
                         and uni.getBoolValue(
                             "isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
Exemplo n.º 37
0
    def refreshTable(self, _path):
        self.values = []
        allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(
            _path, int(uni.MySettings["CoversSubDirectoryDeep"]), "directory",
            uni.getBoolValue("isShowHiddensInCoverTable"))
        allItemNumber = len(allFilesAndDirectories)
        uni.startThreadAction()
        rowNo = 0
        self.setRowCount(allItemNumber)
        for dirName in allFilesAndDirectories:
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if fu.isReadableFileOrDir(
                            dirName, False, True) and fu.isReadableFileOrDir(
                                fu.joinPath(dirName, ".directory"), False,
                                True):
                        content = {}
                        content["path"] = dirName
                        content["baseNameOfDirectory"] = str(
                            str(fu.getBaseName(_path)) +
                            str(fu.getDirName(dirName)).replace(_path, ""))
                        content["baseName"] = fu.getBaseName(dirName)

                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(
                            dirName)
                        selectedName = None
                        if isCorrectedFileContent and currentCover is not None:
                            selectedName = fu.getBaseName(currentCover)
                        sourceCover = fu.getFirstImageInDirectory(
                            dirName, selectedName, False, False)
                        if currentCover is None:
                            currentCover = ""
                        if sourceCover is None:
                            sourceCover = ""
                        else:
                            sourceCover = fu.joinPath(dirName, sourceCover)
                        content["currentCover"] = (currentCover)
                        content["sourceCover"] = (sourceCover)
                        content["destinationCover"] = (sourceCover)
                        content["isCorrectedFileContent"] = (
                            isCorrectedFileContent)
                        self.values.append(content)

                        newBaseNameOfDirectory = Organizer.emend(
                            self.values[rowNo]["baseNameOfDirectory"],
                            "directory")
                        self.createItem(
                            rowNo, "baseNameOfDirectory",
                            newBaseNameOfDirectory,
                            self.values[rowNo]["baseNameOfDirectory"])

                        newBaseName = Organizer.emend(
                            self.values[rowNo]["baseName"], "directory")
                        self.createItem(rowNo, "baseName", newBaseName,
                                        self.values[rowNo]["baseName"])

                        newCurrentCover = str(
                            self.values[rowNo]["currentCover"])
                        newCurrentCover = newCurrentCover.replace(
                            self.values[rowNo]["path"], ".")
                        itemCurrentCover = self.createItem(
                            rowNo, "currentCover", newCurrentCover,
                            newCurrentCover, True)
                        if self.values[rowNo][
                                "isCorrectedFileContent"] is False:
                            itemCurrentCover.setBackground(
                                MBrush(MColor(255, 163, 163)))

                        newSourceCover = str(self.values[rowNo]["sourceCover"])
                        newSourceCover = newSourceCover.replace(
                            self.values[rowNo]["path"], ".")
                        oldSourceCover = self.values[rowNo]["currentCover"]
                        oldSourceCover = oldSourceCover.replace(
                            self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "sourceCover", newSourceCover,
                                        oldSourceCover)

                        newDestinationCover = self.values[rowNo][
                            "destinationCover"]
                        newDestinationCover = newDestinationCover.replace(
                            self.values[rowNo]["path"], ".")
                        newDestinationCover = Organizer.emend(
                            newDestinationCover, "file")
                        oldDestinationCover = self.values[rowNo][
                            "currentCover"]
                        oldDestinationCover = oldDestinationCover.replace(
                            self.values[rowNo]["path"], ".")
                        self.createItem(rowNo, "destinationCover",
                                        newDestinationCover,
                                        oldDestinationCover)
                        rowNo += 1
                    else:
                        allItemNumber -= 1
                except:
                    ReportBug.ReportBug()
                    allItemNumber -= 1
            else:
                allItemNumber = rowNo
            Dialogs.showState(translate("Tables", "Generating Table..."),
                              rowNo, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        self.setRowCount(len(
            self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 38
0
 def clearEmptyDirectories(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             if fu.isWritableFileOrDir(_path):
                 fu.activateSmartCheckIcon()
                 fu.checkEmptyDirectories(_path, True, True, True, True)
                 if fu.isDir(_path):
                     fu.completeSmartCheckIcon()
                 Dialogs.show(translate("QuickMake", "Directory Cleaned"),
                              str(translate("QuickMake",
                                            "\"%s\" is cleaned based on the criteria you set.")) % Organizer.getLink(
                                  _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 39
0
    def __init__(self, _artistId, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        if Commands.getArtistName(_artistId) is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.changeArtist(_artistId)
                        dialog.activateWindow()
                        dialog.raise_()
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                MDialog.__init__(self, MApplication.activeWindow())
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.infoLabels = {}
                self.infoValues = {}
                self.artistValues = {}
                self.pbtnClose = MPushButton(translate("AmarokArtistDetails", "Close"))
                self.pbtnSave = MPushButton(translate("AmarokArtistDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"), self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [translate("AmarokArtistDetails", "Current Artist: "),
                               translate("AmarokArtistDetails", "Corrected Artist: ")]
                self.songTableColumns = [translate("AmarokArtistDetails", "File Path"),
                                         translate("AmarokArtistDetails", "Artist"),
                                         translate("AmarokArtistDetails", "Title"),
                                         translate("AmarokArtistDetails", "Album"),
                                         translate("AmarokArtistDetails", "Album Artist"),
                                         translate("AmarokArtistDetails", "Track No"),
                                         translate("AmarokArtistDetails", "Year"),
                                         translate("AmarokArtistDetails", "Genre"),
                                         translate("AmarokArtistDetails", "Comment")]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeArtist(_artistId, True)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.setMinimumWidth(700)
                self.setMinimumHeight(500)
        else:
            Dialogs.showError(translate("AmarokArtistDetails", "Artist Does Not Exist"),
                              str(translate("AmarokArtistDetails",
                                            "\"%s\" does not exist in \"id\" column of \"artist\" table.<br>Table will be refreshed automatically!<br>Please retry.")
                              ) % Organizer.getLink(str(_artistId)))
            if hasattr(getMainWindow(),
                       "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Exemplo n.º 40
0
 def removeOnlySubFiles(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "directory")
         if _path is not None:
             answer = Dialogs.ask(translate("QuickMake", "All Files Will Be Removed"),
                                  str(translate("QuickMake",
                                                "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink(
                                      _path))
             if answer == Dialogs.Yes:
                 getMainWindow().setEnabled(False)
                 fu.removeOnlySubFiles(_path)
                 getMainWindow().setEnabled(True)
                 Dialogs.show(translate("QuickMake", "Removed Only All Files"),
                              str(translate("QuickMake",
                                            "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink(
                                  _path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 41
0
 def apply(self):
     self.checkCompleters()
     self.reFillCompleters()
     getMainTable().createHistoryPoint()
     searchStrings = str(self.leSearch.text()).split(";")
     replaceStrings = str(self.leReplace.text()).split(";")
     for filterNo in range(0, len(searchStrings)):
         if self.specialTools.btChange.isChecked():
             pass
         elif self.specialTools.tbAddToBefore.isChecked():
             replaceStrings[filterNo] += searchStrings[filterNo]
         elif self.specialTools.tbAddToAfter.isChecked():
             replaceStrings[filterNo] = searchStrings[filterNo] + replaceStrings[filterNo]
     while len(replaceStrings) != len(searchStrings):
         replaceStrings.append("")
     selectedColumnKey = self.columns.currentData()
     if selectedColumnKey == "all":
         columnKeys = getMainTable().getWritableColumnKeys()
     else:
         columnKeys = [selectedColumnKey]
     for columnKey in columnKeys:
         columnNo = getMainTable().getColumnNoFromKey(columnKey)
         if getMainTable().checkReadOnlyColumn(columnKey) is False:
             continue
         if getMainTable().checkHiddenColumn(columnKey, False) is False:
             continue
         for rowNo in range(getMainTable().rowCount()):
             if getMainTable().isChangeableItem(rowNo, columnKey, None, True):
                 newString = str(getMainTable().item(rowNo, columnNo).text())
                 newString = uni.trUnicode(newString)
                 myString = ""
                 informationSectionX = self.specialTools.cbInformationSectionX.value()
                 informationSectionY = self.specialTools.cbInformationSectionY.value()
                 isCaseInsensitive = self.cckbCaseInsensitive.isChecked()
                 isRegExp = self.cckbRegExp.isChecked()
                 if self.specialTools.cbInformationSection.currentIndex() == 0:
                     myString = Organizer.searchAndReplace(newString, searchStrings,
                                                           replaceStrings, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 1:
                     myString = Organizer.searchAndReplace(newString[:informationSectionX], searchStrings,
                                                           replaceStrings, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 2:
                     myString = newString[:informationSectionX]
                     myString += Organizer.searchAndReplace(newString[informationSectionX:], searchStrings,
                                                            replaceStrings, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 3:
                     myString = Organizer.searchAndReplace(newString[:-informationSectionX], searchStrings,
                                                           replaceStrings, isCaseInsensitive, isRegExp)
                     myString += newString[-informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 4:
                     myString = newString[:-informationSectionX]
                     myString += Organizer.searchAndReplace(newString[-informationSectionX:], searchStrings,
                                                            replaceStrings, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex() == 5:
                     myString = newString[:informationSectionX]
                     myString += Organizer.searchAndReplace(newString[informationSectionX:informationSectionY],
                                                            searchStrings,
                                                            replaceStrings, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionY:]
                 elif self.specialTools.cbInformationSection.currentIndex() == 6:
                     myString = Organizer.searchAndReplace(newString[:informationSectionX], searchStrings,
                                                           replaceStrings, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionX:informationSectionY]
                     myString += Organizer.searchAndReplace(newString[informationSectionY:], searchStrings,
                                                            replaceStrings, isCaseInsensitive, isRegExp)
                 getMainTable().item(rowNo, columnNo).setText(str(myString))
Exemplo n.º 42
0
def clickedAnAction(_action):
    try:
        actionName = _action.objectName()
        if actionName == "Open State":
            f = Dialogs.getOpenFileName(
                translate("MenuBar", "Open State Of Hamsi Manager"),
                fu.userDirectoryPath,
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.openStateOfSettings(f)
        elif actionName == "Save State":
            f = Dialogs.getSaveFileName(
                translate("MenuBar", "Save State Of Hamsi Manager"),
                fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"),
                translate("MenuBar", "Application Runner") + " (*.desktop)")
            if f is not None:
                Settings.saveStateOfSettings(f)
                Dialogs.show(
                    translate("MenuBar", "Current State Saved"),
                    translate(
                        "MenuBar",
                        "Current state saved with preferences.<br>You can continue where you left off."
                    ))
        elif actionName == "With This Profile (My Settings)":
            if Execute.executeAsRootWithThread(
                ["--sDirectoryPath", fu.pathOfSettingsDirectory],
                    "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "With Root Profile (Own Settings)":
            if Execute.executeAsRootWithThread([], "HamsiManager"):
                getMainWindow().close()
            else:
                Dialogs.showError(
                    translate("MenuBar", "Can Not Run As Root"),
                    translate("MenuBar", "Hamsi Manager can not run as root."))
        elif actionName == "Quit":
            getMainWindow().close()
        elif actionName == "HTML Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "html", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "html", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "html", "title")
        elif actionName == "Text Format":
            if _action.parent().objectName() == "Export To File":
                getMainTable().exportValues("file", "plainText", "title")
            elif _action.parent().objectName() == "Show In New Window":
                getMainTable().exportValues("dialog", "plainText", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                getMainTable().exportValues("clipboard", "plainText", "title")
        elif actionName == "HTML Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "html", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "html", "fileTree", "title")
        elif actionName == "Text Format (File Tree)":
            if _action.parent().objectName() == "Export To File":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "file", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Show In New Window":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "dialog", "plainText", "fileTree", "title")
            elif _action.parent().objectName() == "Copy To Clipboard":
                fu.getFileTree((getMainWindow().FileManager.currentDirectory),
                               0, "clipboard", "plainText", "fileTree",
                               "title")
        elif actionName == "About QT":
            if isActivePyKDE4:
                QMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
            else:
                MMessageBox.aboutQt(getMainWindow(),
                                    translate("MenuBar", "About QT"))
        elif actionName == "Options":
            from Options import OptionsForm

            OptionsForm.OptionsForm(getMainWindow())
        elif actionName == "My Plugins":
            import MyPlugins

            MyPlugins.MyPlugins()
        elif actionName == "Reconfigure":
            from Tools import Configurator

            Configurator.Configurator("configurePage")
        elif actionName == "My Plugins (System)":
            Execute.execute(["--qm", "--plugins", "--runAsRoot"],
                            "HamsiManager")
        elif actionName == "Reconfigure (System)":
            Execute.execute(["--qm", "--configurator", "--runAsRoot"],
                            "HamsiManager")
        elif actionName == "Update":
            from Core import UpdateControl

            UpdateControl.UpdateControl(getMainWindow())
        elif actionName == "Report Bug":
            ReportBug.ReportBug(True)
        elif actionName == "Suggest Idea":
            from Core import SuggestIdea

            SuggestIdea.SuggestIdea()
        elif actionName == "About Hamsi Manager":
            if isActivePyKDE4 is False:
                MMessageBox.about(getMainWindow(),
                                  translate("MenuBar", "About Hamsi Manager"),
                                  uni.aboutOfHamsiManager)
        elif actionName == translate("ToolsBar", "Check Icon"):
            getMainWindow().setEnabled(False)
            fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath())
            Dialogs.show(
                translate("ToolsBar", "Directory Icon Checked"),
                translate(
                    "ToolsBar",
                    "Current directory icon checked.<br>The default action based on the data is executed."
                ))
            getMainWindow().setEnabled(True)
        elif actionName == "Clear Empty Directories":
            if getMainTable().checkUnSavedValues() is False:
                _action.setChecked(False)
                return False
            answer = Dialogs.ask(
                translate("ToolsBar", "Empty Directories Will Be Removed"),
                str(
                    translate(
                        "ToolsBar",
                        "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?"
                    )) % Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                currentDirPath = getMainWindow(
                ).FileManager.getCurrentDirectoryPath()
                if fu.isWritableFileOrDir(currentDirPath):
                    fu.checkEmptyDirectories(currentDirPath, True, True, True,
                                             True)
                    Dialogs.show(
                        translate("ToolsBar", "Directory Cleaned"),
                        translate(
                            "ToolsBar",
                            "The current directory is cleaned based on the criteria you set."
                        ))
                getMainWindow().setEnabled(True)
                getMainWindow().FileManager.makeRefresh()
        elif actionName == "Pack":
            from Tools import Packager

            Packager.Packager(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Hash":
            from Tools import Hasher

            Hasher.Hasher(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Clear":
            from Tools import Cleaner

            Cleaner.Cleaner(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Text Corrector":
            from Tools import TextCorrector

            TextCorrector.TextCorrector(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "File Tree":
            from Tools import FileTreeBuilder

            FileTreeBuilder.FileTreeBuilder(
                getMainWindow().FileManager.getCurrentDirectoryPath())
        elif actionName == "Search":
            from Tools import Searcher

            Searcher.Searcher(
                [getMainWindow().FileManager.getCurrentDirectoryPath()])
        elif actionName == "Script Manager":
            from Tools import ScriptManager

            if ScriptManager.ScriptManager.checkScriptManager():
                ScriptManager.ScriptManager(getMainWindow())
        elif actionName == "Show Last Actions":
            from Core import RecordsForm

            RecordsForm.RecordsForm(getMainWindow())
        elif actionName == "Remove Sub Files":
            answer = Dialogs.ask(
                translate("ToolsBar", "All Files Will Be Removed"),
                str(
                    translate(
                        "ToolsBar",
                        "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders."
                    )) % Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
            if answer == Dialogs.Yes:
                getMainWindow().setEnabled(False)
                fu.removeOnlySubFiles(
                    getMainWindow().FileManager.getCurrentDirectoryPath())
                getMainWindow().setEnabled(True)
                Dialogs.show(
                    translate("ToolsBar", "Removed Only All Files"),
                    str(
                        translate(
                            "ToolsBar",
                            "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders."
                        )) %
                    Organizer.getLink(
                        getMainWindow().FileManager.getCurrentDirectoryPath()))
        elif actionName == "Amarok Embedded Database Configurator":
            import Amarok

            if Amarok.checkAmarok():
                Amarok.openEmbeddedDBConfigurator()
        elif _action.parent().objectName() == "Table Types":
            changeTableType(_action)
        elif _action.parent().objectName() == "File Renamer Types":
            changeReNamerType(_action)
        elif _action.parent().objectName() == "Scripts":
            from Core import Scripts

            Scripts.runScriptFile(
                fu.joinPath(Scripts.pathOfScripsDirectory, actionName))
        Records.saveAllRecords()
    except:
        ReportBug.ReportBug()
Exemplo n.º 43
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if musicFileValuesWithNames is not None:
                        allItemNumber = len(musicFileValuesWithNames)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in musicFileValuesWithNames:
                            isContinueThreadAction = uni.isContinueThreadAction()
                            if isContinueThreadAction:
                                try:
                                    if (fu.isFile(musicFileRow["filePath"]) and
                                            fu.isReadableFileOrDir(musicFileRow["filePath"], False, True)):
                                        details = fu.getDetails(musicFileRow["filePath"])
                                        content = {}
                                        if Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Amarok (Smart)":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = fu.getBaseName(
                                                fu.getDirName(musicFileRow["filePath"]))
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(musicFileRow["filePath"])
                                            except:
                                                if tagger.isSupportInfo:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                            else:
                                                if content["artist"].strip() == "":
                                                    content["artist"] = tagger.getArtist()
                                                if content["title"].strip() == "":
                                                    content["title"] = tagger.getTitle()
                                                if content["album"].strip() == "":
                                                    content["album"] = tagger.getAlbum()
                                                if content["albumArtist"].strip() == "":
                                                    content["albumArtist"] = tagger.getAlbumArtist()
                                                if str(content["trackNum"]).strip() == "":
                                                    content["trackNum"] = tagger.getTrackNum()
                                                if str(content["year"]).strip() == "":
                                                    content["year"] = tagger.getYear()
                                                if content["genre"].strip() == "":
                                                    content["genre"] = tagger.getGenre()
                                                if content["firstComment"].strip() == "":
                                                    content["firstComment"] = tagger.getFirstComment()
                                                if content["firstLyrics"].strip() == "":
                                                    content["firstLyrics"] = tagger.getFirstLyrics()
                                                if tagger.isSupportInfo:
                                                    content["length"] = tagger.getLength()
                                                    content["bitrate"] = tagger.getBitrate()
                                                    content["sampleRate"] = tagger.getSampleRate()
                                                    content["mode"] = tagger.getMode()
                                        elif Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Only Amarok":
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = ""
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = musicFileRow["artist"]
                                            content["title"] = musicFileRow["title"]
                                            content["album"] = musicFileRow["album"]
                                            content["albumArtist"] = musicFileRow["albumArtist"]
                                            content["trackNum"] = musicFileRow["trackNumber"]
                                            content["year"] = musicFileRow["year"]
                                            content["genre"] = musicFileRow["genre"]
                                            content["firstComment"] = musicFileRow["comment"]
                                            content["firstLyrics"] = musicFileRow["lyrics"]
                                            tagger = Taggers.getTagger()
                                            if tagger.isSupportInfo:
                                                try:
                                                    tagger.loadFile(musicFileRow["filePath"])
                                                except:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                                else:
                                                    content["length"] = tagger.getLength()
                                                    content["bitrate"] = tagger.getBitrate()
                                                    content["sampleRate"] = tagger.getSampleRate()
                                                    content["mode"] = tagger.getMode()
                                        else:
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(musicFileRow["filePath"])
                                            except:
                                                Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
                                                                  str(translate("FileUtils/Musics",
                                                                                "\"%s\" : this file has the incorrect tag so can't read tags.")
                                                                  ) % Organizer.getLink(musicFileRow["filePath"]))
                                            content["path"] = musicFileRow["filePath"]
                                            content["baseNameOfDirectory"] = ""
                                            content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
                                            content["artist"] = tagger.getArtist()
                                            content["title"] = tagger.getTitle()
                                            content["album"] = tagger.getAlbum()
                                            content["albumArtist"] = tagger.getAlbumArtist()
                                            content["trackNum"] = tagger.getTrackNum()
                                            content["year"] = tagger.getYear()
                                            content["genre"] = tagger.getGenre()
                                            content["firstComment"] = tagger.getFirstComment()
                                            content["firstLyrics"] = tagger.getFirstLyrics()
                                            if tagger.isSupportInfo:
                                                content["length"] = tagger.getLength()
                                                content["bitrate"] = tagger.getBitrate()
                                                content["sampleRate"] = tagger.getSampleRate()
                                                content["mode"] = tagger.getMode()
                                        content["size"] = details[stat.ST_SIZE]
                                        content["lastAccessed"] = details[stat.ST_ATIME]
                                        content["lastModified"] = details[stat.ST_MTIME]
                                        content["lastMetadataChanged"] = details[stat.ST_CTIME]
                                        self.values.append(content)
                                        newBaseNameOfDirectory = Organizer.emend(
                                            self.values[rowNo]["baseNameOfDirectory"], "directory")
                                        self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
                                                        self.values[rowNo]["baseNameOfDirectory"])

                                        newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
                                        self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])

                                        newArtist = Organizer.emend(self.values[rowNo]["artist"])
                                        self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])

                                        newTitle = Organizer.emend(self.values[rowNo]["title"])
                                        self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])

                                        newAlbum = Organizer.emend(self.values[rowNo]["album"])
                                        self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])

                                        newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
                                        self.createItem(rowNo, "albumArtist", newAlbumArtist,
                                                        self.values[rowNo]["albumArtist"])

                                        newTrackNum = str(self.values[rowNo]["trackNum"])
                                        self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])

                                        newYear = Organizer.emend(self.values[rowNo]["year"])
                                        self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])

                                        newGenre = Organizer.emend(self.values[rowNo]["genre"])
                                        self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])

                                        newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
                                        self.createItem(rowNo, "firstComment", newFirstComment,
                                                        self.values[rowNo]["firstComment"])

                                        newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
                                        self.createItem(rowNo, "firstLyrics", newFirstLyrics,
                                                        self.values[rowNo]["firstLyrics"])

                                        if Taggers.getTagger().isSupportInfo:
                                            self.createItem(rowNo, "length", content["length"])
                                            self.createItem(rowNo, "bitrate", content["bitrate"])
                                            self.createItem(rowNo, "sampleRate", content["sampleRate"])
                                            self.createItem(rowNo, "mode", content["mode"])

                                        self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))

                                        self.createItem(rowNo, "lastAccessed",
                                                        Organizer.getCorrectedTime(content["lastAccessed"]))

                                        self.createItem(rowNo, "lastModified",
                                                        Organizer.getCorrectedTime(content["lastModified"]))

                                        self.createItem(rowNo, "lastMetadataChanged",
                                                        Organizer.getCorrectedTime(content["lastMetadataChanged"]))

                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 44
0
    def writeContents(self):
        self.changedValueNumber = 0
        uni.startThreadAction()
        import Amarok

        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    if self.isRowHidden(rowNo) is False:
                        baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
                        baseName = str(self.values[rowNo]["baseName"])
                        if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                            baseNameOfDirectory = str(self.item(rowNo, 0).text())
                            self.changedValueNumber += 1
                        if self.isChangeableItem(rowNo, "baseName", baseName, False):
                            baseName = str(self.item(rowNo, 1).text())
                            self.changedValueNumber += 1
                        newFilePath = fu.getRealPath(
                            fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory,
                                        baseName))
                        if fu.isFile(self.values[rowNo]["path"]) and fu.isReadableFileOrDir(
                            self.values[rowNo]["path"], False, True):
                            if fu.isWritableFileOrDir(newFilePath, False, True):
                                newFilePathCopied = fu.copyOrChange(self.values[rowNo]["path"],
                                                                    newFilePath)
                                if self.values[rowNo]["path"] != newFilePathCopied:
                                    newFilePath = newFilePathCopied
                                    try:
                                        tagger = Taggers.getTagger()
                                        tagger.loadFileForWrite(newFilePath)
                                        if self.isChangeableItem(rowNo, "artist"):
                                            value = str(self.item(rowNo, 2).text())
                                            tagger.setArtist(value)
                                            Records.add(str(translate("MusicTable", "Artist")),
                                                        str(self.values[rowNo]["artist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "title"):
                                            value = str(self.item(rowNo, 3).text())
                                            tagger.setTitle(value)
                                            Records.add(str(translate("MusicTable", "Title")),
                                                        str(self.values[rowNo]["title"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "album"):
                                            value = str(self.item(rowNo, 4).text())
                                            tagger.setAlbum(value)
                                            Records.add(str(translate("MusicTable", "Album")),
                                                        str(self.values[rowNo]["album"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "albumArtist"):
                                            value = str(self.item(rowNo, 5).text())
                                            tagger.setAlbumArtist(value)
                                            Records.add(str(translate("MusicTable", "Album Artist")),
                                                        str(self.values[rowNo]["albumArtist"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "trackNum"):
                                            value = str(self.item(rowNo, 6).text())
                                            tagger.setTrackNum(value)
                                            Records.add(str(translate("MusicTable", "Track No")),
                                                        str(self.values[rowNo]["trackNum"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "year"):
                                            value = str(self.item(rowNo, 7).text())
                                            tagger.setDate(value)
                                            Records.add(str(translate("MusicTable", "Year")),
                                                        str(self.values[rowNo]["year"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "genre"):
                                            value = str(self.item(rowNo, 8).text())
                                            tagger.setGenre(value)
                                            Records.add(str(translate("MusicTable", "Genre")),
                                                        str(self.values[rowNo]["genre"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstComment"):
                                            value = str(self.item(rowNo, 9).text())
                                            tagger.setFirstComment(value)
                                            Records.add(str(translate("MusicTable", "Comment")), str(
                                                self.values[rowNo]["firstComment"]), value)
                                            self.changedValueNumber += 1
                                        if self.isChangeableItem(rowNo, "firstLyrics"):
                                            value = str(self.item(rowNo, 10).text())
                                            tagger.setFirstLyrics(value)
                                            Records.add(str(translate("MusicTable", "Lyrics")),
                                                        str(self.values[rowNo]["firstLyrics"]),
                                                        value)
                                            self.changedValueNumber += 1
                                        tagger.update()
                                    except:
                                        Dialogs.showError(translate("MusicTable", "Tags Cannot Changed"),
                                                          str(translate("MusicTable",
                                                                        "\"%s\" : cannot be changed tags.")
                                                          ) % Organizer.getLink(newFilePath))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        return True
Exemplo n.º 45
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(translate("Details", "File Is Not Supported"),
                                           str(translate("Details",
                                                         "\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
                                               str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(translate("Details", "Directories Is Not Supported"),
                                       str(translate("Details",
                                                     "\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
                                           str(_filePath)))
             else:
                 Dialogs.showError(translate("Details", "File Is Not Exist"),
                                   str(translate("Details",
                                                 "\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
                                       str(_filePath)))
     except:
         answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
                                     str(translate("Details",
                                                   "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
                                         str(_filePath)),
                                     translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Exemplo n.º 46
0
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
Exemplo n.º 47
0
    def refreshTable(self, _path):
        self.values = []
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(
            translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                directoriesAndValues = Operations.getDirectoriesAndValues(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(
                    translate("AmarokMusicTable",
                              "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if directoriesAndValues is not None:
                        allItemNumber = len(directoriesAndValues)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for dirPath, dirRow in directoriesAndValues.items():
                            isContinueThreadAction = uni.isContinueThreadAction(
                            )
                            if isContinueThreadAction:
                                try:
                                    if fu.isReadableFileOrDir(
                                            dirPath, False,
                                            True) and fu.isReadableFileOrDir(
                                                fu.joinPath(
                                                    dirPath, ".directory"),
                                                False, True):
                                        content = {}
                                        content["path"] = dirPath
                                        content[
                                            "pathOfParentDirectory"] = fu.getDirName(
                                                dirPath)
                                        content["baseName"] = fu.getBaseName(
                                            dirPath)
                                        currentCover, isCorrectedFileContent = fu.getIconFromDirectory(
                                            dirPath)
                                        if currentCover is None:
                                            currentCover = ""
                                        content["currentCover"] = (
                                            currentCover)
                                        content["sourceCover"] = (
                                            dirRow["coverPath"][0].replace(
                                                dirPath, "."))
                                        content["destinationCover"] = (
                                            "./" + Organizer.getIconName(
                                                dirRow["artist"][0],
                                                dirRow["album"][0],
                                                dirRow["genre"][0],
                                                dirRow["year"][0]))
                                        content["flagColor"] = {}
                                        if isCorrectedFileContent is False:
                                            content["flagColor"][
                                                "currentCover"] = 255, 163, 163
                                        if fu.isFile(content["sourceCover"]
                                                     ) is False:
                                            content["flagColor"][
                                                "sourceCover"] = 255, 163, 163
                                        self.values.append(content)

                                        newPathOfParentDirectory = Organizer.emend(
                                            self.values[rowNo]
                                            ["pathOfParentDirectory"],
                                            "directory")
                                        self.createItem(
                                            rowNo, "pathOfParentDirectory",
                                            newPathOfParentDirectory,
                                            self.values[rowNo]
                                            ["pathOfParentDirectory"])

                                        newBaseName = Organizer.emend(
                                            self.values[rowNo]["baseName"],
                                            "directory")
                                        self.createItem(
                                            rowNo, "pathOfParentDirectory",
                                            newBaseName,
                                            self.values[rowNo]["baseName"])

                                        newCurrentCover = fu.getShortPath(
                                            self.values[rowNo]["currentCover"],
                                            self.values[rowNo]["path"])
                                        itemCurrentCover = self.createItem(
                                            rowNo, "currentCover",
                                            newCurrentCover, newCurrentCover,
                                            True)
                                        self.setItemColor(
                                            itemCurrentCover, rowNo, 2,
                                            "currentCover")

                                        newSourceCover = fu.getShortPath(
                                            self.values[rowNo]["sourceCover"],
                                            self.values[rowNo]["path"])
                                        itemSourceCover = self.createItem(
                                            rowNo, "sourceCover",
                                            newSourceCover,
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["currentCover"],
                                                self.values[rowNo]["path"]))
                                        self.setItemColor(
                                            itemSourceCover, rowNo, 3,
                                            "sourceCover")

                                        newDestinationCover = Organizer.emend(
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["destinationCover"],
                                                self.values[rowNo]["path"]),
                                            "file")
                                        itemDestinationCover = self.createItem(
                                            rowNo, "destinationCover",
                                            newDestinationCover,
                                            fu.getShortPath(
                                                self.values[rowNo]
                                                ["currentCover"],
                                                self.values[rowNo]["path"]))
                                        self.setItemColor(
                                            itemDestinationCover, rowNo, 4,
                                            "destinationCover")
                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(
                                translate("Tables", "Generating Table..."),
                                rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(
            self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 48
0
 def copyPath(self):
     try:
         _path = self.checkSource(str(QuickMakeParameters[1]), "fileAndDirectory", False)
         if _path is not None:
             MApplication.clipboard().setText(str(_path))
             Dialogs.show(translate("QuickMake", "Copied To Clipboard"),
                          str(translate("QuickMake", "\"%s\" copied to clipboard.")) % Organizer.getLink(_path))
         self.close()
     except:
         ReportBug.ReportBug()
Exemplo n.º 49
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(
                                 _path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(
                             _path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(
                             translate("Details", "File Is Not Supported"),
                             str(
                                 translate(
                                     "Details",
                                     "\"%s\" couldn't opened. This file is not supported."
                                 )) % Organizer.getLink(str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(
                         translate("Details",
                                   "Directories Is Not Supported"),
                         str(
                             translate(
                                 "Details",
                                 "\"%s\" couldn't opened. Directories is not supported to show details."
                             )) % Organizer.getLink(str(_filePath)))
             else:
                 Dialogs.showError(
                     translate("Details", "File Is Not Exist"),
                     str(
                         translate(
                             "Details",
                             "\"%s\" couldn't opened. This file is not exist."
                         )) % Organizer.getLink(str(_filePath)))
     except:
         answer = Dialogs.askSpecial(
             translate("Details", "File Couldn't Opened"),
             str(
                 translate(
                     "Details",
                     "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us."
                 )) % Organizer.getLink(str(_filePath)),
             translate("QuickMake", "Report This Bug"),
             translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Exemplo n.º 50
0
    def refreshTable(self, _path):
        self.values = []
        self.setColumnWidth(6, 70)
        self.setColumnWidth(7, 40)
        uni.startThreadAction()
        import Amarok

        Dialogs.showState(
            translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
        if Amarok.checkAmarok():
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                from Amarok import Operations

                musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
                    uni.MySettings[self.amarokFilterKeyName])
                Dialogs.showState(
                    translate("AmarokMusicTable",
                              "Values Are Being Processed"), 1, 1)
                isContinueThreadAction = uni.isContinueThreadAction()
                if isContinueThreadAction:
                    if musicFileValuesWithNames is not None:
                        allItemNumber = len(musicFileValuesWithNames)
                        self.setRowCount(allItemNumber)
                        rowNo = 0
                        for musicFileRow in musicFileValuesWithNames:
                            isContinueThreadAction = uni.isContinueThreadAction(
                            )
                            if isContinueThreadAction:
                                try:
                                    if (fu.isFile(musicFileRow["filePath"])
                                            and fu.isReadableFileOrDir(
                                                musicFileRow["filePath"],
                                                False, True)):
                                        details = fu.getDetails(
                                            musicFileRow["filePath"])
                                        content = {}
                                        if Amarok.getSelectedTagSourseType(
                                                "AmarokMusicTable"
                                        ) == "Amarok (Smart)":
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content["artist"] = musicFileRow[
                                                "artist"]
                                            content["title"] = musicFileRow[
                                                "title"]
                                            content["album"] = musicFileRow[
                                                "album"]
                                            content[
                                                "albumArtist"] = musicFileRow[
                                                    "albumArtist"]
                                            content["trackNum"] = musicFileRow[
                                                "trackNumber"]
                                            content["year"] = musicFileRow[
                                                "year"]
                                            content["genre"] = musicFileRow[
                                                "genre"]
                                            content[
                                                "firstComment"] = musicFileRow[
                                                    "comment"]
                                            content[
                                                "firstLyrics"] = musicFileRow[
                                                    "lyrics"]
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(
                                                    musicFileRow["filePath"])
                                            except:
                                                if tagger.isSupportInfo:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                            else:
                                                if content["artist"].strip(
                                                ) == "":
                                                    content[
                                                        "artist"] = tagger.getArtist(
                                                        )
                                                if content["title"].strip(
                                                ) == "":
                                                    content[
                                                        "title"] = tagger.getTitle(
                                                        )
                                                if content["album"].strip(
                                                ) == "":
                                                    content[
                                                        "album"] = tagger.getAlbum(
                                                        )
                                                if content[
                                                        "albumArtist"].strip(
                                                        ) == "":
                                                    content[
                                                        "albumArtist"] = tagger.getAlbumArtist(
                                                        )
                                                if str(content["trackNum"]
                                                       ).strip() == "":
                                                    content[
                                                        "trackNum"] = tagger.getTrackNum(
                                                        )
                                                if str(content["year"]).strip(
                                                ) == "":
                                                    content[
                                                        "year"] = tagger.getYear(
                                                        )
                                                if content["genre"].strip(
                                                ) == "":
                                                    content[
                                                        "genre"] = tagger.getGenre(
                                                        )
                                                if content[
                                                        "firstComment"].strip(
                                                        ) == "":
                                                    content[
                                                        "firstComment"] = tagger.getFirstComment(
                                                        )
                                                if content[
                                                        "firstLyrics"].strip(
                                                        ) == "":
                                                    content[
                                                        "firstLyrics"] = tagger.getFirstLyrics(
                                                        )
                                                if tagger.isSupportInfo:
                                                    content[
                                                        "length"] = tagger.getLength(
                                                        )
                                                    content[
                                                        "bitrate"] = tagger.getBitrate(
                                                        )
                                                    content[
                                                        "sampleRate"] = tagger.getSampleRate(
                                                        )
                                                    content[
                                                        "mode"] = tagger.getMode(
                                                        )
                                        elif Amarok.getSelectedTagSourseType(
                                                "AmarokMusicTable"
                                        ) == "Only Amarok":
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content["artist"] = musicFileRow[
                                                "artist"]
                                            content["title"] = musicFileRow[
                                                "title"]
                                            content["album"] = musicFileRow[
                                                "album"]
                                            content[
                                                "albumArtist"] = musicFileRow[
                                                    "albumArtist"]
                                            content["trackNum"] = musicFileRow[
                                                "trackNumber"]
                                            content["year"] = musicFileRow[
                                                "year"]
                                            content["genre"] = musicFileRow[
                                                "genre"]
                                            content[
                                                "firstComment"] = musicFileRow[
                                                    "comment"]
                                            content[
                                                "firstLyrics"] = musicFileRow[
                                                    "lyrics"]
                                            tagger = Taggers.getTagger()
                                            if tagger.isSupportInfo:
                                                try:
                                                    tagger.loadFile(
                                                        musicFileRow[
                                                            "filePath"])
                                                except:
                                                    content["length"] = ""
                                                    content["bitrate"] = ""
                                                    content["sampleRate"] = ""
                                                    content["mode"] = ""
                                                else:
                                                    content[
                                                        "length"] = tagger.getLength(
                                                        )
                                                    content[
                                                        "bitrate"] = tagger.getBitrate(
                                                        )
                                                    content[
                                                        "sampleRate"] = tagger.getSampleRate(
                                                        )
                                                    content[
                                                        "mode"] = tagger.getMode(
                                                        )
                                        else:
                                            tagger = Taggers.getTagger()
                                            try:
                                                tagger.loadFile(
                                                    musicFileRow["filePath"])
                                            except:
                                                Dialogs.showError(
                                                    translate(
                                                        "FileUtils/Musics",
                                                        "Incorrect Tag"),
                                                    str(
                                                        translate(
                                                            "FileUtils/Musics",
                                                            "\"%s\" : this file has the incorrect tag so can't read tags."
                                                        )) % Organizer.getLink(
                                                            musicFileRow[
                                                                "filePath"]))
                                            content["path"] = musicFileRow[
                                                "filePath"]
                                            content[
                                                "baseNameOfDirectory"] = fu.getBaseName(
                                                    fu.getDirName(musicFileRow[
                                                        "filePath"]))
                                            content[
                                                "baseName"] = fu.getBaseName(
                                                    musicFileRow["filePath"])
                                            content[
                                                "artist"] = tagger.getArtist()
                                            content["title"] = tagger.getTitle(
                                            )
                                            content["album"] = tagger.getAlbum(
                                            )
                                            content[
                                                "albumArtist"] = tagger.getAlbumArtist(
                                                )
                                            content[
                                                "trackNum"] = tagger.getTrackNum(
                                                )
                                            content["year"] = tagger.getYear()
                                            content["genre"] = tagger.getGenre(
                                            )
                                            content[
                                                "firstComment"] = tagger.getFirstComment(
                                                )
                                            content[
                                                "firstLyrics"] = tagger.getFirstLyrics(
                                                )
                                            if tagger.isSupportInfo:
                                                content[
                                                    "length"] = tagger.getLength(
                                                    )
                                                content[
                                                    "bitrate"] = tagger.getBitrate(
                                                    )
                                                content[
                                                    "sampleRate"] = tagger.getSampleRate(
                                                    )
                                                content[
                                                    "mode"] = tagger.getMode()
                                        content["size"] = details[stat.ST_SIZE]
                                        content["lastAccessed"] = details[
                                            stat.ST_ATIME]
                                        content["lastModified"] = details[
                                            stat.ST_MTIME]
                                        content[
                                            "lastMetadataChanged"] = details[
                                                stat.ST_CTIME]
                                        self.values.append(content)
                                        newBaseNameOfDirectory = Organizer.emend(
                                            self.values[rowNo]
                                            ["baseNameOfDirectory"],
                                            "directory")
                                        self.createItem(
                                            rowNo, "baseNameOfDirectory",
                                            newBaseNameOfDirectory,
                                            self.values[rowNo]
                                            ["baseNameOfDirectory"])

                                        newBaseName = Organizer.emend(
                                            self.values[rowNo]["baseName"],
                                            "file")
                                        self.createItem(
                                            rowNo, "baseName", newBaseName,
                                            self.values[rowNo]["baseName"])

                                        newArtist = Organizer.emend(
                                            self.values[rowNo]["artist"])
                                        self.createItem(
                                            rowNo, "artist", newArtist,
                                            self.values[rowNo]["artist"])

                                        newTitle = Organizer.emend(
                                            self.values[rowNo]["title"])
                                        self.createItem(
                                            rowNo, "title", newTitle,
                                            self.values[rowNo]["title"])

                                        newAlbum = Organizer.emend(
                                            self.values[rowNo]["album"])
                                        self.createItem(
                                            rowNo, "album", newAlbum,
                                            self.values[rowNo]["album"])

                                        newAlbumArtist = Organizer.emend(
                                            self.values[rowNo]["albumArtist"])
                                        self.createItem(
                                            rowNo, "albumArtist",
                                            newAlbumArtist,
                                            self.values[rowNo]["albumArtist"])

                                        newTrackNum = str(
                                            self.values[rowNo]["trackNum"])
                                        self.createItem(
                                            rowNo, "trackNum", newTrackNum,
                                            self.values[rowNo]["trackNum"])

                                        newYear = Organizer.emend(
                                            self.values[rowNo]["year"])
                                        self.createItem(
                                            rowNo, "year", newYear,
                                            self.values[rowNo]["year"])

                                        newGenre = Organizer.emend(
                                            self.values[rowNo]["genre"])
                                        self.createItem(
                                            rowNo, "genre", newGenre,
                                            self.values[rowNo]["genre"])

                                        newFirstComment = Organizer.emend(
                                            self.values[rowNo]["firstComment"])
                                        self.createItem(
                                            rowNo, "firstComment",
                                            newFirstComment,
                                            self.values[rowNo]["firstComment"])

                                        newFirstLyrics = Organizer.emend(
                                            self.values[rowNo]["firstLyrics"])
                                        self.createItem(
                                            rowNo, "firstLyrics",
                                            newFirstLyrics,
                                            self.values[rowNo]["firstLyrics"])

                                        if Taggers.getTagger().isSupportInfo:
                                            self.createItem(
                                                rowNo, "length",
                                                content["length"])
                                            self.createItem(
                                                rowNo, "bitrate",
                                                content["bitrate"])
                                            self.createItem(
                                                rowNo, "sampleRate",
                                                content["sampleRate"])
                                            self.createItem(
                                                rowNo, "mode", content["mode"])

                                        self.createItem(
                                            rowNo, "size",
                                            Organizer.getCorrectedFileSize(
                                                content["size"]))

                                        self.createItem(
                                            rowNo, "lastAccessed",
                                            Organizer.getCorrectedTime(
                                                content["lastAccessed"]))

                                        self.createItem(
                                            rowNo, "lastModified",
                                            Organizer.getCorrectedTime(
                                                content["lastModified"]))

                                        self.createItem(
                                            rowNo, "lastMetadataChanged",
                                            Organizer.getCorrectedTime(
                                                content["lastMetadataChanged"])
                                        )

                                        rowNo += 1
                                    else:
                                        allItemNumber -= 1
                                except:
                                    ReportBug.ReportBug()
                                    allItemNumber -= 1
                            else:
                                allItemNumber = rowNo
                            Dialogs.showState(
                                translate("Tables", "Generating Table..."),
                                rowNo, allItemNumber, True)
                            if isContinueThreadAction is False:
                                break
        uni.finishThreadAction()
        self.setRowCount(len(
            self.values))  # In case of Non Readable Files and Canceled process
Exemplo n.º 51
0
 def apply(self):
     self.checkCompleters()
     self.reFillCompleters()
     getMainTable().createHistoryPoint()
     getMainTable().isAskShowHiddenColumn = True
     selectedColumnKey = self.columns.currentData()
     if selectedColumnKey == "all":
         columnKeys = getMainTable().getWritableColumnKeys()
     else:
         columnKeys = [selectedColumnKey]
     for columnKey in columnKeys:
         columnNo = getMainTable().getColumnNoFromKey(columnKey)
         if getMainTable().checkReadOnlyColumn(columnKey) is False:
             continue
         if getMainTable().checkHiddenColumn(columnKey, False) is False:
             continue
         for rowNo in range(getMainTable().rowCount()):
             if getMainTable().isChangeableItem(rowNo, columnKey):
                 newString = str(getMainTable().item(rowNo,
                                                     columnNo).text())
                 newString = uni.trDecode(newString, "utf-8")
                 informationSectionX = self.specialTools.cbInformationSectionX.value(
                 )
                 informationSectionY = self.specialTools.cbInformationSectionY.value(
                 )
                 isCaseInsensitive = self.cckbCaseInsensitive.isChecked()
                 oldString = str(self.leClear.text())
                 cbClearType = self.cbClearType.currentText()
                 isRegExp = self.cckbRegExp.isChecked()
                 myString = None
                 if self.specialTools.cbInformationSection.currentIndex(
                 ) == 0:
                     myString = Organizer.clear(cbClearType, newString,
                                                oldString,
                                                isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 1:
                     myString = Organizer.clear(
                         cbClearType, newString[:informationSectionX],
                         oldString, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 2:
                     myString = newString[:informationSectionX]
                     myString += Organizer.clear(
                         cbClearType, newString[informationSectionX:],
                         oldString, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 3:
                     myString = Organizer.clear(
                         cbClearType, newString[:-informationSectionX],
                         oldString, isCaseInsensitive, isRegExp)
                     myString += newString[-informationSectionX:]
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 4:
                     myString = newString[:-informationSectionX]
                     myString += Organizer.clear(
                         cbClearType, newString[-informationSectionX:],
                         oldString, isCaseInsensitive, isRegExp)
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 5:
                     myString = newString[:informationSectionX]
                     myString += Organizer.clear(
                         cbClearType,
                         newString[informationSectionX:informationSectionY],
                         oldString, isCaseInsensitive, isRegExp)
                     myString += newString[informationSectionY:]
                 elif self.specialTools.cbInformationSection.currentIndex(
                 ) == 6:
                     myString = Organizer.clear(
                         cbClearType, newString[:informationSectionX],
                         oldString, isCaseInsensitive, isRegExp)
                     myString += newString[
                         informationSectionX:informationSectionY]
                     myString += Organizer.clear(
                         cbClearType, newString[informationSectionY:],
                         oldString, isCaseInsensitive, isRegExp)
                 getMainTable().item(rowNo, columnNo).setText(str(myString))
Exemplo n.º 52
0
    def writeContents(self):
        self.changedValueNumber = 0
        oldAndNewPathValues = []
        changingTags = []
        isNewDirectoriesSame = True
        isMovedToNewDirectory = False
        currentDirectoryPath = ""
        newDirectoryPath = ""
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok

            if Amarok.checkAmarok(True, False) is False:
                return False
        uni.startThreadAction()
        allItemNumber = len(self.values)
        Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
        for rowNo in range(self.rowCount()):
            isContinueThreadAction = uni.isContinueThreadAction()
            if isContinueThreadAction:
                try:
                    changingTag = {"path": self.values[rowNo]["path"]}
                    if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
                        if self.isRowHidden(rowNo):
                            fu.removeFileOrDir(self.values[rowNo]["path"])
                            self.changedValueNumber += 1
                        else:
                            baseNameOfDirectory = str(
                                self.values[rowNo]["baseNameOfDirectory"])
                            baseName = str(self.values[rowNo]["baseName"])
                            tagger = Taggers.getTagger()
                            tagger.loadFileForWrite(self.values[rowNo]["path"])
                            isCheckLike = (tagger.isNeedUpdate or
                                           (uni.isActiveAmarok and
                                            uni.getBoolValue("isMusicTableValuesChangeInAmarokDB")))
                            if self.isChangeableItem(rowNo, "artist", self.values[rowNo]["artist"], True, isCheckLike):
                                value = str(self.item(rowNo, 2).text())
                                tagger.setArtist(value)
                                changingTag["artist"] = value
                                Records.add(str(translate("MusicTable", "Artist")),
                                            str(self.values[rowNo]["artist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "title", self.values[rowNo]["title"], True, isCheckLike):
                                value = str(self.item(rowNo, 3).text())
                                tagger.setTitle(value)
                                changingTag["title"] = value
                                Records.add(str(translate("MusicTable", "Title")),
                                            str(self.values[rowNo]["title"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "album", self.values[rowNo]["album"], True, isCheckLike):
                                value = str(self.item(rowNo, 4).text())
                                tagger.setAlbum(value)
                                changingTag["album"] = value
                                Records.add(str(translate("MusicTable", "Album")),
                                            str(self.values[rowNo]["album"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "albumArtist", self.values[rowNo]["albumArtist"], True,
                                                     isCheckLike):
                                value = str(self.item(rowNo, 5).text())
                                tagger.setAlbumArtist(value)
                                changingTag["albumArtist"] = value
                                Records.add(str(translate("MusicTable", "Album Artist")),
                                            str(self.values[rowNo]["albumArtist"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "trackNum", self.values[rowNo]["trackNum"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 6).text())
                                tagger.setTrackNum(value)
                                changingTag["trackNum"] = value
                                Records.add(str(translate("MusicTable", "Track No")),
                                            str(self.values[rowNo]["trackNum"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "year", self.values[rowNo]["year"], True, isCheckLike):
                                value = str(self.item(rowNo, 7).text())
                                tagger.setDate(value)
                                changingTag["year"] = value
                                Records.add(str(translate("MusicTable", "Year")),
                                            str(self.values[rowNo]["year"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "genre", self.values[rowNo]["genre"], True, isCheckLike):
                                value = str(self.item(rowNo, 8).text())
                                tagger.setGenre(value)
                                changingTag["genre"] = value
                                Records.add(str(translate("MusicTable", "Genre")),
                                            str(self.values[rowNo]["genre"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstComment", self.values[rowNo]["firstComment"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 9).text())
                                tagger.setFirstComment(value)
                                changingTag["firstComment"] = value
                                Records.add(str(translate("MusicTable", "Comment")),
                                            str(self.values[rowNo]["firstComment"]), value)
                                self.changedValueNumber += 1
                            if self.isChangeableItem(rowNo, "firstLyrics", self.values[rowNo]["firstLyrics"],
                                                     True, isCheckLike):
                                value = str(self.item(rowNo, 10).text())
                                tagger.setFirstLyrics(value)
                                changingTag["firstLyrics"] = value
                                Records.add(str(translate("MusicTable", "Lyrics")),
                                            str(self.values[rowNo]["firstLyrics"]), value)
                                self.changedValueNumber += 1
                            if len(changingTag) > 1:
                                changingTags.append(changingTag)
                            tagger.update()
                            if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
                                baseNameOfDirectory = str(self.item(rowNo, 0).text())
                                self.changedValueNumber += 1
                                isMovedToNewDirectory = True
                                currentDirectoryPath = fu.getDirName(
                                    self.values[rowNo]["path"])
                                newDirectoryPath = fu.joinPath(
                                    fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                    baseNameOfDirectory)
                                self.setNewDirectory(newDirectoryPath)
                                if rowNo > 0:
                                    if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                        isNewDirectoriesSame = False
                            if self.isChangeableItem(rowNo, "baseName", baseName, False):
                                baseName = str(self.item(rowNo, 1).text())
                                self.changedValueNumber += 1
                            newFilePath = fu.joinPath(
                                fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                baseNameOfDirectory, baseName)
                            oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
                            newFilePath = fu.getRealPath(newFilePath)
                            if oldFilePath != newFilePath:
                                oldAndNewPaths = {}
                                oldAndNewPaths["oldPath"] = oldFilePath
                                oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
                                if oldFilePath != oldAndNewPaths["newPath"]:
                                    oldAndNewPathValues.append(oldAndNewPaths)
                                    oldDirName = fu.getDirName(oldFilePath)
                                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                                        fu.checkEmptyDirectories(oldDirName, True, True,
                                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                except:
                    ReportBug.ReportBug()
            else:
                allItemNumber = rowNo + 1
            Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags And Informations"), rowNo + 1, allItemNumber, True)
            if isContinueThreadAction is False:
                break
        uni.finishThreadAction()
        if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
            otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
            if len(otherFileNames) > 0:
                answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                     str(translate("FileUtils/Musics",
                                                   "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                         Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
                if answer == Dialogs.Yes:
                    uni.startThreadAction()
                    allItemNumber = len(otherFileNames)
                    for rowNo, fileName in enumerate(otherFileNames):
                        isContinueThreadAction = uni.isContinueThreadAction()
                        if isContinueThreadAction:
                            try:
                                oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                                newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                                if oldFilePath != newFilePath:
                                    oldAndNewPaths = {}
                                    oldAndNewPaths["oldPath"] = oldFilePath
                                    oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                                fu.getObjectType(oldFilePath))
                                    if oldFilePath != oldAndNewPaths["newPath"]:
                                        oldAndNewPathValues.append(oldAndNewPaths)
                            except:
                                ReportBug.ReportBug()
                        else:
                            allItemNumber = rowNo + 1
                        Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                          rowNo + 1, allItemNumber, True)
                        if isContinueThreadAction is False:
                            break
                    uni.finishThreadAction()
                    if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                        fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                                 uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                    if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                            uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                        fu.checkIcon(newDirectoryPath)
        if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
            import Amarok
            from Amarok import Operations

            Operations.changeTags(changingTags)
            if len(oldAndNewPathValues) > 0:
                Operations.changePaths(oldAndNewPathValues, "file")
        return True