mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 17:09:34 -05:00
all messages in MessagesDialog are now editable from context menu or with double click
changes from defnax with some corrections from me git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3135 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f4186fb7c8
commit
5b1fae0123
@ -755,12 +755,22 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
|||||||
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
|
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
|
||||||
contextMnu.addAction( forwardmsgAct);
|
contextMnu.addAction( forwardmsgAct);
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
|
|
||||||
QList<int> RowsRead;
|
QList<int> RowsRead;
|
||||||
QList<int> RowsUnread;
|
QList<int> RowsUnread;
|
||||||
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread);
|
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread);
|
||||||
|
|
||||||
|
QAction *editAct = new QAction(tr( "Edit..." ), this );
|
||||||
|
connect(editAct, SIGNAL(triggered()), this, SLOT(editmessage()));
|
||||||
|
contextMnu.addAction(editAct);
|
||||||
|
|
||||||
|
if (nCount == 1) {
|
||||||
|
editAct->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
editAct->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), this);
|
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), this);
|
||||||
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
|
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
|
||||||
contextMnu.addAction(markAsRead);
|
contextMnu.addAction(markAsRead);
|
||||||
@ -782,7 +792,7 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
|||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
QAction *removemsgAct;
|
QAction *removemsgAct;
|
||||||
if (nCount > 1) {
|
if (nCount > 1) {
|
||||||
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), this );
|
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), this );
|
||||||
} else {
|
} else {
|
||||||
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
|
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
|
||||||
@ -858,6 +868,30 @@ void MessagesDialog::newmessage()
|
|||||||
/* window will destroy itself! */
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesDialog::editmessage()
|
||||||
|
{
|
||||||
|
std::string cid;
|
||||||
|
std::string mid;
|
||||||
|
|
||||||
|
if(!getCurrentMsg(cid, mid))
|
||||||
|
return ;
|
||||||
|
|
||||||
|
MessageInfo msgInfo;
|
||||||
|
if (!rsMsgs->getMessage(mid, msgInfo)) {
|
||||||
|
std::cerr << "MessagesDialog::editmessage() Couldn't find Msg" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageComposer *pMsgDialog = new MessageComposer();
|
||||||
|
/* fill it in */
|
||||||
|
pMsgDialog->newMsg(msgInfo.msgId);
|
||||||
|
|
||||||
|
pMsgDialog->show();
|
||||||
|
pMsgDialog->activateWindow();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesDialog::replytomessage()
|
void MessagesDialog::replytomessage()
|
||||||
{
|
{
|
||||||
/* put msg on msgBoard, and switch to it. */
|
/* put msg on msgBoard, and switch to it. */
|
||||||
@ -1594,35 +1628,11 @@ void MessagesDialog::clicked(const QModelIndex &index )
|
|||||||
// double click in messagestreeView
|
// double click in messagestreeView
|
||||||
void MessagesDialog::doubleClicked(const QModelIndex &index)
|
void MessagesDialog::doubleClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
int mappedRow = proxyModel->mapToSource(index).row();
|
/* activate row */
|
||||||
|
clicked (index);
|
||||||
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! */
|
|
||||||
|
|
||||||
|
/* edit message */
|
||||||
|
editmessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// show current message directly
|
// show current message directly
|
||||||
|
@ -73,6 +73,7 @@ private slots:
|
|||||||
void doubleClicked(const QModelIndex &);
|
void doubleClicked(const QModelIndex &);
|
||||||
|
|
||||||
void newmessage();
|
void newmessage();
|
||||||
|
void editmessage();
|
||||||
|
|
||||||
void replytomessage();
|
void replytomessage();
|
||||||
void replyallmessage();
|
void replyallmessage();
|
||||||
|
@ -43,7 +43,9 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
|||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
m_nBox = -1; // not defined
|
||||||
|
|
||||||
setupFileActions();
|
setupFileActions();
|
||||||
setupEditActions();
|
setupEditActions();
|
||||||
setupViewActions();
|
setupViewActions();
|
||||||
@ -397,6 +399,7 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
|
|||||||
insertSendList();
|
insertSendList();
|
||||||
|
|
||||||
m_sMsgId = msgId;
|
m_sMsgId = msgId;
|
||||||
|
m_nBox = -1; // not defined
|
||||||
|
|
||||||
if (m_sMsgId.empty() == false) {
|
if (m_sMsgId.empty() == false) {
|
||||||
// fill existing message
|
// fill existing message
|
||||||
@ -407,6 +410,8 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_nBox = msgInfo.msgflags & RS_MSG_BOXMASK;
|
||||||
|
|
||||||
insertTitleText( QString::fromStdWString(msgInfo.title).toStdString());
|
insertTitleText( QString::fromStdWString(msgInfo.title).toStdString());
|
||||||
setWindowTitle( tr ("Compose: ") + QString::fromStdWString(msgInfo.title));
|
setWindowTitle( tr ("Compose: ") + QString::fromStdWString(msgInfo.title));
|
||||||
|
|
||||||
@ -518,7 +523,10 @@ void MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bDraftbox) {
|
if (bDraftbox) {
|
||||||
mi.msgId = m_sMsgId;
|
if (m_nBox != -1 && (m_nBox & RS_MSG_DRAFTBOX) == RS_MSG_DRAFTBOX) {
|
||||||
|
// only save draft box to draft box again, for all other message create a new one in draft box
|
||||||
|
mi.msgId = m_sMsgId;
|
||||||
|
}
|
||||||
rsMsgs->MessageToDraft(mi);
|
rsMsgs->MessageToDraft(mi);
|
||||||
} else {
|
} else {
|
||||||
rsMsgs->MessageSend(mi);
|
rsMsgs->MessageSend(mi);
|
||||||
|
@ -175,7 +175,8 @@ private:
|
|||||||
QHash<QString, QString> autoLinkTitleDictionary;
|
QHash<QString, QString> autoLinkTitleDictionary;
|
||||||
QHash<QString, int> autoLinkTargetDictionary;
|
QHash<QString, int> autoLinkTargetDictionary;
|
||||||
|
|
||||||
std::string m_sMsgId; // exisiting message
|
std::string m_sMsgId; // existing message id
|
||||||
|
int m_nBox; // box from the existing message
|
||||||
|
|
||||||
/* maps of files */
|
/* maps of files */
|
||||||
std::list<AttachFileItem *> mAttachments;
|
std::list<AttachFileItem *> mAttachments;
|
||||||
|
Loading…
Reference in New Issue
Block a user