forked from linuxdeepin/deepin-unioncode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [toolchain] Optimize the CMake toolchain configuration
as title Log: Optimize toolchain configuration
- Loading branch information
1 parent
410d290
commit e357e32
Showing
35 changed files
with
1,999 additions
and
1,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "kitlistmodel.h" | ||
|
||
#include <QUuid> | ||
|
||
KitListModel::KitListModel(QObject *parent) | ||
: QAbstractItemModel(parent) | ||
{ | ||
} | ||
|
||
int KitListModel::columnCount(const QModelIndex &parent) const | ||
{ | ||
return 1; | ||
} | ||
|
||
QVariant KitListModel::data(const QModelIndex &index, int role) const | ||
{ | ||
if (index.row() < 0 || index.row() >= kitItemList.size()) | ||
return {}; | ||
|
||
switch (role) { | ||
case Qt::ToolTipRole: | ||
case Qt::DisplayRole: | ||
return kitItemList.value(index.row()).kitName(); | ||
default: | ||
break; | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
QModelIndex KitListModel::index(int row, int column, const QModelIndex &parent) const | ||
{ | ||
Q_UNUSED(parent) | ||
|
||
if (column == 0 && row < kitItemList.size()) { | ||
const auto &item = kitItemList.at(row); | ||
return createIndex(row, 0, const_cast<Kit *>(&item)); | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
QModelIndex KitListModel::parent(const QModelIndex &child) const | ||
{ | ||
return {}; | ||
} | ||
|
||
int KitListModel::rowCount(const QModelIndex &parent) const | ||
{ | ||
return kitItemList.size(); | ||
} | ||
|
||
Kit *KitListModel::itemForIndex(const QModelIndex &index) | ||
{ | ||
return static_cast<Kit *>(index.internalPointer()); | ||
} | ||
|
||
void KitListModel::setItemList(const QList<Kit> &itemList) | ||
{ | ||
beginResetModel(); | ||
kitItemList = itemList; | ||
endResetModel(); | ||
} | ||
|
||
QModelIndex KitListModel::addItem() | ||
{ | ||
Kit item; | ||
item.setKitName(tr("Unnamed")); | ||
|
||
int pos = kitItemList.size(); | ||
beginInsertRows(QModelIndex(), pos, pos); | ||
kitItemList.append(item); | ||
endInsertRows(); | ||
|
||
return index(pos, 0); | ||
} | ||
|
||
void KitListModel::removeItem(const QModelIndex &index) | ||
{ | ||
auto item = itemForIndex(index); | ||
if (!item) | ||
return; | ||
|
||
int pos = kitItemList.indexOf(*item); | ||
beginRemoveRows(QModelIndex(), pos, pos); | ||
kitItemList.removeAt(pos); | ||
endRemoveRows(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef KITLISTMODEL_H | ||
#define KITLISTMODEL_H | ||
|
||
#include "global_define.h" | ||
#include "cmake/option/kit.h" | ||
|
||
#include <QAbstractItemModel> | ||
|
||
class KitListModel : public QAbstractItemModel | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit KitListModel(QObject *parent = nullptr); | ||
|
||
int columnCount(const QModelIndex &parent = QModelIndex()) const override; | ||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | ||
QModelIndex parent(const QModelIndex &child) const override; | ||
int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
|
||
Kit *itemForIndex(const QModelIndex &index); | ||
void setItemList(const QList<Kit> &itemList); | ||
QList<Kit> itemList() const { return kitItemList; } | ||
QModelIndex addItem(); | ||
void removeItem(const QModelIndex &index); | ||
|
||
private: | ||
QList<Kit> kitItemList; | ||
}; | ||
|
||
#endif // KITLISTMODEL_H |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.