improvement MessagesDialog:

- enabled draft box

bugfix MessagesDialog:
- correct from and to in list and message header

changes MessageComposer:
- cleaned channel part


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2994 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-05-25 09:32:14 +00:00
parent dba460ce0c
commit b0c1467abe
16 changed files with 281 additions and 242 deletions

View File

@ -124,6 +124,8 @@ virtual bool getMessage(std::string mId, MessageInfo &msg) = 0;
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox) = 0;
virtual bool MessageSend(MessageInfo &info) = 0;
virtual bool MessageToDraft(MessageInfo &info) = 0;
virtual bool MessageDelete(std::string mid) = 0;
virtual bool MessageRead(std::string mid) = 0;

View File

@ -75,6 +75,11 @@ bool p3Msgs::MessageSend(MessageInfo &info)
return mMsgSrv->MessageSend(info);
}
bool p3Msgs::MessageToDraft(MessageInfo &info)
{
return mMsgSrv->MessageToDraft(info);
}
/****************************************/
/****************************************/
bool p3Msgs::MessageDelete(std::string mid)

View File

@ -57,7 +57,8 @@ class p3Msgs: public RsMsgs
virtual bool getMessage(std::string mId, MessageInfo &msg);
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox);
virtual bool MessageSend(MessageInfo &info);
virtual bool MessageSend(MessageInfo &info);
virtual bool MessageToDraft(MessageInfo &info);
virtual bool MessageDelete(std::string mid);
virtual bool MessageRead(std::string mid);

View File

@ -264,9 +264,6 @@ int p3MsgService::checkOutgoingMessages()
bool p3MsgService::saveConfiguration()
{
std::list<std::string>::iterator it;
std::string empty("");
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
"p3MsgService::save_config()");
@ -309,8 +306,6 @@ bool p3MsgService::saveConfiguration()
bool p3MsgService::loadConfiguration(std::string &loadHash)
{
std::list<std::string>::iterator it;
std::string msgfile = Filename();
RsSerialiser *rss = new RsSerialiser();
@ -659,6 +654,51 @@ bool p3MsgService::MessageSend(MessageInfo &info)
return true;
}
bool p3MsgService::MessageToDraft(MessageInfo &info)
{
RsMsgItem *msg = initMIRsMsg(info, mConnMgr->getOwnId());
if (msg)
{
uint32_t msgId = 0;
if (info.msgId.empty() == false) {
std::istringstream instream(info.msgId);
instream >> msgId;
}
if (msgId) {
msg->msgId = msgId;
} else {
msg->msgId = getNewUniqueMsgId(); /* grabs Mtx as well */
}
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
/* add pending flag */
msg->msgFlags |= (RS_MSG_OUTGOING | RS_MSG_FLAGS_DRAFT);
if (msgId) {
// remove existing message
RsMsgItem *existingMsg = imsg[msgId];
if (existingMsg) {
delete (existingMsg);
}
imsg.erase(msgId);
}
/* STORE MsgID */
imsg[msg->msgId] = msg;
}
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
return true;
}
return false;
}
/****************************************/
/****************************************/
@ -686,7 +726,11 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{
mi.msgflags |= RS_MSG_PENDING;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW)
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{
mi.msgflags |= RS_MSG_DRAFT;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{
mi.msgflags |= RS_MSG_NEW;
}
@ -761,7 +805,11 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{
mis.msgflags |= RS_MSG_PENDING;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW)
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{
mis.msgflags |= RS_MSG_DRAFT;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{
mis.msgflags |= RS_MSG_NEW;
}

View File

@ -63,6 +63,7 @@ bool removeMsgId(std::string mid);
bool markMsgIdRead(std::string mid);
bool MessageSend(MessageInfo &info);
bool MessageToDraft(MessageInfo &info);

View File

@ -1344,7 +1344,7 @@ void ForumsDialog::replytomessage()
if (rsPeers->getPeerName(msgInfo.srcId) !="")
{
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;

View File

@ -133,6 +133,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
connect( ui.messagestreeView, SIGNAL(doubleClicked ( const QModelIndex& ) ) , this, SLOT( doubleClicked( const QModelIndex & ) ) );
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
@ -475,7 +476,7 @@ void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
void MessagesDialog::newmessage()
{
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
@ -504,7 +505,7 @@ void MessagesDialog::replytomessage()
if (!rsMsgs -> getMessage(mid, msgInfo))
return ;
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
@ -552,7 +553,7 @@ void MessagesDialog::replyallmessage()
if (!rsMsgs -> getMessage(mid, msgInfo))
return ;
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
@ -607,7 +608,7 @@ void MessagesDialog::forwardmessage()
if (!rsMsgs -> getMessage(mid, msgInfo))
return ;
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
@ -978,7 +979,7 @@ void MessagesDialog::insertMessages()
// From ....
{
if (msgbox == RS_MSG_INBOX) {
if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX) {
text = QString::fromStdString(rsPeers->getPeerName(it->srcId));
} else {
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
@ -1098,6 +1099,40 @@ void MessagesDialog::clicked(const QModelIndex &index )
updateCurrentMessage();
}
// double click in messagestreeView
void MessagesDialog::doubleClicked(const QModelIndex &index)
{
int mappedRow = proxyModel->mapToSource(index).row();
QStandardItem *pItem = MessagesModel->item(mappedRow, COLUMN_MSGID);
if (pItem == NULL) {
return;
}
std::string mid = pItem->text().toStdString();
MessageInfo msgInfo;
if (!rsMsgs->getMessage(mid, msgInfo)) {
std::cerr << "MessagesDialog::doubleClicked() Couldn't find Msg" << std::endl;
return;
}
if ((msgInfo.msgflags & RS_MSG_BOXMASK) != RS_MSG_DRAFTBOX) {
// only draft box for now
return;
}
MessageComposer *pMsgDialog = new MessageComposer();
/* fill it in */
pMsgDialog->newMsg(msgInfo.msgId);
pMsgDialog->show();
pMsgDialog->activateWindow();
/* window will destroy itself! */
}
// show current message directly
void MessagesDialog::updateCurrentMessage()
{
@ -1316,8 +1351,16 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.dateText-> setText(timestamp);
}
ui.toText->setText(msgTxt);
ui.fromText->setText("<a style='color: blue;' href='" + QString::fromStdString(rsPeers->getPeerName(msgInfo.srcId)) + "@" + QString::fromStdString(msgInfo.srcId) + "'> " + QString::fromStdString(rsPeers->getPeerName(msgInfo.srcId)) +"</a>");
ui.fromText->setToolTip(QString::fromStdString(rsPeers->getPeerName(msgInfo.srcId)) + "@" + QString::fromStdString(msgInfo.srcId));
std::string sSrcId;
if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) {
// outgoing message are from me
sSrcId = rsPeers->getOwnId();
} else {
sSrcId = msgInfo.srcId;
}
ui.fromText->setText("<a style='color: blue;' href='" + QString::fromStdString(rsPeers->getPeerName(sSrcId)) + "@" + QString::fromStdString(sSrcId) + "'> " + QString::fromStdString(rsPeers->getPeerName(sSrcId)) +"</a>");
ui.fromText->setToolTip(QString::fromStdString(rsPeers->getPeerName(sSrcId)) + "@" + QString::fromStdString(sSrcId));
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
ui.msgText->setHtml(QString::fromStdWString(msgInfo.msg));

View File

@ -63,6 +63,7 @@ private slots:
void updateCurrentMessage();
void currentChanged(const QModelIndex&);
void clicked(const QModelIndex&);
void doubleClicked(const QModelIndex &);
void newmessage();

View File

@ -846,7 +846,7 @@ void MessengerWindow::sendMessage()
}
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->show();

View File

@ -712,7 +712,7 @@ void PeersDialog::msgfriend()
}
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->show();

View File

@ -1194,7 +1194,7 @@ void SearchDialog::sendLinkTo( )
copysearchLink();
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->insertTitleText("New RetroShare Link(s)");

View File

@ -334,7 +334,7 @@ void SharedFilesDialog::sendremoteLinkTo()
copyLinkRemote ();
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in
* files are receommended already
@ -355,7 +355,7 @@ void SharedFilesDialog::sendLinkTo()
copyLinkLocal ();
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in
@ -378,7 +378,7 @@ void SharedFilesDialog::sendHtmlLinkTo( )
copyLinkLocal ();
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in
* files are receommended already
@ -517,7 +517,7 @@ void SharedFilesDialog::recommendFilesTo( std::string rsid )
return ;
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in
* files are receommended already
@ -547,7 +547,7 @@ void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
/* create a message */
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->insertFileList(files_info) ;
nMsgDialog->newMsg();

View File

@ -254,7 +254,7 @@ void MsgItem::replyMsg()
if (!rsMsgs -> getMessage(mMsgId, msgInfo))
return ;
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;

View File

@ -294,7 +294,7 @@ void PeerItem::sendMsg()
{
//mParent->openMsg(FEEDHOLDER_MSG_MESSAGE, mPeerId, "");
MessageComposer *nMsgDialog = new MessageComposer(true);
MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg();
nMsgDialog->addRecipient( mPeerId ) ;

View File

@ -37,8 +37,8 @@
/** Constructor */
MessageComposer::MessageComposer(bool msg, QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), mIsMsg(msg), mCheckAttachment(true)
MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), mCheckAttachment(true)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -108,17 +108,7 @@ MessageComposer::MessageComposer(bool msg, QWidget *parent, Qt::WFlags flags)
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
/* if Msg */
if (mIsMsg)
{
connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
}
else
{
connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
this, SLOT(toggleChannelItem( QTreeWidgetItem *, int ) ));
}
connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
connect(ui.msgFileList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
this, SLOT(toggleRecommendItem( QTreeWidgetItem *, int ) ));
@ -202,34 +192,41 @@ MessageComposer::MessageComposer(bool msg, QWidget *parent, Qt::WFlags flags)
void MessageComposer::closeEvent (QCloseEvent * event)
{
//=== uncheck all repecient's boxes =======
QTreeWidget *sendWidget = ui.msgSendList;
bool bClose = true;
for(int i=0;i<sendWidget->topLevelItemCount();++i)
sendWidget->topLevelItem(i)->setCheckState(0,Qt::Unchecked) ;
/* Save to Drafts? */
event->accept();
return;
/* We can save to Drafts.... but we'll do this later.
* ... no auto saving for the moment,
*/
#if 0
if (maybeSave())
{
event->accept();
if (ui.msgText->document()->isModified()) {
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, tr("Save Message"),
tr("Message has not been Sent.\n"
"Do you want to save message to draft box?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
switch (ret) {
case QMessageBox::Yes:
sendMessage_internal(true);
break;
case QMessageBox::Cancel:
bClose = false;
break;
default:
break;
}
}
else
{
event->ignore();
hide();
Settings->saveWidgetInformation(this);
}
#endif
if (bClose) {
Settings->saveWidgetInformation(this);
//=== uncheck all repecient's boxes =======
QTreeWidget *sendWidget = ui.msgSendList;
for (int i=0;i<sendWidget->topLevelItemCount();++i)
sendWidget->topLevelItem(i)->setCheckState(0,Qt::Unchecked) ;
QMainWindow::closeEvent(event);
} else {
event->ignore();
}
}
void MessageComposer::insertSendList()
@ -304,75 +301,6 @@ void MessageComposer::insertSendList()
}
void MessageComposer::insertChannelSendList()
{
#if 0
rsiface->lockData(); /* Lock Interface */
std::map<RsChanId,ChannelInfo>::const_iterator it;
const std::map<RsChanId,ChannelInfo> &chans =
rsiface->getChannels();
/* get a link to the table */
QTreeWidget *sendWidget = ui.msgSendList;
/* remove old items ??? */
sendWidget->clear();
sendWidget->setColumnCount(4);
QList<QTreeWidgetItem *> items;
for(it = chans.begin(); it != chans.end(); it++)
{
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* (0) Title */
item -> setText(0, QString::fromStdString(it->second.chanName));
if (it->second.publisher)
{
item -> setText(1, "Publisher");
}
else
{
item -> setText(1, "Listener");
}
{
std::ostringstream out;
out << it->second.chanId;
item -> setText(2, QString::fromStdString(out.str()));
}
item -> setText(3, "Channel");
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item -> setCheckState(0, Qt::Unchecked);
if (it -> second.inBroadcast)
{
item -> setCheckState(0, Qt::Checked);
}
else
{
item -> setCheckState(0, Qt::Unchecked);
}
/* add to the list */
items.append(item);
}
/* add the items in! */
sendWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
sendWidget->update(); /* update display */
#endif
}
/* Utility Fns */
/***
RsCertId getSenderRsCertId(QTreeWidgetItem *i)
@ -446,27 +374,44 @@ void MessageComposer::insertFileList(const std::list<FileInfo>& files_info)
tree->update(); /* update display */
}
void MessageComposer::newMsg()
void MessageComposer::newMsg(std::string msgId /*= ""*/)
{
/* clear all */
QString titlestring = ui.titleEdit->text();
/* clear all */
QString titlestring = ui.titleEdit->text();
setWindowTitle(tr("Compose: ") + titlestring );
ui.titleEdit->setText("No Title");
setWindowTitle(tr("Compose: ") + titlestring );
ui.titleEdit->setText("No Title");
ui.msgText->setText("");
ui.msgText->setText("");
/* worker fns */
if (mIsMsg)
{
insertSendList();
}
else
{
insertChannelSendList();
}
/* worker fns */
insertSendList();
// insertFileList(std::list<DirDetails>());
m_sMsgId = msgId;
if (m_sMsgId.empty() == false) {
// fill existing message
MessageInfo msgInfo;
if (!rsMsgs->getMessage(m_sMsgId, msgInfo)) {
std::cerr << "MessageComposer::newMsg() Couldn't find Msg" << std::endl;
m_sMsgId.clear();
return;
}
insertTitleText( QString::fromStdWString(msgInfo.title).toStdString());
setWindowTitle( tr ("Compose: ") + QString::fromStdWString(msgInfo.title));
insertMsgText(QString::fromStdWString(msgInfo.msg).toStdString());
insertFileList(msgInfo.files);
std::list<std::string>::iterator to;
for (to = msgInfo.msgto.begin(); to != msgInfo.msgto.end(); to++ ) {
addRecipient(*to) ;
}
ui.msgText->document()->setModified(false);
}
}
void MessageComposer::insertTitleText(std::string title)
@ -476,91 +421,102 @@ void MessageComposer::insertTitleText(std::string title)
void MessageComposer::insertPastedText(std::string msg)
{
std::string::size_type i=0 ;
while( (i=msg.find_first_of('\n',i+1)) < msg.size())
msg.replace(i,1,std::string("\n<BR/>> ")) ;
std::string::size_type i=0 ;
while( (i=msg.find_first_of('\n',i+1)) < msg.size())
msg.replace(i,1,std::string("\n<BR/>> ")) ;
ui.msgText->setHtml(QString("<HTML><font color=\"blue\">")+QString::fromStdString(std::string("> ") + msg)+"</font><br/><br/></HTML>") ;
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->setHtml(QString("<HTML><font color=\"blue\">")+QString::fromStdString(std::string("> ") + msg)+"</font><br/><br/></HTML>") ;
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
}
void MessageComposer::insertForwardPastedText(std::string msg)
{
std::string::size_type i=0 ;
while( (i=msg.find_first_of('\n',i+1)) < msg.size())
msg.replace(i,1,std::string("\n<BR/>> ")) ;
std::string::size_type i=0 ;
while( (i=msg.find_first_of('\n',i+1)) < msg.size())
msg.replace(i,1,std::string("\n<BR/>> ")) ;
ui.msgText->setHtml(QString("<HTML><blockquote [type=cite]><font color=\"blue\">")+QString::fromStdString(std::string("") + msg)+"</font><br/><br/></blockquote></HTML>") ;
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->setHtml(QString("<HTML><blockquote [type=cite]><font color=\"blue\">")+QString::fromStdString(std::string("") + msg)+"</font><br/><br/></blockquote></HTML>") ;
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
}
void MessageComposer::insertMsgText(std::string msg)
{
ui.msgText->setText(QString::fromStdString(msg));
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->setText(QString::fromStdString(msg));
ui.msgText->setFocus( Qt::OtherFocusReason );
QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
}
void MessageComposer::insertHtmlText(std::string msg)
{
ui.msgText->setHtml(QString("<a href='") + QString::fromStdString(std::string(msg + "'> ") ) + QString::fromStdString(std::string(msg)) + "</a>") ;
}
ui.msgText->setHtml(QString("<a href='") + QString::fromStdString(std::string(msg + "'> ") ) + QString::fromStdString(std::string(msg)) + "</a>") ;
ui.msgText->document()->setModified(true);
}
void MessageComposer::sendMessage()
{
/* construct a message */
MessageInfo mi;
mi.title = ui.titleEdit->text().toStdWString();
mi.msg = ui.msgText->toHtml().toStdWString();
rsiface->lockData(); /* Lock Interface */
// const std::list<FileInfo>& recList = rsiface->getRecommendList();
for(std::list<FileInfo>::const_iterator it(_recList.begin()); it != _recList.end(); ++it)
if (it -> inRecommend)
mi.files.push_back(*it);
rsiface->unlockData(); /* UnLock Interface */
/* get the ids from the send list */
std::list<std::string> peers;
std::list<std::string> msgto;
std::list<std::string>::iterator iit;
rsPeers->getFriendList(peers);
for(iit = peers.begin(); iit != peers.end(); iit++)
{
if (rsicontrol->IsInMsg(*iit))
{
mi.msgto.push_back(*iit);
}
}
rsMsgs->MessageSend(mi);
close();
return;
sendMessage_internal(false);
close();
}
void MessageComposer::sendMessage_internal(bool bDraftbox)
{
/* construct a message */
MessageInfo mi;
mi.title = ui.titleEdit->text().toStdWString();
mi.msg = ui.msgText->toHtml().toStdWString();
rsiface->lockData(); /* Lock Interface */
// const std::list<FileInfo>& recList = rsiface->getRecommendList();
for(std::list<FileInfo>::const_iterator it(_recList.begin()); it != _recList.end(); ++it)
if (it -> inRecommend)
mi.files.push_back(*it);
rsiface->unlockData(); /* UnLock Interface */
/* get the ids from the send list */
std::list<std::string> peers;
std::list<std::string>::iterator iit;
rsPeers->getFriendList(peers);
for(iit = peers.begin(); iit != peers.end(); iit++) {
if (rsicontrol->IsInMsg(*iit)) {
mi.msgto.push_back(*iit);
}
}
if (bDraftbox) {
mi.msgId = m_sMsgId;
rsMsgs->MessageToDraft(mi);
} else {
rsMsgs->MessageSend(mi);
}
ui.msgText->document()->setModified(false);
}
void MessageComposer::cancelMessage()
{
@ -604,24 +560,6 @@ void MessageComposer::togglePersonItem( QTreeWidgetItem *item, int col )
return;
}
/* Second the Channel ones */
void MessageComposer::toggleChannelItem( QTreeWidgetItem *item, int col )
{
//std::cerr << "ToggleChannelItem()" << std::endl;
/* extract id */
std::string id = (item -> text(2)).toStdString();
/* get state */
bool inBroad = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
/* call control fns */
rsicontrol -> SetInBroadcast(id, inBroad);
return;
}
/* This is actually for both */
void MessageComposer::toggleRecommendItem( QTreeWidgetItem *item, int col )
{
//std::cerr << "ToggleRecommendItem()" << std::endl;

View File

@ -44,15 +44,13 @@ class MessageComposer : public QMainWindow
public:
/** Default Constructor */
MessageComposer(bool isMsg, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
MessageComposer(QWidget *parent = 0, Qt::WFlags flags = 0);
void newMsg();
void newMsg(std::string msgId = "");
/* worker fns */
void insertSendList(); /* for Msgs */
void insertChannelSendList(); /* for Channels */
void insertFileList(const std::list<DirDetails>&); /* for Both */
void insertSendList();
void insertFileList(const std::list<DirDetails>&);
void insertFileList(const std::list<FileInfo>&);
void insertTitleText(std::string title);
void insertPastedText(std::string msg) ;
@ -80,7 +78,6 @@ private slots:
/* for toggling flags */
void togglePersonItem( QTreeWidgetItem *item, int col );
void toggleChannelItem( QTreeWidgetItem *item, int col );
void toggleRecommendItem( QTreeWidgetItem *item, int col );
void fileNew();
@ -136,6 +133,8 @@ private:
void colorChanged(const QColor &c);
void alignmentChanged(Qt::Alignment a);
void sendMessage_internal(bool bDraftbox);
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
@ -165,11 +164,12 @@ private:
QHash<QString, QString> autoLinkDictionary;
QHash<QString, QString> autoLinkTitleDictionary;
QHash<QString, int> autoLinkTargetDictionary;
/* maps of files */
std::list<AttachFileItem *> mAttachments;
bool mIsMsg; /* different behaviour for Msg or ChanMsg */
std::string m_sMsgId; // exisiting message
/* maps of files */
std::list<AttachFileItem *> mAttachments;
bool mCheckAttachment;
/** Qt Designer generated object */