mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-09-21 13:24:49 -04:00
Refuse directory drop for extrafile
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1220 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
35740d89b1
commit
fc9ed005bf
1 changed files with 17 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "PopupChatDialog.h"
|
#include "PopupChatDialog.h"
|
||||||
|
|
||||||
|
@ -849,7 +850,7 @@ void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
if (event->mimeData()->hasUrls())
|
if (event->mimeData()->hasUrls())
|
||||||
{
|
{
|
||||||
std::cerr << "GeneralMsgDialog::dropEvent() Urls:";
|
std::cerr << "PopupChatDialog::dropEvent() Urls:";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
QList<QUrl> urls = event->mimeData()->urls();
|
QList<QUrl> urls = event->mimeData()->urls();
|
||||||
|
@ -864,8 +865,21 @@ void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
if (localpath.size() > 0)
|
if (localpath.size() > 0)
|
||||||
{
|
{
|
||||||
|
struct stat buf;
|
||||||
PopupChatDialog::addAttachment(localpath);
|
//Check that the file does exist and is not a directory
|
||||||
|
if ((-1 == stat(localpath.c_str(), &buf))) {
|
||||||
|
std::cerr << "PopupChatDialog::dropEvent() file does not exists."<< std::endl;
|
||||||
|
QMessageBox mb(tr("Drop file error."), tr("The dropped does not exist."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||||
|
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||||
|
mb.exec();
|
||||||
|
} else if (S_ISDIR(buf.st_mode)) {
|
||||||
|
std::cerr << "PopupChatDialog::dropEvent() directory not accepted."<< std::endl;
|
||||||
|
QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||||
|
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||||
|
mb.exec();
|
||||||
|
} else {
|
||||||
|
PopupChatDialog::addAttachment(localpath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue