book.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef BOOK_H
  2. #define BOOK_H
  3. #include <QObject>
  4. #include <QtDeclarative/QDeclarativeItem>
  5. #include <QStringList>
  6. #include <QPixmap>
  7. #include <QUrl>
  8. class BookPage;
  9. class Book : public QObject
  10. {
  11. Q_OBJECT
  12. //Q_DISABLE_COPY(Book)
  13. Q_PROPERTY(QString name READ getBookName CONSTANT)
  14. Q_PROPERTY(QUrl image READ getListImage CONSTANT)
  15. Q_PROPERTY(QDeclarativeListProperty<BookPage> pages READ pages CONSTANT)
  16. Q_PROPERTY(int count READ count CONSTANT)
  17. public:
  18. Book(QObject *parent = 0);
  19. ~Book();
  20. enum ArchiveType {
  21. Nothing,
  22. Zip,
  23. Rar
  24. };
  25. QDeclarativeListProperty<BookPage> pages();
  26. int count() const;
  27. void setFilenameList(QStringList& list);
  28. void setBookName(QString name);
  29. QString getBookName();
  30. void setListImage(QUrl img);
  31. QUrl getListImage();
  32. void setBookArchiveName(QString name);
  33. QString getBookArchiveName();
  34. Book::ArchiveType getArchiveType();
  35. void setFirstPageFilename(QString name);
  36. QString getFirstPageFilename();
  37. signals:
  38. void imageFilesReady();
  39. public slots:
  40. private:
  41. static BookPage* atFunction(QDeclarativeListProperty<BookPage> *property, int index);
  42. static int countFunction(QDeclarativeListProperty<BookPage> *property);
  43. private:
  44. QList<BookPage*> m_pages;
  45. QString m_bookname;
  46. QUrl m_img;
  47. QString m_archiveName;
  48. QString m_firstPageFilename;
  49. };
  50. QML_DECLARE_TYPE(Book)
  51. #endif // BOOK_H