mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 06:35:08 -04:00
Some more changes for utf8 in Windows.
Changes in RetroShareLink and drag'n'drop of files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3511 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fff12a58c6
commit
5277ca61e2
6 changed files with 106 additions and 107 deletions
|
@ -920,7 +920,7 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
|
|||
|
||||
|
||||
|
||||
message+= RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtmlSize();
|
||||
message+= RetroShareLink(QString::fromUtf8(file->FileName().c_str()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtmlSize();
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "PopupChatDialog::anchorClicked message : " << message.toStdString() << std::endl;
|
||||
|
@ -946,63 +946,61 @@ void PopupChatDialog::anchorClicked (const QUrl& link )
|
|||
|
||||
void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dropEvent() Rejecting uncopyable DropAction";
|
||||
std::cerr << std::endl;
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dropEvent() Rejecting uncopyable DropAction";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "PopupChatDialog::dropEvent() Formats";
|
||||
std::cerr << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
std::cerr << "PopupChatDialog::dropEvent() Formats";
|
||||
std::cerr << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dropEvent() Urls:";
|
||||
std::cerr << std::endl;
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "PopupChatDialog::dropEvent() Urls:";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
QList<QUrl>::iterator uit;
|
||||
for(uit = urls.begin(); uit != urls.end(); uit++)
|
||||
{
|
||||
std::string localpath = uit->toLocalFile().toStdString();
|
||||
std::cerr << "Whole URL: " << uit->toString().toStdString();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "or As Local File: " << localpath;
|
||||
std::cerr << std::endl;
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
QList<QUrl>::iterator uit;
|
||||
for(uit = urls.begin(); uit != urls.end(); uit++)
|
||||
{
|
||||
QString localpath = uit->toLocalFile();
|
||||
std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
|
||||
std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;
|
||||
|
||||
if (localpath.size() > 0)
|
||||
{
|
||||
struct stat buf;
|
||||
//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("File not found or file name not accepted."),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,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localpath.isEmpty() == false)
|
||||
{
|
||||
//Check that the file does exist and is not a directory
|
||||
QDir dir(localpath);
|
||||
if (dir.exists()) {
|
||||
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 if (QFile::exists(localpath)) {
|
||||
PopupChatDialog::addAttachment(localpath.toUtf8().constData(), false);
|
||||
} else {
|
||||
std::cerr << "PopupChatDialog::dropEvent() file does not exists."<< std::endl;
|
||||
QMessageBox mb(tr("Drop file error."), tr("File not found or file name not accepted."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
mb.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void PopupChatDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue