mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove qstring_to_unicode
This commit is contained in:
parent
f20255b98e
commit
547fd01be9
@ -218,9 +218,6 @@ def info_dialog(parent, title, msg, det_msg='', show=False):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
def qstring_to_unicode(q):
|
|
||||||
return unicode(q)
|
|
||||||
|
|
||||||
def human_readable(size):
|
def human_readable(size):
|
||||||
""" Convert a size in bytes into a human readable form """
|
""" Convert a size in bytes into a human readable form """
|
||||||
divisor, suffix = 1, "B"
|
divisor, suffix = 1, "B"
|
||||||
@ -380,7 +377,7 @@ class FileIconProvider(QFileIconProvider):
|
|||||||
if fileinfo.isDir():
|
if fileinfo.isDir():
|
||||||
key = 'dir'
|
key = 'dir'
|
||||||
else:
|
else:
|
||||||
ext = qstring_to_unicode(fileinfo.completeSuffix()).lower()
|
ext = unicode(fileinfo.completeSuffix()).lower()
|
||||||
key = self.key_from_ext(ext)
|
key = self.key_from_ext(ext)
|
||||||
return self.cached_icon(key)
|
return self.cached_icon(key)
|
||||||
|
|
||||||
|
@ -6,18 +6,17 @@ __docformat__ = 'restructuredtext en'
|
|||||||
''''''
|
''''''
|
||||||
from PyQt4.QtGui import QDialog
|
from PyQt4.QtGui import QDialog
|
||||||
from calibre.gui2.dialogs.comicconf_ui import Ui_Dialog
|
from calibre.gui2.dialogs.comicconf_ui import Ui_Dialog
|
||||||
from calibre.gui2 import qstring_to_unicode
|
|
||||||
from calibre.ebooks.lrf.comic.convert_from import config, PROFILES
|
from calibre.ebooks.lrf.comic.convert_from import config, PROFILES
|
||||||
|
|
||||||
def set_conversion_defaults(window):
|
def set_conversion_defaults(window):
|
||||||
d = ComicConf(window)
|
d = ComicConf(window)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def get_bulk_conversion_options(window):
|
def get_bulk_conversion_options(window):
|
||||||
d = ComicConf(window, config_defaults=config(None).as_string())
|
d = ComicConf(window, config_defaults=config(None).as_string())
|
||||||
if d.exec_() == QDialog.Accepted:
|
if d.exec_() == QDialog.Accepted:
|
||||||
return d.config.parse()
|
return d.config.parse()
|
||||||
|
|
||||||
def get_conversion_options(window, defaults, title, author):
|
def get_conversion_options(window, defaults, title, author):
|
||||||
if defaults is None:
|
if defaults is None:
|
||||||
defaults = config(None).as_string()
|
defaults = config(None).as_string()
|
||||||
@ -26,10 +25,10 @@ def get_conversion_options(window, defaults, title, author):
|
|||||||
if d.exec_() == QDialog.Accepted:
|
if d.exec_() == QDialog.Accepted:
|
||||||
return d.config.parse(), d.config.src
|
return d.config.parse(), d.config.src
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
class ComicConf(QDialog, Ui_Dialog):
|
class ComicConf(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
def __init__(self, window, config_defaults=None, generic=True,
|
def __init__(self, window, config_defaults=None, generic=True,
|
||||||
title=_('Set defaults for conversion of comics (CBR/CBZ files)')):
|
title=_('Set defaults for conversion of comics (CBR/CBZ files)')):
|
||||||
QDialog.__init__(self, window)
|
QDialog.__init__(self, window)
|
||||||
@ -63,12 +62,12 @@ class ComicConf(QDialog, Ui_Dialog):
|
|||||||
self.opt_despeckle.setChecked(opts.despeckle)
|
self.opt_despeckle.setChecked(opts.despeckle)
|
||||||
self.opt_wide.setChecked(opts.wide)
|
self.opt_wide.setChecked(opts.wide)
|
||||||
self.opt_right2left.setChecked(opts.right2left)
|
self.opt_right2left.setChecked(opts.right2left)
|
||||||
|
|
||||||
for opt in self.config.option_set.preferences:
|
for opt in self.config.option_set.preferences:
|
||||||
g = getattr(self, 'opt_'+opt.name, False)
|
g = getattr(self, 'opt_'+opt.name, False)
|
||||||
if opt.help and g:
|
if opt.help and g:
|
||||||
g.setToolTip(opt.help)
|
g.setToolTip(opt.help)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
for opt in self.config.option_set.preferences:
|
for opt in self.config.option_set.preferences:
|
||||||
g = getattr(self, 'opt_'+opt.name, False)
|
g = getattr(self, 'opt_'+opt.name, False)
|
||||||
@ -78,9 +77,9 @@ class ComicConf(QDialog, Ui_Dialog):
|
|||||||
elif hasattr(g, 'value'):
|
elif hasattr(g, 'value'):
|
||||||
val = g.value()
|
val = g.value()
|
||||||
elif hasattr(g, 'itemText'):
|
elif hasattr(g, 'itemText'):
|
||||||
val = qstring_to_unicode(g.itemText(g.currentIndex()))
|
val = unicode(g.itemText(g.currentIndex()))
|
||||||
elif hasattr(g, 'text'):
|
elif hasattr(g, 'text'):
|
||||||
val = qstring_to_unicode(g.text())
|
val = unicode(g.text())
|
||||||
else:
|
else:
|
||||||
raise Exception('Bad coding')
|
raise Exception('Bad coding')
|
||||||
self.config.set(opt.name, val)
|
self.config.set(opt.name, val)
|
||||||
|
@ -13,7 +13,7 @@ from PyQt4.Qt import QDialog, QListWidgetItem, QIcon, \
|
|||||||
from calibre.constants import iswindows, isosx, preferred_encoding
|
from calibre.constants import iswindows, isosx, preferred_encoding
|
||||||
from calibre.gui2.dialogs.config.config_ui import Ui_Dialog
|
from calibre.gui2.dialogs.config.config_ui import Ui_Dialog
|
||||||
from calibre.gui2.dialogs.config.create_custom_column import CreateCustomColumn
|
from calibre.gui2.dialogs.config.create_custom_column import CreateCustomColumn
|
||||||
from calibre.gui2 import qstring_to_unicode, choose_dir, error_dialog, config, \
|
from calibre.gui2 import choose_dir, error_dialog, config, \
|
||||||
ALL_COLUMNS, NONE, info_dialog, choose_files, \
|
ALL_COLUMNS, NONE, info_dialog, choose_files, \
|
||||||
warning_dialog, ResizableDialog
|
warning_dialog, ResizableDialog
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
@ -650,7 +650,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
|||||||
if idx < 0:
|
if idx < 0:
|
||||||
self.messagebox(_('You must select a column to delete it'))
|
self.messagebox(_('You must select a column to delete it'))
|
||||||
return
|
return
|
||||||
col = qstring_to_unicode(self.columns.item(idx).data(Qt.UserRole).toString())
|
col = unicode(self.columns.item(idx).data(Qt.UserRole).toString())
|
||||||
if col not in self.custcols:
|
if col not in self.custcols:
|
||||||
self.messagebox(_('The selected column is not a custom column'))
|
self.messagebox(_('The selected column is not a custom column'))
|
||||||
return
|
return
|
||||||
@ -759,12 +759,12 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
|||||||
config['use_roman_numerals_for_series_number'] = bool(self.roman_numerals.isChecked())
|
config['use_roman_numerals_for_series_number'] = bool(self.roman_numerals.isChecked())
|
||||||
config['new_version_notification'] = bool(self.new_version_notification.isChecked())
|
config['new_version_notification'] = bool(self.new_version_notification.isChecked())
|
||||||
prefs['network_timeout'] = int(self.timeout.value())
|
prefs['network_timeout'] = int(self.timeout.value())
|
||||||
path = qstring_to_unicode(self.location.text())
|
path = unicode(self.location.text())
|
||||||
input_cols = [unicode(self.input_order.item(i).data(Qt.UserRole).toString()) for i in range(self.input_order.count())]
|
input_cols = [unicode(self.input_order.item(i).data(Qt.UserRole).toString()) for i in range(self.input_order.count())]
|
||||||
prefs['input_format_order'] = input_cols
|
prefs['input_format_order'] = input_cols
|
||||||
|
|
||||||
####### Now deal with changes to columns
|
####### Now deal with changes to columns
|
||||||
cols = [qstring_to_unicode(self.columns.item(i).data(Qt.UserRole).toString())\
|
cols = [unicode(self.columns.item(i).data(Qt.UserRole).toString())\
|
||||||
for i in range(self.columns.count()) \
|
for i in range(self.columns.count()) \
|
||||||
if self.columns.item(i).checkState()==Qt.Checked]
|
if self.columns.item(i).checkState()==Qt.Checked]
|
||||||
if not cols:
|
if not cols:
|
||||||
|
@ -14,7 +14,7 @@ import traceback
|
|||||||
from PyQt4.Qt import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread, QDate, \
|
from PyQt4.Qt import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread, QDate, \
|
||||||
QPixmap, QListWidgetItem, QDialog
|
QPixmap, QListWidgetItem, QDialog
|
||||||
|
|
||||||
from calibre.gui2 import qstring_to_unicode, error_dialog, file_icon_provider, \
|
from calibre.gui2 import error_dialog, file_icon_provider, \
|
||||||
choose_files, choose_images, ResizableDialog, \
|
choose_files, choose_images, ResizableDialog, \
|
||||||
warning_dialog
|
warning_dialog
|
||||||
from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog
|
from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog
|
||||||
@ -552,12 +552,12 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
|
|
||||||
def fetch_metadata(self):
|
def fetch_metadata(self):
|
||||||
isbn = re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text()))
|
isbn = re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text()))
|
||||||
title = qstring_to_unicode(self.title.text())
|
title = unicode(self.title.text())
|
||||||
try:
|
try:
|
||||||
author = string_to_authors(unicode(self.authors.text()))[0]
|
author = string_to_authors(unicode(self.authors.text()))[0]
|
||||||
except:
|
except:
|
||||||
author = ''
|
author = ''
|
||||||
publisher = qstring_to_unicode(self.publisher.currentText())
|
publisher = unicode(self.publisher.currentText())
|
||||||
if isbn or title or author or publisher:
|
if isbn or title or author or publisher:
|
||||||
d = FetchMetadata(self, isbn, title, author, publisher, self.timeout)
|
d = FetchMetadata(self, isbn, title, author, publisher, self.timeout)
|
||||||
self._fetch_metadata_scope = d
|
self._fetch_metadata_scope = d
|
||||||
@ -623,12 +623,12 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
|
|
||||||
def remove_unused_series(self):
|
def remove_unused_series(self):
|
||||||
self.db.remove_unused_series()
|
self.db.remove_unused_series()
|
||||||
idx = qstring_to_unicode(self.series.currentText())
|
idx = unicode(self.series.currentText())
|
||||||
self.series.clear()
|
self.series.clear()
|
||||||
self.initialize_series()
|
self.initialize_series()
|
||||||
if idx:
|
if idx:
|
||||||
for i in range(self.series.count()):
|
for i in range(self.series.count()):
|
||||||
if qstring_to_unicode(self.series.itemText(i)) == idx:
|
if unicode(self.series.itemText(i)) == idx:
|
||||||
self.series.setCurrentIndex(i)
|
self.series.setCurrentIndex(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
|||||||
self.db.set_isbn(self.id,
|
self.db.set_isbn(self.id,
|
||||||
re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text())), notify=False)
|
re.sub(r'[^0-9a-zA-Z]', '', unicode(self.isbn.text())), notify=False)
|
||||||
self.db.set_rating(self.id, 2*self.rating.value(), notify=False)
|
self.db.set_rating(self.id, 2*self.rating.value(), notify=False)
|
||||||
self.db.set_publisher(self.id, qstring_to_unicode(self.publisher.currentText()), notify=False)
|
self.db.set_publisher(self.id, unicode(self.publisher.currentText()), notify=False)
|
||||||
self.db.set_tags(self.id, [x.strip() for x in
|
self.db.set_tags(self.id, [x.strip() for x in
|
||||||
unicode(self.tags.text()).split(',')], notify=False)
|
unicode(self.tags.text()).split(',')], notify=False)
|
||||||
self.db.set_series(self.id,
|
self.db.set_series(self.id,
|
||||||
|
@ -5,38 +5,38 @@ from PyQt4.QtGui import QDialog, QLineEdit
|
|||||||
from PyQt4.QtCore import SIGNAL, Qt
|
from PyQt4.QtCore import SIGNAL, Qt
|
||||||
|
|
||||||
from calibre.gui2.dialogs.password_ui import Ui_Dialog
|
from calibre.gui2.dialogs.password_ui import Ui_Dialog
|
||||||
from calibre.gui2 import qstring_to_unicode, dynamic
|
from calibre.gui2 import dynamic
|
||||||
|
|
||||||
class PasswordDialog(QDialog, Ui_Dialog):
|
class PasswordDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
def __init__(self, window, name, msg):
|
def __init__(self, window, name, msg):
|
||||||
QDialog.__init__(self, window)
|
QDialog.__init__(self, window)
|
||||||
Ui_Dialog.__init__(self)
|
Ui_Dialog.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.cfg_key = re.sub(r'[^0-9a-zA-Z]', '_', name)
|
self.cfg_key = re.sub(r'[^0-9a-zA-Z]', '_', name)
|
||||||
|
|
||||||
un = dynamic[self.cfg_key+'__un']
|
un = dynamic[self.cfg_key+'__un']
|
||||||
pw = dynamic[self.cfg_key+'__pw']
|
pw = dynamic[self.cfg_key+'__pw']
|
||||||
if not un: un = ''
|
if not un: un = ''
|
||||||
if not pw: pw = ''
|
if not pw: pw = ''
|
||||||
self.gui_username.setText(un)
|
self.gui_username.setText(un)
|
||||||
self.gui_password.setText(pw)
|
self.gui_password.setText(pw)
|
||||||
self.sname = name
|
self.sname = name
|
||||||
self.msg.setText(msg)
|
self.msg.setText(msg)
|
||||||
self.connect(self.show_password, SIGNAL('stateChanged(int)'), self.toggle_password)
|
self.connect(self.show_password, SIGNAL('stateChanged(int)'), self.toggle_password)
|
||||||
|
|
||||||
def toggle_password(self, state):
|
def toggle_password(self, state):
|
||||||
if state == Qt.Unchecked:
|
if state == Qt.Unchecked:
|
||||||
self.gui_password.setEchoMode(QLineEdit.Password)
|
self.gui_password.setEchoMode(QLineEdit.Password)
|
||||||
else:
|
else:
|
||||||
self.gui_password.setEchoMode(QLineEdit.Normal)
|
self.gui_password.setEchoMode(QLineEdit.Normal)
|
||||||
|
|
||||||
def username(self):
|
def username(self):
|
||||||
return qstring_to_unicode(self.gui_username.text())
|
return unicode(self.gui_username.text())
|
||||||
|
|
||||||
def password(self):
|
def password(self):
|
||||||
return qstring_to_unicode(self.gui_password.text())
|
return unicode(self.gui_password.text())
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
dynamic.set(self.cfg_key+'__un', unicode(self.gui_username.text()))
|
dynamic.set(self.cfg_key+'__un', unicode(self.gui_username.text()))
|
||||||
dynamic.set(self.cfg_key+'__pw', unicode(self.gui_password.text()))
|
dynamic.set(self.cfg_key+'__pw', unicode(self.gui_password.text()))
|
||||||
|
@ -4,7 +4,6 @@ import re
|
|||||||
from PyQt4.QtGui import QDialog
|
from PyQt4.QtGui import QDialog
|
||||||
|
|
||||||
from calibre.gui2.dialogs.search_ui import Ui_Dialog
|
from calibre.gui2.dialogs.search_ui import Ui_Dialog
|
||||||
from calibre.gui2 import qstring_to_unicode
|
|
||||||
from calibre.library.caches import CONTAINS_MATCH, EQUALS_MATCH
|
from calibre.library.caches import CONTAINS_MATCH, EQUALS_MATCH
|
||||||
|
|
||||||
class SearchDialog(QDialog, Ui_Dialog):
|
class SearchDialog(QDialog, Ui_Dialog):
|
||||||
@ -48,11 +47,11 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
def token(self):
|
def token(self):
|
||||||
txt = qstring_to_unicode(self.text.text()).strip()
|
txt = unicode(self.text.text()).strip()
|
||||||
if txt:
|
if txt:
|
||||||
if self.negate.isChecked():
|
if self.negate.isChecked():
|
||||||
txt = '!'+txt
|
txt = '!'+txt
|
||||||
tok = self.FIELDS[qstring_to_unicode(self.field.currentText())]+txt
|
tok = self.FIELDS[unicode(self.field.currentText())]+txt
|
||||||
if re.search(r'\s', tok):
|
if re.search(r'\s', tok):
|
||||||
tok = '"%s"'%tok
|
tok = '"%s"'%tok
|
||||||
return tok
|
return tok
|
||||||
|
@ -7,7 +7,7 @@ from PyQt4.QtCore import SIGNAL, Qt
|
|||||||
from PyQt4.QtGui import QDialog, QIcon, QListWidgetItem
|
from PyQt4.QtGui import QDialog, QIcon, QListWidgetItem
|
||||||
|
|
||||||
from calibre.gui2.dialogs.tag_categories_ui import Ui_TagCategories
|
from calibre.gui2.dialogs.tag_categories_ui import Ui_TagCategories
|
||||||
from calibre.gui2 import qstring_to_unicode, config
|
from calibre.gui2 import config
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.constants import islinux
|
from calibre.constants import islinux
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
|||||||
|
|
||||||
def add_category(self):
|
def add_category(self):
|
||||||
self.save_category()
|
self.save_category()
|
||||||
cat_name = qstring_to_unicode(self.input_box.text()).strip()
|
cat_name = unicode(self.input_box.text()).strip()
|
||||||
if cat_name == '':
|
if cat_name == '':
|
||||||
return False
|
return False
|
||||||
if cat_name not in self.categories:
|
if cat_name not in self.categories:
|
||||||
|
@ -4,7 +4,6 @@ from PyQt4.QtCore import SIGNAL, Qt
|
|||||||
from PyQt4.QtGui import QDialog
|
from PyQt4.QtGui import QDialog
|
||||||
|
|
||||||
from calibre.gui2.dialogs.tag_editor_ui import Ui_TagEditor
|
from calibre.gui2.dialogs.tag_editor_ui import Ui_TagEditor
|
||||||
from calibre.gui2 import qstring_to_unicode
|
|
||||||
from calibre.gui2 import question_dialog, error_dialog
|
from calibre.gui2 import question_dialog, error_dialog
|
||||||
from calibre.constants import islinux
|
from calibre.constants import islinux
|
||||||
|
|
||||||
@ -57,26 +56,26 @@ class TagEditor(QDialog, Ui_TagEditor):
|
|||||||
error_dialog(self, 'No tags selected', 'You must select at least one tag from the list of Available tags.').exec_()
|
error_dialog(self, 'No tags selected', 'You must select at least one tag from the list of Available tags.').exec_()
|
||||||
return
|
return
|
||||||
for item in items:
|
for item in items:
|
||||||
if self.db.is_tag_used(qstring_to_unicode(item.text())):
|
if self.db.is_tag_used(unicode(item.text())):
|
||||||
confirms.append(item)
|
confirms.append(item)
|
||||||
else:
|
else:
|
||||||
deletes.append(item)
|
deletes.append(item)
|
||||||
if confirms:
|
if confirms:
|
||||||
ct = ', '.join([qstring_to_unicode(item.text()) for item in confirms])
|
ct = ', '.join([unicode(item.text()) for item in confirms])
|
||||||
if question_dialog(self, _('Are your sure?'),
|
if question_dialog(self, _('Are your sure?'),
|
||||||
'<p>'+_('The following tags are used by one or more books. '
|
'<p>'+_('The following tags are used by one or more books. '
|
||||||
'Are you certain you want to delete them?')+'<br>'+ct):
|
'Are you certain you want to delete them?')+'<br>'+ct):
|
||||||
deletes += confirms
|
deletes += confirms
|
||||||
|
|
||||||
for item in deletes:
|
for item in deletes:
|
||||||
self.db.delete_tag(qstring_to_unicode(item.text()))
|
self.db.delete_tag(unicode(item.text()))
|
||||||
self.available_tags.takeItem(self.available_tags.row(item))
|
self.available_tags.takeItem(self.available_tags.row(item))
|
||||||
|
|
||||||
|
|
||||||
def apply_tags(self, item=None):
|
def apply_tags(self, item=None):
|
||||||
items = self.available_tags.selectedItems() if item is None else [item]
|
items = self.available_tags.selectedItems() if item is None else [item]
|
||||||
for item in items:
|
for item in items:
|
||||||
tag = qstring_to_unicode(item.text())
|
tag = unicode(item.text())
|
||||||
self.tags.append(tag)
|
self.tags.append(tag)
|
||||||
self.available_tags.takeItem(self.available_tags.row(item))
|
self.available_tags.takeItem(self.available_tags.row(item))
|
||||||
|
|
||||||
@ -90,7 +89,7 @@ class TagEditor(QDialog, Ui_TagEditor):
|
|||||||
def unapply_tags(self, item=None):
|
def unapply_tags(self, item=None):
|
||||||
items = self.applied_tags.selectedItems() if item is None else [item]
|
items = self.applied_tags.selectedItems() if item is None else [item]
|
||||||
for item in items:
|
for item in items:
|
||||||
tag = qstring_to_unicode(item.text())
|
tag = unicode(item.text())
|
||||||
self.tags.remove(tag)
|
self.tags.remove(tag)
|
||||||
self.available_tags.addItem(tag)
|
self.available_tags.addItem(tag)
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ class TagEditor(QDialog, Ui_TagEditor):
|
|||||||
self.available_tags.sortItems()
|
self.available_tags.sortItems()
|
||||||
|
|
||||||
def add_tag(self):
|
def add_tag(self):
|
||||||
tags = qstring_to_unicode(self.add_tag_input.text()).split(',')
|
tags = unicode(self.add_tag_input.text()).split(',')
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
tag = tag.strip()
|
tag = tag.strip()
|
||||||
for item in self.available_tags.findItems(tag, Qt.MatchFixedString):
|
for item in self.available_tags.findItems(tag, Qt.MatchFixedString):
|
||||||
|
@ -9,7 +9,7 @@ from PyQt4.Qt import SIGNAL, QUrl, QDesktopServices, QAbstractListModel, Qt, \
|
|||||||
from calibre.web.feeds.recipes import compile_recipe
|
from calibre.web.feeds.recipes import compile_recipe
|
||||||
from calibre.web.feeds.news import AutomaticNewsRecipe
|
from calibre.web.feeds.news import AutomaticNewsRecipe
|
||||||
from calibre.gui2.dialogs.user_profiles_ui import Ui_Dialog
|
from calibre.gui2.dialogs.user_profiles_ui import Ui_Dialog
|
||||||
from calibre.gui2 import qstring_to_unicode, error_dialog, question_dialog, \
|
from calibre.gui2 import error_dialog, question_dialog, \
|
||||||
choose_files, ResizableDialog, NONE
|
choose_files, ResizableDialog, NONE
|
||||||
from calibre.gui2.widgets import PythonHighlighter
|
from calibre.gui2.widgets import PythonHighlighter
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
@ -162,19 +162,19 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
|
|||||||
else:
|
else:
|
||||||
self.stacks.setCurrentIndex(1)
|
self.stacks.setCurrentIndex(1)
|
||||||
self.toggle_mode_button.setText(_('Switch to Basic mode'))
|
self.toggle_mode_button.setText(_('Switch to Basic mode'))
|
||||||
if not qstring_to_unicode(self.source_code.toPlainText()).strip():
|
if not unicode(self.source_code.toPlainText()).strip():
|
||||||
src = self.options_to_profile()[0].replace('AutomaticNewsRecipe', 'BasicNewsRecipe')
|
src = self.options_to_profile()[0].replace('AutomaticNewsRecipe', 'BasicNewsRecipe')
|
||||||
self.source_code.setPlainText(src.replace('BasicUserRecipe', 'AdvancedUserRecipe'))
|
self.source_code.setPlainText(src.replace('BasicUserRecipe', 'AdvancedUserRecipe'))
|
||||||
self.highlighter = PythonHighlighter(self.source_code.document())
|
self.highlighter = PythonHighlighter(self.source_code.document())
|
||||||
|
|
||||||
|
|
||||||
def add_feed(self, *args):
|
def add_feed(self, *args):
|
||||||
title = qstring_to_unicode(self.feed_title.text()).strip()
|
title = unicode(self.feed_title.text()).strip()
|
||||||
if not title:
|
if not title:
|
||||||
error_dialog(self, _('Feed must have a title'),
|
error_dialog(self, _('Feed must have a title'),
|
||||||
_('The feed must have a title')).exec_()
|
_('The feed must have a title')).exec_()
|
||||||
return
|
return
|
||||||
url = qstring_to_unicode(self.feed_url.text()).strip()
|
url = unicode(self.feed_url.text()).strip()
|
||||||
if not url:
|
if not url:
|
||||||
error_dialog(self, _('Feed must have a URL'),
|
error_dialog(self, _('Feed must have a URL'),
|
||||||
_('The feed %s must have a URL')%title).exec_()
|
_('The feed %s must have a URL')%title).exec_()
|
||||||
@ -190,7 +190,7 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
|
|||||||
|
|
||||||
def options_to_profile(self):
|
def options_to_profile(self):
|
||||||
classname = 'BasicUserRecipe'+str(int(time.time()))
|
classname = 'BasicUserRecipe'+str(int(time.time()))
|
||||||
title = qstring_to_unicode(self.profile_title.text()).strip()
|
title = unicode(self.profile_title.text()).strip()
|
||||||
if not title:
|
if not title:
|
||||||
title = classname
|
title = classname
|
||||||
self.profile_title.setText(title)
|
self.profile_title.setText(title)
|
||||||
@ -229,7 +229,7 @@ class %(classname)s(%(base_class)s):
|
|||||||
return
|
return
|
||||||
profile = src
|
profile = src
|
||||||
else:
|
else:
|
||||||
src = qstring_to_unicode(self.source_code.toPlainText())
|
src = unicode(self.source_code.toPlainText())
|
||||||
try:
|
try:
|
||||||
title = compile_recipe(src).title
|
title = compile_recipe(src).title
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
@ -19,7 +19,7 @@ from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, pyqtSignal, \
|
|||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.ebooks.metadata import string_to_authors, fmt_sidx, authors_to_string
|
from calibre.ebooks.metadata import string_to_authors, fmt_sidx, authors_to_string
|
||||||
from calibre.ebooks.metadata.meta import set_metadata as _set_metadata
|
from calibre.ebooks.metadata.meta import set_metadata as _set_metadata
|
||||||
from calibre.gui2 import NONE, TableView, qstring_to_unicode, config, error_dialog
|
from calibre.gui2 import NONE, TableView, config, error_dialog
|
||||||
from calibre.gui2.dialogs.comments_dialog import CommentsDialog
|
from calibre.gui2.dialogs.comments_dialog import CommentsDialog
|
||||||
from calibre.gui2.widgets import EnLineEdit, TagsLineEdit
|
from calibre.gui2.widgets import EnLineEdit, TagsLineEdit
|
||||||
from calibre.library.caches import _match, CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
|
from calibre.library.caches import _match, CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
|
||||||
@ -813,7 +813,7 @@ class BooksModel(QAbstractTableModel):
|
|||||||
def set_custom_column_data(self, row, colhead, value):
|
def set_custom_column_data(self, row, colhead, value):
|
||||||
typ = self.custom_columns[colhead]['datatype']
|
typ = self.custom_columns[colhead]['datatype']
|
||||||
if typ in ('text', 'comments'):
|
if typ in ('text', 'comments'):
|
||||||
val = qstring_to_unicode(value.toString()).strip()
|
val = unicode(value.toString()).strip()
|
||||||
val = val if val else None
|
val = val if val else None
|
||||||
if typ == 'bool':
|
if typ == 'bool':
|
||||||
val = value.toInt()[0] # tristate checkboxes put unknown in the middle
|
val = value.toInt()[0] # tristate checkboxes put unknown in the middle
|
||||||
@ -823,7 +823,7 @@ class BooksModel(QAbstractTableModel):
|
|||||||
val = 0 if val < 0 else 5 if val > 5 else val
|
val = 0 if val < 0 else 5 if val > 5 else val
|
||||||
val *= 2
|
val *= 2
|
||||||
elif typ in ('int', 'float'):
|
elif typ in ('int', 'float'):
|
||||||
val = qstring_to_unicode(value.toString()).strip()
|
val = unicode(value.toString()).strip()
|
||||||
if val is None or not val:
|
if val is None or not val:
|
||||||
val = None
|
val = None
|
||||||
elif typ == 'datetime':
|
elif typ == 'datetime':
|
||||||
@ -1034,7 +1034,7 @@ class BooksView(TableView):
|
|||||||
and represent files with extensions.
|
and represent files with extensions.
|
||||||
'''
|
'''
|
||||||
if event.mimeData().hasFormat('text/uri-list'):
|
if event.mimeData().hasFormat('text/uri-list'):
|
||||||
urls = [qstring_to_unicode(u.toLocalFile()) for u in event.mimeData().urls()]
|
urls = [unicode(u.toLocalFile()) for u in event.mimeData().urls()]
|
||||||
return [u for u in urls if os.path.splitext(u)[1] and os.access(u, os.R_OK)]
|
return [u for u in urls if os.path.splitext(u)[1] and os.access(u, os.R_OK)]
|
||||||
|
|
||||||
def dragEnterEvent(self, event):
|
def dragEnterEvent(self, event):
|
||||||
@ -1390,7 +1390,7 @@ class DeviceBooksModel(BooksModel):
|
|||||||
row, col = index.row(), index.column()
|
row, col = index.row(), index.column()
|
||||||
if col in [2, 3]:
|
if col in [2, 3]:
|
||||||
return False
|
return False
|
||||||
val = qstring_to_unicode(value.toString()).strip()
|
val = unicode(value.toString()).strip()
|
||||||
idx = self.map[row]
|
idx = self.map[row]
|
||||||
if col == 0:
|
if col == 0:
|
||||||
self.db[idx].title = val
|
self.db[idx].title = val
|
||||||
|
@ -9,7 +9,6 @@ from PyQt4.QtGui import QFont, QColor, QPixmap, QGraphicsPixmapItem, \
|
|||||||
from calibre.ebooks.lrf.fonts import FONT_MAP
|
from calibre.ebooks.lrf.fonts import FONT_MAP
|
||||||
from calibre.ebooks.BeautifulSoup import Tag
|
from calibre.ebooks.BeautifulSoup import Tag
|
||||||
from calibre.ebooks.hyphenate import hyphenate_word
|
from calibre.ebooks.hyphenate import hyphenate_word
|
||||||
from calibre.gui2 import qstring_to_unicode
|
|
||||||
|
|
||||||
WEIGHT_MAP = lambda wt : int((wt/10.)-1)
|
WEIGHT_MAP = lambda wt : int((wt/10.)-1)
|
||||||
NULL = lambda a, b: a
|
NULL = lambda a, b: a
|
||||||
@ -527,12 +526,12 @@ class Line(QGraphicsItem):
|
|||||||
while True:
|
while True:
|
||||||
word = words.next()
|
word = words.next()
|
||||||
word.highlight = False
|
word.highlight = False
|
||||||
if tokens[0] in qstring_to_unicode(word.string).lower():
|
if tokens[0] in unicode(word.string).lower():
|
||||||
matches.append(word)
|
matches.append(word)
|
||||||
for c in range(1, len(tokens)):
|
for c in range(1, len(tokens)):
|
||||||
word = words.next()
|
word = words.next()
|
||||||
print tokens[c], word.string
|
print tokens[c], word.string
|
||||||
if tokens[c] not in qstring_to_unicode(word.string):
|
if tokens[c] not in unicode(word.string):
|
||||||
return None
|
return None
|
||||||
matches.append(word)
|
matches.append(word)
|
||||||
for w in matches:
|
for w in matches:
|
||||||
@ -556,7 +555,7 @@ class Line(QGraphicsItem):
|
|||||||
if isinstance(tok, (int, float)):
|
if isinstance(tok, (int, float)):
|
||||||
s += ' '
|
s += ' '
|
||||||
elif isinstance(tok, Word):
|
elif isinstance(tok, Word):
|
||||||
s += qstring_to_unicode(tok.string)
|
s += unicode(tok.string)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -7,7 +7,7 @@ from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
|
|||||||
from PyQt4.QtCore import Qt, QSize, SIGNAL, QCoreApplication, pyqtSignal
|
from PyQt4.QtCore import Qt, QSize, SIGNAL, QCoreApplication, pyqtSignal
|
||||||
|
|
||||||
from calibre import fit_image, preferred_encoding, isosx
|
from calibre import fit_image, preferred_encoding, isosx
|
||||||
from calibre.gui2 import qstring_to_unicode, config
|
from calibre.gui2 import config
|
||||||
from calibre.gui2.widgets import IMAGE_EXTENSIONS
|
from calibre.gui2.widgets import IMAGE_EXTENSIONS
|
||||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
from calibre.gui2.notify import get_notifier
|
from calibre.gui2.notify import get_notifier
|
||||||
@ -260,7 +260,7 @@ class StatusBar(QStatusBar):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def jobs(self):
|
def jobs(self):
|
||||||
src = qstring_to_unicode(self.movie_button.jobs.text())
|
src = unicode(self.movie_button.jobs.text())
|
||||||
return int(re.search(r'\d+', src).group())
|
return int(re.search(r'\d+', src).group())
|
||||||
|
|
||||||
def show_book_info(self):
|
def show_book_info(self):
|
||||||
@ -268,7 +268,7 @@ class StatusBar(QStatusBar):
|
|||||||
|
|
||||||
def job_added(self, nnum):
|
def job_added(self, nnum):
|
||||||
jobs = self.movie_button.jobs
|
jobs = self.movie_button.jobs
|
||||||
src = qstring_to_unicode(jobs.text())
|
src = unicode(jobs.text())
|
||||||
num = self.jobs()
|
num = self.jobs()
|
||||||
text = src.replace(str(num), str(nnum))
|
text = src.replace(str(num), str(nnum))
|
||||||
jobs.setText(text)
|
jobs.setText(text)
|
||||||
@ -276,7 +276,7 @@ class StatusBar(QStatusBar):
|
|||||||
|
|
||||||
def job_done(self, nnum):
|
def job_done(self, nnum):
|
||||||
jobs = self.movie_button.jobs
|
jobs = self.movie_button.jobs
|
||||||
src = qstring_to_unicode(jobs.text())
|
src = unicode(jobs.text())
|
||||||
num = self.jobs()
|
num = self.jobs()
|
||||||
text = src.replace(str(num), str(nnum))
|
text = src.replace(str(num), str(nnum))
|
||||||
jobs.setText(text)
|
jobs.setText(text)
|
||||||
|
@ -9,7 +9,7 @@ from PyQt4.Qt import Qt, QDialog, QAbstractTableModel, QVariant, SIGNAL, \
|
|||||||
QModelIndex, QInputDialog, QLineEdit, QFileDialog
|
QModelIndex, QInputDialog, QLineEdit, QFileDialog
|
||||||
|
|
||||||
from calibre.gui2.viewer.bookmarkmanager_ui import Ui_BookmarkManager
|
from calibre.gui2.viewer.bookmarkmanager_ui import Ui_BookmarkManager
|
||||||
from calibre.gui2 import NONE, qstring_to_unicode
|
from calibre.gui2 import NONE
|
||||||
|
|
||||||
class BookmarkManager(QDialog, Ui_BookmarkManager):
|
class BookmarkManager(QDialog, Ui_BookmarkManager):
|
||||||
def __init__(self, parent, bookmarks):
|
def __init__(self, parent, bookmarks):
|
||||||
@ -111,7 +111,7 @@ class BookmarkTableModel(QAbstractTableModel):
|
|||||||
|
|
||||||
def setData(self, index, value, role):
|
def setData(self, index, value, role):
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
self.bookmarks[index.row()] = (qstring_to_unicode(value.toString()).strip(), self.bookmarks[index.row()][1])
|
self.bookmarks[index.row()] = (unicode(value.toString()).strip(), self.bookmarks[index.row()][1])
|
||||||
self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
|
self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -14,7 +14,7 @@ from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
|||||||
QMenu, QStringListModel, QCompleter, QStringList
|
QMenu, QStringListModel, QCompleter, QStringList
|
||||||
|
|
||||||
from calibre.gui2 import human_readable, NONE, TableView, \
|
from calibre.gui2 import human_readable, NONE, TableView, \
|
||||||
qstring_to_unicode, error_dialog, pixmap_to_data
|
error_dialog, pixmap_to_data
|
||||||
from calibre.gui2.dialogs.job_view_ui import Ui_Dialog
|
from calibre.gui2.dialogs.job_view_ui import Ui_Dialog
|
||||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
@ -72,7 +72,7 @@ class FilenamePattern(QWidget, Ui_Form):
|
|||||||
error_dialog(self, _('Invalid regular expression'),
|
error_dialog(self, _('Invalid regular expression'),
|
||||||
_('Invalid regular expression: %s')%err).exec_()
|
_('Invalid regular expression: %s')%err).exec_()
|
||||||
return
|
return
|
||||||
mi = metadata_from_filename(qstring_to_unicode(self.filename.text()), pat)
|
mi = metadata_from_filename(unicode(self.filename.text()), pat)
|
||||||
if mi.title:
|
if mi.title:
|
||||||
self.title.setText(mi.title)
|
self.title.setText(mi.title)
|
||||||
else:
|
else:
|
||||||
@ -96,7 +96,7 @@ class FilenamePattern(QWidget, Ui_Form):
|
|||||||
|
|
||||||
|
|
||||||
def pattern(self):
|
def pattern(self):
|
||||||
pat = qstring_to_unicode(self.re.text())
|
pat = unicode(self.re.text())
|
||||||
return re.compile(pat)
|
return re.compile(pat)
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
@ -158,7 +158,7 @@ class ImageView(QLabel):
|
|||||||
and represent files with extensions.
|
and represent files with extensions.
|
||||||
'''
|
'''
|
||||||
if event.mimeData().hasFormat('text/uri-list'):
|
if event.mimeData().hasFormat('text/uri-list'):
|
||||||
urls = [qstring_to_unicode(u.toLocalFile()) for u in event.mimeData().urls()]
|
urls = [unicode(u.toLocalFile()) for u in event.mimeData().urls()]
|
||||||
urls = [u for u in urls if os.path.splitext(u)[1] and os.access(u, os.R_OK)]
|
urls = [u for u in urls if os.path.splitext(u)[1] and os.access(u, os.R_OK)]
|
||||||
return [u for u in urls if os.path.splitext(u)[1][1:].lower() in cls.DROPABBLE_EXTENSIONS]
|
return [u for u in urls if os.path.splitext(u)[1][1:].lower() in cls.DROPABBLE_EXTENSIONS]
|
||||||
|
|
||||||
@ -630,13 +630,13 @@ class TagsLineEdit(EnLineEdit):
|
|||||||
self.completer.update_tags_cache(tags)
|
self.completer.update_tags_cache(tags)
|
||||||
|
|
||||||
def text_changed(self, text):
|
def text_changed(self, text):
|
||||||
all_text = qstring_to_unicode(text)
|
all_text = unicode(text)
|
||||||
text = all_text[:self.cursorPosition()]
|
text = all_text[:self.cursorPosition()]
|
||||||
prefix = text.split(',')[-1].strip()
|
prefix = text.split(',')[-1].strip()
|
||||||
|
|
||||||
text_tags = []
|
text_tags = []
|
||||||
for t in all_text.split(self.separator):
|
for t in all_text.split(self.separator):
|
||||||
t1 = qstring_to_unicode(t).strip()
|
t1 = unicode(t).strip()
|
||||||
if t1 != '':
|
if t1 != '':
|
||||||
text_tags.append(t)
|
text_tags.append(t)
|
||||||
text_tags = list(set(text_tags))
|
text_tags = list(set(text_tags))
|
||||||
@ -646,8 +646,8 @@ class TagsLineEdit(EnLineEdit):
|
|||||||
|
|
||||||
def complete_text(self, text):
|
def complete_text(self, text):
|
||||||
cursor_pos = self.cursorPosition()
|
cursor_pos = self.cursorPosition()
|
||||||
before_text = qstring_to_unicode(self.text())[:cursor_pos]
|
before_text = unicode(self.text())[:cursor_pos]
|
||||||
after_text = qstring_to_unicode(self.text())[cursor_pos:]
|
after_text = unicode(self.text())[cursor_pos:]
|
||||||
prefix_len = len(before_text.split(',')[-1].strip())
|
prefix_len = len(before_text.split(',')[-1].strip())
|
||||||
self.setText('%s%s%s %s' % (before_text[:cursor_pos - prefix_len],
|
self.setText('%s%s%s %s' % (before_text[:cursor_pos - prefix_len],
|
||||||
text, self.separator, after_text))
|
text, self.separator, after_text))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user