2021-10-16 16:19:51 +01:00
|
|
|
#pragma once
|
|
|
|
#include <qwidget.h>
|
|
|
|
#include "../SbiePlusAPI.h"
|
2022-02-05 14:09:53 +00:00
|
|
|
#include "../SbieProcess.h"
|
2021-10-16 16:19:51 +01:00
|
|
|
#include "../../MiscHelpers/Common/TreeItemModel.h"
|
2022-04-16 14:01:01 +01:00
|
|
|
#include <QMimeData>
|
2022-05-16 20:30:40 +01:00
|
|
|
#include <QFileIconProvider>
|
2021-10-16 16:19:51 +01:00
|
|
|
|
|
|
|
class CSbieModel : public CTreeItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CSbieModel(QObject *parent = 0);
|
|
|
|
~CSbieModel();
|
|
|
|
|
|
|
|
QList<QVariant> Sync(const QMap<QString, CSandBoxPtr>& BoxList, const QMap<QString, QStringList>& Groups = QMap<QString, QStringList>(), bool ShowHidden = false);
|
|
|
|
|
2022-09-29 17:28:48 +01:00
|
|
|
void SetTree(bool bTree) { m_bTree = bTree; }
|
|
|
|
bool IsTree() const { return m_bTree; }
|
|
|
|
void SetLargeIcons(bool bSet = true) { m_LargeIcons = bSet; }
|
2022-07-09 10:46:07 +01:00
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
CSandBoxPtr GetSandBox(const QModelIndex &index) const;
|
|
|
|
CBoxedProcessPtr GetProcess(const QModelIndex &index) const;
|
2022-04-16 14:01:01 +01:00
|
|
|
QString GetGroup(const QModelIndex &index) const;
|
2021-10-16 16:19:51 +01:00
|
|
|
QVariant GetID(const QModelIndex &index) const;
|
|
|
|
|
|
|
|
enum ETypes
|
|
|
|
{
|
|
|
|
eNone = 0,
|
|
|
|
eGroup,
|
|
|
|
eBox,
|
|
|
|
eProcess
|
|
|
|
} GetType(const QModelIndex &index) const;
|
|
|
|
|
2022-04-16 14:01:01 +01:00
|
|
|
Qt::DropActions supportedDropActions() const { return Qt::MoveAction; }
|
2022-07-09 10:46:07 +01:00
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
2022-04-16 14:01:01 +01:00
|
|
|
QStringList mimeTypes() { return QStringList() << m_SbieModelMimeType; }
|
|
|
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
|
|
|
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const { return true; }
|
|
|
|
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
|
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
enum EColumns
|
|
|
|
{
|
|
|
|
eName = 0,
|
|
|
|
eProcessId,
|
|
|
|
eTitle,
|
|
|
|
eStatus,
|
2022-05-16 20:30:40 +01:00
|
|
|
eInfo,
|
|
|
|
//eSize,
|
2021-10-16 16:19:51 +01:00
|
|
|
//eLogCount,
|
2022-05-16 20:30:40 +01:00
|
|
|
//eTimeStamp,
|
2021-10-16 16:19:51 +01:00
|
|
|
ePath,
|
|
|
|
eCount
|
|
|
|
};
|
|
|
|
|
2022-04-16 14:01:01 +01:00
|
|
|
signals:
|
2022-06-04 20:07:04 +01:00
|
|
|
void MoveBox(const QString& Name, const QString& To, int row);
|
|
|
|
void MoveGroup(const QString& Name, const QString& To, int row);
|
2022-04-16 14:01:01 +01:00
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
protected:
|
|
|
|
bool Sync(const CSandBoxPtr& pBox, const QList<QVariant>& Path, const QMap<quint32, CBoxedProcessPtr>& ProcessList, QMap<QList<QVariant>, QList<STreeNode*> >& New, QHash<QVariant, STreeNode*>& Old, QList<QVariant>& Added);
|
|
|
|
|
|
|
|
struct SSandBoxNode: STreeNode
|
|
|
|
{
|
2023-05-29 19:50:51 +01:00
|
|
|
SSandBoxNode(CTreeItemModel* pModel, const QVariant& Id) : STreeNode(pModel, Id) { inUse = false; bOpen = false; busyState = 0; boxType = -1; boxDel = false; boxNoForce = false; boxColor = 0; OrderNumber = 0; }
|
2021-10-16 16:19:51 +01:00
|
|
|
|
|
|
|
CSandBoxPtr pBox;
|
|
|
|
bool inUse;
|
2022-09-29 17:28:48 +01:00
|
|
|
bool bOpen;
|
2022-02-05 14:09:53 +00:00
|
|
|
int busyState;
|
2021-10-16 16:19:51 +01:00
|
|
|
int boxType;
|
2022-11-07 11:06:15 +00:00
|
|
|
bool boxDel;
|
2023-04-29 10:55:43 +01:00
|
|
|
bool boxNoForce;
|
2022-07-10 17:28:10 +01:00
|
|
|
int boxColor;
|
2021-10-16 16:19:51 +01:00
|
|
|
int OrderNumber;
|
2022-12-16 12:08:49 +00:00
|
|
|
QString BoxIcon;
|
2021-10-16 16:19:51 +01:00
|
|
|
|
|
|
|
CBoxedProcessPtr pProcess;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual QVariant NodeData(STreeNode* pNode, int role, int section) const;
|
|
|
|
|
2023-05-29 19:50:51 +01:00
|
|
|
virtual STreeNode* MkNode(const QVariant& Id) { return new SSandBoxNode(this, Id); }
|
2021-10-16 16:19:51 +01:00
|
|
|
|
|
|
|
QList<QVariant> MakeProcPath(const QString& BoxName, const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList);
|
2022-01-06 17:36:09 +00:00
|
|
|
void MakeProcPath(const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList, QList<QVariant>& Path);
|
2021-10-16 16:19:51 +01:00
|
|
|
bool TestProcPath(const QList<QVariant>& Path, const QString& BoxName, const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList, int Index = 0);
|
|
|
|
|
|
|
|
QString FindParent(const QVariant& Name, const QMap<QString, QStringList>& Groups);
|
|
|
|
QList<QVariant> MakeBoxPath(const QVariant& Name, const QMap<QString, QStringList>& Groups);
|
|
|
|
void MakeBoxPath(const QVariant& Name, const QMap<QString, QStringList>& Groups, QList<QVariant>& Path);
|
|
|
|
|
|
|
|
//virtual QVariant GetDefaultIcon() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-09-29 17:28:48 +01:00
|
|
|
bool m_bTree;
|
2022-07-09 10:46:07 +01:00
|
|
|
bool m_LargeIcons;
|
2021-10-16 16:19:51 +01:00
|
|
|
//QIcon m_BoxEmpty;
|
|
|
|
//QIcon m_BoxInUse;
|
|
|
|
QIcon m_ExeIcon;
|
2022-04-16 14:01:01 +01:00
|
|
|
|
|
|
|
QString m_SbieModelMimeType;
|
2022-05-16 20:30:40 +01:00
|
|
|
QFileIconProvider m_IconProvider;
|
2020-06-01 17:11:56 +01:00
|
|
|
};
|