mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
fix drop profile behavior
This commit is contained in:
parent
0b6422d38e
commit
1e1941807e
@ -34,6 +34,8 @@ namespace Configs
|
||||
|
||||
bool SwapProfiles(int idx1, int idx2);
|
||||
|
||||
bool EmplaceProfile(int idx, int newIdx);
|
||||
|
||||
bool HasProfile(int id) const;
|
||||
};
|
||||
}// namespace Configs
|
||||
|
||||
@ -22,7 +22,7 @@ protected:
|
||||
const int row_dst = item->row();
|
||||
if (rowsSwapped)
|
||||
{
|
||||
rowsSwapped(row_dst, currentRow());
|
||||
rowsSwapped(currentRow(), row_dst);
|
||||
clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +58,15 @@ namespace Configs
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::EmplaceProfile(int idx, int newIdx)
|
||||
{
|
||||
if (profiles.size() <= idx || profiles.size() <= newIdx) return false;
|
||||
profiles.insert(newIdx+1, profiles[idx]);
|
||||
if (idx < newIdx) profiles.remove(idx);
|
||||
else profiles.remove(idx+1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::HasProfile(int id) const
|
||||
{
|
||||
return profiles.contains(id);
|
||||
|
||||
@ -267,10 +267,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
// table UI
|
||||
ui->proxyListTable->rowsSwapped = [=](int row1, int row2)
|
||||
{
|
||||
if (row1 == row2) return;
|
||||
auto group = Configs::profileManager->CurrentGroup();
|
||||
group->SwapProfiles(row1, row2);
|
||||
refresh_proxy_list(group->profiles[row1]);
|
||||
refresh_proxy_list(group->profiles[row2]);
|
||||
group->EmplaceProfile(row1, row2);
|
||||
refresh_proxy_list();
|
||||
group->Save();
|
||||
};
|
||||
if (auto button = ui->proxyListTable->findChild<QAbstractButton *>(QString(), Qt::FindDirectChildrenOnly)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user