Implemented batch rename in GUI

git-svn-id: http://comictagger.googlecode.com/svn/trunk@312 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville 2013-01-19 03:12:25 +00:00
parent 2bf9b9ed7c
commit c3d5d44788
5 changed files with 85 additions and 56 deletions

View File

@ -1,3 +1,3 @@
# This file should contan only these comments, and the line below.
# Used by packaging makefiles and app
version="0.9.5-beta"
version="0.9.6-beta-pre"

View File

@ -88,10 +88,10 @@ class FileSelectionList(QWidget):
self.modifiedFlag = modified
def selectAll( self ):
self.twList.setRangeSelected( QTableWidgetSelectionRange ( 0, 0, self.twList.rowCount()-1, 1 ), True )
self.twList.setRangeSelected( QTableWidgetSelectionRange ( 0, 0, self.twList.rowCount()-1, 3 ), True )
def deselectAll( self ):
self.twList.setRangeSelected( QTableWidgetSelectionRange ( 0, 0, self.twList.rowCount()-1, 1 ), False )
self.twList.setRangeSelected( QTableWidgetSelectionRange ( 0, 0, self.twList.rowCount()-1, 3 ), False )
def removeSelection( self ):
row_list = []
@ -110,12 +110,12 @@ class FileSelectionList(QWidget):
row_list.sort()
row_list.reverse()
self.twList.itemSelectionChanged.disconnect( self.itemSelectionChangedCB )
self.twList.currentItemChanged.disconnect( self.currentItemChangedCB )
for i in row_list:
self.twList.removeRow(i)
self.twList.itemSelectionChanged.connect( self.itemSelectionChangedCB )
self.twList.currentItemChanged.connect( self.currentItemChangedCB )
if self.twList.rowCount() > 0:
self.twList.selectRow(0)
@ -190,8 +190,8 @@ class FileSelectionList(QWidget):
filename_item = QTableWidgetItem()
folder_item = QTableWidgetItem()
cix_item = QTableWidgetItem()
cbi_item = QTableWidgetItem()
cix_item = FileTableWidgetItem()
cbi_item = FileTableWidgetItem()
filename_item.setFlags(Qt.ItemIsSelectable| Qt.ItemIsEnabled)
filename_item.setData( Qt.UserRole , fi )
@ -246,9 +246,26 @@ class FileSelectionList(QWidget):
fi.ca.readCIX()
fi.ca.hasCBI()
def getSelectedArchiveList( self ):
ca_list = []
for r in range( self.twList.rowCount() ):
item = self.twList.item(r, 0)
if self.twList.isItemSelected(item):
fi = item.data( Qt.UserRole ).toPyObject()
ca_list.append(fi.ca)
return ca_list
def updateCurrentRow( self ):
self.updateRow( self.twList.currentRow() )
def updateSelectedRows( self ):
self.twList.setSortingEnabled(False)
for r in range( self.twList.rowCount() ):
item = self.twList.item(r, 0)
if self.twList.isItemSelected(item):
self.updateRow( r )
self.twList.setSortingEnabled(True)
def currentItemChangedCB( self, curr, prev ):

View File

@ -28,29 +28,42 @@ import utils
class RenameWindow(QtGui.QDialog):
def __init__( self, parent, comic_archive, metadata, settings ):
def __init__( self, parent, comic_archive_list, data_style, settings ):
super(RenameWindow, self).__init__(parent)
uic.loadUi(os.path.join(ComicTaggerSettings.baseDir(), 'renamewindow.ui' ), self)
self.settings = settings
self.metadata = metadata
self.comic_archive = comic_archive
self.new_name = None
self.comic_archive_list = comic_archive_list
self.data_style = data_style
self.btnSettings.clicked.connect( self.modifySettings )
self.configRenamer()
self.doPreview()
def configRenamer( self ):
self.renamer = FileRenamer( self.metadata )
self.renamer = FileRenamer( None )
self.renamer.setTemplate( self.settings.rename_template )
self.renamer.setIssueZeroPadding( self.settings.rename_issue_number_padding )
self.renamer.setSmartCleanup( self.settings.rename_use_smart_string_cleanup )
def doPreview( self ):
self.new_name = self.renamer.determineName( self.comic_archive.path )
preview = u"\"{0}\" ==> \"{1}\"".format( self.comic_archive.path, self.new_name )
preview = ""
self.rename_list = []
for ca in self.comic_archive_list:
md = ca.readMetadata(self.data_style)
if md.isEmpty:
md = ca.metadataFromFilename()
self.renamer.setMetadata( md )
new_name = self.renamer.determineName( ca.path )
preview += u"\"{0}\" ==> \"{1}\"\n".format( ca.path, new_name )
dict_item = dict()
dict_item['archive'] = ca
dict_item['new_name'] = new_name
self.rename_list.append( dict_item)
self.textEdit.setPlainText( preview )
def modifySettings( self ):
@ -64,16 +77,20 @@ class RenameWindow(QtGui.QDialog):
def accept( self ):
QtGui.QDialog.accept(self)
if self.new_name == os.path.basename( self.comic_archive.path ):
#print msg_hdr + "Filename is already good!"
return
folder = os.path.dirname( os.path.abspath( self.comic_archive.path ) )
new_abs_path = utils.unique_file( os.path.join( folder, self.new_name ) )
os.rename( self.comic_archive.path, new_abs_path )
self.new_name = new_abs_path
self.comic_archive.rename( new_abs_path )
for item in self.rename_list:
if item['new_name'] == os.path.basename( item['archive'].path ):
print item['new_name'] , "Filename is already good!"
break
if not item['archive'].isWritable():
break
folder = os.path.dirname( os.path.abspath( item['archive'].path ) )
new_abs_path = utils.unique_file( os.path.join( folder, item['new_name'] ) )
os.rename( item['archive'].path, new_abs_path )
item['archive'].rename( new_abs_path )

View File

@ -1368,12 +1368,16 @@ class TaggerWindow( QtGui.QMainWindow):
def renameArchive(self):
if self.comic_archive is not None:
self.formToMetadata()
dlg = RenameWindow( self, self.comic_archive, self.metadata, self.settings )
dlg.setModal( True )
if dlg.exec_():
self.fileSelectionList.updateCurrentRow()
self.loadArchive( self.comic_archive )
if self.dirtyFlagVerification( "File Rename",
"If rename files now, unsave data in the form will be lost. Are you sure?"):
#get list of archives from filelist
ca_list = self.fileSelectionList.getSelectedArchiveList()
dlg = RenameWindow( self, ca_list, self.load_data_style, self.settings )
dlg.setModal( True )
if dlg.exec_():
self.fileSelectionList.updateSelectedRows()
self.loadArchive( self.comic_archive )
def fileListSelectionChanged( self, qvarFI ):

View File

@ -5,38 +5,43 @@ Features
Multi-file:
Batch Functions:
Delete
Auto-Select
Start/Options Dialog
Progress Dialog - maybe reuse
Interactive dialog at end
Summary Dialog
Rename
Start dialog with preview
maybe table with checkboxes?
Copy Block
Verify overwrites
Delete
Rename
maybe make preview a table with checkboxes?
Export to CBZ?
Filelist:
Add archive type column
add read-only column
-----------------------------------------------------
Bugs
-----------------------------------------------------
Ultimate Spider-Man files can't be read
---Maybe the foldername in the archive?
-----------------------------------------------------
Big Future Features
-----------------------------------------------------
GUI to handle mutliple files or folders
Scrape alternate Covers from ComicVine issue pages
GCD scraper or DB reader
pyComicMetaThis CBI features
Auto search:
Searching w/o issue #
-----------------------------------------------------
Small(er) Future Feature
-----------------------------------------------------
@ -55,7 +60,6 @@ Archive function to detect tag blocks out of sync
Settings
Add setting to dis-allow writing CBI to RAR
Overwrite or overlay
Google App engine to store hashes
Content Hashes, Image hashes, who knows?
@ -86,17 +90,4 @@ Release Process
----------------------------------------------
COMIC RACK Questions
Missing from XML as enterable in ComicRack:
Main Character or Team
Review
User Rating
Some that seem library only:
"Series Complete"
Tags
Proposed Values
Community Rating