mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -20,6 +20,7 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QShortcut>
|
||||
#include <QWidgetAction>
|
||||
@ -1561,7 +1562,7 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file)
|
||||
// sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||
// std::string fileSize = *(&fileSizeChar);
|
||||
|
||||
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),
|
||||
std::string mesgString = RetroShareLink(QString::fromUtf8(file->FileName().c_str()),
|
||||
file->FileSize(),
|
||||
QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
||||
|
||||
@ -1586,57 +1587,57 @@ void PeersDialog::anchorClicked (const QUrl& link )
|
||||
|
||||
void PeersDialog::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "PeersDialog::dropEvent() Rejecting uncopyable DropAction" << std::endl;
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "PeersDialog::dropEvent() Rejecting uncopyable DropAction" << std::endl;
|
||||
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "PeersDialog::dropEvent() Formats" << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString() << std::endl;
|
||||
}
|
||||
std::cerr << "PeersDialog::dropEvent() Formats" << std::endl;
|
||||
QStringList formats = event->mimeData()->formats();
|
||||
QStringList::iterator it;
|
||||
for(it = formats.begin(); it != formats.end(); it++)
|
||||
{
|
||||
std::cerr << "Format: " << (*it).toStdString() << std::endl;
|
||||
}
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "PeersDialog::dropEvent() Urls:" << std::endl;
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "PeersDialog::dropEvent() Urls:" << 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::endl;
|
||||
std::cerr << "or As Local File: " << localpath << 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 << "PeersDialog::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 << "PeersDialog::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 {
|
||||
PeersDialog::addAttachment(localpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localpath.isEmpty() == false)
|
||||
{
|
||||
//Check that the file does exist and is not a directory
|
||||
QDir dir(localpath);
|
||||
if (dir.exists()) {
|
||||
std::cerr << "PeersDialog::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)) {
|
||||
PeersDialog::addAttachment(localpath.toUtf8().constData());
|
||||
} else {
|
||||
std::cerr << "PeersDialog::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 PeersDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
@ -252,14 +252,14 @@ bool RetroShareLink::process(std::list<std::string> *psrcIds, int flag)
|
||||
|
||||
case TYPE_FILE:
|
||||
{
|
||||
std::cerr << " RetroShareLink::process FileRequest : fileName : " << name().toStdString() << ". fileHash : " << hash().toStdString() << ". fileSize : " << size() << std::endl;
|
||||
std::cerr << " RetroShareLink::process FileRequest : fileName : " << name().toUtf8().constData() << ". fileHash : " << hash().toStdString() << ". fileSize : " << size() << std::endl;
|
||||
|
||||
std::list<std::string> srcIds;
|
||||
if (psrcIds) {
|
||||
srcIds = *psrcIds;
|
||||
}
|
||||
|
||||
if (rsFiles->FileRequest(name().toStdString(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) {
|
||||
if (rsFiles->FileRequest(name().toUtf8().constData(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) {
|
||||
if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) {
|
||||
QMessageBox mb(QObject::tr("File Request Confirmation"), QObject::tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
|
@ -275,7 +275,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
||||
continue;
|
||||
|
||||
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
|
||||
RetroShareLink link(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str());
|
||||
|
||||
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
||||
urls.push_back(link) ;
|
||||
@ -283,7 +283,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
}
|
||||
else
|
||||
{
|
||||
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
|
||||
RetroShareLink link(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str());
|
||||
|
||||
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
||||
urls.push_back(link) ;
|
||||
|
@ -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)
|
||||
|
@ -169,7 +169,7 @@ void AttachFileItem::updateItemStatic()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
QString filename = QString::fromStdString(mFileName);
|
||||
QString filename = QString::fromUtf8(mFileName.c_str());
|
||||
mDivisor = 1;
|
||||
|
||||
if (mFileSize > 10000000) /* 10 Mb */
|
||||
@ -239,7 +239,7 @@ void AttachFileItem::updateItemStatic()
|
||||
break;
|
||||
|
||||
case AFI_STATE_EXTRA:
|
||||
filename = QString::fromStdString(mPath);
|
||||
filename = QString::fromUtf8(mPath.c_str());
|
||||
|
||||
progressBar->setRange(0, 100);
|
||||
progressBar->setFormat("HASHING");
|
||||
|
@ -264,7 +264,7 @@ void MessageComposer::recommendFriend(std::list <std::string> &peerids)
|
||||
continue;
|
||||
}
|
||||
|
||||
RetroShareLink link(QString::fromStdString(detail.name), QString::fromStdString(detail.id));
|
||||
RetroShareLink link(QString::fromUtf8(detail.name.c_str()), QString::fromStdString(detail.id));
|
||||
if (link.valid() == false || link.type() != RetroShareLink::TYPE_PERSON) {
|
||||
continue;
|
||||
}
|
||||
@ -1297,7 +1297,7 @@ void MessageComposer::attachFile()
|
||||
// select a file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath = qfile.toStdString();
|
||||
std::string filePath = qfile.toUtf8().constData();
|
||||
if (filePath != "")
|
||||
{
|
||||
MessageComposer::addAttachment(filePath);
|
||||
@ -1342,7 +1342,7 @@ void MessageComposer::fileHashingFinished(AttachFileItem* file) {
|
||||
return;
|
||||
}
|
||||
|
||||
RetroShareLink message(QString::fromStdString(file->FileName()), file->FileSize(), QString::fromStdString(file->FileHash()));
|
||||
RetroShareLink message(QString::fromUtf8(file->FileName().c_str()), file->FileSize(), QString::fromStdString(file->FileHash()));
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "MessageComposer::anchorClicked message : " << message.toHtmlFull().toStdString() << std::endl;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user