add list bind function
This commit is contained in:
		| @@ -60,6 +60,7 @@ SOURCES += \ | ||||
|         shader/DoricTextNode.cpp \ | ||||
|         shader/DoricVLayoutNode.cpp \ | ||||
|         shader/DoricViewNode.cpp \ | ||||
|         shader/list/DoricListAdapter.cpp \ | ||||
|         shader/list/DoricListItemNode.cpp \ | ||||
|         shader/list/DoricListNode.cpp \ | ||||
|         shader/slider/DoricSlideItemNode.cpp \ | ||||
| @@ -156,6 +157,7 @@ HEADERS += \ | ||||
|     shader/DoricTextNode.h \ | ||||
|     shader/DoricVLayoutNode.h \ | ||||
|     shader/DoricViewNode.h \ | ||||
|     shader/list/DoricListAdapter.h \ | ||||
|     shader/list/DoricListItemNode.h \ | ||||
|     shader/list/DoricListNode.h \ | ||||
|     shader/slider/DoricSlideItemNode.h \ | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import QtQuick 2.12 | ||||
| import QtQuick.Controls 2.5 | ||||
| import QtQuick.Layouts 1.15 | ||||
| import QtQuick.Layouts 1.14 | ||||
| import QtGraphicalEffects 1.12 | ||||
|  | ||||
| import "util.mjs" as Util | ||||
|   | ||||
| @@ -47,7 +47,7 @@ ListView { | ||||
|  | ||||
|     delegate: Rectangle { | ||||
|         Component.onCompleted: { | ||||
| //            listBridge.getItemModel(index) | ||||
|             listBridge.bind(wrapper, this, index) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										9
									
								
								doric-Qt/example/doric/shader/list/DoricListAdapter.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								doric-Qt/example/doric/shader/list/DoricListAdapter.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #include "DoricListAdapter.h" | ||||
|  | ||||
| #include <QDebug> | ||||
|  | ||||
| DoricListAdapter::DoricListAdapter() {} | ||||
|  | ||||
| void DoricListAdapter::bind(QVariant rectangle, int position) { | ||||
|   qDebug() << "==========" << rectangle << " " << position; | ||||
| } | ||||
							
								
								
									
										13
									
								
								doric-Qt/example/doric/shader/list/DoricListAdapter.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								doric-Qt/example/doric/shader/list/DoricListAdapter.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #ifndef DORICLISTADAPTER_H | ||||
| #define DORICLISTADAPTER_H | ||||
|  | ||||
| #include <QVariant> | ||||
|  | ||||
| class DoricListAdapter { | ||||
| public: | ||||
|   DoricListAdapter(); | ||||
|  | ||||
|   void bind(QVariant rectangle, int position); | ||||
| }; | ||||
|  | ||||
| #endif // DORICLISTADAPTER_H | ||||
| @@ -21,6 +21,19 @@ DoricViewNode *DoricListNode::getSubNodeById(QString id) {} | ||||
|  | ||||
| void DoricListNode::blendSubNode(QJsonValue subProperties) {} | ||||
|  | ||||
| void DoricListNode::blend(QQuickItem *view, QString name, QJsonValue prop) {} | ||||
| void DoricListNode::blend(QQuickItem *view, QString name, QJsonValue prop) { | ||||
|   if (name == "itemCount") { | ||||
|     this->itemCount = prop.toInt(); | ||||
|   } else { | ||||
|     DoricSuperNode::blend(view, name, prop); | ||||
|   } | ||||
| } | ||||
|  | ||||
| void DoricListNode::afterBlended(QJsonValue prop) {} | ||||
| void DoricListNode::afterBlended(QJsonValue prop) { | ||||
|   mView->setProperty("model", this->itemCount); | ||||
| } | ||||
|  | ||||
| // adapter method | ||||
| void DoricListNode::bind(QVariant rectangle, int position) { | ||||
|   listAdapter.bind(rectangle, position); | ||||
| } | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
|  | ||||
| #include "DoricListItemNode.h" | ||||
| #include "shader/DoricSuperNode.h" | ||||
| #include "DoricListAdapter.h" | ||||
|  | ||||
| class DORIC_EXPORT DoricListNode : public DoricSuperNode { | ||||
|  | ||||
| @@ -17,7 +18,7 @@ private: | ||||
|   QString loadMoreViewId; | ||||
|   QString onScrollFuncId; | ||||
|   QString onScrollEndFuncId; | ||||
|   QList<DoricListItemNode *> childNodes; | ||||
|   DoricListAdapter listAdapter; | ||||
|  | ||||
| public: | ||||
|   using DoricSuperNode::DoricSuperNode; | ||||
| @@ -31,6 +32,8 @@ public: | ||||
|   virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; | ||||
|  | ||||
|   virtual void afterBlended(QJsonValue prop) override; | ||||
|  | ||||
|   void bind(QVariant rectangle, int position); | ||||
| }; | ||||
|  | ||||
| #endif // DORICLISTNODE_H | ||||
|   | ||||
| @@ -1,3 +1,10 @@ | ||||
| #include "DoricListBridge.h" | ||||
| #include "shader/list/DoricListNode.h" | ||||
|  | ||||
| DoricListBridge::DoricListBridge(QObject *parent) : QObject(parent) {} | ||||
|  | ||||
| void DoricListBridge::bind(QString pointer, QVariant rectangle, int position) { | ||||
|   QObject *object = (QObject *)(pointer.toULongLong()); | ||||
|   DoricListNode *listNode = dynamic_cast<DoricListNode *>(object); | ||||
|   listNode->bind(rectangle, position); | ||||
| } | ||||
|   | ||||
| @@ -10,6 +10,9 @@ class DORIC_EXPORT DoricListBridge : public QObject { | ||||
|   Q_OBJECT | ||||
| public: | ||||
|   explicit DoricListBridge(QObject *parent = nullptr); | ||||
|  | ||||
|   Q_INVOKABLE | ||||
|   void bind(QString pointer, QVariant rectangle, int position); | ||||
| }; | ||||
|  | ||||
| #endif // DORICLISTBRIDGE_H | ||||
|   | ||||
		Reference in New Issue
	
	Block a user