More work on managing mutiple files in the GUI
git-svn-id: http://comictagger.googlecode.com/svn/trunk@310 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
parent
7a7adc1c3f
commit
cfca394bcb
@ -486,11 +486,8 @@ def main():
|
||||
splash.raise_()
|
||||
app.processEvents()
|
||||
|
||||
try:
|
||||
fname = None
|
||||
if opts.filename is not None:
|
||||
fname = opts.filename.decode(filename_encoding, 'replace')
|
||||
tagger_window = TaggerWindow( fname, settings )
|
||||
try:
|
||||
tagger_window = TaggerWindow( opts.file_list, settings )
|
||||
tagger_window.show()
|
||||
|
||||
if platform.system() != "Linux":
|
||||
|
@ -69,7 +69,6 @@ class FileSelectionList(QWidget):
|
||||
#self.twList = FileTableWidget( self )
|
||||
#gridlayout = QGridLayout( self )
|
||||
#gridlayout.addWidget( self.twList )
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
self.twList.itemSelectionChanged.connect( self.itemSelectionChangedCB )
|
||||
|
||||
@ -111,25 +110,6 @@ class FileSelectionList(QWidget):
|
||||
self.twList.selectRow(0)
|
||||
else:
|
||||
self.listCleared.emit()
|
||||
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
self.droppedFiles = None
|
||||
if event.mimeData().hasUrls():
|
||||
|
||||
# walk through the URL list and build a file list
|
||||
for url in event.mimeData().urls():
|
||||
if url.isValid() and url.scheme() == "file":
|
||||
if self.droppedFiles is None:
|
||||
self.droppedFiles = []
|
||||
self.droppedFiles.append(url.toLocalFile())
|
||||
|
||||
if self.droppedFiles is not None:
|
||||
event.accept()
|
||||
|
||||
def dropEvent(self, event):
|
||||
self.addPathList( self.droppedFiles)
|
||||
event.accept()
|
||||
|
||||
def addPathList( self, pathlist ):
|
||||
filelist = []
|
||||
@ -148,15 +128,21 @@ class FileSelectionList(QWidget):
|
||||
progdialog.setWindowTitle( "Adding Files" )
|
||||
progdialog.setWindowModality(Qt.WindowModal)
|
||||
|
||||
firstAdded = None
|
||||
self.twList.setSortingEnabled(False)
|
||||
for idx,f in enumerate(filelist):
|
||||
QCoreApplication.processEvents()
|
||||
if progdialog.wasCanceled():
|
||||
break
|
||||
progdialog.setValue(idx)
|
||||
self.addPathItem( f )
|
||||
|
||||
row = self.addPathItem( f )
|
||||
if firstAdded is None and row is not None:
|
||||
firstAdded = row
|
||||
|
||||
progdialog.close()
|
||||
if firstAdded is not None:
|
||||
self.twList.selectRow(firstAdded)
|
||||
|
||||
self.twList.setSortingEnabled(True)
|
||||
|
||||
#Maybe set a max size??
|
||||
@ -178,7 +164,7 @@ class FileSelectionList(QWidget):
|
||||
#print "processing", path
|
||||
|
||||
if self.isListDupe(path):
|
||||
return
|
||||
return None
|
||||
|
||||
ca = ComicArchive( path )
|
||||
if self.settings.rar_exe_path != "":
|
||||
@ -246,6 +232,7 @@ class FileSelectionList(QWidget):
|
||||
else:
|
||||
item.setData(Qt.UserRole, False)
|
||||
self.twList.setItem(row, 3, item)
|
||||
return row
|
||||
|
||||
def itemSelectionChangedCB( self ):
|
||||
idx = self.twList.currentRow()
|
||||
|
@ -82,16 +82,9 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
appName = "ComicTagger"
|
||||
version = ctversion.version
|
||||
|
||||
def __init__(self, filename, settings, parent = None):
|
||||
def __init__(self, file_list, settings, parent = None):
|
||||
super(TaggerWindow, self).__init__(parent)
|
||||
|
||||
# Set up a timer so the interpreter runs every so often
|
||||
# This helps catch and process SIGINT from console
|
||||
#self.timer = QtCore.QTimer()
|
||||
#self.timer.start(500)
|
||||
#self.timer.timeout.connect(lambda: None)
|
||||
#signal.signal(signal.SIGINT, self.sigint_handler)
|
||||
|
||||
uic.loadUi(os.path.join(ComicTaggerSettings.baseDir(), 'taggerwindow.ui' ), self)
|
||||
self.settings = settings
|
||||
|
||||
@ -143,6 +136,10 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
|
||||
#TODO set up an RE validator for issueNum that allows
|
||||
# for all sorts of wacky things
|
||||
|
||||
#make sure some editable comboboxes don't take drop actions
|
||||
self.cbFormat.lineEdit().setAcceptDrops(False)
|
||||
self.cbMaturityRating.lineEdit().setAcceptDrops(False)
|
||||
|
||||
# hook up the callbacks
|
||||
self.cbDataStyle.currentIndexChanged.connect(self.setDataStyle)
|
||||
@ -165,9 +162,9 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
self.raise_()
|
||||
QtCore.QCoreApplication.processEvents()
|
||||
|
||||
if filename is not None:
|
||||
self.openArchive( filename )
|
||||
|
||||
if len(file_list) != 0:
|
||||
self.fileSelectionList.addPathList( file_list )
|
||||
|
||||
if self.settings.show_disclaimer:
|
||||
checked = OptionalMessageDialog.msg( self, "Welcome!",
|
||||
"""
|
||||
@ -232,6 +229,10 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
self.actionLoad.setStatusTip( 'Load comic archive' )
|
||||
self.actionLoad.triggered.connect( self.selectFile )
|
||||
|
||||
#self.actionLoadFolder.setShortcut( 'Ctrl+F' )
|
||||
self.actionLoadFolder.setStatusTip( 'Load folder with comic archives' )
|
||||
self.actionLoadFolder.triggered.connect( self.selectFolder )
|
||||
|
||||
self.actionWrite_Tags.setShortcut( 'Ctrl+S' )
|
||||
self.actionWrite_Tags.setStatusTip( 'Save tags to comic archive' )
|
||||
self.actionWrite_Tags.triggered.connect( self.commitMetadata )
|
||||
@ -388,19 +389,26 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
msgBox.exec_()
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
self.droppedFile=None
|
||||
self.droppedFiles = None
|
||||
if event.mimeData().hasUrls():
|
||||
url=event.mimeData().urls()[0]
|
||||
if url.isValid():
|
||||
if url.scheme()=="file":
|
||||
self.droppedFile=url.toLocalFile()
|
||||
event.accept()
|
||||
|
||||
|
||||
# walk through the URL list and build a file list
|
||||
for url in event.mimeData().urls():
|
||||
if url.isValid() and url.scheme() == "file":
|
||||
if self.droppedFiles is None:
|
||||
self.droppedFiles = []
|
||||
self.droppedFiles.append(url.toLocalFile())
|
||||
|
||||
if self.droppedFiles is not None:
|
||||
event.accept()
|
||||
|
||||
def dropEvent(self, event):
|
||||
if self.dirtyFlagVerification( "Open Archive",
|
||||
"If you open a new archive now, data in the form will be lost. Are you sure?"):
|
||||
self.openArchive( unicode(self.droppedFile))
|
||||
|
||||
#self.openArchive( unicode(self.droppedFile))
|
||||
self.fileSelectionList.addPathList( self.droppedFiles )
|
||||
event.accept()
|
||||
|
||||
def openArchive( self, path, explicit_style=None, clear_form=True ):
|
||||
|
||||
if path is None or path == "":
|
||||
@ -845,33 +853,37 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
self.metadata.overlay( new_metadata )
|
||||
self.metadataToForm()
|
||||
|
||||
def selectFile( self ):
|
||||
def selectFolder( self ):
|
||||
self.selectFile( folder_mode=True )
|
||||
|
||||
def selectFile( self , folder_mode = False):
|
||||
|
||||
dialog = QtGui.QFileDialog(self)
|
||||
dialog.setFileMode(QtGui.QFileDialog.ExistingFile)
|
||||
if folder_mode:
|
||||
dialog.setFileMode(QtGui.QFileDialog.Directory)
|
||||
else:
|
||||
dialog.setFileMode(QtGui.QFileDialog.ExistingFiles)
|
||||
|
||||
if self.settings.last_opened_folder is not None:
|
||||
dialog.setDirectory( self.settings.last_opened_folder )
|
||||
#dialog.setFileMode(QtGui.QFileDialog.Directory )
|
||||
|
||||
if platform.system() != "Windows" and utils.which("unrar") is None:
|
||||
archive_filter = "Comic archive files (*.cbz *.zip)"
|
||||
else:
|
||||
archive_filter = "Comic archive files (*.cbz *.zip *.cbr *.rar)"
|
||||
|
||||
filters = [
|
||||
archive_filter,
|
||||
"Any files (*)"
|
||||
]
|
||||
|
||||
dialog.setNameFilters(filters)
|
||||
#dialog.setFilter (self, QString filter)
|
||||
if not folder_mode:
|
||||
if platform.system() != "Windows" and utils.which("unrar") is None:
|
||||
archive_filter = "Comic archive files (*.cbz *.zip)"
|
||||
else:
|
||||
archive_filter = "Comic archive files (*.cbz *.zip *.cbr *.rar)"
|
||||
filters = [
|
||||
archive_filter,
|
||||
"Any files (*)"
|
||||
]
|
||||
dialog.setNameFilters(filters)
|
||||
|
||||
if (dialog.exec_()):
|
||||
fileList = dialog.selectedFiles()
|
||||
if self.dirtyFlagVerification( "Open Archive",
|
||||
"If you open a new archive now, data in the form will be lost. Are you sure?"):
|
||||
self.openArchive( unicode(fileList[0]) )
|
||||
|
||||
self.fileSelectionList.addPathList( fileList )
|
||||
|
||||
def autoSelectSearch(self):
|
||||
if self.comic_archive is None:
|
||||
|
@ -254,7 +254,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
@ -544,7 +544,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIssueNum"/>
|
||||
<widget class="QLineEdit" name="leIssueNum">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
@ -554,7 +558,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leVolumeNum"/>
|
||||
<widget class="QLineEdit" name="leVolumeNum">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
@ -577,6 +585,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
@ -598,6 +609,9 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIssueCount">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
@ -612,6 +626,9 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leVolumeCount">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
@ -638,6 +655,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
@ -923,7 +943,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QTextEdit" name="teComments"/>
|
||||
<widget class="QTextEdit" name="teComments">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
@ -933,7 +957,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="teNotes"/>
|
||||
<widget class="QTextEdit" name="teNotes">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
@ -943,7 +971,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leWebLink"/>
|
||||
<widget class="QLineEdit" name="leWebLink">
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="userRatingLabel">
|
||||
@ -966,6 +998,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -1012,6 +1047,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@ -1035,6 +1073,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
@ -1058,6 +1099,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
@ -1087,6 +1131,9 @@
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -1119,7 +1166,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>968</width>
|
||||
<height>25</height>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuComicTagger">
|
||||
@ -1150,6 +1197,7 @@
|
||||
<addaction name="actionViewRawCBLTags"/>
|
||||
</widget>
|
||||
<addaction name="actionLoad"/>
|
||||
<addaction name="actionLoadFolder"/>
|
||||
<addaction name="actionWrite_Tags"/>
|
||||
<addaction name="menuReload"/>
|
||||
<addaction name="menuRemove"/>
|
||||
@ -1353,6 +1401,11 @@
|
||||
<string>Apply CBL Transform</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadFolder">
|
||||
<property name="text">
|
||||
<string>Open Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user