glodata: add global struct data.
This commit is contained in:
@@ -37,7 +37,7 @@ void Compare::InitTabWidget()
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||
|
||||
ui->tableWidget->setDragEnabled(true);
|
||||
ui->tableWidget->setDragEnabled(false);
|
||||
ui->tableWidget->viewport()->setAcceptDrops(true);
|
||||
ui->tableWidget->setDropIndicatorShown(true);
|
||||
ui->tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
@@ -27,17 +27,19 @@ void FileManager::SetModeStr(const QString& modeStr, int type, ClientCore* clien
|
||||
|
||||
ui->lbMode->setText(modeStr);
|
||||
if (type == 0) {
|
||||
isRemote_ = false;
|
||||
fileHelper_ = std::make_shared<LocalFile>();
|
||||
} else {
|
||||
auto remotePtr = std::make_shared<RemoteFile>();
|
||||
remotePtr->setClientCore(clientCore);
|
||||
isRemote_ = true;
|
||||
ui->tableWidget->setIsRemote(true);
|
||||
fileHelper_ = remotePtr;
|
||||
}
|
||||
|
||||
ui->tableWidget->setOwnIDCall([this]() { return cliCore_->GetOwnID(); });
|
||||
ui->tableWidget->setRemoteIDCall([this]() { return cliCore_->GetRemoteID(); });
|
||||
ui->tableWidget->setBasePathCall([this]() { return curRoot_; });
|
||||
ui->tableWidget->setBasePathCall([this]() { return GetRoot(); });
|
||||
|
||||
connect(fileHelper_.get(), &DirFileHelper::sigHome, this, &FileManager::ShowPath);
|
||||
connect(fileHelper_.get(), &DirFileHelper::sigDirFile, this, &FileManager::ShowFile);
|
||||
@@ -177,15 +179,33 @@ void FileManager::ShowFile(const DirFileInfoVec& info)
|
||||
ui->tableWidget->setItem(i, 4, item);
|
||||
}
|
||||
ui->tableWidget->resizeColumnToContents(0);
|
||||
curRoot_ = info.root;
|
||||
ShowPath(curRoot_);
|
||||
SetRoot(info.root);
|
||||
ShowPath(GetRoot());
|
||||
}
|
||||
|
||||
void FileManager::SetRoot(const QString& path)
|
||||
{
|
||||
if (isRemote_) {
|
||||
GlobalData::Ins()->SetRemoteRoot(path);
|
||||
} else {
|
||||
GlobalData::Ins()->SetLocalRoot(path);
|
||||
}
|
||||
}
|
||||
|
||||
QString FileManager::GetRoot()
|
||||
{
|
||||
if (isRemote_) {
|
||||
return GlobalData::Ins()->GetRemoteRoot();
|
||||
} else {
|
||||
return GlobalData::Ins()->GetLocalRoot();
|
||||
}
|
||||
}
|
||||
|
||||
void FileManager::evtHome()
|
||||
{
|
||||
auto r = fileHelper_->GetHome();
|
||||
auto curPath = ui->comboBox->currentText();
|
||||
curRoot_ = curPath;
|
||||
SetRoot(curPath);
|
||||
qDebug() << QString(tr("%1 get home ret:%2").arg(__FUNCTION__).arg(r));
|
||||
}
|
||||
|
||||
@@ -193,13 +213,13 @@ void FileManager::evtFile()
|
||||
{
|
||||
auto curPath = ui->comboBox->currentText();
|
||||
auto r = fileHelper_->GetDirFile(curPath);
|
||||
curRoot_ = curPath;
|
||||
SetRoot(curPath);
|
||||
qDebug() << QString(tr("%1 get files ret:%2").arg(__FUNCTION__).arg(r));
|
||||
}
|
||||
|
||||
void FileManager::evtUp()
|
||||
{
|
||||
QString path(curRoot_);
|
||||
QString path(GetRoot());
|
||||
QDir dir(path);
|
||||
path = QDir::cleanPath(dir.absolutePath() + "/..");
|
||||
if (path.isEmpty()) {
|
||||
@@ -207,8 +227,8 @@ void FileManager::evtUp()
|
||||
}
|
||||
auto r = fileHelper_->GetDirFile(path);
|
||||
if (r) {
|
||||
curRoot_ = path;
|
||||
ShowPath(curRoot_);
|
||||
SetRoot(path);
|
||||
ShowPath(GetRoot());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +246,7 @@ void FileManager::doubleClick(int row, int column)
|
||||
return;
|
||||
}
|
||||
|
||||
QDir dir(curRoot_);
|
||||
QDir dir(GetRoot());
|
||||
QString np = dir.filePath(item->text());
|
||||
fileHelper_->GetDirFile(np);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ public:
|
||||
~FileManager();
|
||||
|
||||
public:
|
||||
QString GetRoot();
|
||||
void SetModeStr(const QString& modeStr, int type = 0, ClientCore* clientCore = nullptr);
|
||||
void SetOtherSideCall(const std::function<QString()>& call);
|
||||
QString GetCurRoot();
|
||||
|
||||
signals:
|
||||
void sigSendTasks(const QVector<TransTask>& tasks);
|
||||
@@ -35,6 +35,7 @@ private:
|
||||
void ShowPath(const QString& path);
|
||||
void ShowFile(const DirFileInfoVec& info);
|
||||
void doubleClick(int row, int column);
|
||||
void SetRoot(const QString& path);
|
||||
|
||||
private:
|
||||
void evtHome();
|
||||
@@ -42,8 +43,8 @@ private:
|
||||
void evtUp();
|
||||
|
||||
private:
|
||||
bool isRemote_;
|
||||
Ui::FileManager* ui;
|
||||
QString curRoot_;
|
||||
QMenu* menu_;
|
||||
ClientCore* cliCore_;
|
||||
QMutex cbMut_;
|
||||
|
||||
@@ -17,12 +17,31 @@ CpTableWidget::~CpTableWidget()
|
||||
|
||||
void CpTableWidget::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist");
|
||||
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
||||
|
||||
QList<QTableWidgetItem*> draggedItems;
|
||||
while (!stream.atEnd()) {
|
||||
int row, col;
|
||||
QMap<int, QVariant> roleData;
|
||||
stream >> row >> col >> roleData;
|
||||
if (col != 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CpTableWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
|
||||
if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
event->acceptProposedAction();
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@ void CustomTableWidget::setBasePathCall(const std::function<QString()>& call)
|
||||
basePathCall_ = call;
|
||||
}
|
||||
|
||||
QString FileManager::GetCurRoot()
|
||||
{
|
||||
return curRoot_;
|
||||
}
|
||||
|
||||
void CustomTableWidget::setOwnIDCall(const std::function<QString()>& call)
|
||||
{
|
||||
oidCall_ = call;
|
||||
|
||||
@@ -47,9 +47,9 @@ void frelayGUI::InitControl()
|
||||
remoteFile_ = new FileManager(this);
|
||||
|
||||
localFile_->SetModeStr(tr("Local:"), 0, clientCore_);
|
||||
localFile_->SetOtherSideCall([this]() { return remoteFile_->GetCurRoot(); });
|
||||
localFile_->SetOtherSideCall([this]() { return remoteFile_->GetRoot(); });
|
||||
remoteFile_->SetModeStr(tr("Remote:"), 1, clientCore_);
|
||||
remoteFile_->SetOtherSideCall([this]() { return localFile_->GetCurRoot(); });
|
||||
remoteFile_->SetOtherSideCall([this]() { return localFile_->GetRoot(); });
|
||||
|
||||
tabWidget_ = new QTabWidget(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user