mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Channels
- removed settings button - deals with hashing of its own files subfileitem - absolved from file hashing responsibility - added play button functionality(taken from transfer dialog, thanks) blog - removed file attachments feature (only for blogging ), will add pic support later git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2867 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e1c4992680
commit
c5e8669ec0
@ -147,7 +147,7 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="channelpushButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -192,19 +192,6 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -217,20 +204,6 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="configPushButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/settings16.png</normaloff>:/images/settings16.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -554,8 +527,8 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>429</width>
|
||||
<height>331</height>
|
||||
<width>425</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -250,7 +250,7 @@ void CreateChannelMsg::addAttachment(std::string hash, std::string fname, uint64
|
||||
|
||||
/* add widget in for new destination */
|
||||
|
||||
uint32_t flags = SFI_TYPE_ATTACH;
|
||||
uint32_t flags = SFI_TYPE_CHANNEL;
|
||||
if (local)
|
||||
{
|
||||
flags |= SFI_STATE_LOCAL;
|
||||
@ -262,7 +262,7 @@ void CreateChannelMsg::addAttachment(std::string hash, std::string fname, uint64
|
||||
return;
|
||||
}
|
||||
|
||||
SubFileItem *file = new SubFileItem(hash, fname, size, flags, srcId);
|
||||
SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed
|
||||
|
||||
mAttachments.push_back(file);
|
||||
QLayout *layout = fileFrame->layout();
|
||||
@ -300,15 +300,17 @@ void CreateChannelMsg::addAttachment(std::string path)
|
||||
std::cerr << "CreateChannelMsg::addAttachment()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* add to ExtraList here,
|
||||
* use default TIMEOUT of 30 days (time to fetch it).
|
||||
*/
|
||||
//uint32_t period = 30 * 24 * 60 * 60;
|
||||
//uint32_t flags = 0;
|
||||
//rsFiles->ExtraFileHash(localpath, period, flags);
|
||||
|
||||
/* add widget in for new destination */
|
||||
SubFileItem *file = new SubFileItem(path);
|
||||
uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA;
|
||||
|
||||
// channels creates copy of file into channels directory and shares this
|
||||
|
||||
FileInfo fInfo;
|
||||
rsChannels->channelExtraFileHash(path, mChannelId, fInfo);
|
||||
|
||||
// file is not innitial
|
||||
SubFileItem *file = new SubFileItem(fInfo.hash, fInfo.fname, fInfo.path, fInfo.size,
|
||||
flags, mChannelId); // destroyed when fileFrame (this subfileitem) is destroyed
|
||||
|
||||
mAttachments.push_back(file);
|
||||
QLayout *layout = fileFrame->layout();
|
||||
@ -335,9 +337,12 @@ void CreateChannelMsg::checkAttachmentReady()
|
||||
{
|
||||
if (!(*fit)->ready())
|
||||
{
|
||||
/*
|
||||
/* ensure file is hashed or file will be hashed, thus
|
||||
* recognized by librs but not correctly by gui (can't
|
||||
* formally remove it)
|
||||
*/
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
||||
break;
|
||||
|
||||
|
||||
@ -349,6 +354,7 @@ void CreateChannelMsg::checkAttachmentReady()
|
||||
if (fit == mAttachments.end())
|
||||
{
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
|
||||
}
|
||||
|
||||
/* repeat... */
|
||||
@ -359,8 +365,16 @@ void CreateChannelMsg::checkAttachmentReady()
|
||||
|
||||
void CreateChannelMsg::cancelMsg()
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::cancelMsg()";
|
||||
std::cerr << "CreateChannelMsg::cancelMsg() :"
|
||||
<< "Deleting EXTRA attachments" << std::endl;
|
||||
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<SubFileItem* >::const_iterator it;
|
||||
|
||||
for(it = mAttachments.begin(); it != mAttachments.end(); it++)
|
||||
rsChannels->channelExtraFileRemove((*it)->FileHash(), mChannelId);
|
||||
|
||||
close();
|
||||
return;
|
||||
}
|
||||
@ -410,13 +424,14 @@ void CreateChannelMsg::sendMsg()
|
||||
files.push_back(fi);
|
||||
|
||||
/* commence downloads - if we don't have the file */
|
||||
|
||||
if (!(*fit)->done())
|
||||
{
|
||||
if ((*fit)->ready())
|
||||
{
|
||||
(*fit)->download();
|
||||
}
|
||||
// Skips unhashed files.
|
||||
// Skips unhashed files.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -435,7 +450,7 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::
|
||||
tr("Please add a Subject"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return; //Don't add a empty Subject!!
|
||||
return; //Don't add an empty Subject!!
|
||||
}
|
||||
else
|
||||
|
||||
|
@ -76,7 +76,7 @@ void BlogMsgItem::updateItemStatic()
|
||||
for(i = 0; i < total; i++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", 1283918, SFI_STATE_REMOTE, mPeerId);
|
||||
SubFileItem *fi = new SubFileItem("dummyHash", "dummy_File", "", 1283918, SFI_STATE_REMOTE, mPeerId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
@ -113,8 +113,8 @@ void ChanMsgItem::updateItemStatic()
|
||||
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size,
|
||||
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size,
|
||||
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, mChanId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
@ -129,7 +129,7 @@ void MsgItem::updateItemStatic()
|
||||
for(it = mi.files.begin(); it != mi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size, SFI_STATE_REMOTE, mi.srcId);
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.srcId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
@ -65,9 +65,10 @@
|
||||
const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
||||
|
||||
/** Constructor */
|
||||
SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
SubFileItem::SubFileItem(std::string hash, std::string name, std::string path, uint64_t size,
|
||||
uint32_t flags, std::string srcId)
|
||||
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId)
|
||||
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),
|
||||
mPath(path)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
@ -77,10 +78,6 @@ SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
mMode = flags & SFI_MASK_STATE;
|
||||
mType = flags & SFI_MASK_TYPE;
|
||||
|
||||
if (mMode == SFI_STATE_EXTRA)
|
||||
{
|
||||
mMode = SFI_STATE_ERROR;
|
||||
}
|
||||
/**** Enable ****
|
||||
*****/
|
||||
|
||||
@ -94,25 +91,6 @@ SubFileItem::SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
Setup();
|
||||
}
|
||||
|
||||
/** Constructor */
|
||||
SubFileItem::SubFileItem(std::string path)
|
||||
:QWidget(NULL), mPath(path), mFileSize(0)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
mMode = SFI_STATE_EXTRA;
|
||||
mType = SFI_TYPE_ATTACH;
|
||||
|
||||
/* ask for Files to hash/prepare it for us */
|
||||
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path, SFI_DEFAULT_PERIOD, 0)))
|
||||
{
|
||||
mMode = SFI_STATE_ERROR;
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
|
||||
void SubFileItem::Setup()
|
||||
{
|
||||
@ -581,12 +559,33 @@ void SubFileItem::cancel()
|
||||
|
||||
void SubFileItem::play()
|
||||
{
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "SubFileItem::play() :" << mPath;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
FileInfo info;
|
||||
uint32_t flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
|
||||
|
||||
//openFile(mPath);
|
||||
|
||||
if (!rsFiles->FileDetails( mFileHash, flags, info))
|
||||
return;
|
||||
|
||||
if (done()) {
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(info.path.c_str());
|
||||
if (qinfo.exists()) {
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
||||
std::cerr << "openTransfer(): can't open file " << info.path << std::endl;
|
||||
}
|
||||
}else{
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 does not exist at location.").arg(info.path.c_str()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* rise a message box for incompleted download file */
|
||||
QMessageBox::information(this, tr("Play File"),
|
||||
tr("File %1 is not completed.").arg(info.fname.c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,14 +41,21 @@ const uint32_t SFI_STATE_UPLOAD = 0x0006;
|
||||
const uint32_t SFI_TYPE_CHANNEL = 0x0010;
|
||||
const uint32_t SFI_TYPE_ATTACH = 0x0020;
|
||||
|
||||
|
||||
//! This create a gui widget that allows users to access files shared by user
|
||||
/*!
|
||||
* Widget that allows user to share files with a visual attachment interface
|
||||
* Note: extra files (files not already shared/hashed in rs) need to
|
||||
* be hashed by the clients of this class or else objects of this class will
|
||||
* have reduced functionality
|
||||
*/
|
||||
class SubFileItem : public QWidget, private Ui::SubFileItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
SubFileItem(std::string localpath);
|
||||
SubFileItem(std::string hash, std::string name, uint64_t size,
|
||||
SubFileItem(std::string hash, std::string name, std::string path, uint64_t size,
|
||||
uint32_t flags, std::string srcId);
|
||||
|
||||
/** Default Destructor */
|
||||
|
@ -103,20 +103,6 @@ void BlogsMsgItem::updateItemStatic()
|
||||
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm:ss");
|
||||
datetimelabel->setText(timestamp);
|
||||
|
||||
|
||||
|
||||
std::list<FileInfo>::iterator it;
|
||||
for(it = cmi.files.begin(); it != cmi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size,
|
||||
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
layout->addWidget(fi);
|
||||
}
|
||||
|
||||
//playButton->setEnabled(false);
|
||||
|
||||
if (mIsHome)
|
||||
@ -139,32 +125,11 @@ void BlogsMsgItem::updateItem()
|
||||
{
|
||||
/* fill in */
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "ChanMsgItem::updateItem()";
|
||||
std::cerr << "BlogMsgItem::updateItem()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
int msec_rate = 10000;
|
||||
|
||||
/* Very slow Tick to check when all files are downloaded */
|
||||
std::list<SubFileItem *>::iterator it;
|
||||
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
|
||||
{
|
||||
if (!(*it)->done())
|
||||
{
|
||||
/* loop again */
|
||||
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* At this point cannot create a playlist....
|
||||
* so can't enable play for all.
|
||||
|
||||
if (mFileItems.size() > 0)
|
||||
{
|
||||
playButton->setEnabled(true);
|
||||
}
|
||||
***/
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,6 @@ private:
|
||||
|
||||
bool mIsHome;
|
||||
|
||||
std::list<SubFileItem *> mFileItems;
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
||||
|
||||
/** Constructor */
|
||||
CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags)
|
||||
: mBlogId(cId), QMainWindow (parent, flags) ,mCheckAttachment(true)
|
||||
: mBlogId(cId), QMainWindow (parent, flags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -92,8 +92,6 @@ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags)
|
||||
|
||||
connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg()));
|
||||
connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew()));
|
||||
|
||||
connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
|
||||
|
||||
connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease()));
|
||||
connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease()));
|
||||
@ -169,306 +167,6 @@ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags)
|
||||
|
||||
}
|
||||
|
||||
/* Dropping */
|
||||
|
||||
void CreateBlogMsg::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
/* print out mimeType */
|
||||
std::cerr << "CreateChannelMsg::dragEnterEvent() 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()->hasFormat("text/plain"))
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dragEnterEvent() Accepting PlainText";
|
||||
std::cerr << std::endl;
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dragEnterEvent() Accepting Urls";
|
||||
std::cerr << std::endl;
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dragEnterEvent() accepting Application/x-qabs...";
|
||||
std::cerr << std::endl;
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dragEnterEvent() No PlainText/Urls";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CreateBlogMsg::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (!(Qt::CopyAction & event->possibleActions()))
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dropEvent() Rejecting uncopyable DropAction";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* can't do it */
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "CreateChannelMsg::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()->hasText())
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dropEvent() Plain Text:";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << event->mimeData()->text().toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::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;
|
||||
|
||||
if (localpath.size() > 0)
|
||||
{
|
||||
|
||||
addAttachment(localpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
|
||||
{
|
||||
std::cerr << "CreateChannelMsg::dropEvent() Application/x-rsfilelist";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
QByteArray data = event->mimeData()->data("application/x-rsfilelist");
|
||||
std::cerr << "Data Len:" << data.length();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Data is:" << data.data();
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::string newattachments(data.data());
|
||||
parseRsFileListAttachments(newattachments);
|
||||
}
|
||||
|
||||
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CreateBlogMsg::parseRsFileListAttachments(std::string attachList)
|
||||
{
|
||||
/* split into lines */
|
||||
QString input = QString::fromStdString(attachList);
|
||||
|
||||
QStringList attachItems = input.split("\n");
|
||||
QStringList::iterator it;
|
||||
QStringList::iterator it2;
|
||||
|
||||
for(it = attachItems.begin(); it != attachItems.end(); it++)
|
||||
{
|
||||
std::cerr << "CreateBlogMsg::parseRsFileListAttachments() Entry: ";
|
||||
|
||||
QStringList parts = (*it).split("/");
|
||||
|
||||
bool ok = false;
|
||||
quint64 qsize = 0;
|
||||
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
uint64_t size = 0;
|
||||
std::string source;
|
||||
|
||||
int i = 0;
|
||||
for(it2 = parts.begin(); it2 != parts.end(); it2++, i++)
|
||||
{
|
||||
std::cerr << "\"" << it2->toStdString() << "\" ";
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
fname = it2->toStdString();
|
||||
break;
|
||||
case 1:
|
||||
hash = it2->toStdString();
|
||||
break;
|
||||
case 2:
|
||||
qsize = it2->toULongLong(&ok, 10);
|
||||
size = qsize;
|
||||
break;
|
||||
case 3:
|
||||
source = it2->toStdString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\tfname: " << fname << std::endl;
|
||||
std::cerr << "\thash: " << hash << std::endl;
|
||||
std::cerr << "\tsize: " << size << std::endl;
|
||||
std::cerr << "\tsource: " << source << std::endl;
|
||||
|
||||
/* basic error checking */
|
||||
if ((ok) && (hash.size() == 40))
|
||||
{
|
||||
std::cerr << "Item Ok" << std::endl;
|
||||
if (source == "Local")
|
||||
{
|
||||
addAttachment(hash, fname, size, true, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
// TEMP NOT ALLOWED UNTIL FT WORKING.
|
||||
addAttachment(hash, fname, size, false, source);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateBlogMsg::addAttachment(std::string hash, std::string fname, uint64_t size, bool local, std::string srcId)
|
||||
{
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "CreateChannelMsg::addAttachment()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* add widget in for new destination */
|
||||
|
||||
uint32_t flags = SFI_TYPE_ATTACH;
|
||||
if (local)
|
||||
{
|
||||
flags |= SFI_STATE_LOCAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= SFI_STATE_REMOTE;
|
||||
// TMP REMOVED REMOTE ADD FOR DEMONSTRATOR
|
||||
return;
|
||||
}
|
||||
|
||||
SubFileItem *file = new SubFileItem(hash, fname, size, flags, srcId);
|
||||
|
||||
mAttachments.push_back(file);
|
||||
ui.verticalLayout_3->addWidget(file);
|
||||
|
||||
if (mCheckAttachment)
|
||||
{
|
||||
checkAttachmentReady();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void CreateBlogMsg::addExtraFile()
|
||||
{
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "CreateChannelMsg::addExtraFile() opening file dialog";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// select a file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath = qfile.toStdString();
|
||||
if (filePath != "")
|
||||
{
|
||||
addAttachment(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateBlogMsg::addAttachment(std::string path)
|
||||
{
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "CreateChannelMsg::addAttachment()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* add to ExtraList here,
|
||||
* use default TIMEOUT of 30 days (time to fetch it).
|
||||
*/
|
||||
//uint32_t period = 30 * 24 * 60 * 60;
|
||||
//uint32_t flags = 0;
|
||||
//rsFiles->ExtraFileHash(localpath, period, flags);
|
||||
|
||||
/* add widget in for new destination */
|
||||
SubFileItem *file = new SubFileItem(path);
|
||||
|
||||
mAttachments.push_back(file);
|
||||
ui.verticalLayout_3->addWidget(file);
|
||||
|
||||
if (mCheckAttachment)
|
||||
{
|
||||
checkAttachmentReady();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void CreateBlogMsg::checkAttachmentReady()
|
||||
{
|
||||
std::list<SubFileItem *>::iterator fit;
|
||||
|
||||
mCheckAttachment = false;
|
||||
|
||||
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
|
||||
{
|
||||
if (!(*fit)->isHidden())
|
||||
{
|
||||
if (!(*fit)->ready())
|
||||
{
|
||||
/*
|
||||
*/
|
||||
ui.actionPublish->setEnabled(false);
|
||||
break;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fit == mAttachments.end())
|
||||
{
|
||||
ui.actionPublish->setEnabled(true);
|
||||
}
|
||||
|
||||
/* repeat... */
|
||||
int msec_rate = 1000;
|
||||
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
|
||||
}
|
||||
|
||||
|
||||
void CreateBlogMsg::cancelMsg()
|
||||
{
|
||||
@ -493,8 +191,6 @@ void CreateBlogMsg::newBlogMsg()
|
||||
|
||||
ui.channelName->setText(QString::fromStdWString(ci.blogName));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -507,38 +203,11 @@ void CreateBlogMsg::sendMsg()
|
||||
std::wstring subject = ui.subjectEdit->text().toStdWString();
|
||||
std::wstring msg = ui.msgEdit->toHtml().toStdWString();
|
||||
|
||||
std::list<FileInfo> files;
|
||||
|
||||
std::list<SubFileItem *>::iterator fit;
|
||||
|
||||
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
|
||||
{
|
||||
if (!(*fit)->isHidden())
|
||||
{
|
||||
FileInfo fi;
|
||||
fi.hash = (*fit)->FileHash();
|
||||
fi.fname = (*fit)->FileName();
|
||||
fi.size = (*fit)->FileSize();
|
||||
|
||||
files.push_back(fi);
|
||||
|
||||
/* commence downloads - if we don't have the file */
|
||||
if (!(*fit)->done())
|
||||
{
|
||||
if ((*fit)->ready())
|
||||
{
|
||||
(*fit)->download();
|
||||
}
|
||||
// Skips unhashed files.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(subject, msg, files);
|
||||
sendMessage(subject, msg);
|
||||
|
||||
}
|
||||
|
||||
void CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files)
|
||||
void CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg)
|
||||
{
|
||||
std::cerr << "CreateBlogMsg::sendMessage()" << std::endl;
|
||||
|
||||
@ -564,7 +233,6 @@ void CreateBlogMsg::sendMessage(std::wstring subject, std::wstring msg, std::lis
|
||||
|
||||
msgInfo.subject = subject;
|
||||
msgInfo.msg = msg;
|
||||
msgInfo.files = files;
|
||||
msgInfo.msgIdReply = "nothing";
|
||||
rsBlogs->BlogMessageSend(msgInfo);
|
||||
}
|
||||
@ -1281,4 +949,4 @@ void CreateBlogMsg::Create_New_Image_Tag( const QString urlremoteorlocal )
|
||||
ui.msgEdit->textCursor().insertFragment(fragment);
|
||||
//emit statusMessage(QString("Image new :").arg(urlremoteorlocal));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -61,13 +61,7 @@ public:
|
||||
|
||||
void Create_New_Image_Tag( const QString urlremoteorlocal );
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
private slots:
|
||||
void addExtraFile();
|
||||
void checkAttachmentReady();
|
||||
|
||||
void cancelMsg();
|
||||
void sendMsg();
|
||||
@ -129,15 +123,10 @@ private:
|
||||
void colorChanged(const QColor &c);
|
||||
void alignmentChanged(Qt::Alignment a);
|
||||
|
||||
void parseRsFileListAttachments(std::string attachList);
|
||||
|
||||
void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files);
|
||||
void sendMessage(std::wstring subject, std::wstring msg);
|
||||
|
||||
std::string mBlogId;
|
||||
|
||||
std::list<SubFileItem *> mAttachments;
|
||||
|
||||
bool mCheckAttachment;
|
||||
|
||||
QAction *actionSave,
|
||||
*actionTextBold,
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string>New Blog Post</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@ -94,7 +94,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@ -149,145 +149,6 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Attachments</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/attachment.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Attachments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>334</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addFileButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>639</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>438</width>
|
||||
<height>137</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -301,7 +162,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>666</width>
|
||||
<height>21</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@ -348,7 +209,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/hi22-action-format-text-blockquote.png</normaloff>:/images/textedit/hi22-action-format-text-blockquote.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -357,7 +218,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionIncreasefontsize">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/format_font_size_more.png</normaloff>:/images/textedit/format_font_size_more.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -366,7 +227,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionDecreasefontsize">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/format_font_size_less.png</normaloff>:/images/textedit/format_font_size_less.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -375,7 +236,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionBold">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/textbold.png</normaloff>:/images/textedit/textbold.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -384,7 +245,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionUnderline">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/textunder.png</normaloff>:/images/textedit/textunder.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -393,7 +254,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionItalic">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/textitalic.png</normaloff>:/images/textedit/textitalic.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -412,7 +273,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionCode">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/hi22-action-format-text-code.png</normaloff>:/images/textedit/hi22-action-format-text-code.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -421,7 +282,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionsplitPost">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/hi22-action-insert-more-mark.png</normaloff>:/images/textedit/hi22-action-insert-more-mark.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -430,7 +291,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionOrderedlist">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/format-list-ordered.png</normaloff>:/images/textedit/format-list-ordered.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -439,7 +300,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionUnorderedlist">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/format-list-unordered.png</normaloff>:/images/textedit/format-list-unordered.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -451,7 +312,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/editcut.png</normaloff>:/images/textedit/editcut.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -460,7 +321,7 @@ border: 1px solid #CCCCCC;}</string>
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<iconset resource="../../images.qrc">
|
||||
<normaloff>:/images/textedit/editundo.png</normaloff>:/images/textedit/editundo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -475,9 +336,8 @@ border: 1px solid #CCCCCC;}</string>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../../images.qrc"/>
|
||||
<include location="../../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user