diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
index aa9b50298..83e3219c3 100644
--- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
+++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
@@ -442,7 +442,7 @@ public:
{
QString strPath = QString::fromUtf8(fileInfo.path.c_str());
QString strPathAfterDL = strPath;
- strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),"");
+ strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),"[Download Dir]");
return QVariant(strPathAfterDL);
}
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
index 66eb0f793..23f5f5b93 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
@@ -50,15 +50,12 @@ GxsChannelFilesStatusWidget::GxsChannelFilesStatusWidget(const RsGxsFile &file,
connect(ui->openFilePushButton, SIGNAL(clicked()), this, SLOT(openFile()));
ui->downloadPushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/download.png"));
- ui->openFolderToolButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/arrow.png"));
- QAction *openfolder = new QAction(tr("Open folder"), this);
- connect(openfolder, SIGNAL(triggered()), this, SLOT(openFolder()));
+ ui->openFolderPushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/folderopen.png"));
+ ui->openFolderPushButton->setToolTip(tr("Open folder"));
+
+ connect(ui->openFolderPushButton, SIGNAL(clicked()), this, SLOT(openFolder()));
- QMenu *menu = new QMenu();
- menu->addAction(openfolder);
- ui->openFolderToolButton->setMenu(menu);
-
check();
}
@@ -90,7 +87,9 @@ void GxsChannelFilesStatusWidget::setSize(uint64_t size)
void GxsChannelFilesStatusWidget::check()
{
FileInfo fileInfo;
- if (rsFiles->alreadyHaveFile(mFile.mHash, fileInfo)) {
+
+ if(haveFile(fileInfo))
+ {
mState = STATE_LOCAL;
setSize(fileInfo.size);
@@ -103,27 +102,25 @@ void GxsChannelFilesStatusWidget::check()
ui->openFilePushButton->setText(tr("Play"));
ui->openFilePushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/play.png"));
}
-
- } else {
- FileInfo fileInfo;
- bool detailsOk = rsFiles->FileDetails(mFile.mHash, RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, fileInfo);
-
- if (detailsOk) {
- switch (fileInfo.downloadStatus) {
+ }
+ else
+ {
+ switch (fileInfo.downloadStatus)
+ {
case FT_STATE_WAITING:
mState = STATE_WAITING;
break;
case FT_STATE_DOWNLOADING:
- if (fileInfo.avail == fileInfo.size) {
+ if (fileInfo.avail == fileInfo.size)
mState = STATE_LOCAL;
- } else {
+ else
mState = STATE_DOWNLOAD;
- }
+
setSize(fileInfo.size);
ui->progressBar->setValue(fileInfo.avail / mDivisor);
break;
- case FT_STATE_COMPLETE:
- mState = STATE_DOWNLOAD;
+ case FT_STATE_COMPLETE: // this should not happen, since the case is handled earlier
+ mState = STATE_ERROR;
break;
case FT_STATE_QUEUED:
mState = STATE_WAITING;
@@ -134,14 +131,11 @@ void GxsChannelFilesStatusWidget::check()
case FT_STATE_CHECKING_HASH:
mState = STATE_CHECKING;
break;
- case FT_STATE_FAILED:
- mState = STATE_ERROR;
- break;
- }
- } else {
- mState = STATE_REMOTE;
- }
- }
+ default:
+ mState = STATE_REMOTE;
+ break;
+ }
+ }
int repeat = 0;
QString statusText;
@@ -156,7 +150,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->hide();
ui->progressBar->hide();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
statusText = tr("Error");
@@ -171,7 +165,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->hide();
ui->progressBar->hide();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
break;
@@ -184,7 +178,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->show();
ui->progressBar->show();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
break;
@@ -197,7 +191,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->show();
ui->progressBar->hide();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
statusText = tr("Paused");
@@ -212,7 +206,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->show();
ui->progressBar->hide();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
statusText = tr("Waiting");
@@ -227,7 +221,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->show();
ui->progressBar->hide();
ui->openFilePushButton->hide();
- ui->openFolderToolButton->hide();
+ ui->openFolderPushButton->hide();
statusText = tr("Checking");
@@ -242,7 +236,7 @@ void GxsChannelFilesStatusWidget::check()
ui->cancelToolButton->hide();
ui->progressBar->hide();
ui->openFilePushButton->show();
- ui->openFolderToolButton->show();
+ ui->openFolderPushButton->show();
break;
}
@@ -324,35 +318,60 @@ void GxsChannelFilesStatusWidget::cancel()
void GxsChannelFilesStatusWidget::openFolder()
{
FileInfo fileInfo;
- if (!rsFiles->alreadyHaveFile(mFile.mHash, fileInfo)) {
+ if (!haveFile(fileInfo))
return;
- }
- /* open folder with a suitable application */
- QDir dir = QFileInfo(QString::fromUtf8(fileInfo.path.c_str())).absoluteDir();
- if (dir.exists()) {
- if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(dir.absolutePath()))) {
- if(!mUsedAsEditor)
- QMessageBox::warning(this, "", QString("%1 %2").arg(tr("Can't open folder"), dir.absolutePath()));
- else
- RsErr() << "Can't open folder " << dir.absolutePath().toStdString() ;
+ QFileInfo finfo;
+ finfo.setFile(QString::fromUtf8(fileInfo.path.c_str()));
- }
- }
+ /* open folder with a suitable application */
+ if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(finfo.absolutePath()))) {
+ if(!mUsedAsEditor)
+ QMessageBox::warning(this, "", QString("%1 %2").arg(tr("Can't open folder"), finfo.absolutePath()));
+ else
+ RsErr() << "Can't open folder " << finfo.absolutePath().toStdString() ;
+ }
+}
+
+bool GxsChannelFilesStatusWidget::haveFile(FileInfo& info)
+{
+ bool already_has_file = rsFiles->alreadyHaveFile(mFile.mHash, info);
+
+ if(!already_has_file)
+ if(!(rsFiles->FileDetails(mFile.mHash, RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, info) && info.downloadStatus==FT_STATE_COMPLETE))
+ return false;
+
+ // We need the code below because FileDetails() returns fileInfo.path as the directory when the file in COMPLETE and
+ // as a full path when the file is shared. The former is inconsistent with the documentation in rstypes.h, but I'm not
+ // sure what are the implications of changing the code in libretroshare so that the full path is always returned.
+
+ QFileInfo finfo;
+
+ if(QDir(QString::fromUtf8(info.path.c_str())).exists())
+ finfo.setFile(QString::fromUtf8(info.path.c_str()),QString::fromUtf8(info.fname.c_str()));
+ else if(QFile(QString::fromUtf8(info.path.c_str())).exists())
+ finfo.setFile(QString::fromUtf8(info.path.c_str()));
+ else
+ {
+ RsErr() << "Cannot find file!" << std::endl;
+ return false;
+ }
+
+ info.path = finfo.absoluteFilePath().toStdString();
+ return true;
}
void GxsChannelFilesStatusWidget::openFile()
{
FileInfo fileInfo;
- if (!rsFiles->alreadyHaveFile(mFile.mHash, fileInfo)) {
+ if(!haveFile(fileInfo))
return;
- }
- /* open file with a suitable application */
- QFileInfo qinfo;
- qinfo.setFile(QString::fromUtf8(fileInfo.path.c_str()));
- if (qinfo.exists()) {
- if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
+ QFileInfo finfo;
+ finfo.setFile(QString::fromUtf8(fileInfo.path.c_str()));
+
+ if (finfo.exists()) {
+ if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(finfo.absoluteFilePath()))) {
std::cerr << "GxsChannelFilesStatusWidget(): can't open file " << fileInfo.path << std::endl;
}
}else{
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.h
index 7ae09ce6b..0dbb5c072 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.h
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.h
@@ -53,6 +53,7 @@ private slots:
private:
void setSize(uint64_t size);
+ bool haveFile(FileInfo& info);
private:
enum State
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.ui
index 2c51ded6c..e8ee2d512 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.ui
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.ui
@@ -6,8 +6,8 @@
0
0
- 421
- 29
+ 473
+ 36
@@ -139,7 +139,7 @@
-
-
+
0
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp
index 54b787e65..0796b6ce1 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp
@@ -348,7 +348,14 @@ public:
if(r1 && r2)
return (ord==Qt::AscendingOrder)?(fi1.transferedfi2.transfered);
else
+ {
+ FileInfo fitmp;
+
+ if(!r1 && rsFiles->alreadyHaveFile(f1.mHash,fitmp)) fi1.downloadStatus = FT_STATE_COMPLETE;
+ if(!r2 && rsFiles->alreadyHaveFile(f2.mHash,fitmp)) fi2.downloadStatus = FT_STATE_COMPLETE;
+
return (ord==Qt::AscendingOrder)?(fi1.downloadStatusfi2.downloadStatus);
+ }
}
}