From bfea0ba25d8fd9d0685c394f0e71bd99f511dc4c Mon Sep 17 00:00:00 2001 From: tianduanrui <2407223896@qq.com> Date: Sat, 20 Jan 2018 16:27:18 +0800 Subject: [PATCH] update --- project.md | 2 +- src/app_deploy.pri | 53 +++++--- src/core/qqtdictionary.h | 2 +- src/core/qqtobjectfactory.h | 235 +++++++++++++++++----------------- src/printsupport/qqtprinter.h | 2 +- 5 files changed, 157 insertions(+), 137 deletions(-) diff --git a/project.md b/project.md index 07c63cc2..6df078d5 100644 --- a/project.md +++ b/project.md @@ -28,7 +28,7 @@ 最后注意一下,目录的层次要按照图中的层次安排,才会清晰。 工程目录和编译目录并排,和工具并排,和发布目录并排。 -工程目录里面,Library和Application工程并排。 +工程目录里面,Library和Application工程并排。 ![补充一点Android开发用目录](screenshot/y6.png "这是Android开发目录") 补充一点Android开发需要设置的目录 diff --git a/src/app_deploy.pri b/src/app_deploy.pri index 75905e89..dd5aed5f 100644 --- a/src/app_deploy.pri +++ b/src/app_deploy.pri @@ -1,22 +1,8 @@ #------------------------------------------------------------- #user computer path settings #------------------------------------------------------------- -#deploy root -isEmpty(APP_DEPLOY_ROOT){ - message($${TARGET} $${CONFIG_FILE}) - message(APP_DEPLOY_ROOT = /user/set/path is required, please modify .qmake/app_configure.pri ) - error( please check $$CONFIG_FILE under qqt_library.pri) -} -message($${TARGET} deploy root: $$APP_DEPLOY_ROOT) - -#set app deploy pwd -APP_DEPLOY_PWD = $${APP_DEPLOY_ROOT}/$${TARGET}/$${QKIT_STD_DIR} -contains(QKIT_PRIVATE, WIN32||WIN64) { - APP_DEPLOY_PWD~=s,/,\\,g -} - -APP_DEST_DIR=$${DESTDIR} -isEmpty(APP_DEST_DIR):APP_DEST_DIR=. +#example(in /user/conf/path/.qmake/app_configure.pri) +#APP_DEPLOY_ROOT = /where/app/wants/to/deploy/app/root defineReplace(deploy_app_on_mac) { #need QQT_BUILD_PWD @@ -75,7 +61,40 @@ defineReplace(deploy_app_for_android) { return ($$command) } -CONFIG += deploy_app +##------------------------------------------------- +##work flow +##------------------------------------------------- +#set app deploy pwd +APP_DEPLOY_PWD = $${APP_DEPLOY_ROOT}/$${TARGET}/$${QKIT_STD_DIR} +contains(QKIT_PRIVATE, WIN32||WIN64) { + APP_DEPLOY_PWD~=s,/,\\,g +} + +APP_DEST_DIR=$${DESTDIR} +isEmpty(APP_DEST_DIR):APP_DEST_DIR=. + +#deploy root +isEmpty(APP_DEPLOY_ROOT){ + message($${TARGET} $${CONFIG_FILE}) + message(APP_DEPLOY_ROOT = /user/set/path is required, please modify .qmake/app_configure.pri ) + error( please check $$CONFIG_FILE under link_qqt_library.pri) +} +message($${TARGET} deploy root: $$APP_DEPLOY_ROOT) + +#如果 配置文件里 没有配置 APP_DEPLOY_ROOT 那么返回,不拷贝发布任何应用 +#不会走到。 +isEmpty(APP_DEPLOY_ROOT) { + message("$${TARGET} hasn't deploied any app files") + greaterThan(QT_MAJOR_VERSION, 5):return() +} + +##4.8 qmake arm32 return() 函数无效 +!isEmpty(APP_DEPLOY_ROOT) { + CONFIG += deploy_app + message("$${TARGET} has deploied some app files") +} + + contains(CONFIG, deploy_app) { contains(QKIT_PRIVATE, WIN32||WIN64) { QMAKE_POST_LINK += $$deploy_app_on_win() diff --git a/src/core/qqtdictionary.h b/src/core/qqtdictionary.h index 5aadf42f..830a7594 100644 --- a/src/core/qqtdictionary.h +++ b/src/core/qqtdictionary.h @@ -122,7 +122,7 @@ public: /*操作符*/ /*警告:可读、可写*/ - /*don't out of range*/ + /*don't out of range? no, it is ok now.*/ QQtDictNode& operator [] ( int index ); const QQtDictNode& operator[] ( int index ) const; QQtDictNode& operator [] ( const QString& key ); diff --git a/src/core/qqtobjectfactory.h b/src/core/qqtobjectfactory.h index 6c6315b3..e6b65a45 100644 --- a/src/core/qqtobjectfactory.h +++ b/src/core/qqtobjectfactory.h @@ -11,123 +11,6 @@ #include "qqt-local.h" #include "qqtcore.h" -#if 0 -class QQTSHARED_EXPORT QQtConstructer : public QObject - -{ - Q_OBJECT -public: - explicit QQtConstructer ( QObject* parent = 0 ) : - QObject ( parent ) {} - virtual ~QQtConstructer() {} - -protected: - virtual QString constructorName() = 0; -}; - -/** - * @brief The QQtObjectConstructer class - * QQt 对象生产器 - */ -class QQTSHARED_EXPORT QQtObjectConstructer : public QQtConstructer - -{ - Q_OBJECT -public: - explicit QQtObjectConstructer ( QObject* parent = 0 ) : - QQtConstructer ( parent ) {} - virtual ~QQtObjectConstructer() {} - - virtual QString constructorName() { return "QObject"; } - -private: - typedef QObject* ( *Constructor ) ( QObject* parent ); - - template - static QObject* constructorHelper ( QObject* parent = 0 ) { - return new T ( parent ); - } - - static QHash& constructors() { - /* - * 保存生成类对象的具体(非模板)函数 - */ - static QHash instance; - return instance; - } -}; - -/** - * @brief The QQtWidgetConstructer class - * QQt 对象生产器 - */ -class QQTSHARED_EXPORT QQtWidgetConstructer : public QQtConstructer - -{ - Q_OBJECT -public: - explicit QQtWidgetConstructer ( QObject* parent = 0 ) : - QQtConstructer ( parent ) {} - virtual ~QQtWidgetConstructer() {} - - virtual QString constructorName() { return "QWidget"; } - -private: - typedef QWidget* ( *Constructor ) ( QWidget* parent ); - - template - static QWidget* constructorHelper ( QWidget* parent = 0 ) { - return new T ( parent ); - } - - static QHash& constructors() { - /* - * 保存生成类对象的具体(非模板)函数 - */ - static QHash instance; - return instance; - } -}; - -/** - * @brief The QQtObjectFactory class - * QQt 对象生产器 工厂模式 - */ -class QQTSHARED_EXPORT QQtObjectFactory2 -{ -public: - -private: - template - static QQtConstructer* objectContructor() { - static QList* objcList = NULL; - - if ( !objcList ) { - objcList = new QList(); - //add custom contructor - objcList->push_back ( new QQtObjectConstructer() ); - objcList->push_back ( new QQtWidgetConstructer() ); - } - - T obj; - QQtConstructer* objcc = NULL; - /* - QListIterator itor ( objcList ); - - while ( itor.hasNext() ) { - QQtConstructer* objc = *itor.next(); - - if ( obj.inherits ( objc->constructorName() ) ) { - objcc = objc; - break; - } - } - */ - - return objcc; - } -}; -#endif /** * @brief The QQtObjectFactory class @@ -294,4 +177,122 @@ private: } }; +#if 0 +class QQTSHARED_EXPORT QQtConstructer : public QObject + +{ + Q_OBJECT +public: + explicit QQtConstructer ( QObject* parent = 0 ) : + QObject ( parent ) {} + virtual ~QQtConstructer() {} + +protected: + virtual QString constructorName() = 0; +}; + +/** + * @brief The QQtObjectConstructer class + * QQt 对象生产器 + */ +class QQTSHARED_EXPORT QQtObjectConstructer : public QQtConstructer + +{ + Q_OBJECT +public: + explicit QQtObjectConstructer ( QObject* parent = 0 ) : + QQtConstructer ( parent ) {} + virtual ~QQtObjectConstructer() {} + + virtual QString constructorName() { return "QObject"; } + +private: + typedef QObject* ( *Constructor ) ( QObject* parent ); + + template + static QObject* constructorHelper ( QObject* parent = 0 ) { + return new T ( parent ); + } + + static QHash& constructors() { + /* + * 保存生成类对象的具体(非模板)函数 + */ + static QHash instance; + return instance; + } +}; + +/** + * @brief The QQtWidgetConstructer class + * QQt 对象生产器 + */ +class QQTSHARED_EXPORT QQtWidgetConstructer : public QQtConstructer + +{ + Q_OBJECT +public: + explicit QQtWidgetConstructer ( QObject* parent = 0 ) : + QQtConstructer ( parent ) {} + virtual ~QQtWidgetConstructer() {} + + virtual QString constructorName() { return "QWidget"; } + +private: + typedef QWidget* ( *Constructor ) ( QWidget* parent ); + + template + static QWidget* constructorHelper ( QWidget* parent = 0 ) { + return new T ( parent ); + } + + static QHash& constructors() { + /* + * 保存生成类对象的具体(非模板)函数 + */ + static QHash instance; + return instance; + } +}; + +/** + * @brief The QQtObjectFactory class + * QQt 对象生产器 工厂模式 + */ +class QQTSHARED_EXPORT QQtObjectFactory2 +{ +public: + +private: + template + static QQtConstructer* objectContructor() { + static QList* objcList = NULL; + + if ( !objcList ) { + objcList = new QList(); + //add custom contructor + objcList->push_back ( new QQtObjectConstructer() ); + objcList->push_back ( new QQtWidgetConstructer() ); + } + + T obj; + QQtConstructer* objcc = NULL; + /* + QListIterator itor ( objcList ); + + while ( itor.hasNext() ) { + QQtConstructer* objc = *itor.next(); + + if ( obj.inherits ( objc->constructorName() ) ) { + objcc = objc; + break; + } + } + */ + + return objcc; + } +}; +#endif + #endif // QQTOBJECTFACTORY_H diff --git a/src/printsupport/qqtprinter.h b/src/printsupport/qqtprinter.h index d5cc5918..9921c747 100644 --- a/src/printsupport/qqtprinter.h +++ b/src/printsupport/qqtprinter.h @@ -7,7 +7,7 @@ class QQTSHARED_EXPORT QQtPrinter : public QPrinter { public: - QQtPrinter ( PrinterMode mode = HighResolution ); + explicit QQtPrinter ( PrinterMode mode = HighResolution ); void setOutputFileName ( const QString& ); void print();