mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Fix duplicates dialog for large lists of duplicates and remember sorted column
This commit is contained in:
parent
7e9ffe0445
commit
d373ae7d13
@ -247,6 +247,7 @@ _check_symlinks_prescript()
|
|||||||
f.close()
|
f.close()
|
||||||
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|
||||||
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
|
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
|
||||||
|
shutil.copyfile('/usr/lib/libiconv.2.dylib', os.path.join(frameworks_dir, 'libiconv.2.dylib'))
|
||||||
self.add_plugins()
|
self.add_plugins()
|
||||||
|
|
||||||
|
|
||||||
@ -264,10 +265,15 @@ _check_symlinks_prescript()
|
|||||||
shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False)
|
shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False)
|
||||||
|
|
||||||
print
|
print
|
||||||
print 'Adding libxml2'
|
print 'Adding lxml dependencies'
|
||||||
|
subprocess.check_call('install_name_tool -id @executable_path/../Frameworks/libiconv.2.dylib '+ os.path.join(frameworks_dir, 'libiconv.2.dylib'), shell=True)
|
||||||
|
deps = []
|
||||||
for f in glob.glob(os.path.expanduser('~/libxml2/*')):
|
for f in glob.glob(os.path.expanduser('~/libxml2/*')):
|
||||||
shutil.copyfile(f, os.path.join(frameworks_dir, os.path.basename(f)))
|
tgt = os.path.join(frameworks_dir, os.path.basename(f))
|
||||||
|
shutil.copyfile(f, tgt)
|
||||||
|
deps.append(tgt)
|
||||||
self.fix_lxml_dependencies(resource_dir)
|
self.fix_lxml_dependencies(resource_dir)
|
||||||
|
self.fix_misc_dependencies(deps)
|
||||||
|
|
||||||
print
|
print
|
||||||
print 'Adding IPython'
|
print 'Adding IPython'
|
||||||
|
113
src/calibre/gui2/dialogs/warning.ui
Normal file
113
src/calibre/gui2/dialogs/warning.ui
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<ui version="4.0" >
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>727</width>
|
||||||
|
<height>432</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon" >
|
||||||
|
<iconset resource="../images.qrc" >
|
||||||
|
<normaloff>:/images/dialog_warning.svg</normaloff>:/images/dialog_warning.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="msg" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap" >
|
||||||
|
<pixmap resource="../images.qrc" >:/images/dialog_warning.svg</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="details" />
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" >
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons" >
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../images.qrc" />
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -49,6 +49,7 @@ from calibre.ebooks.lrf import preferred_source_formats as LRF_PREFERRED_SOURCE_
|
|||||||
from calibre.library.database2 import LibraryDatabase2, CoverCache
|
from calibre.library.database2 import LibraryDatabase2, CoverCache
|
||||||
from calibre.parallel import JobKilled
|
from calibre.parallel import JobKilled
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
|
from calibre.gui2.widgets import WarningDialog
|
||||||
|
|
||||||
class Main(MainWindow, Ui_MainWindow):
|
class Main(MainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
@ -236,7 +237,7 @@ in which you want to store your books files. Any existing books will be automati
|
|||||||
os.remove(self.olddb.dbpath)
|
os.remove(self.olddb.dbpath)
|
||||||
self.olddb = None
|
self.olddb = None
|
||||||
prefs['library_path'] = self.library_path
|
prefs['library_path'] = self.library_path
|
||||||
self.library_view.sortByColumn(3, Qt.DescendingOrder)
|
self.library_view.sortByColumn(*dynamic.get('sort_column', (3, Qt.DescendingOrder)))
|
||||||
if not self.library_view.restore_column_widths():
|
if not self.library_view.restore_column_widths():
|
||||||
self.library_view.resizeColumnsToContents()
|
self.library_view.resizeColumnsToContents()
|
||||||
self.library_view.resizeRowsToContents()
|
self.library_view.resizeRowsToContents()
|
||||||
@ -504,10 +505,10 @@ in which you want to store your books files. Any existing books will be automati
|
|||||||
files = _('<p>Books with the same title as the following already exist in the database. Add them anyway?<ul>')
|
files = _('<p>Books with the same title as the following already exist in the database. Add them anyway?<ul>')
|
||||||
for mi in duplicates[2]:
|
for mi in duplicates[2]:
|
||||||
files += '<li>'+mi.title+'</li>\n'
|
files += '<li>'+mi.title+'</li>\n'
|
||||||
d = question_dialog(self, _('Duplicates found!'), files+'</ul></p>')
|
d = WarningDialog(_('Duplicates found!'), _('Duplicates found!'), files+'</ul></p>', parent=self)
|
||||||
if d.exec_() == QMessageBox.Yes:
|
if d.exec_() == QDialog.Accepted:
|
||||||
model.add_books(*duplicates, **dict(add_duplicates=True))
|
model.add_books(*duplicates, **dict(add_duplicates=True))
|
||||||
model.resort()
|
self.library_view.sortByColumn(3, Qt.DescendingOrder)
|
||||||
model.research()
|
model.research()
|
||||||
else:
|
else:
|
||||||
self.upload_books(paths, names, infos, on_card=on_card)
|
self.upload_books(paths, names, infos, on_card=on_card)
|
||||||
@ -1262,6 +1263,7 @@ in which you want to store your books files. Any existing books will be automati
|
|||||||
|
|
||||||
def write_settings(self):
|
def write_settings(self):
|
||||||
config.set('main_window_geometry', self.saveGeometry())
|
config.set('main_window_geometry', self.saveGeometry())
|
||||||
|
dynamic.set('sort_column', self.library_view.model().sorted_on)
|
||||||
self.library_view.write_settings()
|
self.library_view.write_settings()
|
||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
self.memory_view.write_settings()
|
self.memory_view.write_settings()
|
||||||
|
@ -6,7 +6,7 @@ Miscellaneous widgets used in the GUI
|
|||||||
import re, os
|
import re, os
|
||||||
from PyQt4.QtGui import QListView, QIcon, QFont, QLabel, QListWidget, \
|
from PyQt4.QtGui import QListView, QIcon, QFont, QLabel, QListWidget, \
|
||||||
QListWidgetItem, QTextCharFormat, QApplication, \
|
QListWidgetItem, QTextCharFormat, QApplication, \
|
||||||
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
QSyntaxHighlighter, QCursor, QColor, QWidget, QDialog, \
|
||||||
QAbstractItemDelegate, QPixmap, QStyle, QFontMetrics
|
QAbstractItemDelegate, QPixmap, QStyle, QFontMetrics
|
||||||
from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, SIGNAL, \
|
from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, SIGNAL, \
|
||||||
QObject, QRegExp, QString, QSettings
|
QObject, QRegExp, QString, QSettings
|
||||||
@ -19,8 +19,16 @@ from calibre import fit_image
|
|||||||
from calibre.utils.fontconfig import find_font_families
|
from calibre.utils.fontconfig import find_font_families
|
||||||
from calibre.ebooks.metadata.meta import metadata_from_filename
|
from calibre.ebooks.metadata.meta import metadata_from_filename
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
|
from calibre.gui2.dialogs.warning_ui import Ui_Dialog as Ui_WarningDialog
|
||||||
|
|
||||||
|
class WarningDialog(QDialog, Ui_WarningDialog):
|
||||||
|
|
||||||
|
def __init__(self, title, msg, details, parent=None):
|
||||||
|
QDialog.__init__(self, parent)
|
||||||
|
self.setupUi(self)
|
||||||
|
self.setWindowTitle(title)
|
||||||
|
self.msg.setText(msg)
|
||||||
|
self.details.setText(details)
|
||||||
|
|
||||||
class FilenamePattern(QWidget, Ui_Form):
|
class FilenamePattern(QWidget, Ui_Form):
|
||||||
|
|
||||||
|
@ -381,6 +381,9 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
path = os.path.join(self.library_path, self.path(id, True))
|
path = os.path.join(self.library_path, self.path(id, True))
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
parent = os.path.dirname(path)
|
||||||
|
if not os.listdir(parent):
|
||||||
|
shutil.rmtree(parent)
|
||||||
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
@ -504,7 +507,8 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
stream = open(path, 'rb')
|
stream = open(path, 'rb')
|
||||||
self.add_format(id, ext, stream, index_is_id=True)
|
self.add_format(id, ext, stream, index_is_id=True)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
|
|
||||||
def move_library_to(self, newloc):
|
def move_library_to(self, newloc):
|
||||||
if not os.path.exists(newloc):
|
if not os.path.exists(newloc):
|
||||||
os.makedirs(newloc)
|
os.makedirs(newloc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user