diff --git a/QQt.pro b/QQt.pro index 900ef803..fc7c2972 100644 --- a/QQt.pro +++ b/QQt.pro @@ -21,8 +21,11 @@ SUBDIRS = src/qqt.pro SUBDIRS += examples/exquisite #can't support ios #SUBDIRS += examples/qqtprintsupportexample -#SUBDIRS += examples/tabwidgetexamples -#SUBDIRS += examples/svgtest +# +SUBDIRS += examples/tabwidgetexamples +# +SUBDIRS += examples/svgtest +SUBDIRS += examples/treeviewexample #----------------------------------------------------------------- #need vlcQt libvlc library diff --git a/examples/treeviewexample/main.cpp b/examples/treeviewexample/main.cpp new file mode 100644 index 00000000..b48f94ec --- /dev/null +++ b/examples/treeviewexample/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/examples/treeviewexample/mainwindow.cpp b/examples/treeviewexample/mainwindow.cpp new file mode 100644 index 00000000..fdf01b5f --- /dev/null +++ b/examples/treeviewexample/mainwindow.cpp @@ -0,0 +1,28 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "QFileSystemModel" +#include "QDirModel" +#include +#include + +MainWindow::MainWindow ( QWidget* parent ) : + QMainWindow ( parent ), + ui ( new Ui::MainWindow ) +{ + ui->setupUi ( this ); + QFileSystemModel* model = new QFileSystemModel ( this ); + //model->setRootPath ( "/Users/abel/Develop/a0-develop/a0-qqtfoundation/examples" ); + QDirModel* model2 = new QDirModel ( this ); + ui->tv0->setModel ( model2 ); + ui->tv0->setRootIndex ( model2->index ( qApp->applicationDirPath() ) ); + + QQtSqlTreeModel* md0 = new QQtSqlTreeModel ( this ); + ui->tv1->setModel ( md0 ); + md0->setAbsoluteFilePath ( "/Users/abel/Develop/d1-product/App/db/Manager.db" ); + md0->query(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/examples/treeviewexample/mainwindow.h b/examples/treeviewexample/mainwindow.h new file mode 100644 index 00000000..a3948a91 --- /dev/null +++ b/examples/treeviewexample/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/examples/treeviewexample/mainwindow.ui b/examples/treeviewexample/mainwindow.ui new file mode 100644 index 00000000..f29957d7 --- /dev/null +++ b/examples/treeviewexample/mainwindow.ui @@ -0,0 +1,58 @@ + + + MainWindow + + + + 0 + 0 + 800 + 480 + + + + MainWindow + + + + + + + 1 + + + + Tab 1 + + + + + + + + + + Tab 2 + + + + + + + + + + + + + + + + QQtTreeWidget + QTreeView +
qqttreewidget.h
+
+
+ + +
diff --git a/examples/treeviewexample/treeviewexample.pro b/examples/treeviewexample/treeviewexample.pro new file mode 100644 index 00000000..a96e1aa3 --- /dev/null +++ b/examples/treeviewexample/treeviewexample.pro @@ -0,0 +1,81 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2017-11-19T09:27:08 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = treeviewexample +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +CONFIG += mobility +MOBILITY = + + +#------------------------------------------------- +#link qqt library +#if you link a library to your app, on android you must select the running kit to the app, not LibQQt e.g. +#------------------------------------------------- +include(../qqtframe2/link_qqt_library.pri) + +#------------------------------------------------- +#install +#------------------------------------------------- +#CONFIG += can_install +can_install:equals(QKIT_PRIVATE, EMBEDDED) { + target.path = /Application + INSTALLS += target +} else: unix { + equals(QKIT_PRIVATE, macOS) { + target.path = /Applications + INSTALLS += target + } +} + +#------------------------------------------------- +##project environ +#------------------------------------------------- +#default +message ($${TARGET} config $${CONFIG}) +message ($${TARGET} define $${DEFINES}) + +contains(QKIT_PRIVATE, ANDROID|ANDROIDX86) { + CONFIG += mobility + MOBILITY = + DISTFILES += \ + android/AndroidManifest.xml \ + android/gradle/wrapper/gradle-wrapper.jar \ + android/gradlew \ + android/res/values/libs.xml \ + android/build.gradle \ + android/gradle/wrapper/gradle-wrapper.properties \ + android/gradlew.bat + + ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android +} + diff --git a/src/gui/qqtfilesystemtreemodel.cpp b/src/gui/qqtfilesystemtreemodel.cpp new file mode 100644 index 00000000..a4ced218 --- /dev/null +++ b/src/gui/qqtfilesystemtreemodel.cpp @@ -0,0 +1,10 @@ +#include "qqtfilesystemtreemodel.h" +#include +#include "qqtcore.h" +#include + +QQtFileSystemTreeModel::QQtFileSystemTreeModel ( QObject* parent ) : QFileSystemModel ( parent ) +{ + +} + diff --git a/src/gui/qqtfilesystemtreemodel.h b/src/gui/qqtfilesystemtreemodel.h new file mode 100644 index 00000000..1dae8be8 --- /dev/null +++ b/src/gui/qqtfilesystemtreemodel.h @@ -0,0 +1,30 @@ +#ifndef QQTFILESYSTEMTREEMODEL_H +#define QQTFILESYSTEMTREEMODEL_H + +#include +#include +#include +/** + * @brief The QQtFileSystemTreeModel class + * QFileSystemModel setRootPath 无效 + * QDirModel 没有设置RootPath函数 + * 两者都可以通过QTreeView的setRootIndex来设置RootPath,其实是在QTreeView里面进行过滤。 + * view->setRootIndex ( model->index ( "the/root/path" ) ); + */ +class QQTSHARED_EXPORT QQtFileSystemTreeModel : public QFileSystemModel +{ + Q_OBJECT +public: + explicit QQtFileSystemTreeModel ( QObject* parent = 0 ); + +signals: + +public slots: + + +protected: + +private: +}; + +#endif // QQTFILESYSTEMTREEMODEL_H diff --git a/src/gui/qqtjsontreemodel.cpp b/src/gui/qqtjsontreemodel.cpp new file mode 100644 index 00000000..2ceb635c --- /dev/null +++ b/src/gui/qqtjsontreemodel.cpp @@ -0,0 +1,130 @@ +#include "qqtjsontreemodel.h" +#include +#include "qqtcore.h" +#include + +QQtJsonTreeModel::QQtJsonTreeModel ( QObject* parent ) : QQtTreeModel ( parent ) +{ + +} + +void QQtJsonTreeModel::setFilePath ( QString fileName ) +{ + QFile file ( fileName ); + + if ( !file.open ( QFile::ReadOnly | QFile::Text ) ) + { + pline() << "Error: Cannot read file " << qPrintable ( fileName ) + << ": " << qPrintable ( file.errorString() ) + << endl; + return; + } + + QString errorStr; + int errorLine; + int errorColumn; + + QDomDocument doc; + + if ( !doc.setContent ( &file, false, &errorStr, &errorLine, + &errorColumn ) ) + { + pline() << "Error: Parse error at line " << errorLine << ", " + << "column " << errorColumn << ": " + << qPrintable ( errorStr ) << endl; + return; + } + + file.close(); + + clear(); + QDomElement rootElement = doc.documentElement(); + parseChildElement ( rootElement ); + + return; +} + +bool QQtJsonTreeModel::query ( QString condition ) +{ + Q_UNUSED ( condition ) + //TODO: + return true; +} + +/** + * @brief QQTXmlTreeModel::parseChildElement + * @param element + * @param parent + * 这套递归代码,第一次和最后一次不同。 + */ +void QQtJsonTreeModel::parseChildElement ( const QDomElement& element, QStandardItem* itemParent ) +{ + /** + * @brief element name + */ + QStandardItem* item = new QStandardItem(); + + item->setData ( element.nodeName(), Qt::EditRole ); + item->setData ( element.text(), Qt::UserRole ); + + if ( element.isNull() && !element.hasChildNodes() ) + item->setData ( itemParent->data ( Qt::UserRole ), Qt::EditRole ); + + pline() << element.nodeName() << element.text(); + + if ( itemParent ) + { + itemParent->appendRow ( item ); + //if column is not enough + //setItem(indexFromItem(itemParent).row(), 0, item); + } + else + { + //first time ok. also + //appendRow(item); + setItem ( 0, 0, item ); + } + + /** + * @brief element attibute + */ + QDomNamedNodeMap nodeMap = element.attributes(); + + if ( nodeMap.count() > columnCount() ) + setColumnCount ( nodeMap.count() ); + + for ( int i = 0; i < nodeMap.count(); i++ ) + { + QString attName = nodeMap.item ( i ).nodeName(); + QString attValue = nodeMap.item ( i ).nodeValue(); + QStandardItem* _item = new QStandardItem(); + _item->setData ( attName, Qt::UserRole ); + _item->setData ( attValue, Qt::EditRole ); + + pline() << attName << attValue << itemParent; + + if ( itemParent ) + { + itemParent->setChild ( item->index().row(), i + 1, _item ); + + /** + * @brief more than two column need this + */ + //setItem(indexFromItem(item).row(), i+1, _item); + } + else + //first time + setItem ( indexFromItem ( item ).row(), i + 1, _item ); + } + + /** + * child element + */ + QDomNode child = element.firstChild(); + + while ( !child.isNull() ) + { + parseChildElement ( child.toElement(), item ); + child = child.nextSibling(); + } +} diff --git a/src/gui/qqtjsontreemodel.h b/src/gui/qqtjsontreemodel.h new file mode 100644 index 00000000..6b2b6710 --- /dev/null +++ b/src/gui/qqtjsontreemodel.h @@ -0,0 +1,35 @@ +#ifndef QQTJSONTREEMODEL_H +#define QQTJSONTREEMODEL_H + +#include +#include +#include + +class QQTSHARED_EXPORT QQtJsonTreeModel : public QQtTreeModel +{ + Q_OBJECT +public: + explicit QQtJsonTreeModel ( QObject* parent = 0 ); + + +signals: + +public slots: + + // QQtJsonTreeModel interface +public: + bool query ( QString condition ) override; + void setFilePath ( QString xmlfile ) override; + +protected: + /** + * @brief parseChildElement + * @param element + */ + void parseChildElement ( const QDomElement& element, QStandardItem* itemParent = 0 ); + +private: + QDomDocument doc; +}; + +#endif // QQTJSONTREEMODEL_H diff --git a/src/gui/qqtsqltreemodel.cpp b/src/gui/qqtsqltreemodel.cpp index a022c5ed..d4ee67d2 100644 --- a/src/gui/qqtsqltreemodel.cpp +++ b/src/gui/qqtsqltreemodel.cpp @@ -2,69 +2,90 @@ #include "qqtcore.h" #include "qqtsql.h" -QQTSqlTreeModel::QQTSqlTreeModel(QObject* parent) : - QQTTreeModel(parent) +QQtSqlTreeModel::QQtSqlTreeModel ( QObject* parent ) : + QQtTreeModel ( parent ) { m_db = newDatabaseConn(); } -void QQTSqlTreeModel::setFilePath(QString dbname) +void QQtSqlTreeModel::setFilePath ( QString dbname ) { - if (dbname.isEmpty()) + if ( dbname.isEmpty() ) { return; } - setDatabaseName(m_db, dbname); + setDatabaseName ( m_db, dbname ); } -bool QQTSqlTreeModel::query(QString condition) +void QQtSqlTreeModel::setAbsoluteFilePath ( QString dbname ) { - Q_UNUSED(condition) + if ( dbname.isEmpty() ) + { + return; + } + + if ( m_db.isOpen() ) + m_db.close(); + + m_db.setDatabaseName ( QString ( "%1" ).arg ( dbname ) ); + + if ( !m_db.open() ) + { + QMessageBox::warning ( 0, QObject::tr ( "QSQLITE %1 Error" ).arg ( m_db.databaseName() ), + m_db.lastError().text() ); + return; + } +} + +bool QQtSqlTreeModel::query ( QString condition ) +{ + Q_UNUSED ( condition ) //TODO: return parseDatabase(); } -bool QQTSqlTreeModel::parseDatabase() +bool QQtSqlTreeModel::parseDatabase() { - QStringList tables = m_db.tables(QSql::Tables); - QStringListIterator itor(tables); + QStringList tables = m_db.tables ( QSql::Tables ); + pline() << tables; + QStringListIterator itor ( tables ); - while (itor.hasNext()) + while ( itor.hasNext() ) { QString table = itor.next(); - parseTable(table); + parseTable ( table ); } return true; } -bool QQTSqlTreeModel::parseTable(QString tableName) +bool QQtSqlTreeModel::parseTable ( QString tableName ) { - QQTTableModel* mdl = new QQTTableModel(this, m_db); - mdl->setTable(tableName); - mdl->query(""); - tableModelList.push_back(mdl);; + QQtTableModel* mdl = new QQtTableModel ( this, m_db ); + mdl->setTable ( tableName ); + mdl->query ( "" ); + tableModelList.push_back ( mdl );; QStandardItem* itemParent = new QStandardItem; - itemParent->setData(tableName, Qt::EditRole); - appendRow(itemParent); + itemParent->setData ( tableName, Qt::EditRole ); + appendRow ( itemParent ); - if (columnCount() < mdl->columnCount()) - setColumnCount(mdl->columnCount()); + if ( columnCount() < mdl->columnCount() ) + setColumnCount ( mdl->columnCount() ); - for (int i = 0; i < mdl->rowCount(); i++) + for ( int i = 0; i < mdl->rowCount(); i++ ) { QStandardItem* _item = new QStandardItem; - _item->setData(mdl->index(i, 0).data(Qt::DisplayRole), Qt::EditRole); - itemParent->appendRow(_item); + _item->setData ( mdl->index ( i, 0 ).data ( Qt::DisplayRole ), Qt::EditRole ); + itemParent->appendRow ( _item ); - for (int j = 1; j < mdl->columnCount(); j++) + for ( int j = 1; j < mdl->columnCount(); j++ ) { QStandardItem* __item = new QStandardItem; - __item->setData(mdl->index(i, j).data(Qt::DisplayRole), Qt::EditRole); + __item->setData ( mdl->index ( i, j ).data ( Qt::DisplayRole ), Qt::EditRole ); //pline() << __item->data(Qt::EditRole).toByteArray(); - itemParent->setChild(_item->index().row(), j, __item); + itemParent->setChild ( _item->index().row(), j, __item ); //setItem(indexFromItem(_item).row(), j, __item); } } diff --git a/src/gui/qqtsqltreemodel.h b/src/gui/qqtsqltreemodel.h index 988ef878..25afccc5 100644 --- a/src/gui/qqtsqltreemodel.h +++ b/src/gui/qqtsqltreemodel.h @@ -6,25 +6,30 @@ #include #include -class QQTSHARED_EXPORT QQTSqlTreeModel : public QQTTreeModel +/** + * @brief The QQtSqlTreeModel class + * 按照树的样式来显示数据库 + */ +class QQTSHARED_EXPORT QQtSqlTreeModel : public QQtTreeModel { Q_OBJECT public: - explicit QQTSqlTreeModel(QObject* parent = 0); + explicit QQtSqlTreeModel ( QObject* parent = 0 ); //TODO: + QSqlDatabase& database() { return m_db; } + void setAbsoluteFilePath ( QString dbname ); - // QQTVirtualTreeModel interface + // QQtSqlTreeModel interface public: - bool query(QString condition) override; - void setFilePath(QString dbname) override; - + virtual bool query ( QString condition = "" ) override; + virtual void setFilePath ( QString dbname ) override; protected: - bool parseDatabase(); - bool parseTable(QString tableName); + virtual bool parseDatabase(); + virtual bool parseTable ( QString tableName ); private: QSqlDatabase m_db; - QList tableModelList; + QList tableModelList; }; #endif // QQTSQLTREEMODEL_H diff --git a/src/gui/qqttablemodel.cpp b/src/gui/qqttablemodel.cpp index 323ca68a..1c36e3b4 100644 --- a/src/gui/qqttablemodel.cpp +++ b/src/gui/qqttablemodel.cpp @@ -1,17 +1,17 @@ #include "qqttablemodel.h" -QQTTableModel::QQTTableModel(QObject* parent, QSqlDatabase db): +QQtTableModel::QQtTableModel(QObject* parent, QSqlDatabase db): QSqlRelationalTableModel(parent, db) { } -void QQTTableModel::query(QString filter) +void QQtTableModel::query(QString filter) { setFilter(filter); select(); } -QVariant QQTTableModel::data(const QModelIndex& index, int role) const +QVariant QQtTableModel::data(const QModelIndex& index, int role) const { switch (role) { @@ -26,12 +26,12 @@ QVariant QQTTableModel::data(const QModelIndex& index, int role) const } -bool QQTTableModel::setData(const QModelIndex& index, const QVariant& value, int role) +bool QQtTableModel::setData(const QModelIndex& index, const QVariant& value, int role) { return QSqlRelationalTableModel::setData(index, value, role); } -Qt::ItemFlags QQTTableModel::flags(const QModelIndex& index) const +Qt::ItemFlags QQtTableModel::flags(const QModelIndex& index) const { return QSqlRelationalTableModel::flags(index); } diff --git a/src/gui/qqttablemodel.h b/src/gui/qqttablemodel.h index a065b84d..50aca7b8 100644 --- a/src/gui/qqttablemodel.h +++ b/src/gui/qqttablemodel.h @@ -5,14 +5,14 @@ #include /** - * @brief The QQTTableModel class + * @brief The QQtTableModel class * QQTSqlRelationalTableModel 方便起见,仅仅使用这个model */ -class QQTSHARED_EXPORT QQTTableModel : public QSqlRelationalTableModel +class QQTSHARED_EXPORT QQtTableModel : public QSqlRelationalTableModel { Q_OBJECT public: - explicit QQTTableModel(QObject* parent = 0, QSqlDatabase db = QSqlDatabase()); + explicit QQtTableModel(QObject* parent = 0, QSqlDatabase db = QSqlDatabase()); void query(QString filter); diff --git a/src/gui/qqttreemodel.cpp b/src/gui/qqttreemodel.cpp index 57701a4e..c433bf58 100644 --- a/src/gui/qqttreemodel.cpp +++ b/src/gui/qqttreemodel.cpp @@ -1,6 +1,6 @@ #include "qqttreemodel.h" -QQTTreeModel::QQTTreeModel(QObject* parent) : QStandardItemModel(parent) +QQtTreeModel::QQtTreeModel(QObject* parent) : QStandardItemModel(parent) { } diff --git a/src/gui/qqttreemodel.h b/src/gui/qqttreemodel.h index c640be6e..ad387f3f 100644 --- a/src/gui/qqttreemodel.h +++ b/src/gui/qqttreemodel.h @@ -9,11 +9,11 @@ * define the tree model's functions name. */ -class QQTSHARED_EXPORT QQTTreeModel : public QStandardItemModel +class QQTSHARED_EXPORT QQtTreeModel : public QStandardItemModel { Q_OBJECT public: - explicit QQTTreeModel(QObject* parent = 0); + explicit QQtTreeModel(QObject* parent = 0); /** * @brief query diff --git a/src/gui/qqtxmltreemodel.cpp b/src/gui/qqtxmltreemodel.cpp index 58ff4c1b..6a300b54 100644 --- a/src/gui/qqtxmltreemodel.cpp +++ b/src/gui/qqtxmltreemodel.cpp @@ -3,19 +3,19 @@ #include "qqtcore.h" #include -QQTXmlTreeModel::QQTXmlTreeModel(QObject* parent) : QQTTreeModel(parent) +QQTXmlTreeModel::QQTXmlTreeModel ( QObject* parent ) : QQtTreeModel ( parent ) { } -void QQTXmlTreeModel::setFilePath(QString fileName) +void QQTXmlTreeModel::setFilePath ( QString fileName ) { - QFile file(fileName); + QFile file ( fileName ); - if (!file.open(QFile::ReadOnly | QFile::Text)) + if ( !file.open ( QFile::ReadOnly | QFile::Text ) ) { - pline() << "Error: Cannot read file " << qPrintable(fileName) - << ": " << qPrintable(file.errorString()) + pline() << "Error: Cannot read file " << qPrintable ( fileName ) + << ": " << qPrintable ( file.errorString() ) << endl; return; } @@ -26,12 +26,12 @@ void QQTXmlTreeModel::setFilePath(QString fileName) QDomDocument doc; - if (!doc.setContent(&file, false, &errorStr, &errorLine, - &errorColumn)) + if ( !doc.setContent ( &file, false, &errorStr, &errorLine, + &errorColumn ) ) { pline() << "Error: Parse error at line " << errorLine << ", " << "column " << errorColumn << ": " - << qPrintable(errorStr) << endl; + << qPrintable ( errorStr ) << endl; return; } @@ -39,14 +39,14 @@ void QQTXmlTreeModel::setFilePath(QString fileName) clear(); QDomElement rootElement = doc.documentElement(); - parseChildElement(rootElement); + parseChildElement ( rootElement ); return; } -bool QQTXmlTreeModel::query(QString condition) +bool QQTXmlTreeModel::query ( QString condition ) { - Q_UNUSED(condition) + Q_UNUSED ( condition ) //TODO: return true; } @@ -57,24 +57,24 @@ bool QQTXmlTreeModel::query(QString condition) * @param parent * 这套递归代码,第一次和最后一次不同。 */ -void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardItem* itemParent) +void QQTXmlTreeModel::parseChildElement ( const QDomElement& element, QStandardItem* itemParent ) { /** * @brief element name */ QStandardItem* item = new QStandardItem(); - item->setData(element.nodeName(), Qt::EditRole); - item->setData(element.text(), Qt::UserRole); + item->setData ( element.nodeName(), Qt::EditRole ); + item->setData ( element.text(), Qt::UserRole ); - if (element.isNull() && !element.hasChildNodes()) - item->setData(itemParent->data(Qt::UserRole), Qt::EditRole); + if ( element.isNull() && !element.hasChildNodes() ) + item->setData ( itemParent->data ( Qt::UserRole ), Qt::EditRole ); pline() << element.nodeName() << element.text(); - if (itemParent) + if ( itemParent ) { - itemParent->appendRow(item); + itemParent->appendRow ( item ); //if column is not enough //setItem(indexFromItem(itemParent).row(), 0, item); } @@ -82,7 +82,7 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte { //first time ok. also //appendRow(item); - setItem(0, 0, item); + setItem ( 0, 0, item ); } /** @@ -90,22 +90,22 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte */ QDomNamedNodeMap nodeMap = element.attributes(); - if (nodeMap.count() > columnCount()) - setColumnCount(nodeMap.count()); + if ( nodeMap.count() > columnCount() ) + setColumnCount ( nodeMap.count() ); - for (int i = 0; i < nodeMap.count(); i++) + for ( int i = 0; i < nodeMap.count(); i++ ) { - QString attName = nodeMap.item(i).nodeName(); - QString attValue = nodeMap.item(i).nodeValue(); + QString attName = nodeMap.item ( i ).nodeName(); + QString attValue = nodeMap.item ( i ).nodeValue(); QStandardItem* _item = new QStandardItem(); - _item->setData(attName, Qt::UserRole); - _item->setData(attValue, Qt::EditRole); + _item->setData ( attName, Qt::UserRole ); + _item->setData ( attValue, Qt::EditRole ); pline() << attName << attValue << itemParent; - if (itemParent) + if ( itemParent ) { - itemParent->setChild(item->index().row(), i + 1, _item); + itemParent->setChild ( item->index().row(), i + 1, _item ); /** * @brief more than two column need this @@ -114,7 +114,7 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte } else //first time - setItem(indexFromItem(item).row(), i + 1, _item); + setItem ( indexFromItem ( item ).row(), i + 1, _item ); } /** @@ -122,9 +122,9 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte */ QDomNode child = element.firstChild(); - while (!child.isNull()) + while ( !child.isNull() ) { - parseChildElement(child.toElement(), item); + parseChildElement ( child.toElement(), item ); child = child.nextSibling(); } } diff --git a/src/gui/qqtxmltreemodel.h b/src/gui/qqtxmltreemodel.h index 0c8753cf..d51ea405 100644 --- a/src/gui/qqtxmltreemodel.h +++ b/src/gui/qqtxmltreemodel.h @@ -5,28 +5,28 @@ #include #include -class QQTSHARED_EXPORT QQTXmlTreeModel : public QQTTreeModel +class QQTSHARED_EXPORT QQTXmlTreeModel : public QQtTreeModel { Q_OBJECT public: - explicit QQTXmlTreeModel(QObject* parent = 0); + explicit QQTXmlTreeModel ( QObject* parent = 0 ); signals: public slots: - // QQTTreeModel interface + // QQtTreeModel interface public: - bool query(QString condition) override; - void setFilePath(QString xmlfile) override; + bool query ( QString condition ) override; + void setFilePath ( QString xmlfile ) override; protected: /** * @brief parseChildElement * @param element */ - void parseChildElement(const QDomElement& element, QStandardItem* itemParent = 0); + void parseChildElement ( const QDomElement& element, QStandardItem* itemParent = 0 ); private: QDomDocument doc; diff --git a/src/qqt_source.pri b/src/qqt_source.pri index 3bc96a15..18f68b03 100644 --- a/src/qqt_source.pri +++ b/src/qqt_source.pri @@ -12,23 +12,9 @@ #if you succeed with LibQQt, please thumb up. #2017年11月10日18:53:56 #------------------------------------------------- +SOURCES += +HEADERS += -SOURCES += \ - $$PWD/svgwidgets/qqtsvgwidget.cpp \ - $$PWD/svgwidgets/qqtsvgpushbutton.cpp \ - $$PWD/svgwidgets/qqtsvgcheckbox.cpp \ - $$PWD/svgwidgets/qqtsvgradiobutton.cpp \ - $$PWD/svgwidgets/qqtgraphicssvgitem.cpp \ - $$PWD/svgwidgets/qqtsvglabel.cpp \ - $$PWD/svgwidgets/qqtsvgprogressbar.cpp -HEADERS += \ - $$PWD/svgwidgets/qqtsvgwidget.h \ - $$PWD/svgwidgets/qqtsvgpushbutton.h \ - $$PWD/svgwidgets/qqtsvgcheckbox.h \ - $$PWD/svgwidgets/qqtsvgradiobutton.h \ - $$PWD/svgwidgets/qqtgraphicssvgitem.h \ - $$PWD/svgwidgets/qqtsvglabel.h \ - $$PWD/svgwidgets/qqtsvgprogressbar.h #root dir HEADERS += $$PWD/qqt.h \ @@ -71,6 +57,8 @@ SOURCES += \ $$PWD/gui/qqtsqltreemodel.cpp \ $$PWD/gui/qqttablemodel.cpp \ $$PWD/gui/qqttreemodel.cpp \ + $$PWD/gui/qqtfilesystemtreemodel.cpp \ + $$PWD/gui/qqtjsontreemodel.cpp \ $$PWD/gui/qqtxmltreemodel.cpp HEADERS += \ @@ -78,6 +66,8 @@ HEADERS += \ $$PWD/gui/qqtsqltreemodel.h \ $$PWD/gui/qqttablemodel.h \ $$PWD/gui/qqttreemodel.h \ + $$PWD/gui/qqtfilesystemtreemodel.h \ + $$PWD/gui/qqtjsontreemodel.h \ $$PWD/gui/qqtxmltreemodel.h \ $$PWD/gui/qqtgui.h @@ -431,3 +421,22 @@ contains (DEFINES, __WEBSOCKETSUPPORT__) { $$PWD/network/qqtwebclient.h \ $$PWD/network/qqtwebserver.h } + +contains (DEFINES, __SVGWIDGETS__) { + SOURCES += \ + $$PWD/svgwidgets/qqtsvgwidget.cpp \ + $$PWD/svgwidgets/qqtsvgpushbutton.cpp \ + $$PWD/svgwidgets/qqtsvgcheckbox.cpp \ + $$PWD/svgwidgets/qqtsvgradiobutton.cpp \ + $$PWD/svgwidgets/qqtgraphicssvgitem.cpp \ + $$PWD/svgwidgets/qqtsvglabel.cpp \ + $$PWD/svgwidgets/qqtsvgprogressbar.cpp + HEADERS += \ + $$PWD/svgwidgets/qqtsvgwidget.h \ + $$PWD/svgwidgets/qqtsvgpushbutton.h \ + $$PWD/svgwidgets/qqtsvgcheckbox.h \ + $$PWD/svgwidgets/qqtsvgradiobutton.h \ + $$PWD/svgwidgets/qqtgraphicssvgitem.h \ + $$PWD/svgwidgets/qqtsvglabel.h \ + $$PWD/svgwidgets/qqtsvgprogressbar.h +} diff --git a/src/widgets/qqttablewidget.cpp b/src/widgets/qqttablewidget.cpp index a0b00c1a..063ac728 100644 --- a/src/widgets/qqttablewidget.cpp +++ b/src/widgets/qqttablewidget.cpp @@ -7,7 +7,7 @@ QQtTableWidget::QQtTableWidget(QWidget* parent) : QQtTableView(parent) { m_db = newDatabaseConn(); - m_model = new QQTTableModel(this, m_db); + m_model = new QQtTableModel(this, m_db); setModel(m_model); /* * 如果没有这个函数,程序存在启动崩溃的情况。 diff --git a/src/widgets/qqttablewidget.h b/src/widgets/qqttablewidget.h index 9ef7226f..0f15eccd 100644 --- a/src/widgets/qqttablewidget.h +++ b/src/widgets/qqttablewidget.h @@ -29,7 +29,7 @@ public: void selectedRows(int column, QMap& ids); private: - QQTTableModel* m_model; + QQtTableModel* m_model; QSqlDatabase m_db; }; diff --git a/src/widgets/qqttreewidget.h b/src/widgets/qqttreewidget.h index d3af1ad2..6342d2e2 100644 --- a/src/widgets/qqttreewidget.h +++ b/src/widgets/qqttreewidget.h @@ -17,7 +17,7 @@ public: public slots: private: - QQTTreeModel* mModel; + QQtTreeModel* mModel; }; #endif // QQTTREEWIDGET_H