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
|
||||
|
||||
|
||||
def qstring_to_unicode(q):
|
||||
return unicode(q)
|
||||
|
||||
def human_readable(size):
|
||||
""" Convert a size in bytes into a human readable form """
|
||||
divisor, suffix = 1, "B"
|
||||
@ -380,7 +377,7 @@ class FileIconProvider(QFileIconProvider):
|
||||
if fileinfo.isDir():
|
||||
key = 'dir'
|
||||
else:
|
||||
ext = qstring_to_unicode(fileinfo.completeSuffix()).lower()
|
||||
ext = unicode(fileinfo.completeSuffix()).lower()
|
||||
key = self.key_from_ext(ext)
|
||||
return self.cached_icon(key)
|
||||
|
||||
|
@ -6,7 +6,6 @@ __docformat__ = 'restructuredtext en'
|
||||
''''''
|
||||
from PyQt4.QtGui import QDialog
|
||||
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
|
||||
|
||||
def set_conversion_defaults(window):
|
||||
@ -78,9 +77,9 @@ class ComicConf(QDialog, Ui_Dialog):
|
||||
elif hasattr(g, 'value'):
|
||||
val = g.value()
|
||||
elif hasattr(g, 'itemText'):
|
||||
val = qstring_to_unicode(g.itemText(g.currentIndex()))
|
||||
val = unicode(g.itemText(g.currentIndex()))
|
||||
elif hasattr(g, 'text'):
|
||||
val = qstring_to_unicode(g.text())
|
||||
val = unicode(g.text())
|
||||
else:
|
||||
raise Exception('Bad coding')
|
||||
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.gui2.dialogs.config.config_ui import Ui_Dialog
|
||||
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, \
|
||||
warning_dialog, ResizableDialog
|
||||
from calibre.utils.config import prefs
|
||||
@ -650,7 +650,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
if idx < 0:
|
||||
self.messagebox(_('You must select a column to delete it'))
|
||||
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:
|
||||
self.messagebox(_('The selected column is not a custom column'))
|
||||
return
|
||||
@ -759,12 +759,12 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
config['use_roman_numerals_for_series_number'] = bool(self.roman_numerals.isChecked())
|
||||
config['new_version_notification'] = bool(self.new_version_notification.isChecked())
|
||||
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())]
|
||||
prefs['input_format_order'] = input_cols
|
||||
|
||||
####### 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()) \
|
||||
if self.columns.item(i).checkState()==Qt.Checked]
|
||||
if not cols:
|
||||
|
@ -14,7 +14,7 @@ import traceback
|
||||
from PyQt4.Qt import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread, QDate, \
|
||||
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, \
|
||||
warning_dialog
|
||||
from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog
|
||||
@ -552,12 +552,12 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
|
||||
def fetch_metadata(self):
|
||||
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:
|
||||
author = string_to_authors(unicode(self.authors.text()))[0]
|
||||
except:
|
||||
author = ''
|
||||
publisher = qstring_to_unicode(self.publisher.currentText())
|
||||
publisher = unicode(self.publisher.currentText())
|
||||
if isbn or title or author or publisher:
|
||||
d = FetchMetadata(self, isbn, title, author, publisher, self.timeout)
|
||||
self._fetch_metadata_scope = d
|
||||
@ -623,12 +623,12 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
|
||||
def remove_unused_series(self):
|
||||
self.db.remove_unused_series()
|
||||
idx = qstring_to_unicode(self.series.currentText())
|
||||
idx = unicode(self.series.currentText())
|
||||
self.series.clear()
|
||||
self.initialize_series()
|
||||
if idx:
|
||||
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)
|
||||
break
|
||||
|
||||
@ -648,7 +648,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
self.db.set_isbn(self.id,
|
||||
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_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
|
||||
unicode(self.tags.text()).split(',')], notify=False)
|
||||
self.db.set_series(self.id,
|
||||
|
@ -5,7 +5,7 @@ from PyQt4.QtGui import QDialog, QLineEdit
|
||||
from PyQt4.QtCore import SIGNAL, Qt
|
||||
|
||||
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):
|
||||
|
||||
@ -32,10 +32,10 @@ class PasswordDialog(QDialog, Ui_Dialog):
|
||||
self.gui_password.setEchoMode(QLineEdit.Normal)
|
||||
|
||||
def username(self):
|
||||
return qstring_to_unicode(self.gui_username.text())
|
||||
return unicode(self.gui_username.text())
|
||||
|
||||
def password(self):
|
||||
return qstring_to_unicode(self.gui_password.text())
|
||||
return unicode(self.gui_password.text())
|
||||
|
||||
def accept(self):
|
||||
dynamic.set(self.cfg_key+'__un', unicode(self.gui_username.text()))
|
||||
|
@ -4,7 +4,6 @@ import re
|
||||
from PyQt4.QtGui import QDialog
|
||||
|
||||
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
|
||||
|
||||
class SearchDialog(QDialog, Ui_Dialog):
|
||||
@ -48,11 +47,11 @@ class SearchDialog(QDialog, Ui_Dialog):
|
||||
return ans
|
||||
|
||||
def token(self):
|
||||
txt = qstring_to_unicode(self.text.text()).strip()
|
||||
txt = unicode(self.text.text()).strip()
|
||||
if txt:
|
||||
if self.negate.isChecked():
|
||||
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):
|
||||
tok = '"%s"'%tok
|
||||
return tok
|
||||
|
@ -7,7 +7,7 @@ from PyQt4.QtCore import SIGNAL, Qt
|
||||
from PyQt4.QtGui import QDialog, QIcon, QListWidgetItem
|
||||
|
||||
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.constants import islinux
|
||||
|
||||
@ -138,7 +138,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
|
||||
def add_category(self):
|
||||
self.save_category()
|
||||
cat_name = qstring_to_unicode(self.input_box.text()).strip()
|
||||
cat_name = unicode(self.input_box.text()).strip()
|
||||
if cat_name == '':
|
||||
return False
|
||||
if cat_name not in self.categories:
|
||||
|
@ -4,7 +4,6 @@ from PyQt4.QtCore import SIGNAL, Qt
|
||||
from PyQt4.QtGui import QDialog
|
||||
|
||||
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.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_()
|
||||
return
|
||||
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)
|
||||
else:
|
||||
deletes.append(item)
|
||||
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?'),
|
||||
'<p>'+_('The following tags are used by one or more books. '
|
||||
'Are you certain you want to delete them?')+'<br>'+ct):
|
||||
deletes += confirms
|
||||
|
||||
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))
|
||||
|
||||
|
||||
def apply_tags(self, item=None):
|
||||
items = self.available_tags.selectedItems() if item is None else [item]
|
||||
for item in items:
|
||||
tag = qstring_to_unicode(item.text())
|
||||
tag = unicode(item.text())
|
||||
self.tags.append(tag)
|
||||
self.available_tags.takeItem(self.available_tags.row(item))
|
||||
|
||||
@ -90,7 +89,7 @@ class TagEditor(QDialog, Ui_TagEditor):
|
||||
def unapply_tags(self, item=None):
|
||||
items = self.applied_tags.selectedItems() if item is None else [item]
|
||||
for item in items:
|
||||
tag = qstring_to_unicode(item.text())
|
||||
tag = unicode(item.text())
|
||||
self.tags.remove(tag)
|
||||
self.available_tags.addItem(tag)
|
||||
|
||||
@ -102,7 +101,7 @@ class TagEditor(QDialog, Ui_TagEditor):
|
||||
self.available_tags.sortItems()
|
||||
|
||||
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:
|
||||
tag = tag.strip()
|
||||
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.news import AutomaticNewsRecipe
|
||||
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
|
||||
from calibre.gui2.widgets import PythonHighlighter
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
@ -162,19 +162,19 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
|
||||
else:
|
||||
self.stacks.setCurrentIndex(1)
|
||||
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')
|
||||
self.source_code.setPlainText(src.replace('BasicUserRecipe', 'AdvancedUserRecipe'))
|
||||
self.highlighter = PythonHighlighter(self.source_code.document())
|
||||
|
||||
|
||||
def add_feed(self, *args):
|
||||
title = qstring_to_unicode(self.feed_title.text()).strip()
|
||||
title = unicode(self.feed_title.text()).strip()
|
||||
if not title:
|
||||
error_dialog(self, _('Feed must have a title'),
|
||||
_('The feed must have a title')).exec_()
|
||||
return
|
||||
url = qstring_to_unicode(self.feed_url.text()).strip()
|
||||
url = unicode(self.feed_url.text()).strip()
|
||||
if not url:
|
||||
error_dialog(self, _('Feed must have a URL'),
|
||||
_('The feed %s must have a URL')%title).exec_()
|
||||
@ -190,7 +190,7 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
|
||||
|
||||
def options_to_profile(self):
|
||||
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:
|
||||
title = classname
|
||||
self.profile_title.setText(title)
|
||||
@ -229,7 +229,7 @@ class %(classname)s(%(base_class)s):
|
||||
return
|
||||
profile = src
|
||||
else:
|
||||
src = qstring_to_unicode(self.source_code.toPlainText())
|
||||
src = unicode(self.source_code.toPlainText())
|
||||
try:
|
||||
title = compile_recipe(src).title
|
||||
except Exception, err:
|
||||
|
@ -19,7 +19,7 @@ from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, pyqtSignal, \
|
||||
from calibre import strftime
|
||||
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.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.widgets import EnLineEdit, TagsLineEdit
|
||||
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):
|
||||
typ = self.custom_columns[colhead]['datatype']
|
||||
if typ in ('text', 'comments'):
|
||||
val = qstring_to_unicode(value.toString()).strip()
|
||||
val = unicode(value.toString()).strip()
|
||||
val = val if val else None
|
||||
if typ == 'bool':
|
||||
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 *= 2
|
||||
elif typ in ('int', 'float'):
|
||||
val = qstring_to_unicode(value.toString()).strip()
|
||||
val = unicode(value.toString()).strip()
|
||||
if val is None or not val:
|
||||
val = None
|
||||
elif typ == 'datetime':
|
||||
@ -1034,7 +1034,7 @@ class BooksView(TableView):
|
||||
and represent files with extensions.
|
||||
'''
|
||||
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)]
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
@ -1390,7 +1390,7 @@ class DeviceBooksModel(BooksModel):
|
||||
row, col = index.row(), index.column()
|
||||
if col in [2, 3]:
|
||||
return False
|
||||
val = qstring_to_unicode(value.toString()).strip()
|
||||
val = unicode(value.toString()).strip()
|
||||
idx = self.map[row]
|
||||
if col == 0:
|
||||
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.BeautifulSoup import Tag
|
||||
from calibre.ebooks.hyphenate import hyphenate_word
|
||||
from calibre.gui2 import qstring_to_unicode
|
||||
|
||||
WEIGHT_MAP = lambda wt : int((wt/10.)-1)
|
||||
NULL = lambda a, b: a
|
||||
@ -527,12 +526,12 @@ class Line(QGraphicsItem):
|
||||
while True:
|
||||
word = words.next()
|
||||
word.highlight = False
|
||||
if tokens[0] in qstring_to_unicode(word.string).lower():
|
||||
if tokens[0] in unicode(word.string).lower():
|
||||
matches.append(word)
|
||||
for c in range(1, len(tokens)):
|
||||
word = words.next()
|
||||
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
|
||||
matches.append(word)
|
||||
for w in matches:
|
||||
@ -556,7 +555,7 @@ class Line(QGraphicsItem):
|
||||
if isinstance(tok, (int, float)):
|
||||
s += ' '
|
||||
elif isinstance(tok, Word):
|
||||
s += qstring_to_unicode(tok.string)
|
||||
s += unicode(tok.string)
|
||||
return s
|
||||
|
||||
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 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.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.notify import get_notifier
|
||||
@ -260,7 +260,7 @@ class StatusBar(QStatusBar):
|
||||
return ret
|
||||
|
||||
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())
|
||||
|
||||
def show_book_info(self):
|
||||
@ -268,7 +268,7 @@ class StatusBar(QStatusBar):
|
||||
|
||||
def job_added(self, nnum):
|
||||
jobs = self.movie_button.jobs
|
||||
src = qstring_to_unicode(jobs.text())
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
@ -276,7 +276,7 @@ class StatusBar(QStatusBar):
|
||||
|
||||
def job_done(self, nnum):
|
||||
jobs = self.movie_button.jobs
|
||||
src = qstring_to_unicode(jobs.text())
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
|
@ -9,7 +9,7 @@ from PyQt4.Qt import Qt, QDialog, QAbstractTableModel, QVariant, SIGNAL, \
|
||||
QModelIndex, QInputDialog, QLineEdit, QFileDialog
|
||||
|
||||
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):
|
||||
def __init__(self, parent, bookmarks):
|
||||
@ -111,7 +111,7 @@ class BookmarkTableModel(QAbstractTableModel):
|
||||
|
||||
def setData(self, index, value, role):
|
||||
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)
|
||||
return True
|
||||
return False
|
||||
|
@ -14,7 +14,7 @@ from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
||||
QMenu, QStringListModel, QCompleter, QStringList
|
||||
|
||||
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.filename_pattern_ui import Ui_Form
|
||||
from calibre import fit_image
|
||||
@ -72,7 +72,7 @@ class FilenamePattern(QWidget, Ui_Form):
|
||||
error_dialog(self, _('Invalid regular expression'),
|
||||
_('Invalid regular expression: %s')%err).exec_()
|
||||
return
|
||||
mi = metadata_from_filename(qstring_to_unicode(self.filename.text()), pat)
|
||||
mi = metadata_from_filename(unicode(self.filename.text()), pat)
|
||||
if mi.title:
|
||||
self.title.setText(mi.title)
|
||||
else:
|
||||
@ -96,7 +96,7 @@ class FilenamePattern(QWidget, Ui_Form):
|
||||
|
||||
|
||||
def pattern(self):
|
||||
pat = qstring_to_unicode(self.re.text())
|
||||
pat = unicode(self.re.text())
|
||||
return re.compile(pat)
|
||||
|
||||
def commit(self):
|
||||
@ -158,7 +158,7 @@ class ImageView(QLabel):
|
||||
and represent files with extensions.
|
||||
'''
|
||||
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)]
|
||||
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)
|
||||
|
||||
def text_changed(self, text):
|
||||
all_text = qstring_to_unicode(text)
|
||||
all_text = unicode(text)
|
||||
text = all_text[:self.cursorPosition()]
|
||||
prefix = text.split(',')[-1].strip()
|
||||
|
||||
text_tags = []
|
||||
for t in all_text.split(self.separator):
|
||||
t1 = qstring_to_unicode(t).strip()
|
||||
t1 = unicode(t).strip()
|
||||
if t1 != '':
|
||||
text_tags.append(t)
|
||||
text_tags = list(set(text_tags))
|
||||
@ -646,8 +646,8 @@ class TagsLineEdit(EnLineEdit):
|
||||
|
||||
def complete_text(self, text):
|
||||
cursor_pos = self.cursorPosition()
|
||||
before_text = qstring_to_unicode(self.text())[:cursor_pos]
|
||||
after_text = qstring_to_unicode(self.text())[cursor_pos:]
|
||||
before_text = unicode(self.text())[:cursor_pos]
|
||||
after_text = unicode(self.text())[cursor_pos:]
|
||||
prefix_len = len(before_text.split(',')[-1].strip())
|
||||
self.setText('%s%s%s %s' % (before_text[:cursor_pos - prefix_len],
|
||||
text, self.separator, after_text))
|
||||
|
Loading…
x
Reference in New Issue
Block a user