Fix #14. Additional minor GUI bug fixes

This commit is contained in:
Kovid Goyal 2007-01-03 18:44:02 +00:00
parent 0af98226c1
commit 07ad6648de
2 changed files with 39 additions and 27 deletions

View File

@ -200,7 +200,6 @@ class Main(QObject, Ui_MainWindow):
self.write_settings()
e.accept()
@report_error
def add(self, action):
settings = QSettings()
_dir = settings.value("add books dialog dir", \
@ -215,20 +214,26 @@ class Main(QObject, Ui_MainWindow):
files = unicode(files.join("|||").toUtf8(), 'utf-8').split("|||")
self.add_books(files)
@report_error
def add_books(self, files):
self.window.setCursor(Qt.WaitCursor)
for _file in files:
_file = os.path.abspath(_file)
self.library_view.model().add_book(_file)
if self.library_view.isVisible():
self.search.clear()
else:
self.library_model.search("")
hv = self.library_view.horizontalHeader()
col = hv.sortIndicatorSection()
order = hv.sortIndicatorOrder()
self.library_view.model().sort(col, order)
self.window.setCursor(Qt.ArrowCursor)
try:
for _file in files:
_file = os.path.abspath(_file)
self.library_view.model().add_book(_file)
if self.library_view.isVisible():
if len(str(self.search.text())):
self.search.clear()
else:
self.library_model.search("")
else:
self.library_model.search("")
hv = self.library_view.horizontalHeader()
col = hv.sortIndicatorSection()
order = hv.sortIndicatorOrder()
self.library_view.model().sort(col, order)
finally:
self.window.setCursor(Qt.ArrowCursor)
@report_error
def edit(self, action):
@ -292,9 +297,12 @@ class Main(QObject, Ui_MainWindow):
order = hv.sortIndicatorOrder()
model = self.card_model if oncard else self.reader_model
model.sort(col, order)
if self.device_view.isVisible() and self.device_view.model()\
== model:
self.search.clear()
if self.device_view.isVisible() and \
self.device_view.model() == model:
if len(str(self.search.text())):
self.search.clear()
else:
self.device_view.model().search("")
else:
model.search("")

View File

@ -165,7 +165,7 @@ class TableView(FileDragAndDrop, QTableView):
@classmethod
def wrap(cls, s, width=20):
cls.wrapper.width = 20
cls.wrapper.width = width
return cls.wrapper.fill(s)
@classmethod
@ -566,12 +566,12 @@ class LibraryBooksModel(QAbstractTableModel):
r = 5
return QVariant(r)
if col == 0:
text = TableView.wrap(row["title"], width=25)
text = TableView.wrap(row["title"], width=35)
elif col == 1:
au = row["authors"]
if au:
au = au.split("&")
jau = [ TableView.wrap(a, width=25).strip() for a in au ]
jau = [ TableView.wrap(a, width=30).strip() for a in au ]
text = "\n".join(jau)
elif col == 2:
text = TableView.human_readable(row["size"])
@ -587,7 +587,7 @@ class LibraryBooksModel(QAbstractTableModel):
return QVariant(text)
elif role == Qt.TextAlignmentRole and index.column() in [2,3,4]:
return QVariant(Qt.AlignRight | Qt.AlignVCenter)
elif role == Qt.ToolTipRole:
elif role == Qt.ToolTipRole and index.isValid():
if index.column() in [0, 1, 4, 5]:
edit = "Double click to <b>edit</b> me<br><br>"
else:
@ -780,21 +780,25 @@ class DeviceBooksModel(QAbstractTableModel):
class DeviceModel(QAbstractListModel):
memory_free = 0
memory_free = 0
card_free = 0
show_reader = False
show_card = False
show_reader = False
show_card = False
def update_devices(self, reader=None, card=None):
if reader != None:
self.show_reader = reader
if card != None:
self.show_card = card
self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), \
self.index(1), self.index(2))
self.emit(SIGNAL("layoutChanged()"))
def rowCount(self, parent):
return 3
base = 1
if self.show_reader:
base += 1
if self.show_card:
base += 1
return base
def update_free_space(self, reader, card):
self.memory_free = reader