Call: Use signal slots uniformly for calling.
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
#include "LocalFile.h"
|
||||
#include "LocalFile.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
LocalFile::LocalFile(QObject* parent) : DirFileHelper(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool LocalFile::GetHome()
|
||||
{
|
||||
auto home = Util::GetUserHome();
|
||||
pathCall_(home);
|
||||
emit sigHome(home);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,7 +21,7 @@ bool LocalFile::GetDirFile(const QString& dir)
|
||||
if (!GetDirFile(dir, vec)) {
|
||||
return false;
|
||||
}
|
||||
fileCall_(vec);
|
||||
emit sigDirFile(vec);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef LOCALFILE_H
|
||||
#ifndef LOCALFILE_H
|
||||
#define LOCALFILE_H
|
||||
|
||||
#include <InfoDirFile.h>
|
||||
@@ -8,7 +8,7 @@
|
||||
class LocalFile : public DirFileHelper
|
||||
{
|
||||
public:
|
||||
LocalFile() = default;
|
||||
LocalFile(QObject* parent = nullptr);
|
||||
~LocalFile() override = default;
|
||||
|
||||
public:
|
||||
|
||||
@@ -109,12 +109,7 @@ QString DirFileHelper::GetErr() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
void DirFileHelper::registerPathCall(const std::function<void(const QString& path)>& call)
|
||||
DirFileHelper::DirFileHelper(QObject* parent) : QObject(parent)
|
||||
{
|
||||
pathCall_ = call;
|
||||
}
|
||||
|
||||
void DirFileHelper::registerFileCall(const std::function<void(const DirFileInfoVec& vec)>& call)
|
||||
{
|
||||
fileCall_ = call;
|
||||
}
|
||||
}
|
||||
10
Util/Util.h
10
Util/Util.h
@@ -22,18 +22,18 @@ class DirFileHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DirFileHelper() = default;
|
||||
DirFileHelper(QObject* parent = nullptr);
|
||||
virtual ~DirFileHelper() = default;
|
||||
|
||||
public:
|
||||
QString GetErr() const;
|
||||
void registerPathCall(const std::function<void(const QString& path)>& call);
|
||||
void registerFileCall(const std::function<void(const DirFileInfoVec& vec)>& call);
|
||||
|
||||
signals:
|
||||
void sigHome(const QString& path);
|
||||
void sigDirFile(const DirFileInfoVec& dirFile);
|
||||
|
||||
protected:
|
||||
QString err_;
|
||||
std::function<void(const QString& path)> pathCall_;
|
||||
std::function<void(const DirFileInfoVec& info)> fileCall_;
|
||||
|
||||
public:
|
||||
virtual bool GetHome() = 0;
|
||||
|
||||
Reference in New Issue
Block a user