mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Merge from custcol trunk
This commit is contained in:
commit
eda505f755
@ -4,6 +4,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
from calibre.customize import Plugin as _Plugin
|
from calibre.customize import Plugin as _Plugin
|
||||||
|
|
||||||
@ -238,7 +239,7 @@ class OutputProfile(Plugin):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tags_to_string(cls, tags):
|
def tags_to_string(cls, tags):
|
||||||
return ', '.join(tags)
|
return escape(', '.join(tags))
|
||||||
|
|
||||||
class iPadOutput(OutputProfile):
|
class iPadOutput(OutputProfile):
|
||||||
|
|
||||||
@ -383,7 +384,8 @@ class KindleOutput(OutputProfile):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tags_to_string(cls, tags):
|
def tags_to_string(cls, tags):
|
||||||
return 'ttt '.join(tags)+'ttt '
|
return u'%s <br/><span style="color: white">%s</span>' % (', '.join(tags),
|
||||||
|
'ttt '.join(tags)+'ttt ')
|
||||||
|
|
||||||
class KindleDXOutput(OutputProfile):
|
class KindleDXOutput(OutputProfile):
|
||||||
|
|
||||||
@ -399,7 +401,8 @@ class KindleDXOutput(OutputProfile):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tags_to_string(cls, tags):
|
def tags_to_string(cls, tags):
|
||||||
return 'ttt '.join(tags)+'ttt '
|
return u'%s <br/><span style="color: white">%s</span>' % (', '.join(tags),
|
||||||
|
'ttt '.join(tags)+'ttt ')
|
||||||
|
|
||||||
class IlliadOutput(OutputProfile):
|
class IlliadOutput(OutputProfile):
|
||||||
|
|
||||||
|
@ -34,6 +34,6 @@ class Worker(threading.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
'''Thread loops taking jobs from the queue as they become available'''
|
'''Thread loops taking jobs from the queue as they become available'''
|
||||||
while True:
|
while True:
|
||||||
job = self.jobs.get(True, None)
|
self.jobs.get(True, None)
|
||||||
# Do job
|
# Do job
|
||||||
self.jobs.task_done()
|
self.jobs.task_done()
|
@ -99,7 +99,7 @@ class Jacket(object):
|
|||||||
except:
|
except:
|
||||||
tags = []
|
tags = []
|
||||||
if tags:
|
if tags:
|
||||||
tags = '<b>Tags: </b>' + escape(self.opts.dest.tags_to_string(tags))
|
tags = '<b>Tags: </b>' + self.opts.dest.tags_to_string(tags)
|
||||||
else:
|
else:
|
||||||
tags = ''
|
tags = ''
|
||||||
try:
|
try:
|
||||||
|
@ -354,7 +354,6 @@ if another paragraph_def is found, the state changes to collect_tokens.
|
|||||||
def __tab_stop_func(self, line):
|
def __tab_stop_func(self, line):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
type = 'tabs-%s' % self.__tab_type
|
|
||||||
self.__att_val_dict['tabs'] += '%s:' % self.__tab_type
|
self.__att_val_dict['tabs'] += '%s:' % self.__tab_type
|
||||||
self.__att_val_dict['tabs'] += '%s;' % line[20:-1]
|
self.__att_val_dict['tabs'] += '%s;' % line[20:-1]
|
||||||
self.__tab_type = 'left'
|
self.__tab_type = 'left'
|
||||||
@ -373,7 +372,6 @@ if another paragraph_def is found, the state changes to collect_tokens.
|
|||||||
"""
|
"""
|
||||||
leader = self.__tab_type_dict.get(self.__token_info)
|
leader = self.__tab_type_dict.get(self.__token_info)
|
||||||
if leader != None:
|
if leader != None:
|
||||||
type = 'tabs-%s' % self.__tab_type
|
|
||||||
self.__att_val_dict['tabs'] += '%s^' % leader
|
self.__att_val_dict['tabs'] += '%s^' % leader
|
||||||
else:
|
else:
|
||||||
if self.__run_level > 3:
|
if self.__run_level > 3:
|
||||||
|
@ -318,7 +318,6 @@ class Styles:
|
|||||||
Try to add the number to dictionary entry tabs-left, or tabs-right, etc.
|
Try to add the number to dictionary entry tabs-left, or tabs-right, etc.
|
||||||
If the dictionary entry doesn't exist, create one.
|
If the dictionary entry doesn't exist, create one.
|
||||||
"""
|
"""
|
||||||
type = 'tabs-%s' % self.__tab_type
|
|
||||||
try:
|
try:
|
||||||
if self.__leader_found:
|
if self.__leader_found:
|
||||||
self.__styles_dict['par'][self.__styles_num]['tabs']\
|
self.__styles_dict['par'][self.__styles_num]['tabs']\
|
||||||
@ -362,7 +361,6 @@ class Styles:
|
|||||||
leader = self.__tab_type_dict.get(self.__token_info)
|
leader = self.__tab_type_dict.get(self.__token_info)
|
||||||
if leader != None:
|
if leader != None:
|
||||||
leader += '^'
|
leader += '^'
|
||||||
type = 'tabs-%s' % self.__tab_type
|
|
||||||
try:
|
try:
|
||||||
self.__styles_dict['par'][self.__styles_num]['tabs'] += ':%s;' % leader
|
self.__styles_dict['par'][self.__styles_num]['tabs'] += ':%s;' % leader
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
|
||||||
from PyQt4.Qt import QDialog
|
from PyQt4.Qt import QDialog
|
||||||
from calibre.gui2 import ResizableDialog
|
|
||||||
from calibre.gui2.dialogs.comments_dialog_ui import Ui_CommentsDialog
|
from calibre.gui2.dialogs.comments_dialog_ui import Ui_CommentsDialog
|
||||||
|
|
||||||
class CommentsDialog(QDialog, Ui_CommentsDialog):
|
class CommentsDialog(QDialog, Ui_CommentsDialog):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import os, re, time, textwrap, sys, copy
|
import os, re, time, textwrap, copy
|
||||||
|
|
||||||
from PyQt4.Qt import QDialog, QListWidgetItem, QIcon, \
|
from PyQt4.Qt import QDialog, QListWidgetItem, QIcon, \
|
||||||
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
|
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
|
||||||
@ -17,7 +17,6 @@ from calibre.gui2 import qstring_to_unicode, 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
|
||||||
from calibre.gui2.library import BooksModel
|
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.ebooks.oeb.iterator import is_supported
|
from calibre.ebooks.oeb.iterator import is_supported
|
||||||
from calibre.library import server_config
|
from calibre.library import server_config
|
||||||
@ -666,10 +665,10 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def add_custcol(self):
|
def add_custcol(self):
|
||||||
d = CreateCustomColumn(self, False, self.model.orig_headers, ALL_COLUMNS)
|
CreateCustomColumn(self, False, self.model.orig_headers, ALL_COLUMNS)
|
||||||
|
|
||||||
def edit_custcol(self):
|
def edit_custcol(self):
|
||||||
d = CreateCustomColumn(self, True, self.model.orig_headers, ALL_COLUMNS)
|
CreateCustomColumn(self, True, self.model.orig_headers, ALL_COLUMNS)
|
||||||
|
|
||||||
def view_server_logs(self):
|
def view_server_logs(self):
|
||||||
from calibre.library.server import log_access_file, log_error_file
|
from calibre.library.server import log_access_file, log_error_file
|
||||||
|
@ -3,10 +3,9 @@ __copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
'''Dialog to create a new custom column'''
|
'''Dialog to create a new custom column'''
|
||||||
|
|
||||||
from PyQt4.QtCore import SIGNAL, QObject
|
from PyQt4.QtCore import SIGNAL
|
||||||
from PyQt4.Qt import QDialog, Qt, QMessageBox, QListWidgetItem, QVariant
|
from PyQt4.Qt import QDialog, Qt, QListWidgetItem, QVariant
|
||||||
from calibre.gui2.dialogs.config.create_custom_column_ui import Ui_QCreateCustomColumn
|
from calibre.gui2.dialogs.config.create_custom_column_ui import Ui_QCreateCustomColumn
|
||||||
from calibre.gui2 import ALL_COLUMNS, qstring_to_unicode
|
|
||||||
|
|
||||||
class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
||||||
column_types = {
|
column_types = {
|
||||||
@ -38,7 +37,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
if idx < 0:
|
if idx < 0:
|
||||||
self.parent.messagebox(_('No column has been selected'))
|
self.parent.messagebox(_('No column has been selected'))
|
||||||
return
|
return
|
||||||
col = qstring_to_unicode(parent.columns.item(idx).data(Qt.UserRole).toString())
|
col = unicode(parent.columns.item(idx).data(Qt.UserRole).toString())
|
||||||
if col not in parent.custcols:
|
if col not in parent.custcols:
|
||||||
self.parent.messagebox(_('Selected column is not a user-defined column'))
|
self.parent.messagebox(_('Selected column is not a user-defined column'))
|
||||||
return
|
return
|
||||||
@ -54,8 +53,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
col = qstring_to_unicode(self.column_name_box.text())
|
col = unicode(self.column_name_box.text())
|
||||||
col_heading = qstring_to_unicode(self.column_heading_box.text())
|
col_heading = unicode(self.column_heading_box.text())
|
||||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||||
if col_type == '*text':
|
if col_type == '*text':
|
||||||
col_type='text'
|
col_type='text'
|
||||||
@ -88,8 +87,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
if bad_head:
|
if bad_head:
|
||||||
self.parent.messagebox(_('The heading %s is already used')%col_heading)
|
self.parent.messagebox(_('The heading %s is already used')%col_heading)
|
||||||
return
|
return
|
||||||
if col.find(':') >= 0 or col.find(' ') >= 0 and \
|
if ':' in col or ' ' in col or col.lower() != col:
|
||||||
(not is_alpha(col) or is_lower(col)):
|
|
||||||
self.parent.messagebox(_('The lookup name must be lower case and cannot contain ":"s or spaces'))
|
self.parent.messagebox(_('The lookup name must be lower case and cannot contain ":"s or spaces'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2,16 +2,12 @@ __license__ = 'GPL v3'
|
|||||||
|
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
from copy import copy
|
|
||||||
|
|
||||||
from PyQt4.QtCore import SIGNAL, Qt, QVariant
|
from PyQt4.QtCore import SIGNAL, Qt
|
||||||
from PyQt4.QtGui import QDialog, QDialogButtonBox, QLineEdit, QComboBox, \
|
from PyQt4.QtGui import QDialog, QIcon, QListWidgetItem
|
||||||
QIcon, QListWidgetItem
|
|
||||||
from PyQt4.Qt import QString
|
|
||||||
|
|
||||||
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 qstring_to_unicode, config
|
||||||
from calibre.gui2 import question_dialog, error_dialog
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -6,16 +6,15 @@ import os, textwrap, traceback, re, shutil, functools
|
|||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from math import cos, sin, pi
|
from math import cos, sin, pi
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
from PyQt4.QtGui import QTableView, QAbstractItemView, QColor, \
|
from PyQt4.QtGui import QTableView, QAbstractItemView, QColor, \
|
||||||
QPainterPath, QLinearGradient, QBrush, \
|
QPainterPath, QLinearGradient, QBrush, \
|
||||||
QPen, QStyle, QPainter, QStyleOptionViewItemV4, \
|
QPen, QStyle, QPainter, QStyleOptionViewItemV4, \
|
||||||
QIcon, QImage, QMenu, \
|
QIcon, QImage, QMenu, \
|
||||||
QStyledItemDelegate, QCompleter, QIntValidator, \
|
QStyledItemDelegate, QCompleter, QIntValidator, \
|
||||||
QPlainTextEdit, QDoubleValidator, QCheckBox, QMessageBox
|
QDoubleValidator, QCheckBox
|
||||||
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, pyqtSignal, \
|
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, pyqtSignal, \
|
||||||
SIGNAL, QObject, QSize, QModelIndex, QDate, QRect
|
SIGNAL, QObject, QSize, QModelIndex, QDate
|
||||||
|
|
||||||
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
|
||||||
@ -25,7 +24,7 @@ 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
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.utils.config import tweaks, prefs
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.date import dt_factory, qt_to_dt, isoformat
|
from calibre.utils.date import dt_factory, qt_to_dt, isoformat
|
||||||
from calibre.utils.pyparsing import ParseException
|
from calibre.utils.pyparsing import ParseException
|
||||||
from calibre.utils.search_query_parser import SearchQueryParser
|
from calibre.utils.search_query_parser import SearchQueryParser
|
||||||
@ -222,10 +221,7 @@ class CcBoolDelegate(QStyledItemDelegate):
|
|||||||
QStyledItemDelegate.__init__(self, parent)
|
QStyledItemDelegate.__init__(self, parent)
|
||||||
|
|
||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
m = index.model()
|
|
||||||
col = m.column_map[index.column()]
|
|
||||||
editor = QCheckBox(parent)
|
editor = QCheckBox(parent)
|
||||||
val = m.db.data[index.row()][m.db.FIELD_MAP[m.custom_columns[col]['num']]]
|
|
||||||
if tweaks['bool_custom_columns_are_tristate'] == 'no':
|
if tweaks['bool_custom_columns_are_tristate'] == 'no':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -8,7 +8,6 @@ Browsing book collection by tags.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
from copy import copy
|
|
||||||
|
|
||||||
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, \
|
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, \
|
||||||
QFont, SIGNAL, QSize, QIcon, QPoint, \
|
QFont, SIGNAL, QSize, QIcon, QPoint, \
|
||||||
|
@ -62,8 +62,6 @@ from calibre.library.caches import CoverCache
|
|||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.dialogs.tag_categories import TagCategories
|
from calibre.gui2.dialogs.tag_categories import TagCategories
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class SaveMenu(QMenu):
|
class SaveMenu(QMenu):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
@ -129,7 +127,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
pixmap_to_data(pixmap))
|
pixmap_to_data(pixmap))
|
||||||
|
|
||||||
def __init__(self, listener, opts, actions, parent=None):
|
def __init__(self, listener, opts, actions, parent=None):
|
||||||
self.last_time = datetime.now()
|
self.last_time = datetime.datetime.now()
|
||||||
self.preferences_action, self.quit_action = actions
|
self.preferences_action, self.quit_action = actions
|
||||||
self.spare_servers = []
|
self.spare_servers = []
|
||||||
self.must_restart_before_config = False
|
self.must_restart_before_config = False
|
||||||
@ -2167,7 +2165,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
return
|
return
|
||||||
for row in rows:
|
for row in rows:
|
||||||
path = self.library_view.model().db.abspath(row.row())
|
path = self.library_view.model().db.abspath(row.row())
|
||||||
QDesktopServices.openUrl(QUrl('file:'+path))
|
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||||
|
|
||||||
|
|
||||||
def view_book(self, triggered):
|
def view_book(self, triggered):
|
||||||
|
@ -13,7 +13,7 @@ from datetime import timedelta
|
|||||||
from PyQt4.QtCore import QThread, QReadWriteLock
|
from PyQt4.QtCore import QThread, QReadWriteLock
|
||||||
from PyQt4.QtGui import QImage
|
from PyQt4.QtGui import QImage
|
||||||
|
|
||||||
from calibre.utils.config import tweaks, prefs
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.date import parse_date, now
|
from calibre.utils.date import parse_date, now
|
||||||
from calibre.utils.search_query_parser import SearchQueryParser
|
from calibre.utils.search_query_parser import SearchQueryParser
|
||||||
from calibre.utils.pyparsing import ParseException
|
from calibre.utils.pyparsing import ParseException
|
||||||
|
@ -54,7 +54,7 @@ def set_metadata(stream, mi):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
ret = p.wait()
|
p.wait()
|
||||||
break
|
break
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
if e.errno == errno.EINTR:
|
if e.errno == errno.EINTR:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user