mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 09:27:09 -05:00
fixed context menu
This commit is contained in:
parent
5cbff98e40
commit
0570c3fa38
@ -541,40 +541,31 @@ int MessagesDialog::getSelectedMessages(QList<QString>& mid)
|
|||||||
return mid.size();
|
return mid.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessagesDialog::getSelectedMsgCount (QList<QTreeWidgetItem*> *items, QList<QTreeWidgetItem*> *itemsRead, QList<QTreeWidgetItem*> *itemsUnread, QList<QTreeWidgetItem*> *itemsStar)
|
int MessagesDialog::getSelectedMsgCount (QList<QModelIndex> *items, QList<QModelIndex> *itemsRead, QList<QModelIndex> *itemsUnread, QList<QModelIndex> *itemsStar)
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
QModelIndexList qmil = ui.messageTreeWidget->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if (items) items->clear();
|
if (items) items->clear();
|
||||||
if (itemsRead) itemsRead->clear();
|
if (itemsRead) itemsRead->clear();
|
||||||
if (itemsUnread) itemsUnread->clear();
|
if (itemsUnread) itemsUnread->clear();
|
||||||
if (itemsStar) itemsStar->clear();
|
if (itemsStar) itemsStar->clear();
|
||||||
|
|
||||||
//To check if the selection has more than one row.
|
foreach(const QModelIndex& m, qmil)
|
||||||
QList<QString> selectedMessages;
|
|
||||||
getSelectedMessages(selectedMessages);
|
|
||||||
|
|
||||||
foreach (const QString&, selectedMessages)
|
|
||||||
{
|
{
|
||||||
if (items || itemsRead || itemsUnread || itemsStar) {
|
if (items)
|
||||||
if (items) items->append(item);
|
items->append(m);
|
||||||
|
|
||||||
if (item->data(COLUMN_DATA, ROLE_UNREAD).toBool()) {
|
if (m.data(RsMessageModel::UnreadRole).toBool())
|
||||||
if (itemsUnread) itemsUnread->append(item);
|
if (itemsUnread)
|
||||||
} else {
|
itemsUnread->append(m);
|
||||||
if (itemsRead) itemsRead->append(item);
|
else if(itemsRead)
|
||||||
}
|
itemsRead->append(m);
|
||||||
|
|
||||||
if (itemsStar) {
|
if (itemsStar && m.data(RsMessageModel::MsgFlagsRole).toInt() & RS_MSG_STAR)
|
||||||
if (item->data(COLUMN_DATA, ROLE_MSGFLAGS).toInt() & RS_MSG_STAR) {
|
itemsStar->append(m);
|
||||||
itemsStar->append(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedItems.size();
|
return qmil.size();
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesDialog::isMessageRead(const QModelIndex& index)
|
bool MessagesDialog::isMessageRead(const QModelIndex& index)
|
||||||
@ -608,9 +599,10 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/)
|
|||||||
if(!rsMail->getMessage(mid, msgInfo))
|
if(!rsMail->getMessage(mid, msgInfo))
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> itemsRead;
|
QList<QModelIndex> itemsRead;
|
||||||
QList<QTreeWidgetItem*> itemsUnread;
|
QList<QModelIndex> itemsUnread;
|
||||||
QList<QTreeWidgetItem*> itemsStar;
|
QList<QModelIndex> itemsStar;
|
||||||
|
|
||||||
int nCount = getSelectedMsgCount (NULL, &itemsRead, &itemsUnread, &itemsStar);
|
int nCount = getSelectedMsgCount (NULL, &itemsRead, &itemsUnread, &itemsStar);
|
||||||
|
|
||||||
/** Defines the actions for the context menu */
|
/** Defines the actions for the context menu */
|
||||||
@ -1438,47 +1430,51 @@ void MessagesDialog::updateCurrentMessage()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read)
|
// void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read)
|
||||||
{
|
// {
|
||||||
LockUpdate Lock (this, false);
|
// LockUpdate Lock (this, false);
|
||||||
|
//
|
||||||
foreach (QTreeWidgetItem *item, items) {
|
// foreach (QTreeWidgetItem *item, items) {
|
||||||
std::string mid = item->data(COLUMN_DATA, RsMessageModel::MsgIdRole).toString().toStdString();
|
// std::string mid = item->data(COLUMN_DATA, RsMessageModel::MsgIdRole).toString().toStdString();
|
||||||
|
//
|
||||||
if (rsMail->MessageRead(mid, !read)) {
|
// if (rsMail->MessageRead(mid, !read)) {
|
||||||
int msgFlag = item->data(COLUMN_DATA, RsMessageModel::MsgFlagsRole).toInt();
|
// int msgFlag = item->data(COLUMN_DATA, RsMessageModel::MsgFlagsRole).toInt();
|
||||||
msgFlag &= ~RS_MSG_NEW;
|
// msgFlag &= ~RS_MSG_NEW;
|
||||||
|
//
|
||||||
if (read) {
|
// if (read) {
|
||||||
msgFlag &= ~RS_MSG_UNREAD_BY_USER;
|
// msgFlag &= ~RS_MSG_UNREAD_BY_USER;
|
||||||
} else {
|
// } else {
|
||||||
msgFlag |= RS_MSG_UNREAD_BY_USER;
|
// msgFlag |= RS_MSG_UNREAD_BY_USER;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
item->setData(COLUMN_DATA, RsMessageModel::MsgFlagsRole, msgFlag);
|
// item->setData(COLUMN_DATA, RsMessageModel::MsgFlagsRole, msgFlag);
|
||||||
|
//
|
||||||
InitIconAndFont(item);
|
// InitIconAndFont(item);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// LockUpdate
|
// // LockUpdate
|
||||||
}
|
// }
|
||||||
|
|
||||||
void MessagesDialog::markAsRead()
|
void MessagesDialog::markAsRead()
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem*> itemsUnread;
|
QList<QModelIndex> itemsUnread;
|
||||||
getSelectedMsgCount (NULL, NULL, &itemsUnread, NULL);
|
getSelectedMsgCount (NULL, NULL, &itemsUnread, NULL);
|
||||||
|
|
||||||
setMsgAsReadUnread (itemsUnread, true);
|
foreach(const QModelIndex& index,itemsUnread)
|
||||||
|
mMessageModel->setMsgReadStatus(index,true);
|
||||||
|
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::markAsUnread()
|
void MessagesDialog::markAsUnread()
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem*> itemsRead;
|
QList<QModelIndex> itemsRead;
|
||||||
getSelectedMsgCount (NULL, &itemsRead, NULL, NULL);
|
getSelectedMsgCount (NULL, &itemsRead, NULL, NULL);
|
||||||
|
|
||||||
setMsgAsReadUnread (itemsRead, false);
|
foreach(const QModelIndex& index,itemsRead)
|
||||||
|
mMessageModel->setMsgReadStatus(index,false);
|
||||||
|
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ private:
|
|||||||
bool getCurrentMsg(std::string &cid, std::string &mid);
|
bool getCurrentMsg(std::string &cid, std::string &mid);
|
||||||
void setMsgAsReadUnread(const QList<QTreeWidgetItem *> &items, bool read);
|
void setMsgAsReadUnread(const QList<QTreeWidgetItem *> &items, bool read);
|
||||||
|
|
||||||
int getSelectedMsgCount (QList<QTreeWidgetItem *> *items, QList<QTreeWidgetItem *> *itemsRead, QList<QTreeWidgetItem *> *itemsUnread, QList<QTreeWidgetItem *> *itemsStar);
|
int getSelectedMsgCount (QList<QModelIndex> *items, QList<QModelIndex> *itemsRead, QList<QModelIndex> *itemsUnread, QList<QModelIndex> *itemsStar);
|
||||||
bool isMessageRead(const QModelIndex &index);
|
bool isMessageRead(const QModelIndex &index);
|
||||||
bool hasMessageStar(const QModelIndex &index);
|
bool hasMessageStar(const QModelIndex &index);
|
||||||
|
|
||||||
|
@ -652,14 +652,16 @@ void RsMessageModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
|
|||||||
|
|
||||||
preMods();
|
preMods();
|
||||||
rsMsgs->MessageRead(i.data(MsgIdRole).toString().toStdString(),!read_status);
|
rsMsgs->MessageRead(i.data(MsgIdRole).toString().toStdString(),!read_status);
|
||||||
postMods();
|
|
||||||
|
emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsMessageModel::setMsgStar(const QModelIndex& i,bool star)
|
void RsMessageModel::setMsgStar(const QModelIndex& i,bool star)
|
||||||
{
|
{
|
||||||
preMods();
|
preMods();
|
||||||
rsMsgs->MessageStar(i.data(MsgIdRole).toString().toStdString(),star);
|
rsMsgs->MessageStar(i.data(MsgIdRole).toString().toStdString(),star);
|
||||||
postMods();
|
|
||||||
|
emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
|
QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
|
||||||
|
Loading…
Reference in New Issue
Block a user