mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 17:51:26 -05:00
Added attaching files support via drag and drop for Create Forum Message.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3193 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fc6a0dff50
commit
cca5db6332
@ -29,6 +29,8 @@
|
||||
#include "rsiface/rsforums.h"
|
||||
#include "rsiface/rsfiles.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "gui/feeds/AttachFileItem.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -376,12 +378,89 @@ void CreateForumMsg::fileHashingFinished(AttachFileItem* file) {
|
||||
std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString << std::endl;
|
||||
#endif
|
||||
|
||||
ui.forumMessage->textCursor().insertHtml(QString::fromStdString(mesgString));
|
||||
ui.forumMessage->textCursor().insertHtml(QString::fromStdString(mesgString));
|
||||
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
|
||||
}
|
||||
|
||||
void CreateForumMsg::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "CreateForumMsg::dropEvent() Rejecting uncopyable DropAction" << std::endl;
|
||||
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "CreateForumMsg::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 << "CreateForumMsg::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;
|
||||
|
||||
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 << "CreateForumMsg::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 << "CreateForumMsg::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 {
|
||||
CreateForumMsg::addAttachment(localpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CreateForumMsg::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
/* print out mimeType */
|
||||
std::cerr << "CreateForumMsg::dragEnterEvent() 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 << "CreateForumMsg::dragEnterEvent() Accepting Urls" << std::endl;
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateForumMsg::dragEnterEvent() No Urls" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::pasteLink()
|
||||
{
|
||||
ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
|
||||
|
@ -36,46 +36,49 @@ class CreateForumMsg : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CreateForumMsg(std::string fId, std::string pId);
|
||||
CreateForumMsg(std::string fId, std::string pId);
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
void newMsg(); /* cleanup */
|
||||
|
||||
void loadEmoticonsForums();
|
||||
void loadEmoticonsForums();
|
||||
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumMessageCostumPopupMenu( QPoint point );
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void forumMessageCostumPopupMenu( QPoint point );
|
||||
|
||||
void fileHashingFinished(AttachFileItem* file);
|
||||
void fileHashingFinished(AttachFileItem* file);
|
||||
/* actions to take.... */
|
||||
void createMsg();
|
||||
void cancelMsg();
|
||||
void pasteLink();
|
||||
void pasteLinkFull();
|
||||
void createMsg();
|
||||
void cancelMsg();
|
||||
void pasteLink();
|
||||
void pasteLinkFull();
|
||||
|
||||
void smileyWidgetForums();
|
||||
void smileyWidgetForums();
|
||||
void addSmileys();
|
||||
void addFile();
|
||||
void addAttachment(std::string);
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
void closeEvent (QCloseEvent * event);
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* pasteLinkAct;
|
||||
QAction* pasteLinkFullAct;
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* pasteLinkAct;
|
||||
QAction* pasteLinkFullAct;
|
||||
|
||||
std::string mForumId;
|
||||
std::string mParentId;
|
||||
std::string mForumId;
|
||||
std::string mParentId;
|
||||
|
||||
QHash<QString, QString> smileys;
|
||||
QHash<QString, QString> smileys;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateForumMsg ui;
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateForumMsg ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>406</height>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -110,6 +110,9 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="attachFileButton">
|
||||
<property name="toolTip">
|
||||
<string>Attach File</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@ -233,41 +236,53 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Attach files via drag and drop</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<height>60</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="toolTip">
|
||||
<string>You can attach files via drag and drop here in this window</string>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>440</width>
|
||||
<height>60</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user