mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Ref T345, clear model function
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QAbstractItemModel>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
@@ -412,6 +413,15 @@ namespace BlackGui
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CGuiUtility::clearModel(QAbstractItemModel *model)
|
||||||
|
{
|
||||||
|
if (!model) { return 0; }
|
||||||
|
const int count = model->rowCount();
|
||||||
|
if (count < 1) { return 0; }
|
||||||
|
model->removeRows(0, count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
bool CGuiUtility::isTopLevelWidget(QWidget *widget)
|
bool CGuiUtility::isTopLevelWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
if (!widget) { return false; }
|
if (!widget) { return false; }
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class QLayout;
|
|||||||
class QMimeData;
|
class QMimeData;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
class QGraphicsOpacityEffect;
|
class QGraphicsOpacityEffect;
|
||||||
|
class QAbstractItemModel;
|
||||||
|
|
||||||
namespace BlackMisc { class CIcon; }
|
namespace BlackMisc { class CIcon; }
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
@@ -170,6 +171,9 @@ namespace BlackGui
|
|||||||
//! Only the row part and unique (so no rows is twice in the list)
|
//! Only the row part and unique (so no rows is twice in the list)
|
||||||
static QList<int> indexToUniqueRows(const QModelIndexList &indexes);
|
static QList<int> indexToUniqueRows(const QModelIndexList &indexes);
|
||||||
|
|
||||||
|
//! Clear a model
|
||||||
|
static int clearModel(QAbstractItemModel *model);
|
||||||
|
|
||||||
//! Is top level widget?
|
//! Is top level widget?
|
||||||
static bool isTopLevelWidget(QWidget *widget);
|
static bool isTopLevelWidget(QWidget *widget);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user