fixed display of selected msg

This commit is contained in:
csoler 2019-02-26 14:09:49 +01:00
parent 40832734cc
commit 875d0a15da
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
2 changed files with 77 additions and 89 deletions

View file

@ -153,8 +153,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(ui.messageTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(messageTreeWidgetCustomPopupMenu(const QPoint&))); connect(ui.messageTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(messageTreeWidgetCustomPopupMenu(const QPoint&)));
connect(ui.listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(folderlistWidgetCustomPopupMenu(QPoint))); connect(ui.listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(folderlistWidgetCustomPopupMenu(QPoint)));
connect(ui.messageTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)) , this, SLOT(clicked(QTreeWidgetItem*,int))); connect(ui.messageTreeWidget, SIGNAL(clicked(const QModelIndex&)) , this, SLOT(clicked(const QModelIndex&)));
connect(ui.messageTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)) , this, SLOT(doubleClicked(QTreeWidgetItem*,int))); connect(ui.messageTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)) , this, SLOT(doubleClicked(const QModelIndex&)));
connect(ui.messageTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*))); connect(ui.messageTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*)));
connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(const QModelIndex&))); connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(const QModelIndex&)));
connect(ui.listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changeBox(int))); connect(ui.listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changeBox(int)));
@ -181,8 +181,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
listMode = LIST_NOTHING; listMode = LIST_NOTHING;
mCurrMsgId = "";
mMessageModel = new RsMessageModel(this); mMessageModel = new RsMessageModel(this);
mMessageProxyModel = new MessageSortFilterProxyModel(ui.messageTreeWidget->header(),this); mMessageProxyModel = new MessageSortFilterProxyModel(ui.messageTreeWidget->header(),this);
mMessageProxyModel->setSourceModel(mMessageModel); mMessageProxyModel->setSourceModel(mMessageModel);
@ -257,7 +255,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
msgwheader->resizeSection (COLUMN_ATTACHEMENTS, fm.width('0')*1.2f); msgwheader->resizeSection (COLUMN_ATTACHEMENTS, fm.width('0')*1.2f);
msgwheader->resizeSection (COLUMN_SUBJECT, 250); msgwheader->resizeSection (COLUMN_SUBJECT, 250);
msgwheader->resizeSection (COLUMN_FROM, 140); msgwheader->resizeSection (COLUMN_FROM, 140);
//msgwheader->resizeSection (COLUMN_SIGNATURE, 24);
msgwheader->resizeSection (COLUMN_DATE, 140); msgwheader->resizeSection (COLUMN_DATE, 140);
QHeaderView_setSectionResizeModeColumn(msgwheader, COLUMN_STAR, QHeaderView::Fixed); QHeaderView_setSectionResizeModeColumn(msgwheader, COLUMN_STAR, QHeaderView::Fixed);
@ -1376,44 +1373,44 @@ void MessagesDialog::currentItemChanged(QTreeWidgetItem *item)
} }
// click in messageTreeWidget // click in messageTreeWidget
void MessagesDialog::clicked(QTreeWidgetItem *item, int column) void MessagesDialog::clicked(const QModelIndex& index)
{ {
if (!item) { if(!index.isValid())
return; return;
}
switch (column) { // switch (index.column())
case COLUMN_UNREAD: // {
{ // case COLUMN_UNREAD:
QList<QTreeWidgetItem*> items; // {
items.append(item); // QList<QModelIndex> items;
setMsgAsReadUnread(items, !isMessageRead(item)); // items.append(item);
insertMsgTxtAndFiles(item, false); // setMsgAsReadUnread(items, !isMessageRead(item));
updateMessageSummaryList(); // insertMsgTxtAndFiles(item, false);
return; // updateMessageSummaryList();
} // return;
case COLUMN_STAR: // }
{ // case COLUMN_STAR:
QList<QTreeWidgetItem*> items; // {
items.append(item); // QList<QTreeWidgetItem*> items;
setMsgStar(items, !hasMessageStar(item)); // items.append(item);
return; // setMsgStar(items, !hasMessageStar(item));
} // return;
} // }
// }
#ifdef TODO #ifdef TODO
timer->stop(); timer->stop();
timerIndex = ui.messageTreeWidget->indexOfTopLevelItem(item); timerIndex = ui.messageTreeWidget->indexOfTopLevelItem(item);
#endif #endif
// show current message directly // show current message directly
updateCurrentMessage(); insertMsgTxtAndFiles(index);
} }
// double click in messageTreeWidget // double click in messageTreeWidget
void MessagesDialog::doubleClicked(QTreeWidgetItem *item, int column) void MessagesDialog::doubleClicked(const QModelIndex& index)
{ {
/* activate row */ /* activate row */
clicked (item, column); clicked(index);
std::string cid; std::string cid;
std::string mid; std::string mid;
@ -1445,10 +1442,6 @@ void MessagesDialog::doubleClicked(QTreeWidgetItem *item, int column)
// show current message directly // show current message directly
void MessagesDialog::updateCurrentMessage() void MessagesDialog::updateCurrentMessage()
{ {
#ifdef TODO
timer->stop();
insertMsgTxtAndFiles(ui.messageTreeWidget->topLevelItem(timerIndex));
#endif
} }
void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read) void MessagesDialog::setMsgAsReadUnread(const QList<QTreeWidgetItem*> &items, bool read)
@ -1531,70 +1524,65 @@ void MessagesDialog::setMsgStar(const QList<QTreeWidgetItem*> &items, bool star)
// LockUpdate // LockUpdate
} }
void MessagesDialog::insertMsgTxtAndFiles(QTreeWidgetItem *item, bool bSetToRead) void MessagesDialog::insertMsgTxtAndFiles(const QModelIndex& index)
{ {
/* get its Ids */ /* get its Ids */
std::string cid; std::string cid;
std::string mid; std::string mid;
if (item == NULL) { if(!index.isValid())
{
mCurrMsgId.clear(); mCurrMsgId.clear();
msgWidget->fill(mCurrMsgId); msgWidget->fill(mCurrMsgId);
updateInterface(); updateInterface();
return; return;
} }
mid = item->data(COLUMN_DATA, RsMessageModel::MsgIdRole).toString().toStdString(); mid = index.data(RsMessageModel::MsgIdRole).toString().toStdString();
int nCount = getSelectedMsgCount (NULL, NULL, NULL, NULL); // int nCount = getSelectedMsgCount (NULL, NULL, NULL, NULL);
if (nCount == 1) { //
ui.actionSaveAs->setEnabled(true); // if (nCount == 1) {
ui.actionPrintPreview->setEnabled(true); // ui.actionSaveAs->setEnabled(true);
ui.actionPrint->setEnabled(true); // ui.actionPrintPreview->setEnabled(true);
} else { // ui.actionPrint->setEnabled(true);
ui.actionSaveAs->setDisabled(true); // } else {
ui.actionPrintPreview->setDisabled(true); // ui.actionSaveAs->setDisabled(true);
ui.actionPrint->setDisabled(true); // ui.actionPrintPreview->setDisabled(true);
} // ui.actionPrint->setDisabled(true);
// }
if (mCurrMsgId == mid) {
// message doesn't changed
return;
}
/* Save the Data.... for later */ /* Save the Data.... for later */
mCurrMsgId = mid;
MessageInfo msgInfo; MessageInfo msgInfo;
if (!rsMail -> getMessage(mid, msgInfo)) { if (!rsMail -> getMessage(mid, msgInfo)) {
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl; std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
return; return;
} }
QList<QTreeWidgetItem*> items; // QList<QTreeWidgetItem*> items;
items.append(item); // items.append(item);
//
bool bSetToReadOnActive = Settings->getMsgSetToReadOnActivate(); // bool bSetToReadOnActive = Settings->getMsgSetToReadOnActivate();
//
if (msgInfo.msgflags & RS_MSG_NEW) { // if (msgInfo.msgflags & RS_MSG_NEW) {
// set always to read or unread // // set always to read or unread
if (bSetToReadOnActive == false || bSetToRead == false) { // if (bSetToReadOnActive == false || bSetToRead == false) {
// set locally to unread // // set locally to unread
setMsgAsReadUnread(items, false); // setMsgAsReadUnread(items, false);
} else { // } else {
setMsgAsReadUnread(items, true); // setMsgAsReadUnread(items, true);
} // }
updateMessageSummaryList(); // updateMessageSummaryList();
} else { // } else {
if ((msgInfo.msgflags & RS_MSG_UNREAD_BY_USER) && bSetToRead && bSetToReadOnActive) { // if ((msgInfo.msgflags & RS_MSG_UNREAD_BY_USER) && bSetToRead && bSetToReadOnActive) {
// set to read // // set to read
setMsgAsReadUnread(items, true); // setMsgAsReadUnread(items, true);
updateMessageSummaryList(); // updateMessageSummaryList();
} // }
} // }
updateInterface(); updateInterface();
msgWidget->fill(mCurrMsgId); msgWidget->fill(mid);
} }
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)

View file

@ -77,8 +77,8 @@ private slots:
void changeQuickView(int newrow); void changeQuickView(int newrow);
void updateCurrentMessage(); void updateCurrentMessage();
void currentItemChanged(QTreeWidgetItem *item); void currentItemChanged(QTreeWidgetItem *item);
void clicked(QTreeWidgetItem *item, int column); void clicked(const QModelIndex&);
void doubleClicked(QTreeWidgetItem *item, int column); void doubleClicked(const QModelIndex&);
void newmessage(); void newmessage();
void openAsWindow(); void openAsWindow();
@ -125,7 +125,7 @@ private:
void connectActions(); void connectActions();
void updateMessageSummaryList(); void updateMessageSummaryList();
void insertMsgTxtAndFiles(QTreeWidgetItem *item = NULL, bool bSetToRead = true); void insertMsgTxtAndFiles(const QModelIndex& index = QModelIndex());
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);