Fix #7298 (Remove Restriction - Tag editor cannot be used if you have modified tags)

This commit is contained in:
Kovid Goyal 2010-10-27 21:09:22 -06:00
parent 18652db25e
commit 6681fe6ede
3 changed files with 20 additions and 10 deletions

View File

@ -255,7 +255,7 @@ def error_dialog(parent, title, msg, det_msg='', show=False,
return d
def question_dialog(parent, title, msg, det_msg='', show_copy_button=True,
buttons=QMessageBox.Yes|QMessageBox.No):
buttons=QMessageBox.Yes|QMessageBox.No, yes_button=QMessageBox.Yes):
d = MessageBox(QMessageBox.Question, title, msg, buttons,
parent, det_msg)
d.setIconPixmap(QPixmap(I('dialog_question.png')))
@ -263,7 +263,7 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=True,
if not show_copy_button:
d.cb.setVisible(False)
return d.exec_() == QMessageBox.Yes
return d.exec_() == yes_button
def info_dialog(parent, title, msg, det_msg='', show=False):
d = MessageBox(QMessageBox.Information, title, msg, QMessageBox.Ok,

View File

@ -111,7 +111,7 @@ class ViewAction(InterfaceAction):
'books at once can be slow and have a negative effect on the '
'responsiveness of your computer. Once started the process '
'cannot be stopped until complete. Do you wish to continue?'
) % num)
) % num, show_copy_button=False)
def view_folder(self, *args):
rows = self.gui.current_view().selectionModel().selectedRows()

View File

@ -9,11 +9,11 @@ add/remove formats
import os, re, time, traceback, textwrap
from PyQt4.Qt import SIGNAL, QObject, Qt, QTimer, QThread, QDate, \
QPixmap, QListWidgetItem, QDialog, pyqtSignal
QPixmap, QListWidgetItem, QDialog, pyqtSignal, QMessageBox
from calibre.gui2 import error_dialog, file_icon_provider, dynamic, \
choose_files, choose_images, ResizableDialog, \
warning_dialog
warning_dialog, question_dialog
from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog
from calibre.gui2.dialogs.fetch_metadata import FetchMetadata
from calibre.gui2.dialogs.tag_editor import TagEditor
@ -608,9 +608,16 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
def edit_tags(self):
if self.tags.text() != self.original_tags:
error_dialog(self, _('Cannot use tag editor'),
_('The tags editor cannot be used if you have modified the tags')).exec_()
return
if question_dialog(self, _('Tags changed'),
_('You have changed the tags. In order to use the tags'
' editor, you must either discard or apply these '
'changes'), show_copy_button=False,
buttons=QMessageBox.Apply|QMessageBox.Discard,
yes_button=QMessageBox.Apply):
self.apply_tags(commit=True, notify=True)
self.original_tags = unicode(self.tags.text())
else:
self.tags.setText(self.original_tags)
d = TagEditor(self, self.db, self.row)
d.exec_()
if d.result() == QDialog.Accepted:
@ -764,6 +771,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.series.setCurrentIndex(i)
break
def apply_tags(self, commit=False, notify=False):
self.db.set_tags(self.id, [x.strip() for x in
unicode(self.tags.text()).split(',')],
notify=notify, commit=commit)
def accept(self):
cf = getattr(self, 'cover_fetcher', None)
@ -787,11 +798,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
notify=False, commit=False)
self.db.set_rating(self.id, 2*self.rating.value(), notify=False,
commit=False)
self.apply_tags()
self.db.set_publisher(self.id,
unicode(self.publisher.currentText()).strip(),
notify=False, commit=False)
self.db.set_tags(self.id, [x.strip() for x in
unicode(self.tags.text()).split(',')], notify=False, commit=False)
self.db.set_series(self.id,
unicode(self.series.currentText()).strip(), notify=False,
commit=False)