Browse Source

Make that QXlsx::Document is the only subclass of QObject

master
Debao Zhang 11 years ago
parent
commit
c5bc41bacb
  1. 4
      src/xlsx/xlsxdocument.cpp
  2. 2
      src/xlsx/xlsxdocument_p.h
  3. 3
      src/xlsx/xlsxdrawing.cpp
  4. 7
      src/xlsx/xlsxdrawing_p.h
  5. 2
      src/xlsx/xlsxrelationships_p.h
  6. 2
      src/xlsx/xlsxstyles_p.h
  7. 5
      src/xlsx/xlsxworkbook.cpp
  8. 6
      src/xlsx/xlsxworkbook.h
  9. 1
      src/xlsx/xlsxworksheet.h
  10. 6
      src/xlsx/xlsxzipwriter.cpp
  11. 9
      src/xlsx/xlsxzipwriter_p.h

4
src/xlsx/xlsxdocument.cpp

@ -12,7 +12,7 @@ namespace QXlsx {
DocumentPrivate::DocumentPrivate(Document *p) : DocumentPrivate::DocumentPrivate(Document *p) :
q_ptr(p), defaultPackageName(QStringLiteral("Book1.xlsx")) q_ptr(p), defaultPackageName(QStringLiteral("Book1.xlsx"))
{ {
workbook = new Workbook(p); workbook = QSharedPointer<Workbook>(new Workbook);
} }
void DocumentPrivate::init() void DocumentPrivate::init()
@ -147,7 +147,7 @@ QStringList Document::documentPropertyNames() const
Workbook *Document::workbook() const Workbook *Document::workbook() const
{ {
Q_D(const Document); Q_D(const Document);
return d->workbook; return d->workbook.data();
} }
bool Document::addWorksheet(const QString &name) bool Document::addWorksheet(const QString &name)

2
src/xlsx/xlsxdocument_p.h

@ -22,7 +22,7 @@ public:
QString packageName; //name of the .xlsx file QString packageName; //name of the .xlsx file
QMap<QString, QString> documentProperties; //core, app and custom properties QMap<QString, QString> documentProperties; //core, app and custom properties
Workbook *workbook; QSharedPointer<Workbook> workbook;
}; };
} }

3
src/xlsx/xlsxdrawing.cpp

@ -3,8 +3,7 @@
namespace QXlsx { namespace QXlsx {
Drawing::Drawing(QObject *parent) : Drawing::Drawing()
QObject(parent)
{ {
embedded = false; embedded = false;
orientation = 0; orientation = 0;

7
src/xlsx/xlsxdrawing_p.h

@ -1,8 +1,8 @@
#ifndef QXLSX_DRAWING_H #ifndef QXLSX_DRAWING_H
#define QXLSX_DRAWING_H #define QXLSX_DRAWING_H
#include <QObject>
#include <QList> #include <QList>
#include <QString>
class QIODevice; class QIODevice;
@ -28,11 +28,10 @@ struct XlsxDrawingDimensionData
int shape; int shape;
}; };
class Drawing : public QObject class Drawing
{ {
Q_OBJECT
public: public:
explicit Drawing(QObject *parent = 0); Drawing();
void saveToXmlFile(QIODevice *device); void saveToXmlFile(QIODevice *device);
bool embedded; bool embedded;

2
src/xlsx/xlsxrelationships_p.h

@ -26,8 +26,8 @@
#define XLSXRELATIONSHIPS_H #define XLSXRELATIONSHIPS_H
#include "xlsxglobal.h" #include "xlsxglobal.h"
#include <QObject>
#include <QList> #include <QList>
#include <QString>
class QIODevice; class QIODevice;
namespace QXlsx { namespace QXlsx {

2
src/xlsx/xlsxstyles_p.h

@ -40,7 +40,7 @@ struct FillData;
struct BorderData; struct BorderData;
class XmlStreamWriter; class XmlStreamWriter;
class XLSX_AUTOTEST_EXPORT Styles : public QObject class XLSX_AUTOTEST_EXPORT Styles
{ {
public: public:
Styles(); Styles();

5
src/xlsx/xlsxworkbook.cpp

@ -55,14 +55,15 @@ WorkbookPrivate::WorkbookPrivate(Workbook *q) :
table_count = 0; table_count = 0;
} }
Workbook::Workbook(QObject *parent) : Workbook::Workbook() :
QObject(parent), d_ptr(new WorkbookPrivate(this)) d_ptr(new WorkbookPrivate(this))
{ {
} }
Workbook::~Workbook() Workbook::~Workbook()
{ {
qDeleteAll(d_ptr->worksheets);
delete d_ptr; delete d_ptr;
} }

6
src/xlsx/xlsxworkbook.h

@ -26,7 +26,6 @@
#define XLSXWORKBOOK_H #define XLSXWORKBOOK_H
#include "xlsxglobal.h" #include "xlsxglobal.h"
#include <QObject>
#include <QList> #include <QList>
#include <QImage> #include <QImage>
#include <QSharedPointer> #include <QSharedPointer>
@ -45,9 +44,8 @@ class Document;
class DocumentPrivate; class DocumentPrivate;
class WorkbookPrivate; class WorkbookPrivate;
class Q_XLSX_EXPORT Workbook : public QObject class Q_XLSX_EXPORT Workbook
{ {
Q_OBJECT
Q_DECLARE_PRIVATE(Workbook) Q_DECLARE_PRIVATE(Workbook)
public: public:
~Workbook(); ~Workbook();
@ -72,7 +70,7 @@ private:
friend class Document; friend class Document;
friend class DocumentPrivate; friend class DocumentPrivate;
Workbook(QObject *parent=0); Workbook();
void saveToXmlFile(QIODevice *device); void saveToXmlFile(QIODevice *device);
QByteArray saveToXmlData(); QByteArray saveToXmlData();

1
src/xlsx/xlsxworksheet.h

@ -26,7 +26,6 @@
#define XLSXWORKSHEET_H #define XLSXWORKSHEET_H
#include "xlsxglobal.h" #include "xlsxglobal.h"
#include <QObject>
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
#include <QVariant> #include <QVariant>

6
src/xlsx/xlsxzipwriter.cpp

@ -28,15 +28,13 @@
namespace QXlsx { namespace QXlsx {
ZipWriter::ZipWriter(const QString &filePath, QObject *parent) : ZipWriter::ZipWriter(const QString &filePath)
QObject(parent)
{ {
m_writer = new QZipWriter(filePath, QIODevice::WriteOnly); m_writer = new QZipWriter(filePath, QIODevice::WriteOnly);
m_writer->setCompressionPolicy(QZipWriter::NeverCompress); m_writer->setCompressionPolicy(QZipWriter::NeverCompress);
} }
ZipWriter::ZipWriter(QIODevice *device, QObject *parent) : ZipWriter::ZipWriter(QIODevice *device)
QObject(parent)
{ {
m_writer = new QZipWriter(device); m_writer = new QZipWriter(device);
m_writer->setCompressionPolicy(QZipWriter::NeverCompress); m_writer->setCompressionPolicy(QZipWriter::NeverCompress);

9
src/xlsx/xlsxzipwriter_p.h

@ -25,18 +25,17 @@
#ifndef QXLSX_ZIPWRITER_H #ifndef QXLSX_ZIPWRITER_H
#define QXLSX_ZIPWRITER_H #define QXLSX_ZIPWRITER_H
#include <QObject> #include <QString>
class QIODevice; class QIODevice;
class QZipWriter; class QZipWriter;
namespace QXlsx { namespace QXlsx {
class ZipWriter : public QObject class ZipWriter
{ {
Q_OBJECT
public: public:
explicit ZipWriter(const QString &filePath, QObject *parent = 0); explicit ZipWriter(const QString &filePath);
explicit ZipWriter(QIODevice *device, QObject *parent = 0); explicit ZipWriter(QIODevice *device);
~ZipWriter(); ~ZipWriter();
void addFile(const QString &filePath, QIODevice *device); void addFile(const QString &filePath, QIODevice *device);

Loading…
Cancel
Save