新增存款计算器
This commit is contained in:
@@ -106,6 +106,12 @@ void SaveLog::save(const QString &content)
|
||||
if (toNet) {
|
||||
emit send(content);
|
||||
} else {
|
||||
//检查目录是否存在,不存在则先新建
|
||||
QDir dir(path);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir(path);
|
||||
}
|
||||
|
||||
//方法改进:之前每次输出日志都打开文件,改成只有当日期改变时才新建和打开文件
|
||||
QString fileName = QString("%1/%2_log_%3.txt").arg(path).arg(name).arg(QDATE);
|
||||
if (this->fileName != fileName) {
|
||||
|
||||
@@ -44,10 +44,11 @@ private:
|
||||
//日志文件完整名称
|
||||
QString fileName;
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
//发送内容信号
|
||||
void send(const QString &content);
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
//启动日志服务
|
||||
void start();
|
||||
//暂停日志服务
|
||||
@@ -61,7 +62,6 @@ public slots:
|
||||
void setPath(const QString &path);
|
||||
//设置日志文件名称
|
||||
void setName(const QString &name);
|
||||
|
||||
};
|
||||
|
||||
class SendLog : public QObject
|
||||
@@ -74,13 +74,17 @@ public:
|
||||
|
||||
private:
|
||||
static QScopedPointer<SendLog> self;
|
||||
|
||||
//网络通信对象
|
||||
QTcpSocket *socket;
|
||||
//网络监听服务器
|
||||
QTcpServer *server;
|
||||
|
||||
private slots:
|
||||
//新连接到来
|
||||
void newConnection();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
//发送日志
|
||||
void send(const QString &content);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user