Call: Use signal slots uniformly for calling.
This commit is contained in:
@@ -21,7 +21,7 @@ Connecter::~Connecter()
|
||||
void Connecter::SetClientCore(ClientCore* clientCore)
|
||||
{
|
||||
clientCore_ = clientCore;
|
||||
clientCore_->SetClientsCall([this](const InfoClientVec& clients) { HandleClients(clients); });
|
||||
connect(clientCore_, &ClientCore::sigClients, this, &Connecter::HandleClients);
|
||||
}
|
||||
|
||||
void Connecter::SetRemoteCall(const std::function<void(const QString& id)>& call)
|
||||
|
||||
@@ -26,13 +26,9 @@ void FileManager::SetModeStr(const QString& modeStr, int type, ClientCore* clien
|
||||
ui->lbMode->setText(modeStr);
|
||||
if (type == 0) {
|
||||
fileHelper_ = std::make_shared<LocalFile>();
|
||||
fileHelper_->registerPathCall([this](const QString& path) { ShowPath(path); });
|
||||
fileHelper_->registerFileCall([this](const DirFileInfoVec& info) { ShowFile(info); });
|
||||
} else {
|
||||
cliCore_ = clientCore;
|
||||
auto remotePtr = std::make_shared<RemoteFile>();
|
||||
remotePtr->registerPathCall([this](const QString& path) { ShowPath(path); });
|
||||
remotePtr->registerFileCall([this](const DirFileInfoVec& info) { ShowFile(info); });
|
||||
remotePtr->setClientCore(clientCore);
|
||||
ui->tableWidget->setIsRemote(true);
|
||||
ui->tableWidget->setOwnIDCall([this]() { return cliCore_->GetOwnID(); });
|
||||
@@ -40,6 +36,9 @@ void FileManager::SetModeStr(const QString& modeStr, int type, ClientCore* clien
|
||||
fileHelper_ = remotePtr;
|
||||
}
|
||||
ui->tableWidget->setBasePathCall([this]() { return curRoot_; });
|
||||
|
||||
connect(fileHelper_.get(), &DirFileHelper::sigHome, this, &FileManager::ShowPath);
|
||||
connect(fileHelper_.get(), &DirFileHelper::sigDirFile, this, &FileManager::ShowFile);
|
||||
}
|
||||
|
||||
void FileManager::SetOtherSideCall(const std::function<QString()>& call)
|
||||
@@ -92,6 +91,7 @@ void FileManager::InitMenu(bool remote)
|
||||
|
||||
void FileManager::ShowPath(const QString& path)
|
||||
{
|
||||
QMutexLocker locker(&cbMut_);
|
||||
int existingIndex = ui->comboBox->findText(path);
|
||||
if (existingIndex != -1) {
|
||||
ui->comboBox->removeItem(existingIndex);
|
||||
@@ -104,8 +104,8 @@ void FileManager::ShowPath(const QString& path)
|
||||
|
||||
void FileManager::ShowFile(const DirFileInfoVec& info)
|
||||
{
|
||||
QAbstractItemModel* const mdl = ui->tableWidget->model();
|
||||
mdl->removeRows(0, mdl->rowCount());
|
||||
QMutexLocker locker(&tbMut_);
|
||||
ui->tableWidget->setRowCount(0);
|
||||
ui->tableWidget->setRowCount(info.vec.size());
|
||||
|
||||
for (int i = 0; i < info.vec.size(); ++i) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <InfoDirFile.h>
|
||||
#include <QWidget>
|
||||
#include <Util.h>
|
||||
#include <QMutex>
|
||||
#include <QMenu>
|
||||
|
||||
namespace Ui {
|
||||
@@ -45,6 +46,8 @@ private:
|
||||
QString curRoot_;
|
||||
QMenu* menu_;
|
||||
ClientCore* cliCore_;
|
||||
QMutex cbMut_;
|
||||
QMutex tbMut_;
|
||||
std::shared_ptr<DirFileHelper> fileHelper_;
|
||||
};
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ void frelayGUI::ControlLayout()
|
||||
void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
if (!logPrint) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
|
||||
Reference in New Issue
Block a user