add: try to visit compare's dir.
This commit is contained in:
@@ -11,6 +11,7 @@ Compare::Compare(QWidget* parent) : QWidget(parent), ui(new Ui::Compare)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitControl();
|
||||
InitMenu();
|
||||
}
|
||||
|
||||
Compare::~Compare()
|
||||
@@ -18,6 +19,33 @@ Compare::~Compare()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Compare::InitMenu()
|
||||
{
|
||||
menu_ = new QMenu(ui->tableWidget);
|
||||
menu_->addAction(tr("Try2Local"), this, [this]() {
|
||||
auto selected = ui->tableWidget->selectedItems();
|
||||
if (selected.size() != 3) {
|
||||
return;
|
||||
}
|
||||
auto item = selected[1];
|
||||
auto path = item->text();
|
||||
emit sigTryVisit(true, path);
|
||||
});
|
||||
menu_->addAction(tr("Try2Remote"), this, [this]() {
|
||||
auto selected = ui->tableWidget->selectedItems();
|
||||
if (selected.size() != 3) {
|
||||
return;
|
||||
}
|
||||
auto item = selected[2];
|
||||
auto path = item->text();
|
||||
emit sigTryVisit(false, path);
|
||||
});
|
||||
menu_->addAction(tr("Delete"), this, [this]() { deleteSelectedRows(); });
|
||||
menu_->addSeparator();
|
||||
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this,
|
||||
[this](const QPoint& pos) { menu_->exec(QCursor::pos()); });
|
||||
}
|
||||
|
||||
void Compare::InitControl()
|
||||
{
|
||||
InitTabWidget();
|
||||
@@ -26,7 +54,6 @@ void Compare::InitControl()
|
||||
connect(ui->btnLoad, &QPushButton::clicked, this, &Compare::Load);
|
||||
connect(ui->btnLeft, &QPushButton::clicked, this, &Compare::TransToLeft);
|
||||
connect(ui->btnRight, &QPushButton::clicked, this, &Compare::TransToRight);
|
||||
|
||||
LoadTitles();
|
||||
}
|
||||
|
||||
@@ -49,6 +76,7 @@ void Compare::InitTabWidget()
|
||||
// ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
ui->tableWidget->setDragEnabled(false);
|
||||
ui->tableWidget->viewport()->setAcceptDrops(true);
|
||||
@@ -278,3 +306,22 @@ void Compare::TransToRight()
|
||||
|
||||
emit sigTasks(tasks);
|
||||
}
|
||||
|
||||
void Compare::deleteSelectedRows()
|
||||
{
|
||||
auto r = FTCommon::affirm(this, tr("confirm"), tr("delete selected rows?"));
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
QList<int> rowsToDelete;
|
||||
for (QTableWidgetItem* item : ui->tableWidget->selectedItems()) {
|
||||
int row = item->row();
|
||||
if (!rowsToDelete.contains(row)) {
|
||||
rowsToDelete.append(row);
|
||||
}
|
||||
}
|
||||
std::sort(rowsToDelete.begin(), rowsToDelete.end(), std::greater<int>());
|
||||
for (int row : rowsToDelete) {
|
||||
ui->tableWidget->removeRow(row);
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,12 @@ public:
|
||||
|
||||
signals:
|
||||
void sigTasks(const QVector<TransTask>& tasks);
|
||||
void sigTryVisit(bool local, const QString& path);
|
||||
|
||||
private:
|
||||
void InitControl();
|
||||
void InitTabWidget();
|
||||
void InitMenu();
|
||||
|
||||
private:
|
||||
void Save();
|
||||
@@ -32,7 +34,11 @@ private:
|
||||
void TransToLeft();
|
||||
void TransToRight();
|
||||
|
||||
private slots:
|
||||
void deleteSelectedRows();
|
||||
|
||||
private:
|
||||
QMenu* menu_;
|
||||
Ui::Compare* ui;
|
||||
};
|
||||
|
||||
|
||||
@@ -327,6 +327,15 @@ void FileManager::HeaderClicked(int column)
|
||||
QMetaObject::invokeMethod(this, "RefreshTab", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void FileManager::SetUiCurrentPath(const QString& path)
|
||||
{
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->comboBox->addItem(path);
|
||||
ui->comboBox->setCurrentText(path);
|
||||
}
|
||||
|
||||
void FileManager::FilterFile(const QStringList& selectedTypes)
|
||||
{
|
||||
if (selectedTypes.contains("*")) {
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
public:
|
||||
QString GetRoot();
|
||||
void SetUiCurrentPath(const QString& path);
|
||||
void SetModeStr(const QString& modeStr, int type = 0, ClientCore* clientCore = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -11,23 +11,12 @@
|
||||
|
||||
CpTableWidget::CpTableWidget(QWidget* parent) : QTableWidget(parent)
|
||||
{
|
||||
contexMenu_ = new QMenu(this);
|
||||
delAction_ = new QAction(tr("delete"), this);
|
||||
connect(delAction_, &QAction::triggered, this, &CpTableWidget::deleteSelectedRows);
|
||||
contexMenu_->addAction(delAction_);
|
||||
}
|
||||
|
||||
CpTableWidget::~CpTableWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void CpTableWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
if (selectedItems().count() > 0) {
|
||||
contexMenu_->exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
|
||||
void CpTableWidget::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
@@ -102,22 +91,3 @@ void CpTableWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void CpTableWidget::deleteSelectedRows()
|
||||
{
|
||||
auto r = FTCommon::affirm(this, tr("confirm"), tr("delete selected rows?"));
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
QList<int> rowsToDelete;
|
||||
for (QTableWidgetItem* item : selectedItems()) {
|
||||
int row = item->row();
|
||||
if (!rowsToDelete.contains(row)) {
|
||||
rowsToDelete.append(row);
|
||||
}
|
||||
}
|
||||
std::sort(rowsToDelete.begin(), rowsToDelete.end(), std::greater<int>());
|
||||
for (int row : rowsToDelete) {
|
||||
removeRow(row);
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,6 @@ public:
|
||||
protected:
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void deleteSelectedRows();
|
||||
|
||||
private:
|
||||
QMenu* contexMenu_;
|
||||
QAction* delAction_;
|
||||
};
|
||||
|
||||
#endif // CP_TABLEWIDET_H
|
||||
|
||||
@@ -66,6 +66,15 @@ void frelayGUI::InitControl()
|
||||
connect(localFile_, &FileManager::sigSendTasks, this, &frelayGUI::HandleTask);
|
||||
connect(remoteFile_, &FileManager::sigSendTasks, this, &frelayGUI::HandleTask);
|
||||
connect(compare_, &Compare::sigTasks, this, &frelayGUI::HandleTask);
|
||||
connect(compare_, &Compare::sigTryVisit, this, [this](bool local, const QString& path) {
|
||||
if (local) {
|
||||
localFile_->SetUiCurrentPath(path);
|
||||
localFile_->evtFile();
|
||||
} else {
|
||||
remoteFile_->SetUiCurrentPath(path);
|
||||
remoteFile_->evtFile();
|
||||
}
|
||||
});
|
||||
connect(connecter_, &Connecter::sigConfirmUse, remoteFile_, &FileManager::evtHome);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user