Sandboxie/SandboxiePlus/SandMan/Models/SbieModel.h

75 lines
2.4 KiB
C
Raw Normal View History

2020-06-01 17:11:56 +01:00
#pragma once
#include <qwidget.h>
2020-06-18 16:44:29 +01:00
#include "../SbiePlusAPI.h"
2020-06-01 17:11:56 +01:00
#include "../../MiscHelpers/Common/TreeItemModel.h"
class CSbieModel : public CTreeItemModel
{
Q_OBJECT
public:
CSbieModel(QObject *parent = 0);
~CSbieModel();
2021-01-26 20:58:43 +00:00
QList<QVariant> Sync(const QMap<QString, CSandBoxPtr>& BoxList, const QMap<QString, QStringList>& Groups = QMap<QString, QStringList>(), bool ShowHidden = false);
2020-06-01 17:11:56 +01:00
CSandBoxPtr GetSandBox(const QModelIndex &index) const;
CBoxedProcessPtr GetProcess(const QModelIndex &index) const;
2020-12-07 16:34:20 +00:00
QVariant GetID(const QModelIndex &index) const;
enum ETypes
{
eNone = 0,
eGroup,
eBox,
eProcess
} GetType(const QModelIndex &index) const;
2020-06-01 17:11:56 +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,
2021-01-26 20:58:43 +00:00
eTitle,
2020-06-01 17:11:56 +01:00
eStatus,
//eLogCount,
eTimeStamp,
2020-07-04 11:07:36 +01:00
ePath,
2020-06-01 17:11:56 +01:00
eCount
};
protected:
2020-12-07 16:34:20 +00:00
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);
2020-06-01 17:11:56 +01:00
struct SSandBoxNode: STreeNode
{
2021-07-05 12:37:28 +01:00
SSandBoxNode(const QVariant& Id) : STreeNode(Id) { inUse = false; boxType = -1; }
2020-06-01 17:11:56 +01:00
CSandBoxPtr pBox;
2021-07-05 12:37:28 +01:00
bool inUse;
2020-06-18 16:44:29 +01:00
int boxType;
2020-06-01 17:11:56 +01:00
CBoxedProcessPtr pProcess;
};
virtual STreeNode* MkNode(const QVariant& Id) { return new SSandBoxNode(Id); }
2020-11-28 16:20:56 +00:00
QList<QVariant> MakeProcPath(const QString& BoxName, const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList);
QList<QVariant> MakeProcPath(const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList);
bool TestProcPath(const QList<QVariant>& Path, const QString& BoxName, const CBoxedProcessPtr& pProcess, const QMap<quint32, CBoxedProcessPtr>& ProcessList, int Index = 0);
2020-06-01 17:11:56 +01:00
2020-12-07 16:34:20 +00:00
QString FindParent(const QVariant& Name, const QMap<QString, QStringList>& Groups);
QList<QVariant> MakeBoxPath(const QVariant& Name, const QMap<QString, QStringList>& Groups);
2021-02-14 19:18:29 +00:00
void MakeBoxPath(const QVariant& Name, const QMap<QString, QStringList>& Groups, QList<QVariant>& Path);
2020-12-07 16:34:20 +00:00
2020-06-01 17:11:56 +01:00
//virtual QVariant GetDefaultIcon() const;
private:
2020-06-18 16:44:29 +01:00
//QIcon m_BoxEmpty;
//QIcon m_BoxInUse;
2020-06-01 17:11:56 +01:00
QIcon m_ExeIcon;
};