#include "library.h"
#include "containerhandler.h"
+Book::Book()
+{
+}
+
Book::Book(const QString &path_)
{
mPath = "";
#include <QStringList>
#include <QHash>
#include <QIcon>
+#include <QMetaType>
/** A book. */
class Book
};
/** Construct a book from an EPUB file in path. */
- explicit Book(const QString &path);
+ Book(const QString &path);
+
+ /** Default constructor. */
+ Book();
/** Load book from persistent storage. */
void load();
QString mRootPath; //< Path to root item in EPUB dir.
};
+Q_DECLARE_METATYPE(Book)
+
#endif // BOOK_H
#include <QSettings>
-#include <QString>
#include <QDebug>
#include <QFileInfo>
#include "library.h"
+#include "book.h"
Library *Library::mInstance = 0;
-Library::Library(): mCurrent(0)
+Library::Library(QObject *parent): QAbstractListModel(parent), mCurrent(0)
{
load();
}
return mInstance;
}
+int Library::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return mBooks.size();
+}
+
+QVariant Library::data(const QModelIndex &index, int role) const
+{
+ Q_UNUSED(role);
+ Book *book = mBooks[index.row()];
+ return QVariant::fromValue<Book>(*book);
+}
+
void Library::close()
{
delete mInstance;
#ifndef LIBRARY_H
#define LIBRARY_H
-#include <QObject>
+#include <QAbstractListModel>
+#include <QVariant>
#include <QString>
#include <QList>
-#include "book.h"
+class QObject;
+class Book;
/** Library of books. */
-class Library: public QObject
+class Library: public QAbstractListModel
{
Q_OBJECT
public:
static Library *instance();
static void close();
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
void save();
int find(QString path) const;
int find(const Book *book) const;
void currentBookChanged();
private:
- Library();
+ explicit Library(QObject *parent = 0);
~Library();
void load();
void clear();
+dorian (0.0.10-1) unstable; urgency=low
+
+ * Turn library into proper model
+
+ -- Akos Polster <akos@pipacs.com> Fri, 16 Jul 2010 20:00:00 +0200
+
dorian (0.0.9-1) unstable; urgency=low
* Optify Maemo package