repo-tree-view.cpp (seafile-client-9.0.1) | : | repo-tree-view.cpp (seafile-client-9.0.2) | ||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
#include "rpc/local-repo.h" | #include "rpc/local-repo.h" | |||
#include "download-repo-dialog.h" | #include "download-repo-dialog.h" | |||
#include "clone-tasks-dialog.h" | #include "clone-tasks-dialog.h" | |||
#include "repo-item.h" | #include "repo-item.h" | |||
#include "repo-item-delegate.h" | #include "repo-item-delegate.h" | |||
#include "repo-tree-model.h" | #include "repo-tree-model.h" | |||
#include "repo-detail-dialog.h" | #include "repo-detail-dialog.h" | |||
#include "utils/paint-utils.h" | #include "utils/paint-utils.h" | |||
#include "repo-service.h" | #include "repo-service.h" | |||
#include "auto-login-service.h" | #include "auto-login-service.h" | |||
#include "sync-error-service.h" | ||||
#include "sync-errors-dialog.h" | ||||
#include "filebrowser/file-browser-manager.h" | #include "filebrowser/file-browser-manager.h" | |||
#include "filebrowser/file-browser-dialog.h" | #include "filebrowser/file-browser-dialog.h" | |||
#include "utils/utils-mac.h" | #include "utils/utils-mac.h" | |||
#include "filebrowser/tasks.h" | #include "filebrowser/tasks.h" | |||
#include "filebrowser/progress-dialog.h" | #include "filebrowser/progress-dialog.h" | |||
#include "ui/set-repo-password-dialog.h" | #include "ui/set-repo-password-dialog.h" | |||
#include "ui/private-share-dialog.h" | #include "ui/private-share-dialog.h" | |||
#include "ui/check-repo-root-perm-dialog.h" | #include "ui/check-repo-root-perm-dialog.h" | |||
skipping to change at line 86 | skipping to change at line 88 | |||
pool->start(helper); | pool->start(helper); | |||
return helper; | return helper; | |||
} | } | |||
} // anonymous namespace | } // anonymous namespace | |||
static ServerRepo selected_repo_; | static ServerRepo selected_repo_; | |||
// TODO save localrepo as well to avoid many copys | // TODO save localrepo as well to avoid many copys | |||
RepoTreeView::RepoTreeView(QWidget *parent) | RepoTreeView::RepoTreeView(QWidget *parent) | |||
: QTreeView(parent) | : QTreeView(parent), | |||
sync_errors_dialog_(nullptr) | ||||
{ | { | |||
header()->hide(); | header()->hide(); | |||
createActions(); | createActions(); | |||
// We draw the indicator ourselves | // We draw the indicator ourselves | |||
setIndentation(0); | setIndentation(0); | |||
// We handle the click oursevles | // We handle the click oursevles | |||
setExpandsOnDoubleClick(false); | setExpandsOnDoubleClick(false); | |||
connect(this, SIGNAL(clicked(const QModelIndex&)), | connect(this, SIGNAL(clicked(const QModelIndex&)), | |||
skipping to change at line 136 | skipping to change at line 139 | |||
Account account = seafApplet->accountManager()->currentAccount(); | Account account = seafApplet->accountManager()->currentAccount(); | |||
if (!account.isValid()) { | if (!account.isValid()) { | |||
return; | return; | |||
} | } | |||
expanded_categroies_.clear(); | expanded_categroies_.clear(); | |||
QSettings settings; | QSettings settings; | |||
settings.beginGroup(kRepoTreeViewSettingsGroup); | settings.beginGroup(kRepoTreeViewSettingsGroup); | |||
QString key = QString(kRepoTreeViewSettingsExpandedCategories) + "-" + accou nt.getSignature(); | QString key = QString(kRepoTreeViewSettingsExpandedCategories) + "-" + accou nt.getSignature(); | |||
if (settings.contains(key)) { | if (settings.contains(key)) { | |||
QString cats = settings.value(key, "").toString(); | QString cats = settings.value(key, "").toString(); | |||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) | ||||
QStringList cats_list = cats.split("\t", Qt::SkipEmptyParts); | QStringList cats_list = cats.split("\t", Qt::SkipEmptyParts); | |||
expanded_categroies_ = QSet<QString>(cats_list.begin(), cats_list.end()) ; | expanded_categroies_ = QSet<QString>(cats_list.begin(), cats_list.end()) ; | |||
#else | ||||
expanded_categroies_ = QSet<QString>::fromList(cats.split("\t", QString: | ||||
:SkipEmptyParts)); | ||||
#endif | ||||
} else { | } else { | |||
// Expand "recent updated" on first use | // Expand "recent updated" on first use | |||
expanded_categroies_.insert(tr("Recently Updated")); | expanded_categroies_.insert(tr("Recently Updated")); | |||
} | } | |||
settings.endGroup(); | settings.endGroup(); | |||
} | } | |||
void RepoTreeView::contextMenuEvent(QContextMenuEvent *event) | void RepoTreeView::contextMenuEvent(QContextMenuEvent *event) | |||
{ | { | |||
QPoint pos = event->pos(); | QPoint pos = event->pos(); | |||
skipping to change at line 207 | skipping to change at line 214 | |||
} | } | |||
menu->addAction(show_detail_action_); | menu->addAction(show_detail_action_); | |||
if (item->cloneTask().isCancelable()) { | if (item->cloneTask().isCancelable()) { | |||
menu->addAction(cancel_download_action_); | menu->addAction(cancel_download_action_); | |||
} | } | |||
if (item->localRepo().isValid()) { | if (item->localRepo().isValid()) { | |||
menu->addAction(unsync_action_); | menu->addAction(unsync_action_); | |||
menu->addAction(resync_action_); | menu->addAction(resync_action_); | |||
menu->addAction(view_repo_sync_errors_action_); | ||||
menu->addAction(discard_repo_sync_errors_action_); | ||||
} | } | |||
return menu; | return menu; | |||
} | } | |||
void RepoTreeView::updateRepoActions() | void RepoTreeView::updateRepoActions() | |||
{ | { | |||
RepoItem *item = NULL; | RepoItem *item = NULL; | |||
QItemSelection selected = selectionModel()->selection(); | QItemSelection selected = selectionModel()->selection(); | |||
QModelIndexList indexes = selected.indexes(); | QModelIndexList indexes = selected.indexes(); | |||
skipping to change at line 241 | skipping to change at line 251 | |||
sync_now_action_->setEnabled(false); | sync_now_action_->setEnabled(false); | |||
open_local_folder_action_->setEnabled(false); | open_local_folder_action_->setEnabled(false); | |||
open_local_folder_toolbar_action_->setEnabled(false); | open_local_folder_toolbar_action_->setEnabled(false); | |||
unsync_action_->setEnabled(false); | unsync_action_->setEnabled(false); | |||
resync_action_->setEnabled(false); | resync_action_->setEnabled(false); | |||
set_sync_interval_action_->setEnabled(false); | set_sync_interval_action_->setEnabled(false); | |||
toggle_auto_sync_action_->setEnabled(false); | toggle_auto_sync_action_->setEnabled(false); | |||
view_on_web_action_->setEnabled(false); | view_on_web_action_->setEnabled(false); | |||
open_in_filebrowser_action_->setEnabled(false); | open_in_filebrowser_action_->setEnabled(false); | |||
show_detail_action_->setEnabled(false); | show_detail_action_->setEnabled(false); | |||
view_repo_sync_errors_action_->setVisible(false); | ||||
discard_repo_sync_errors_action_->setVisible(false); | ||||
return; | return; | |||
} | } | |||
LocalRepo r; | LocalRepo r; | |||
seafApplet->rpcClient()->getLocalRepo(item->repo().id, &r); | seafApplet->rpcClient()->getLocalRepo(item->repo().id, &r); | |||
item->setLocalRepo(r); | item->setLocalRepo(r); | |||
if (item->localRepo().isValid()) { | if (item->localRepo().isValid()) { | |||
const LocalRepo& local_repo = item->localRepo(); | const LocalRepo& local_repo = item->localRepo(); | |||
download_action_->setEnabled(false); | download_action_->setEnabled(false); | |||
skipping to change at line 270 | skipping to change at line 282 | |||
unsync_action_->setData(QVariant::fromValue(local_repo)); | unsync_action_->setData(QVariant::fromValue(local_repo)); | |||
unsync_action_->setEnabled(true); | unsync_action_->setEnabled(true); | |||
resync_action_->setData(QVariant::fromValue(local_repo)); | resync_action_->setData(QVariant::fromValue(local_repo)); | |||
resync_action_->setEnabled(true); | resync_action_->setEnabled(true); | |||
set_sync_interval_action_->setData(QVariant::fromValue(local_repo)); | set_sync_interval_action_->setData(QVariant::fromValue(local_repo)); | |||
set_sync_interval_action_->setEnabled(true); | set_sync_interval_action_->setEnabled(true); | |||
int err_id = LastSyncError::instance()->getRepoSyncError(local_repo.id); | ||||
if (local_repo.sync_state == LocalRepo::SYNC_STATE_DONE && err_id >= 0) | ||||
{ | ||||
view_repo_sync_errors_action_->setData(QVariant::fromValue(local_rep | ||||
o)); | ||||
view_repo_sync_errors_action_->setVisible(true); | ||||
discard_repo_sync_errors_action_->setData(QVariant::fromValue(local_ | ||||
repo)); | ||||
discard_repo_sync_errors_action_->setVisible(true); | ||||
} else { | ||||
view_repo_sync_errors_action_->setVisible(false); | ||||
discard_repo_sync_errors_action_->setVisible(false); | ||||
} | ||||
if (seafApplet->settingsManager()->autoSync()) { | if (seafApplet->settingsManager()->autoSync()) { | |||
toggle_auto_sync_action_->setData(QVariant::fromValue(local_repo)); | toggle_auto_sync_action_->setData(QVariant::fromValue(local_repo)); | |||
toggle_auto_sync_action_->setEnabled(true); | toggle_auto_sync_action_->setEnabled(true); | |||
} else { | } else { | |||
toggle_auto_sync_action_->setEnabled(false); | toggle_auto_sync_action_->setEnabled(false); | |||
} | } | |||
if (local_repo.auto_sync) { | if (local_repo.auto_sync) { | |||
toggle_auto_sync_action_->setText(tr("Disable auto sync")); | toggle_auto_sync_action_->setText(tr("Disable auto sync")); | |||
toggle_auto_sync_action_->setToolTip(tr("Disable auto sync")); | toggle_auto_sync_action_->setToolTip(tr("Disable auto sync")); | |||
skipping to change at line 304 | skipping to change at line 328 | |||
} | } | |||
sync_now_action_->setEnabled(false); | sync_now_action_->setEnabled(false); | |||
open_local_folder_action_->setEnabled(false); | open_local_folder_action_->setEnabled(false); | |||
open_local_folder_toolbar_action_->setEnabled(false); | open_local_folder_toolbar_action_->setEnabled(false); | |||
unsync_action_->setEnabled(false); | unsync_action_->setEnabled(false); | |||
resync_action_->setEnabled(false); | resync_action_->setEnabled(false); | |||
set_sync_interval_action_->setEnabled(false); | set_sync_interval_action_->setEnabled(false); | |||
toggle_auto_sync_action_->setEnabled(false); | toggle_auto_sync_action_->setEnabled(false); | |||
view_repo_sync_errors_action_->setVisible(false); | ||||
discard_repo_sync_errors_action_->setVisible(false); | ||||
} | } | |||
selected_repo_ = item->repo(); | selected_repo_ = item->repo(); | |||
view_on_web_action_->setEnabled(true); | view_on_web_action_->setEnabled(true); | |||
open_in_filebrowser_action_->setEnabled(true); | open_in_filebrowser_action_->setEnabled(true); | |||
show_detail_action_->setEnabled(true); | show_detail_action_->setEnabled(true); | |||
if (item->cloneTask().isCancelable()) { | if (item->cloneTask().isCancelable()) { | |||
cancel_download_action_->setEnabled(true); | cancel_download_action_->setEnabled(true); | |||
skipping to change at line 442 | skipping to change at line 468 | |||
resync_action_->setIcon(QIcon(":/images/resync.png")); | resync_action_->setIcon(QIcon(":/images/resync.png")); | |||
resync_action_->setStatusTip(tr("unsync and resync this library")); | resync_action_->setStatusTip(tr("unsync and resync this library")); | |||
connect(resync_action_, SIGNAL(triggered()), this, SLOT(resyncRepo())); | connect(resync_action_, SIGNAL(triggered()), this, SLOT(resyncRepo())); | |||
set_sync_interval_action_ = new QAction(tr("Set sync &Interval"), this); | set_sync_interval_action_ = new QAction(tr("Set sync &Interval"), this); | |||
set_sync_interval_action_->setIcon(QIcon(":/images/clock.png")); | set_sync_interval_action_->setIcon(QIcon(":/images/clock.png")); | |||
set_sync_interval_action_->setStatusTip(tr("set sync interval for this libra ry")); | set_sync_interval_action_->setStatusTip(tr("set sync interval for this libra ry")); | |||
connect(set_sync_interval_action_, SIGNAL(triggered()), this, SLOT(setRepoSy ncInterval())); | connect(set_sync_interval_action_, SIGNAL(triggered()), this, SLOT(setRepoSy ncInterval())); | |||
view_repo_sync_errors_action_ = new QAction(tr("Show sync errors")); | ||||
view_repo_sync_errors_action_->setIcon(QIcon(":/images/info-gray.png")); | ||||
view_repo_sync_errors_action_->setStatusTip(tr("Show sync errors")); | ||||
connect(view_repo_sync_errors_action_, SIGNAL(triggered()), this, SLOT(viewR | ||||
epoSyncErrors())); | ||||
discard_repo_sync_errors_action_ = new QAction(tr("Discard sync errors")); | ||||
discard_repo_sync_errors_action_->setIcon(QIcon(":/images/minus-gray.png")); | ||||
discard_repo_sync_errors_action_->setStatusTip(tr("Ignore sync errors from t | ||||
his library")); | ||||
connect(discard_repo_sync_errors_action_, SIGNAL(triggered()), this, SLOT(di | ||||
scardRepoSyncErrors())); | ||||
} | } | |||
void RepoTreeView::downloadRepo() | void RepoTreeView::downloadRepo() | |||
{ | { | |||
DownloadRepoDialog dialog(seafApplet->accountManager()->currentAccount(), se lected_repo_, QString(), this); | DownloadRepoDialog dialog(seafApplet->accountManager()->currentAccount(), se lected_repo_, QString(), this); | |||
dialog.exec(); | dialog.exec(); | |||
updateRepoActions(); | updateRepoActions(); | |||
} | } | |||
skipping to change at line 736 | skipping to change at line 772 | |||
show_detail_action_->setEnabled(false); | show_detail_action_->setEnabled(false); | |||
} | } | |||
void RepoTreeView::saveExpandedCategries() | void RepoTreeView::saveExpandedCategries() | |||
{ | { | |||
Account account = seafApplet->accountManager()->currentAccount(); | Account account = seafApplet->accountManager()->currentAccount(); | |||
if (!account.isValid()) { | if (!account.isValid()) { | |||
return; | return; | |||
} | } | |||
QSettings settings; | QSettings settings; | |||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) | ||||
QStringList cats = expanded_categroies_.values(); | QStringList cats = expanded_categroies_.values(); | |||
#else | ||||
QStringList cats = expanded_categroies_.toList(); | ||||
#endif | ||||
settings.beginGroup(kRepoTreeViewSettingsGroup); | settings.beginGroup(kRepoTreeViewSettingsGroup); | |||
QString key = QString(kRepoTreeViewSettingsExpandedCategories) + "-" + accou nt.getSignature(); | QString key = QString(kRepoTreeViewSettingsExpandedCategories) + "-" + accou nt.getSignature(); | |||
settings.setValue(key, cats.join("\t")); | settings.setValue(key, cats.join("\t")); | |||
settings.endGroup(); | settings.endGroup(); | |||
} | } | |||
void RepoTreeView::showEvent(QShowEvent *event) | void RepoTreeView::showEvent(QShowEvent *event) | |||
{ | { | |||
updateRepoActions(); | updateRepoActions(); | |||
} | } | |||
skipping to change at line 848 | skipping to change at line 888 | |||
return; | return; | |||
} | } | |||
if (rpc->unsync(server_repo.id) < 0) { | if (rpc->unsync(server_repo.id) < 0) { | |||
seafApplet->warningBox(tr("Failed to unsync library \"%1\"").arg(server_ repo.name)); | seafApplet->warningBox(tr("Failed to unsync library \"%1\"").arg(server_ repo.name)); | |||
return; | return; | |||
} | } | |||
DownloadRepoDialog dialog(seafApplet->accountManager()->currentAccount(), | DownloadRepoDialog dialog(seafApplet->accountManager()->currentAccount(), | |||
RepoService::instance()->getRepo(server_repo.id), QString(), this); | RepoService::instance()->getRepo(server_repo.id), QString(), this); | |||
dialog.setMergeWithExisting(QFileInfo(local_repo.worktree).dir().absolutePat h()); | dialog.setMergeWithExisting(QFileInfo(local_repo.worktree).absoluteFilePath( )); | |||
if (!server_repo.encrypted) { | if (!server_repo.encrypted) { | |||
dialog.setResyncMode(); | dialog.setResyncMode(); | |||
} | } | |||
dialog.exec(); | dialog.exec(); | |||
updateRepoActions(); | updateRepoActions(); | |||
} | } | |||
void RepoTreeView::dropEvent(QDropEvent *event) | void RepoTreeView::dropEvent(QDropEvent *event) | |||
{ | { | |||
skipping to change at line 1100 | skipping to change at line 1140 | |||
} | } | |||
int interval = dialog.intValue(); | int interval = dialog.intValue(); | |||
if (interval != 0 && interval == default_interval) { | if (interval != 0 && interval == default_interval) { | |||
return; | return; | |||
} | } | |||
seafApplet->rpcClient()->setRepoProperty( | seafApplet->rpcClient()->setRepoProperty( | |||
local_repo.id, kSyncIntervalProperty, QString::number(interval)); | local_repo.id, kSyncIntervalProperty, QString::number(interval)); | |||
} | } | |||
void RepoTreeView::viewRepoSyncErrors() | ||||
{ | ||||
LocalRepo local_repo = qvariant_cast<LocalRepo>(set_sync_interval_action_->d | ||||
ata()); | ||||
if (sync_errors_dialog_ == nullptr) { | ||||
sync_errors_dialog_ = new SyncErrorsDialog(); | ||||
} | ||||
sync_errors_dialog_->updateErrors(); | ||||
sync_errors_dialog_->show(); | ||||
sync_errors_dialog_->raise(); | ||||
sync_errors_dialog_->activateWindow(); | ||||
updateRepoActions(); | ||||
} | ||||
void RepoTreeView::discardRepoSyncErrors() | ||||
{ | ||||
LocalRepo local_repo = qvariant_cast<LocalRepo>(set_sync_interval_action_->d | ||||
ata()); | ||||
LastSyncError::instance()->cleanRepoSyncErrors(local_repo.id); | ||||
updateRepoActions(); | ||||
} | ||||
End of changes. 13 change blocks. | ||||
2 lines changed or deleted | 49 lines changed or added |