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 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 MessageSend(MessageInfo &info) = 0;
virtual bool MessageToDraft(MessageInfo &info) = 0;
virtual bool MessageDelete(std::string mid) = 0; virtual bool MessageDelete(std::string mid) = 0;
virtual bool MessageRead(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); return mMsgSrv->MessageSend(info);
} }
bool p3Msgs::MessageToDraft(MessageInfo &info)
{
return mMsgSrv->MessageToDraft(info);
}
/****************************************/ /****************************************/
/****************************************/ /****************************************/
bool p3Msgs::MessageDelete(std::string mid) bool p3Msgs::MessageDelete(std::string mid)

View File

@ -58,6 +58,7 @@ class p3Msgs: public RsMsgs
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox); 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 MessageDelete(std::string mid);
virtual bool MessageRead(std::string mid); virtual bool MessageRead(std::string mid);

View File

@ -264,9 +264,6 @@ int p3MsgService::checkOutgoingMessages()
bool p3MsgService::saveConfiguration() bool p3MsgService::saveConfiguration()
{ {
std::list<std::string>::iterator it;
std::string empty("");
pqioutput(PQL_DEBUG_BASIC, msgservicezone, pqioutput(PQL_DEBUG_BASIC, msgservicezone,
"p3MsgService::save_config()"); "p3MsgService::save_config()");
@ -309,8 +306,6 @@ bool p3MsgService::saveConfiguration()
bool p3MsgService::loadConfiguration(std::string &loadHash) bool p3MsgService::loadConfiguration(std::string &loadHash)
{ {
std::list<std::string>::iterator it;
std::string msgfile = Filename(); std::string msgfile = Filename();
RsSerialiser *rss = new RsSerialiser(); RsSerialiser *rss = new RsSerialiser();
@ -659,6 +654,51 @@ bool p3MsgService::MessageSend(MessageInfo &info)
return true; 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,6 +726,10 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{ {
mi.msgflags |= RS_MSG_PENDING; mi.msgflags |= RS_MSG_PENDING;
} }
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{
mi.msgflags |= RS_MSG_DRAFT;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW) if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{ {
mi.msgflags |= RS_MSG_NEW; mi.msgflags |= RS_MSG_NEW;
@ -761,6 +805,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{ {
mis.msgflags |= RS_MSG_PENDING; mis.msgflags |= RS_MSG_PENDING;
} }
if (msg->msgFlags & RS_MSG_FLAGS_DRAFT)
{
mis.msgflags |= RS_MSG_DRAFT;
}
if (msg->msgFlags & RS_MSG_FLAGS_NEW) if (msg->msgFlags & RS_MSG_FLAGS_NEW)
{ {
mis.msgflags |= RS_MSG_NEW; mis.msgflags |= RS_MSG_NEW;

View File

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

View File

@ -1344,7 +1344,7 @@ void ForumsDialog::replytomessage()
if (rsPeers->getPeerName(msgInfo.srcId) !="") if (rsPeers->getPeerName(msgInfo.srcId) !="")
{ {
MessageComposer *nMsgDialog = new MessageComposer(true); MessageComposer *nMsgDialog = new MessageComposer();
nMsgDialog->newMsg(); nMsgDialog->newMsg();
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ; nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ; 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.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( 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(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.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage())); connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
@ -475,7 +476,7 @@ void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
void MessagesDialog::newmessage() void MessagesDialog::newmessage()
{ {
MessageComposer *nMsgDialog = new MessageComposer(true); MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */ /* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl; //std::cerr << "MessagesDialog::newmessage()" << std::endl;
@ -504,7 +505,7 @@ void MessagesDialog::replytomessage()
if (!rsMsgs -> getMessage(mid, msgInfo)) if (!rsMsgs -> getMessage(mid, msgInfo))
return ; return ;
MessageComposer *nMsgDialog = new MessageComposer(true); MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */ /* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl; //std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
@ -552,7 +553,7 @@ void MessagesDialog::replyallmessage()
if (!rsMsgs -> getMessage(mid, msgInfo)) if (!rsMsgs -> getMessage(mid, msgInfo))
return ; return ;
MessageComposer *nMsgDialog = new MessageComposer(true); MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */ /* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl; //std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
@ -607,7 +608,7 @@ void MessagesDialog::forwardmessage()
if (!rsMsgs -> getMessage(mid, msgInfo)) if (!rsMsgs -> getMessage(mid, msgInfo))
return ; return ;
MessageComposer *nMsgDialog = new MessageComposer(true); MessageComposer *nMsgDialog = new MessageComposer();
/* fill it in */ /* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl; //std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
@ -978,7 +979,7 @@ void MessagesDialog::insertMessages()
// From .... // From ....
{ {
if (msgbox == RS_MSG_INBOX) { if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX) {
text = QString::fromStdString(rsPeers->getPeerName(it->srcId)); text = QString::fromStdString(rsPeers->getPeerName(it->srcId));
} else { } else {
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) { if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
@ -1098,6 +1099,40 @@ void MessagesDialog::clicked(const QModelIndex &index )
updateCurrentMessage(); 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 // show current message directly
void MessagesDialog::updateCurrentMessage() void MessagesDialog::updateCurrentMessage()
{ {
@ -1316,8 +1351,16 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.dateText-> setText(timestamp); ui.dateText-> setText(timestamp);
} }
ui.toText->setText(msgTxt); 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.subjectText->setText(QString::fromStdWString(msgInfo.title));
ui.msgText->setHtml(QString::fromStdWString(msgInfo.msg)); ui.msgText->setHtml(QString::fromStdWString(msgInfo.msg));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,8 +37,8 @@
/** Constructor */ /** Constructor */
MessageComposer::MessageComposer(bool msg, QWidget *parent, Qt::WFlags flags) MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), mIsMsg(msg), mCheckAttachment(true) : QMainWindow(parent, flags), mCheckAttachment(true)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -108,17 +108,7 @@ MessageComposer::MessageComposer(bool msg, QWidget *parent, Qt::WFlags flags)
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
/* if Msg */ connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
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.msgFileList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), connect(ui.msgFileList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
this, SLOT(toggleRecommendItem( 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) void MessageComposer::closeEvent (QCloseEvent * event)
{ {
bool bClose = true;
/* Save to Drafts? */
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;
}
}
if (bClose) {
Settings->saveWidgetInformation(this);
//=== uncheck all repecient's boxes ======= //=== uncheck all repecient's boxes =======
QTreeWidget *sendWidget = ui.msgSendList; QTreeWidget *sendWidget = ui.msgSendList;
for(int i=0;i<sendWidget->topLevelItemCount();++i) for (int i=0;i<sendWidget->topLevelItemCount();++i)
sendWidget->topLevelItem(i)->setCheckState(0,Qt::Unchecked) ; sendWidget->topLevelItem(i)->setCheckState(0,Qt::Unchecked) ;
QMainWindow::closeEvent(event);
event->accept(); } else {
return;
/* We can save to Drafts.... but we'll do this later.
* ... no auto saving for the moment,
*/
#if 0
if (maybeSave())
{
event->accept();
}
else
{
event->ignore(); event->ignore();
hide();
Settings->saveWidgetInformation(this);
} }
#endif
} }
void MessageComposer::insertSendList() 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 */ /* Utility Fns */
/*** /***
RsCertId getSenderRsCertId(QTreeWidgetItem *i) RsCertId getSenderRsCertId(QTreeWidgetItem *i)
@ -446,7 +374,7 @@ void MessageComposer::insertFileList(const std::list<FileInfo>& files_info)
tree->update(); /* update display */ tree->update(); /* update display */
} }
void MessageComposer::newMsg() void MessageComposer::newMsg(std::string msgId /*= ""*/)
{ {
/* clear all */ /* clear all */
QString titlestring = ui.titleEdit->text(); QString titlestring = ui.titleEdit->text();
@ -457,16 +385,33 @@ void MessageComposer::newMsg()
ui.msgText->setText(""); ui.msgText->setText("");
/* worker fns */ /* worker fns */
if (mIsMsg)
{
insertSendList(); insertSendList();
}
else m_sMsgId = msgId;
{
insertChannelSendList(); 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;
} }
// insertFileList(std::list<DirDetails>()); 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) void MessageComposer::insertTitleText(std::string title)
@ -487,6 +432,8 @@ void MessageComposer::insertPastedText(std::string msg)
QTextCursor c = ui.msgText->textCursor(); QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End); c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c); ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
} }
void MessageComposer::insertForwardPastedText(std::string msg) void MessageComposer::insertForwardPastedText(std::string msg)
@ -502,6 +449,8 @@ void MessageComposer::insertForwardPastedText(std::string msg)
QTextCursor c = ui.msgText->textCursor(); QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End); c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c); ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
} }
void MessageComposer::insertMsgText(std::string msg) void MessageComposer::insertMsgText(std::string msg)
@ -513,16 +462,24 @@ void MessageComposer::insertMsgText(std::string msg)
QTextCursor c = ui.msgText->textCursor(); QTextCursor c = ui.msgText->textCursor();
c.movePosition(QTextCursor::End); c.movePosition(QTextCursor::End);
ui.msgText->setTextCursor(c); ui.msgText->setTextCursor(c);
ui.msgText->document()->setModified(true);
} }
void MessageComposer::insertHtmlText(std::string msg) 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() void MessageComposer::sendMessage()
{
sendMessage_internal(false);
close();
}
void MessageComposer::sendMessage_internal(bool bDraftbox)
{ {
/* construct a message */ /* construct a message */
MessageInfo mi; MessageInfo mi;
@ -530,7 +487,6 @@ void MessageComposer::sendMessage()
mi.title = ui.titleEdit->text().toStdWString(); mi.title = ui.titleEdit->text().toStdWString();
mi.msg = ui.msgText->toHtml().toStdWString(); mi.msg = ui.msgText->toHtml().toStdWString();
rsiface->lockData(); /* Lock Interface */ rsiface->lockData(); /* Lock Interface */
// const std::list<FileInfo>& recList = rsiface->getRecommendList(); // const std::list<FileInfo>& recList = rsiface->getRecommendList();
@ -542,26 +498,26 @@ void MessageComposer::sendMessage()
/* get the ids from the send list */ /* get the ids from the send list */
std::list<std::string> peers; std::list<std::string> peers;
std::list<std::string> msgto;
std::list<std::string>::iterator iit; std::list<std::string>::iterator iit;
rsPeers->getFriendList(peers); rsPeers->getFriendList(peers);
for(iit = peers.begin(); iit != peers.end(); iit++) for(iit = peers.begin(); iit != peers.end(); iit++) {
{ if (rsicontrol->IsInMsg(*iit)) {
if (rsicontrol->IsInMsg(*iit))
{
mi.msgto.push_back(*iit); mi.msgto.push_back(*iit);
} }
} }
if (bDraftbox) {
mi.msgId = m_sMsgId;
rsMsgs->MessageToDraft(mi);
} else {
rsMsgs->MessageSend(mi); rsMsgs->MessageSend(mi);
}
close(); ui.msgText->document()->setModified(false);
return;
} }
void MessageComposer::cancelMessage() void MessageComposer::cancelMessage()
{ {
close(); close();
@ -604,24 +560,6 @@ void MessageComposer::togglePersonItem( QTreeWidgetItem *item, int col )
return; 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 ) void MessageComposer::toggleRecommendItem( QTreeWidgetItem *item, int col )
{ {
//std::cerr << "ToggleRecommendItem()" << std::endl; //std::cerr << "ToggleRecommendItem()" << std::endl;

View File

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