diff --git a/src/libprs500/__init__.py b/src/libprs500/__init__.py index f18bf7659b..ee2275a999 100644 --- a/src/libprs500/__init__.py +++ b/src/libprs500/__init__.py @@ -37,6 +37,6 @@ the following rule in C{/etc/udev/rules.d/90-local.rules} :: You may have to adjust the GROUP and the location of the rules file to suit your distribution. """ -__version__ = "0.3.0b2" +__version__ = "0.3.0b3" __docformat__ = "epytext" __author__ = "Kovid Goyal " diff --git a/src/libprs500/gui/database.py b/src/libprs500/gui/database.py index 40e3c87cbf..209da28f58 100644 --- a/src/libprs500/gui/database.py +++ b/src/libprs500/gui/database.py @@ -57,6 +57,7 @@ class LibraryDatabase(object): title, author, publisher, size, cover = os.path.basename(_file), \ None, None, os.stat(_file)[ST_SIZE], None ext = title[title.rfind(".")+1:].lower() if title.find(".") > -1 else None + comments = None if ext == "lrf": lrf = LRFMetaFile(open(_file, "r+b")) title, author, cover, publisher = lrf.title, lrf.author.strip(), \ @@ -65,6 +66,9 @@ class LibraryDatabase(object): publisher = None if "unknown" in author.lower(): author = None + comments = lrf.free_text + if not comments: + comments = None data = open(_file).read() usize = len(data) data = compress(data) @@ -75,7 +79,7 @@ class LibraryDatabase(object): self.con.execute("insert into books_meta (title, authors, publisher, "+\ "size, tags, comments, rating) values "+\ "(?,?,?,?,?,?,?)", \ - (title, author, publisher, size, None, None, None)) + (title, author, publisher, size, None, comments, None)) _id = self.con.execute("select max(id) from books_meta").next()[0] self.con.execute("insert into books_data values (?,?,?,?)", \ (_id, ext, usize, sqlite.Binary(data))) @@ -163,6 +167,9 @@ class LibraryDatabase(object): lrf = LRFMetaFile(s) lrf.author = metadata["authors"] lrf.title = metadata["title"] + # Not sure if I want to override the lrf freetext field + # with a possibly null value + #lrf.free_text = metadata["comments"] except LRFException: pass data = s.getvalue() @@ -201,7 +208,7 @@ class LibraryDatabase(object): return None data = {} for field in ("id", "title", "authors", "publisher", "size", "tags", - "date"): + "date", "comments"): data[field] = row[field] return data diff --git a/src/libprs500/gui/main.py b/src/libprs500/gui/main.py index 6e0c9affdf..e6c68cf8ad 100644 --- a/src/libprs500/gui/main.py +++ b/src/libprs500/gui/main.py @@ -38,10 +38,7 @@ from editbook import EditBookDialog DEFAULT_BOOK_COVER = None -LIBRARY_BOOK_TEMPLATE = QString(" \ - \ -
Formats: %1 \ - Tags: %2
Comments: %3
") +LIBRARY_BOOK_TEMPLATE = QString("Formats: %1
Tags: %2
%3") DEVICE_BOOK_TEMPLATE = QString("\ \ @@ -124,12 +121,13 @@ class Main(QObject, Ui_MainWindow): for r in range(topleft.row(), bottomright.row()+1): self.current_view.resizeRowToContents(r) - def show_book(self, current, previous): - if not len(self.current_view.selectedIndexes()): + def show_book(self, current, previous): + if not current.isValid(): return if self.library_view.isVisible(): formats, tags, comments, cover = self.library_model\ .info(current.row()) + comments = re.sub('\n', '
', comments) data = LIBRARY_BOOK_TEMPLATE.arg(formats).arg(tags).arg(comments) tooltip = "To save the cover, drag it to the desktop.
To \ change the cover drag the new cover onto this picture" @@ -488,7 +486,7 @@ class Main(QObject, Ui_MainWindow): self.df.setText(self.df_template.arg("").arg("").arg("")) window.show() self.library_view.resizeColumnsToContents() - self.library_view.resizeRowsToContents() + self.library_view.resizeRowsToContents() def device_removed(self): diff --git a/src/libprs500/gui/widgets.py b/src/libprs500/gui/widgets.py index 6c53628371..760a0f7071 100644 --- a/src/libprs500/gui/widgets.py +++ b/src/libprs500/gui/widgets.py @@ -526,7 +526,9 @@ class LibraryBooksModel(QAbstractTableModel): tags = row["tags"] if not tags: tags = "" comments = row["comments"] - if not comments: comments = "" + if not comments: + comments = "" + comments = TableView.wrap(comments, width=80) return exts, tags, comments, cover def id_from_index(self, index): return self._data[index.row()]["id"] diff --git a/src/libprs500/lrf/meta.py b/src/libprs500/lrf/meta.py index 3c870d2b73..61b051ed2d 100644 --- a/src/libprs500/lrf/meta.py +++ b/src/libprs500/lrf/meta.py @@ -114,6 +114,8 @@ class xml_field(object): return "" def __set__(self, obj, val): + if val == None: + val = "" document = dom.parseString(obj.info) def create_elem(): elem = document.createElement(self.tag_name)
Title: %1 \  Size: %2
Author: %3