Skip to content

Commit

Permalink
Improve the delete functionality
Browse files Browse the repository at this point in the history
This commit deals with 2 points:

 * when you upload even small files it seems quite slow before the icons tells you it is done:
   * It is still slow the interection with the server.But now, it updates the icon as soon as the upload thread finishes.
 * After deleting the icon still tells you the file is up to date on the repo.
   * This used to occur if the user clicked on reload button while uploading. Now, this button is disabled.

re #7031
  • Loading branch information
gesnerpassos committed Jun 4, 2013
1 parent cb91d34 commit 45b3387
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/RepoModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ const QString DELETABLEENTRY = "deletable";

QString fileDescription(const QModelIndex & index);
QString filePath(const QModelIndex & index);
QString author(const QModelIndex& index);
QString author(const QModelIndex& index);

signals:
void executingThread(bool);
protected:
/// Implements the QAbstractItemModel::removeRows to allow deleting rows from the view.
bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
Expand Down Expand Up @@ -257,7 +260,7 @@ const QString DELETABLEENTRY = "deletable";
QFutureWatcher<QString> upload_watcher;
// keep track of the file being used to the connection with uploader
QString uploading_path;
QModelIndex delete_index;
QModelIndex upload_index;
// check if the file pointed by the index is inside a connection with uploader
bool isUploading(const QModelIndex & index)const ;
private slots:
Expand Down
16 changes: 11 additions & 5 deletions Code/Mantid/MantidQt/API/src/RepoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ bool RepoModel::setData(const QModelIndex & index, const QVariant & value,
}
downloading_path = QString::fromStdString(path);
download_index = index;
emit executingThread(true);
download_threads = QtConcurrent::run(download_thread, repo_ptr, path);
download_watcher.setFuture(download_threads);
ret = true;
Expand Down Expand Up @@ -447,7 +448,8 @@ bool RepoModel::setData(const QModelIndex & index, const QVariant & value,
qDebug() << "Uploading... "<< QString::fromStdString(path) << form->comment()
<< form->author() << form->email() << endl;
uploading_path = QString::fromStdString(path);

upload_index = index;
emit executingThread(true);
upload_threads = QtConcurrent::run(upload_thread, repo_ptr, path, form->email(),
form->author(), form->comment());
upload_watcher.setFuture(upload_threads);
Expand Down Expand Up @@ -532,8 +534,9 @@ bool RepoModel::setData(const QModelIndex & index, const QVariant & value,
// we have all we need to delete from the central repository
// execute the delete in a separate thread, we will use the upload established way, because,
// it will connect to the same server to delete.
delete_index = index;
uploading_path = QString::fromStdString(path);
upload_index = index;
uploading_path = QString::fromStdString(path);
emit executingThread(true);
upload_threads = QtConcurrent::run(delete_thread, repo_ptr, path,
email, author, comment);
upload_watcher.setFuture(upload_threads);
Expand Down Expand Up @@ -929,6 +932,7 @@ void RepoModel::downloadFinished(void){
}
downloading_path = nofile_flag;
emit dataChanged(download_index, download_index);
emit executingThread(false);
}


Expand All @@ -940,7 +944,7 @@ bool RepoModel::isDownloading(const QModelIndex & index)const{
}


void RepoModel::uploadFinished(void){
void RepoModel::uploadFinished(void){
QString info = upload_threads.result();
bool _delete = false;
QString title = "Upload Failed";
Expand All @@ -964,11 +968,13 @@ void RepoModel::uploadFinished(void){
repo_ptr->fileStatus(uploading_path.toStdString());
}catch(...){
// this means that this entry is not inside the ScriptRepository any more.
RepoItem * item = static_cast<RepoItem*>(delete_index.internalPointer());
RepoItem * item = static_cast<RepoItem*>(upload_index.internalPointer());
removeRow(item->row(), createIndex(0,0,item->parent()));
}
}
uploading_path = nofile_flag;
emit dataChanged(upload_index, upload_index);
emit executingThread(false);
}


Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/MantidQt/API/src/ScriptRepositoryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Mantid::Kernel::Logger & ScriptRepositoryView::g_log = Mantid::Kernel::Logger::g
ui->setupUi(this);
connect(ui->reloadPushButton, SIGNAL(clicked()),this,SLOT(updateModel()));
connect(ui->pbHelp, SIGNAL(clicked()),this,SLOT(helpClicked()));
connect(model, SIGNAL(executingThread(bool)),ui->reloadPushButton, SLOT(setDisabled(bool)));

// setup the model and delegates
ui->repo_treeView->setModel(model);
Expand All @@ -155,6 +156,7 @@ Mantid::Kernel::Logger & ScriptRepositoryView::g_log = Mantid::Kernel::Logger::g
void ScriptRepositoryView::updateModel(){
RepoModel * before = model;
model = new RepoModel();
connect(model, SIGNAL(executingThread(bool)),ui->reloadPushButton, SLOT(setDisabled(bool)));
ui->repo_treeView->setModel(model);
delete before;
}
Expand Down

0 comments on commit 45b3387

Please sign in to comment.