1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-31 21:22:58 +08:00

update Model; update Color

This commit is contained in:
jared 2020-11-07 00:51:12 +08:00
parent 75ca962118
commit c3042aed1e
31 changed files with 224 additions and 350 deletions

View File

@ -1,8 +0,0 @@
#include "QuickItemBase.h"
QuickItemBase::QuickItemBase(QObject *parent)
: QObject(parent)
{
}
QuickItemBase::~QuickItemBase() {}

View File

@ -1,117 +0,0 @@
#include "QuickListModelBase.h"
#include "QuickItemBase.h"
QuickListModelBase::QuickListModelBase(QObject *parent)
: QAbstractListModel(parent)
{
}
QuickListModelBase::~QuickListModelBase() {}
int QuickListModelBase::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return mObjs.count();
}
QVariant QuickListModelBase::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= mObjs.size()) {
return {};
}
if (role == Qt::DisplayRole || role == Qt::EditRole) {
auto obj = mObjs.at(index.row());
return QVariant::fromValue(obj);
}
return {};
}
QVariant QuickListModelBase::data(int row, int role) const
{
if (row < 0 || row >= mObjs.size())
{
return {};
}
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
auto obj = mObjs.at(row);
return QVariant::fromValue(obj);
}
return {};
}
void QuickListModelBase::resetData(const QList<QuickItemBase *> &objs)
{
auto oldObjs = mObjs;
beginResetModel();
mObjs = objs;
endResetModel();
qDeleteAll(oldObjs);
updateCalcInfo();
}
void QuickListModelBase::append(const QList<QuickItemBase *> &objs)
{
beginInsertRows({}, mObjs.count(), mObjs.count());
mObjs.append(objs);
endInsertRows();
updateCalcInfo();
}
void QuickListModelBase::prepend(QuickItemBase *obj)
{
beginInsertRows({}, 0, 0);
mObjs.prepend(obj);
endInsertRows();
updateCalcInfo();
}
void QuickListModelBase::insert(int row, const QList<QuickItemBase *> &objs)
{
if (row < 0 || row >= mObjs.size()) {
return;
}
beginInsertRows({}, row, row);
int srow = row;
for (const auto &obj : objs) {
mObjs.insert(srow, obj);
srow++;
}
endInsertRows();
updateCalcInfo();
}
void QuickListModelBase::clear()
{
beginRemoveRows({}, 0, mObjs.count());
qDeleteAll(mObjs);
mObjs.clear();
endRemoveRows();
updateCalcInfo();
}
void QuickListModelBase::removeAt(int row)
{
if (row < 0 || row >= mObjs.size()) {
return;
}
beginRemoveRows({}, row, row);
auto obj = mObjs.at(row);
mObjs.removeAt(row);
endRemoveRows();
obj->deleteLater();
updateCalcInfo();
}
void QuickListModelBase::updateData(int row, QuickItemBase *obj)
{
if (row < 0 || row >= mObjs.size()) {
return;
}
auto oldObj = mObjs.at(row);
mObjs[row] = obj;
emit dataChanged(index(row, 0), index(row, 0));
oldObj->deleteLater();
updateCalcInfo();
}

View File

@ -1,48 +0,0 @@
#pragma once
#include <QAbstractListModel>
#include "TaoCommonGlobal.h"
class QuickItemBase;
class TAO_API QuickListModelBase : public QAbstractListModel
{
Q_OBJECT
public:
explicit QuickListModelBase(QObject *parent = nullptr);
~QuickListModelBase() override;
public:
//[begin] query data
int rowCount(const QModelIndex &parent) const override;
Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Q_INVOKABLE QVariant data(int row, int role = Qt::DisplayRole) const;
//[end] query data
//[begin] reset data
void resetData(const QList<QuickItemBase *> &objs);
const QList<QuickItemBase *> &datas() const
{
return mObjs;
}
//[end] reset data
//[begin] add data
void append(const QList<QuickItemBase *> &objs);
void prepend(QuickItemBase *obj);
void insert(int row, const QList<QuickItemBase *> &objs);
//[end] add data
//[begin] remove data
void clear();
void removeAt(int row);
//[end] remove data
//[begin] update data
void updateData(int row, QuickItemBase *obj);
//[end] update data
public:
virtual void updateCalcInfo() {}
protected:
QList<QuickItemBase *> mObjs;
};

View File

@ -1,6 +1,7 @@
#include "QuickTool.h"
#include <QQuickItem>
#include <QGuiApplication>
QuickTool::QuickTool(QObject *parent) : QObject(parent) {}
QuickTool::QuickTool(QObject *rootObject, QObject *parent)
@ -37,9 +38,9 @@ QRect QuickTool::getItemGeometryToScene(const QString &targetObjName) const
return {};
}
void QuickTool::setAppOverrideCursor(Qt::CursorShape shape)
void QuickTool::setAppOverrideCursor(QCursor cursor)
{
qApp->setOverrideCursor(shape);
qApp->setOverrideCursor(cursor);
}
void QuickTool::restoreAppOverrideCursor()

View File

@ -2,6 +2,7 @@
#include <QObject>
#include <QVariant>
#include <QRect>
#include <QCursor>
#include "TaoCommonGlobal.h"
class TAO_API QuickTool : public QObject
{
@ -10,17 +11,10 @@ public:
explicit QuickTool(QObject *parent = nullptr);
explicit QuickTool(QObject *rootObject, QObject *parent = nullptr);
virtual ~QuickTool() override;
void setRootObjet(QObject *rootObj)
{
pRootObject = rootObj;
}
QObject *rootObject() const
{
return pRootObject;
}
void setRootObjet(QObject *rootObj) { pRootObject = rootObj; }
QObject *rootObject() const { return pRootObject; }
void findRootByNode(QObject *nodeObject);
public slots:
QObject *getObject(const QString &targetObjName) const;
@ -34,8 +28,7 @@ public slots:
QRect getItemGeometryToScene(const QString &targetObjName) const;
void setAppOverrideCursor(Qt::CursorShape shape);
void setAppOverrideCursor(QCursor cursor);
void restoreAppOverrideCursor();
QPoint cursorGlobalPos() const;

View File

@ -10,16 +10,15 @@ INCLUDEPATH += $$PWD \
HEADERS += \
$$PWD/Common/FileReadWrite.h \
$$PWD/Common/ObjectMap.h \
$$PWD/QuickModel/TaoListModelBase.hpp \
$$PWD/QuickTool/QuickTool.h \
$$PWD/Common/Subject.h \
$$PWD/Common/Package.h \
$$PWD/Frameless/TaoFrameLessView.h \
$$PWD/Logger/LoggerTemplate.h \
$$PWD/Logger/Logger.h \
$$PWD/QuickModel/QuickItemBase.h \
$$PWD/QuickModel/QuickListModel.h \
$$PWD/QuickModel/QuickListModelBase.h \
$$PWD/TaoModel/TaoListItemBase.h \
$$PWD/TaoModel/TaoListModel.h \
$$PWD/TaoModel/TaoListModelBase.hpp \
$$PWD/Thread/ThreadCommon.h \
$$PWD/Thread/ThreadPool.h \
$$PWD/Thread/ThreadWorkerController.h \
@ -29,10 +28,9 @@ HEADERS += \
SOURCES += \
$$PWD/Frameless/TaoFrameLessView.cpp \
$$PWD/Logger/Logger.cpp \
$$PWD/QuickModel/QuickItemBase.cpp \
$$PWD/QuickModel/QuickListModel.cpp \
$$PWD/QuickModel/QuickListModelBase.cpp \
$$PWD/QuickTool/QuickTool.cpp \
$$PWD/TaoModel/TaoListItemBase.cpp \
$$PWD/TaoModel/TaoListModel.cpp \
$$PWD/Thread/ThreadPool.cpp \
$$PWD/Trans/Trans.cpp

View File

@ -0,0 +1,8 @@
#include "TaoListItemBase.h"
TaoListItemBase::TaoListItemBase(QObject *parent)
: QObject(parent)
{
}
TaoListItemBase::~TaoListItemBase() {}

View File

@ -2,7 +2,7 @@
#include <QObject>
#include "TaoCommonGlobal.h"
class TAO_API QuickItemBase : public QObject
class TAO_API TaoListItemBase : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isChecked READ isChecked WRITE setIsChecked NOTIFY isCheckedChanged)
@ -10,8 +10,8 @@ class TAO_API QuickItemBase : public QObject
Q_PROPERTY(bool isVisible READ isVisible WRITE setIsVisible NOTIFY isVisibleChanged)
Q_PROPERTY(bool isAlternate READ isAlternate WRITE setIsAlternate NOTIFY isAlternateChanged)
public:
explicit QuickItemBase(QObject *parent = nullptr);
~QuickItemBase() override;
explicit TaoListItemBase(QObject *parent = nullptr);
~TaoListItemBase() override;
bool isChecked() const
{
return mIsChecked;

View File

@ -1,26 +1,26 @@
#include "QuickListModel.h"
#include "QuickItemBase.h"
#include "TaoListModel.h"
#include <algorithm>
QuickListModel::QuickListModel(QObject *parent)
: QuickListModelBase(parent)
TaoListModel::TaoListModel(QObject *parent)
: TaoListModelBase(parent)
{
}
QuickListModel::~QuickListModel()
TaoListModel::~TaoListModel()
{
}
void QuickListModel::check(int row, bool checked)
void TaoListModel::check(int row, bool checked)
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return;
}
mObjs.at(row)->setIsChecked(checked);
if (mObjs.at(row)->isSelected())
mDatas.at(row)->setIsChecked(checked);
if (mDatas.at(row)->isSelected())
{
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible() && obj->isSelected())
{
@ -30,13 +30,13 @@ void QuickListModel::check(int row, bool checked)
}
bool allCheck = true;
if (checked == false || mObjs.count() <= 0)
if (checked == false || mDatas.count() <= 0)
{
allCheck = false;
}
else
{
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible() && false == obj->isChecked())
{
@ -52,9 +52,9 @@ void QuickListModel::check(int row, bool checked)
}
updateCheckedCount();
}
void QuickListModel::setAllChecked(bool allChecked)
void TaoListModel::setAllChecked(bool allChecked)
{
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible())
{
@ -68,10 +68,10 @@ void QuickListModel::setAllChecked(bool allChecked)
mAllChecked = allChecked;
emit allCheckedChanged(mAllChecked);
}
void QuickListModel::search(const QString &searchKey)
void TaoListModel::search(const QString &searchKey)
{
mSearchkey = searchKey.simplified();
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (mVisibleCallback && false == mVisibleCallback(obj))
{
@ -92,9 +92,9 @@ void QuickListModel::search(const QString &searchKey)
updateCalcInfo();
}
void QuickListModel::deselectAll()
void TaoListModel::deselectAll()
{
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible())
{
@ -104,9 +104,9 @@ void QuickListModel::deselectAll()
updateSelectedCount();
}
void QuickListModel::selectAll()
void TaoListModel::selectAll()
{
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible())
{
@ -116,63 +116,63 @@ void QuickListModel::selectAll()
updateSelectedCount();
}
bool QuickListModel::isSelected(int row) const
bool TaoListModel::isSelected(int row) const
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return false;
}
return mObjs.at(row)->isSelected();
return mDatas.at(row)->isSelected();
}
void QuickListModel::select(int row)
void TaoListModel::select(int row)
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return;
}
mObjs.at(row)->setIsSelected(true);
mDatas.at(row)->setIsSelected(true);
updateSelectedCount();
}
void QuickListModel::deselect(int row)
void TaoListModel::deselect(int row)
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return;
}
mObjs.at(row)->setIsSelected(false);
mDatas.at(row)->setIsSelected(false);
updateSelectedCount();
}
void QuickListModel::selectRange(int from, int to)
void TaoListModel::selectRange(int from, int to)
{
int minRow = qMin(from, to);
int maxRow = qMax(from, to);
for (int i = 0; i < mObjs.size(); ++i)
for (int i = 0; i < mDatas.size(); ++i)
{
mObjs.at(i)->setIsSelected(mObjs.at(i)->isVisible() && minRow <= i && i <= maxRow);
mDatas.at(i)->setIsSelected(mDatas.at(i)->isVisible() && minRow <= i && i <= maxRow);
}
updateSelectedCount();
}
void QuickListModel::selectSingle(int row)
void TaoListModel::selectSingle(int row)
{
for (int i = 0; i < mObjs.size(); ++i)
for (int i = 0; i < mDatas.size(); ++i)
{
mObjs.at(i)->setIsSelected(i == row);
mDatas.at(i)->setIsSelected(i == row);
}
updateSelectedCount();
}
void QuickListModel::doPress(int row, bool shift, bool ctrl, bool outRange)
void TaoListModel::doPress(int row, bool shift, bool ctrl, bool outRange)
{
if (outRange)
{
row = mObjs.size();
row = mDatas.size();
}
else
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return;
}
@ -193,16 +193,16 @@ void QuickListModel::doPress(int row, bool shift, bool ctrl, bool outRange)
selectSingle(mLastPressedRow);
}
}
void QuickListModel::doMove(int row, bool outRange)
void TaoListModel::doMove(int row, bool outRange)
{
if (outRange)
{
row = mObjs.size();
row = mDatas.size();
}
else
{
if (row < 0 || row >= mObjs.size())
if (row < 0 || row >= mDatas.size())
{
return;
}
@ -211,37 +211,37 @@ void QuickListModel::doMove(int row, bool outRange)
selectRange(mLastPressedRow, row);
}
}
void QuickListModel::doRelease()
void TaoListModel::doRelease()
{
mIsPressed = false;
}
void QuickListModel::sortByRole()
void TaoListModel::sortByRole()
{
const static auto addRessStr = QStringLiteral("address");
if (mObjs.isEmpty())
if (mDatas.isEmpty())
{
return;
}
const auto &addressCallback = mSortCallbacks.value(addRessStr);
QList<QuickItemBase *> copyObjs;
QList<TaoListItemBase *> copyObjs;
if (mSortRole == addRessStr)
{
if (addressCallback)
{
copyObjs = mObjs;
copyObjs = mDatas;
if (mSortOrder == Qt::SortOrder::AscendingOrder)
{
std::sort(copyObjs.begin(), copyObjs.end(), addressCallback);
}
else
{
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
std::sort(copyObjs.begin(), copyObjs.end(), [=](TaoListItemBase *obj1, TaoListItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
}
beginResetModel();
mObjs = copyObjs;
mDatas = copyObjs;
endResetModel();
}
}
@ -249,21 +249,21 @@ void QuickListModel::sortByRole()
{
if (addressCallback)
{
copyObjs = mObjs;
copyObjs = mDatas;
if (mSortOrder == Qt::SortOrder::AscendingOrder)
{
std::sort(copyObjs.begin(), copyObjs.end(), addressCallback);
}
else
{
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
std::sort(copyObjs.begin(), copyObjs.end(), [=](TaoListItemBase *obj1, TaoListItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
}
}
if (mSortCallbacks.value(mSortRole))
{
if (copyObjs.isEmpty())
{
copyObjs = mObjs;
copyObjs = mDatas;
}
if (mSortOrder == Qt::SortOrder::AscendingOrder)
{
@ -271,19 +271,19 @@ void QuickListModel::sortByRole()
}
else
{
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool {
std::sort(copyObjs.begin(), copyObjs.end(), [=](TaoListItemBase *obj1, TaoListItemBase *obj2) -> bool {
return mSortCallbacks.value(mSortRole)(obj2, obj1);
});
}
beginResetModel();
mObjs = copyObjs;
mDatas = copyObjs;
endResetModel();
}
}
updateAlternate();
}
void QuickListModel::setHeaderRoles(const QStringList &headerRoles)
void TaoListModel::setHeaderRoles(const QStringList &headerRoles)
{
if (mHeaderRoles == headerRoles)
return;
@ -292,7 +292,7 @@ void QuickListModel::setHeaderRoles(const QStringList &headerRoles)
emit headerRolesChanged(mHeaderRoles);
}
void QuickListModel::setSortOrder(Qt::SortOrder sortOrder)
void TaoListModel::setSortOrder(Qt::SortOrder sortOrder)
{
if (mSortOrder == sortOrder)
return;
@ -301,7 +301,7 @@ void QuickListModel::setSortOrder(Qt::SortOrder sortOrder)
emit sortOrderChanged(mSortOrder);
}
void QuickListModel::setSortRole(const QString &sortRole)
void TaoListModel::setSortRole(const QString &sortRole)
{
if (mSortRole == sortRole)
return;
@ -310,11 +310,11 @@ void QuickListModel::setSortRole(const QString &sortRole)
emit sortRoleChanged(mSortRole);
}
void QuickListModel::updateAllCheck()
void TaoListModel::updateAllCheck()
{
bool allCheck = true;
if (!mObjs.empty()) {
allCheck = std::all_of(mObjs.begin(), mObjs.end(), [](QuickItemBase *obj){
if (!mDatas.empty()) {
allCheck = std::all_of(mDatas.begin(), mDatas.end(), [](TaoListItemBase *obj){
return obj->isVisible() && obj->isChecked();
});
}
@ -325,33 +325,33 @@ void QuickListModel::updateAllCheck()
emit allCheckedChanged(mAllChecked);
}
void QuickListModel::updateVisibleCount()
void TaoListModel::updateVisibleCount()
{
int count = std::count_if(mObjs.begin(), mObjs.end(), [](QuickItemBase *obj){
int count = std::count_if(mDatas.begin(), mDatas.end(), [](TaoListItemBase *obj){
return obj->isVisible();
});
setVisibledCount(count);
}
void QuickListModel::updateSelectedCount()
void TaoListModel::updateSelectedCount()
{
int count = std::count_if(mObjs.begin(), mObjs.end(), [](QuickItemBase *obj){
int count = std::count_if(mDatas.begin(), mDatas.end(), [](TaoListItemBase *obj){
return obj->isVisible() && obj->isSelected();
});
setSelectedCount(count);
}
void QuickListModel::updateCheckedCount()
void TaoListModel::updateCheckedCount()
{
int count = std::count_if(mObjs.begin(), mObjs.end(), [](QuickItemBase *obj){
int count = std::count_if(mDatas.begin(), mDatas.end(), [](TaoListItemBase *obj){
return obj->isVisible() && obj->isChecked();
});
setCheckedCount(count);
}
void QuickListModel::updateAlternate()
void TaoListModel::updateAlternate()
{
bool alter = false;
for (const auto &obj : mObjs)
for (const auto &obj : mDatas)
{
if (obj->isVisible())
{
@ -360,7 +360,7 @@ void QuickListModel::updateAlternate()
}
}
}
void QuickListModel::setVisibledCount(int visibledCount)
void TaoListModel::setVisibledCount(int visibledCount)
{
if (mVisibledCount == visibledCount)
return;
@ -369,7 +369,7 @@ void QuickListModel::setVisibledCount(int visibledCount)
emit visibledCountChanged(mVisibledCount);
}
void QuickListModel::setSelectedCount(int selectedCount)
void TaoListModel::setSelectedCount(int selectedCount)
{
if (mSelectedCount == selectedCount)
return;
@ -378,7 +378,7 @@ void QuickListModel::setSelectedCount(int selectedCount)
emit selectedCountChanged(mSelectedCount);
}
void QuickListModel::setCheckedCount(int checkedCount)
void TaoListModel::setCheckedCount(int checkedCount)
{
if (mCheckedCount == checkedCount)
return;
@ -387,7 +387,7 @@ void QuickListModel::setCheckedCount(int checkedCount)
emit checkedCountChanged(mCheckedCount);
}
void QuickListModel::updateCalcInfo()
void TaoListModel::updateCalcInfo()
{
updateAllCheck();
updateCheckedCount();

View File

@ -1,8 +1,9 @@
#pragma once
#include "QuickListModelBase.h"
#include "TaoListModelBase.hpp"
#include "TaoListItemBase.h"
#include "TaoCommonGlobal.h"
class TAO_API QuickListModel : public QuickListModelBase
class TAO_API TaoListModel : public TaoListModelBase<TaoListItemBase *>
{
Q_OBJECT
Q_PROPERTY(bool allChecked READ allChecked WRITE setAllChecked NOTIFY allCheckedChanged)
@ -15,8 +16,8 @@ class TAO_API QuickListModel : public QuickListModelBase
Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged)
public:
explicit QuickListModel(QObject *parent = nullptr);
~QuickListModel() override;
explicit TaoListModel(QObject *parent = nullptr);
~TaoListModel() override;
//[begin] check
bool allChecked() const
@ -29,7 +30,7 @@ public:
//[begin] search. control visible
Q_INVOKABLE void search(const QString &searchKey);
//控制显示隐藏的回调。返回true则show返回false则hide
using VisibleCallback = std::function<bool(QuickItemBase *)>;
using VisibleCallback = std::function<bool(TaoListItemBase *)>;
void setVisibleFilter(const VisibleCallback &callback)
{
mVisibleCallback = callback;
@ -65,7 +66,7 @@ public:
{
return mSortRole;
}
using SortCallback = std::function<bool(QuickItemBase *, QuickItemBase *)>;
using SortCallback = std::function<bool(TaoListItemBase *, TaoListItemBase *)>;
//Map <key, callBack> ,key should match to headerRoles
void setSortCallbacks(const QMap<QString, SortCallback> &callbacksMap)
{

View File

@ -16,14 +16,17 @@ Item {
width: 600
height: 300
border.color: "lightblue"
color: CusConfig.backgroundColor
Rectangle {
x: 10
y: 40
width: 100
height: 100
border.color: "red"
color: CusConfig.themeColor
smooth: true
antialiasing: true
MoveArea {
anchors.fill: parent
onMove: {
@ -38,6 +41,7 @@ Item {
width: 200
height: 160
border.color: "red"
color: CusConfig.backgroundColor
smooth: true
antialiasing: true
CusTemplateDragBorder {
@ -57,7 +61,7 @@ Item {
width: 600
height: 300
border.color: "lightblue"
color: CusConfig.backgroundColor
CusRectDraw {
anchors.fill: parent
}

View File

@ -36,6 +36,20 @@ Item {
}
placeholderText: qsTr("Search") + trans.transString
}
Rectangle {
border.color: CusConfig.controlBorderColor
color: CusConfig.backgroundColor
anchors {
left: cusHeader.left
leftMargin: -1
right: cusHeader.right
rightMargin: -1
top: cusHeader.top
topMargin: -1
bottom: cusView.bottom
bottomMargin: -1
}
}
CusTableHeader {
id: cusHeader
y: 50

View File

@ -14,7 +14,7 @@ CusButton {
background: Rectangle {
width: expandBtn.width
height: expandBtn.height
color: expandBtn.pressed ? CusConfig.controlBorderColor_pressed : (expandBtn.hovered ? CusConfig.controlBorderColor_hovered : CusConfig.controlBorderColor)
color: expandBtn.pressed ? CusConfig.controlBorderColor_pressed : (expandBtn.hovered ? CusConfig.controlBorderColor_hovered : CusConfig.controlColor)
radius: 2
CusImage {
source: imgPath + "Button/expand.png"

View File

@ -70,7 +70,7 @@ Item {
name: "Content Pane"
descript: "show current selected content by list"
targetObjectName: "contentRect"
arrowType: Qt.LeftArrow
arrowType: Qt.RightArrow
}
ListElement {
name: "Tool Buttons"

View File

@ -73,10 +73,9 @@ Item {
noDataText: qsTr("No Data") + trans.transString
section.property: "group"
section.delegate: Rectangle {
section.delegate: Item {
width: listView.width
height: CusConfig.fixedHeight
opacity: 0.8
ExpandBtn {
id: sectionBtn
text: qsTr(section) + trans.transString

View File

@ -1,6 +1,6 @@
#include "DeviceAddItem.h"
DeviceAddItem::DeviceAddItem(QObject *parent)
: QuickItemBase(parent)
: TaoListItemBase(parent)
{
}

View File

@ -1,8 +1,8 @@
#pragma once
#include "QuickModel/QuickItemBase.h"
#include "TaoModel/TaoListItemBase.h"
#include <QObject>
class DeviceAddItem : public QuickItemBase
class DeviceAddItem : public TaoListItemBase
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)

View File

@ -2,9 +2,9 @@
#include "DeviceAddItem.h"
#include <QHostAddress>
DeviceAddModel::DeviceAddModel(QObject *parent)
: QuickListModel(parent)
: TaoListModel(parent)
{
QList<QuickItemBase *> objs;
QList<TaoListItemBase *> objs;
for (int i = 0; i < 20; ++i) {
auto item = new DeviceAddItem;
item->setOnline(i % 7 == 0);
@ -17,13 +17,13 @@ DeviceAddModel::DeviceAddModel(QObject *parent)
setHeaderRoles({ "name", "address", "modelString" });
QMap<QString, SortCallback> callBacks;
callBacks["name"]
= [](QuickItemBase *b1, QuickItemBase *b2) -> bool { return (static_cast<DeviceAddItem *>(b1))->name() < (static_cast<DeviceAddItem *>(b2))->name(); };
callBacks["address"] = [](QuickItemBase *b1, QuickItemBase *b2) -> bool {
= [](TaoListItemBase *b1, TaoListItemBase *b2) -> bool { return (static_cast<DeviceAddItem *>(b1))->name() < (static_cast<DeviceAddItem *>(b2))->name(); };
callBacks["address"] = [](TaoListItemBase *b1, TaoListItemBase *b2) -> bool {
QHostAddress add1(static_cast<DeviceAddItem *>(b1)->address());
QHostAddress add2(static_cast<DeviceAddItem *>(b2)->address());
return add1.toIPv4Address() < add2.toIPv4Address();
};
callBacks["modelString"] = [](QuickItemBase *b1, QuickItemBase *b2) -> bool {
callBacks["modelString"] = [](TaoListItemBase *b1, TaoListItemBase *b2) -> bool {
const QString &s1 = static_cast<DeviceAddItem *>(b1)->modelString();
const QString &s2 = static_cast<DeviceAddItem *>(b2)->modelString();
auto m1 = s1.mid(6, s1.length() - 6).toInt();
@ -44,5 +44,5 @@ void DeviceAddModel::doUpdateName(int row, const QString &name)
{
return;
}
static_cast<DeviceAddItem *>(mObjs.at(row))->setName(name);
static_cast<DeviceAddItem *>(mDatas.at(row))->setName(name);
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <QObject>
#include "QuickModel/QuickListModel.h"
class DeviceAddModel : public QuickListModel
#include "TaoModel/TaoListModel.h"
class DeviceAddModel : public TaoListModel
{
Q_OBJECT
public:

View File

@ -1,8 +1,5 @@
#一部分头文件加入编译预处理,提高编译速度
msvc | gcc | xcode {
CONFIG += precompile_header
PRECOMPILED_HEADER = $$PWD/Src/stdafx.h
}
PRECOMPILED_HEADER = $$PWD/Src/stdafx.h
HEADERS += \
$$PWD/Src/AppInfo.h \

View File

@ -5,10 +5,10 @@ import "../.."
Switch {
id: cusSwitch
property color backgroundColor_on :"#579ee5"
property color backgroundColor_on : CusConfig.themeColor
property color indicatorColor_on: "#ffffff"
property color backgroundColor_on_disable: "#108bcb"
property color backgroundColor_on_disable: Qt.darker(backgroundColor_on, 1.2)
property color indicatorColor_on_disable: "#b6bdc5"
property color backgroundColor_off :"#808080"

View File

@ -95,8 +95,11 @@ ComboBox {
model: cusComboBox.popup.visible ? cusComboBox.delegateModel : null
currentIndex: cusComboBox.highlightedIndex
ScrollBar.vertical: CusScrollBar {
policy: (cusComboBox.popup.height
>= cusComboBox.defaultHeight) ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
// policy: (cusComboBox.popup.height
// >= cusComboBox.defaultHeight) ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
opacity: cusComboBox.popup.height >= cusComboBox.defaultHeight ? 1.0 : 0.0
visible: opacity > 0
active: visible
}
}
@ -128,8 +131,8 @@ ComboBox {
Rectangle {
anchors {
fill: parent
leftMargin: 4
rightMargin: 14
leftMargin: 2
rightMargin: 16
}
radius: CusConfig.controlBorderRadius
color: cusComboBox.hoveredIndex === index ? CusConfig.controlColor_hovered : (cusComboBox.currentIndex === index ? CusConfig.controlColor_pressed : CusConfig.controlColor)

View File

@ -54,7 +54,7 @@ QtObject {
property color controlBorderColor_hovered: Qt.darker(themeColor, 1.2)
property color controlBorderColor_pressed: Qt.darker(themeColor, 1.4)
property color controlColor: Qt.darker(backgroundColor, 1.2)
property color controlColor
property color controlColor_hovered: Qt.darker(themeColor, 1.2)
property color controlColor_pressed: Qt.darker(themeColor, 1.4)
property color controlColor_disabled: Qt.lighter(controlColor, 2.0)
@ -95,7 +95,7 @@ QtObject {
textColor_disabled = t.textColor_disabled
textColor_hovered = t.textColor_hovered
textColor_pressed = t.textColor_pressed
controlColor = t.controlColor
controlBorderColor = t.controlBorderColor
imageColor = t.imageColor
imageColor_disabled = t.imageColor_disabled
@ -120,6 +120,7 @@ QtObject {
textColor_hovered: "#686868"
textColor_pressed: "#212121"
controlColor: "#f5f5f6"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"
@ -129,32 +130,32 @@ QtObject {
ListElement {
name: "Black"
themeColor: "#222225"
backgroundColor: "#272c25"
textColor: "#adafb2"
backgroundColor: "#2b2b2b"
textColor: "#d0d0d0"
splitLineColor:"#c62f2f"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
splitLineColor:"#2d2d30"
invalidColor: "#782c2c"
alterColor: "#383838"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"
textColor_disabled: "#9f9fcf"
textColor_hovered: "#181818"
textColor_pressed: "#000000"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"
scrollBarBackgroundColor: "#e0e0e0"
scrollBarBackgroundColor_hovered: "#cfcfd1"
textColor_disabled: "#877a66"
textColor_hovered: "#ffffff"
textColor_pressed: "#d2d2d2"
controlColor: "#333333"
controlBorderColor: "#555555"
imageColor: "#adafb2"
imageColor_disabled: "#989898"
scrollBarBackgroundColor: "#3f3f3f"
scrollBarBackgroundColor_hovered: "#4a4a4a"
}
ListElement {
name: "Pink"
themeColor: "#faa0c5"
backgroundColor: "#f6f6f6"
backgroundColor: "#ffffff"
textColor: "#5c5c5c"
splitLineColor:"#c62f2f"
splitLineColor:"#fbb8d0"
invalidColor: "#e29696"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
@ -163,7 +164,7 @@ QtObject {
textColor_disabled: "#9f9fcf"
textColor_hovered: "#181818"
textColor_pressed: "#000000"
controlColor: "#f5f5f6"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"
@ -173,10 +174,10 @@ QtObject {
ListElement {
name: "Gold"
themeColor: "#fed98f"
backgroundColor: "#f6f6f6"
backgroundColor: "#ffffff"
textColor: "#5c5c5c"
splitLineColor:"#c62f2f"
splitLineColor:"#f0c896"
invalidColor: "#e29696"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
@ -185,7 +186,7 @@ QtObject {
textColor_disabled: "#9f9fcf"
textColor_hovered: "#181818"
textColor_pressed: "#000000"
controlColor: "#f5f5f6"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"
@ -195,10 +196,10 @@ QtObject {
ListElement {
name: "Green"
themeColor: "#58c979"
backgroundColor: "#f6f6f6"
backgroundColor: "#ffffff"
textColor: "#5c5c5c"
splitLineColor:"#c62f2f"
splitLineColor:"#89d3ad"
invalidColor: "#e29696"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
@ -207,7 +208,7 @@ QtObject {
textColor_disabled: "#9f9fcf"
textColor_hovered: "#181818"
textColor_pressed: "#000000"
controlColor: "#f5f5f6"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"
@ -217,10 +218,10 @@ QtObject {
ListElement {
name: "Blue"
themeColor: "#67c1fd"
backgroundColor: "#f6f6f6"
backgroundColor: "#ffffff"
textColor: "#5c5c5c"
splitLineColor:"#c62f2f"
splitLineColor:"#92cefc"
invalidColor: "#e29696"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
@ -229,7 +230,7 @@ QtObject {
textColor_disabled: "#9f9fcf"
textColor_hovered: "#181818"
textColor_pressed: "#000000"
controlColor: "#f5f5f6"
controlBorderColor: "#cbcbcb"
imageColor: "#373737"
imageColor_disabled: "#9f9fcf"

View File

@ -0,0 +1,22 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
Item {
property alias source: srcImg.source
property alias color: overlayImg.color
Image {
id: srcImg
anchors.fill: parent
visible: false
}
ColorOverlay {
id: overlayImg
source: srcImg
anchors.fill: srcImg
width: srcImg.width
height: srcImg.height
}
}

View File

@ -118,11 +118,13 @@ Item {
color: (moveArea.pressed
|| moveArea.containsMouse) ? CusConfig.controlBorderColor_pressed : CusConfig.controlBorderColor
}
CusImage {
CusImageOverlay {
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
}
width: 8
height: 8
readonly property string ascUrl: CusConfig.imagePathPrefix + "Table_Asc.png"
readonly property string ascUrl_Hovered: CusConfig.imagePathPrefix
+ "Table_Asc_Hovered.png"
@ -136,6 +138,7 @@ Item {
source: visible ? (dataObj.sortOrder === 0 ? ascImageUrl : descImageUrl) : ""
visible: dataObj && dataObj.sortRole === headerRoles[index]
color: headerArea.containsMouse ? CusConfig.imageColor_hovered : CusConfig.imageColor
}
MouseArea {
id: headerArea

View File

@ -110,7 +110,7 @@ ListView {
top: parent.top
topMargin: 10
}
visible: cusTableView.count <= 0
visible: cusTableView.model.visibledCount <= 0
}
CusRectDraw {
id: tableRectItem

View File

@ -4,7 +4,7 @@ import ".."
import "../.."
CusResizeBorder {
id: root
id: cusBorder
x: 0
y: 0
width: parent.width
@ -16,18 +16,19 @@ CusResizeBorder {
property bool rotationEnabled: true
property color rotateHandleColor: "lightgreen"
property color color: CusConfig.themeColor
property color borderColor: CusConfig.controlBorderColor
signal clicked(real x, real y)
signal doubleClicked(real x, real y)
//big
Rectangle {
border.color: CusConfig.controlBorderColor
border.color: cusBorder.borderColor
border.width: 1
color: "transparent"
color: cusBorder.color
radius: borderMargin
anchors.fill: parent
anchors.margins: borderMargin
anchors.margins: borderMargin + 1
}
//line to rotateHandle and Border
Rectangle {
@ -203,10 +204,10 @@ CusResizeBorder {
cursorShape: Qt.PointingHandCursor
drag.target: controller
onClicked: {
root.clicked(x, y)
cusBorder.clicked(x, y)
}
onDoubleClicked: {
root.doubleClicked(x, y)
cusBorder.doubleClicked(x, y)
}
}
}

View File

@ -19,6 +19,7 @@
<file>Qml/CusCheckBox/CusSwitch.qml</file>
<file>Qml/CusComboBox/CusComboBox.qml</file>
<file>Qml/CusImage/CusImage.qml</file>
<file>Qml/CusImage/CusImageOverlay.qml</file>
<file>Qml/CusImage/CusImage_Tip.qml</file>
<file>Qml/CusInput/CusIPAddress.qml</file>
<file>Qml/CusInput/CusTextField.qml</file>

View File

@ -237,6 +237,20 @@ MetaInfo {
Property { name: "height"; type: "int"; value: 80 }
}
}
Type {
name: "TaoQuick.Qml.CusImage.CusImageOverlay"
icon: "images/CusImageOverlay.png"
ItemLibraryEntry {
name: "CusImageOverlay"
category: "TaoQuick - CusImage"
libraryIcon: "images/CusImageOverlay.png"
version: "1.0"
requiredImport: "TaoQuick"
Property { name: "width"; type: "int"; value: 120 }
Property { name: "height"; type: "int"; value: 80 }
}
}
Type {
name: "TaoQuick.Qml.CusImage.CusImage_Tip"
icon: "images/CusImage_Tip.png"
@ -531,20 +545,6 @@ MetaInfo {
Property { name: "height"; type: "int"; value: 80 }
}
}
Type {
name: "TaoQuick.Qml.CusWizard.CusWizardBackground"
icon: "images/CusWizardBackground.png"
ItemLibraryEntry {
name: "CusWizardBackground"
category: "TaoQuick - CusWizard"
libraryIcon: "images/CusWizardBackground.png"
version: "1.0"
requiredImport: "TaoQuick"
Property { name: "width"; type: "int"; value: 120 }
Property { name: "height"; type: "int"; value: 80 }
}
}
Type {
name: "TaoQuick.Qml.CusWizard.CusWizardPage"
icon: "images/CusWizardPage.png"

View File

@ -16,6 +16,7 @@ CusCheckBox 1.0 Qml/CusCheckBox/CusCheckBox.qml
CusSwitch 1.0 Qml/CusCheckBox/CusSwitch.qml
CusComboBox 1.0 Qml/CusComboBox/CusComboBox.qml
CusImage 1.0 Qml/CusImage/CusImage.qml
CusImageOverlay 1.0 Qml/CusImage/CusImageOverlay.qml
CusImage_Tip 1.0 Qml/CusImage/CusImage_Tip.qml
CusIPAddress 1.0 Qml/CusInput/CusIPAddress.qml
CusTextField 1.0 Qml/CusInput/CusTextField.qml