52 lines
729 B
C
52 lines
729 B
C
|
#pragma once
|
|||
|
|
|||
|
#include <QObject>
|
|||
|
#include <QList>
|
|||
|
template <typename T>
|
|||
|
class AutoDeleteList
|
|||
|
{
|
|||
|
public:
|
|||
|
// <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
|||
|
void add(T *obj)
|
|||
|
{
|
|||
|
objs.append(obj);
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
~AutoDeleteList()
|
|||
|
{
|
|||
|
qDeleteAll(objs);
|
|||
|
}
|
|||
|
|
|||
|
private:
|
|||
|
QList<T *> objs;
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
class ExitManager : public QObject
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>˳<EFBFBD>ʱ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
template <typename T>
|
|||
|
void add(T *obj)
|
|||
|
{
|
|||
|
autoDeleteList.add(obj);
|
|||
|
}
|
|||
|
|
|||
|
// <20>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD>
|
|||
|
void exit(int exitCode = 0)
|
|||
|
{
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
emit exitApplication(exitCode);
|
|||
|
}
|
|||
|
|
|||
|
signals:
|
|||
|
// <20>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
void exitApplication(int exitCode);
|
|||
|
|
|||
|
private:
|
|||
|
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
AutoDeleteList<QObject> autoDeleteList;
|
|||
|
};
|