Implemented batch tag remove

more multi-file/batch enhancements

git-svn-id: http://comictagger.googlecode.com/svn/trunk@314 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville 2013-01-19 06:15:33 +00:00
parent c3d5d44788
commit d58e033689
7 changed files with 85 additions and 31 deletions

View File

@ -75,15 +75,23 @@ class FileSelectionList(QWidget):
self.modifiedFlag = False
selectAllAction = QAction("Select All", self)
invertSelectionAction = QAction("Invert Selection", self)
removeAction = QAction("Remove Selected Items", self)
self.separator = QAction("",self)
self.separator.setSeparator(True)
selectAllAction.setShortcut( 'Ctrl+A' )
removeAction.setShortcut( 'Ctrl+X' )
selectAllAction.triggered.connect(self.selectAll)
removeAction.triggered.connect(self.removeSelection)
self.addAction(self.separator)
self.addAction(selectAllAction)
self.addAction(removeAction)
self.addAction(removeAction)
def addAppAction( self, action ):
self.insertAction( self.separator , action )
def setModifiedFlag( self, modified ):
self.modifiedFlag = modified

View File

@ -25,6 +25,9 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="textElideMode">
<enum>Qt::ElideMiddle</enum>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>61</number>
</attribute>

View File

@ -78,14 +78,24 @@ class RenameWindow(QtGui.QDialog):
def accept( self ):
QtGui.QDialog.accept(self)
for item in self.rename_list:
progdialog = QtGui.QProgressDialog("", "Cancel", 0, len(self.rename_list), self)
progdialog.setWindowTitle( "Renaming Archives" )
progdialog.setWindowModality(QtCore.Qt.WindowModal)
for idx,item in enumerate(self.rename_list):
QtCore.QCoreApplication.processEvents()
if progdialog.wasCanceled():
break
idx += 1
progdialog.setValue(idx)
if item['new_name'] == os.path.basename( item['archive'].path ):
print item['new_name'] , "Filename is already good!"
break
continue
if not item['archive'].isWritable():
break
continue
folder = os.path.dirname( os.path.abspath( item['archive'].path ) )
new_abs_path = utils.unique_file( os.path.join( folder, item['new_name'] ) )
@ -93,4 +103,5 @@ class RenameWindow(QtGui.QDialog):
os.rename( item['archive'].path, new_abs_path )
item['archive'].rename( new_abs_path )
progdialog.close()

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<height>210</height>
<width>813</width>
<height>261</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -164,6 +164,10 @@ class TaggerWindow( QtGui.QMainWindow):
self.raise_()
QtCore.QCoreApplication.processEvents()
self.fileSelectionList.addAppAction( self.actionAutoSearch )
self.fileSelectionList.addAppAction( self.actionRename )
self.fileSelectionList.addAppAction( self.actionRemoveAuto )
if len(file_list) != 0:
self.fileSelectionList.addPathList( file_list )
@ -231,7 +235,7 @@ class TaggerWindow( QtGui.QMainWindow):
self.actionLoad.setStatusTip( 'Load comic archive' )
self.actionLoad.triggered.connect( self.selectFile )
#self.actionLoadFolder.setShortcut( 'Ctrl+F' )
self.actionLoadFolder.setShortcut( 'Ctrl+Shift+O' )
self.actionLoadFolder.setStatusTip( 'Load folder with comic archives' )
self.actionLoadFolder.triggered.connect( self.selectFolder )
@ -275,7 +279,7 @@ class TaggerWindow( QtGui.QMainWindow):
self.actionSearchOnline.setStatusTip( 'Search online for tags' )
self.actionSearchOnline.triggered.connect( self.queryOnline )
self.actionAutoSearch.setShortcut( 'Ctrl+A' )
self.actionAutoSearch.setShortcut( 'Ctrl+Shift+A' )
self.actionAutoSearch.triggered.connect( self.autoSelectSearch )
self.actionApplyCBLTransform.setShortcut( 'Ctrl+L' )
@ -436,9 +440,9 @@ class TaggerWindow( QtGui.QMainWindow):
def updateMenus( self ):
# First just disable all the questionable items
self.actionRemoveAuto.setEnabled( False )
self.actionRemoveCRTags.setEnabled( False )
self.actionRemoveCBLTags.setEnabled( False )
self.actionRemoveAuto.setEnabled( True )
self.actionRemoveCRTags.setEnabled( True )
self.actionRemoveCBLTags.setEnabled( True )
self.actionWrite_Tags.setEnabled( False )
self.actionRepackage.setEnabled(False)
self.actionViewRawCBLTags.setEnabled( False )
@ -1279,21 +1283,49 @@ class TaggerWindow( QtGui.QMainWindow):
def removeTags( self, style):
# remove the indicated tags from the archive
# ( keep the form and the current metadata object intact. )
if self.comic_archive is not None and self.comic_archive.hasMetadata( style ):
#ATB
ca_list = self.fileSelectionList.getSelectedArchiveList()
has_md_count = 0
for ca in ca_list:
if ca.hasMetadata( style ):
has_md_count += 1
if has_md_count != 0 and not self.dirtyFlagVerification( "Remove Tags",
"If remove tags now, unsaved data in the form will be lost. Are you sure?"):
return
if has_md_count != 0:
reply = QtGui.QMessageBox.question(self,
self.tr("Remove Tags"),
self.tr("Are you sure you wish to remove the " + MetaDataStyle.name[style] + " tags from this archive?"),
self.tr("Are you sure you wish to remove the {0} tags from {1} archive(s)?".format(MetaDataStyle.name[style], has_md_count)),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No )
if reply == QtGui.QMessageBox.Yes:
path = self.comic_archive.path
if not self.comic_archive.removeMetadata( style ):
QtGui.QMessageBox.warning(self, self.tr("Remove failed"), self.tr("The tag removal operation seemed to fail!"))
else:
self.updateInfoBox()
self.updateMenus()
self.fileSelectionList.updateCurrentRow()
progdialog = QtGui.QProgressDialog("", "Cancel", 0, has_md_count, self)
progdialog.setWindowTitle( "Removing Tags" )
progdialog.setWindowModality(QtCore.Qt.WindowModal)
prog_idx = 0
for ca in ca_list:
if ca.hasMetadata( style ):
QtCore.QCoreApplication.processEvents()
if progdialog.wasCanceled():
break
prog_idx += 1
progdialog.setValue(prog_idx)
if ca.hasMetadata( style ) and ca.isWritable():
if not ca.removeMetadata( style ):
if has_md_count == 1:
QtGui.QMessageBox.warning(self, self.tr("Remove failed"), self.tr("The tag removal operation seemed to fail!"))
else:
QtGui.QMessageBox.warning(self, self.tr("Remove failed"),
self.tr("The tag removal operation seemed to fail for {0} Operation aborted!".format(ca.path)))
break
progdialog.close()
self.fileSelectionList.updateSelectedRows()
self.updateInfoBox()
self.updateMenus()
def dirtyFlagVerification( self, title, desc):
if self.dirtyFlag:
@ -1369,7 +1401,7 @@ class TaggerWindow( QtGui.QMainWindow):
def renameArchive(self):
if self.comic_archive is not None:
if self.dirtyFlagVerification( "File Rename",
"If rename files now, unsave data in the form will be lost. Are you sure?"):
"If rename files now, unsaved 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 )

View File

@ -72,7 +72,7 @@
<item row="1" column="0">
<widget class="QLabel" name="saveStyleLabel">
<property name="text">
<string>Write Style</string>
<string>Modify Style</string>
</property>
</widget>
</item>
@ -1176,7 +1176,7 @@
<x>0</x>
<y>0</y>
<width>968</width>
<height>28</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuComicTagger">

View File

@ -5,15 +5,14 @@ Features
Multi-file:
Batch Functions:
Delete
Auto-Select
Batch Auto-Select
Start/Options Dialog
Progress Dialog - maybe reuse
Interactive dialog at end
Summary Dialog
Copy Block
Batch Tag Copy
Verify overwrites
Rename
@ -24,7 +23,8 @@ Multi-file:
Filelist:
Add archive type column
add read-only column
Better column sizing
Text display to cut out middle if too short?
-----------------------------------------------------
Bugs