Add PlaceHolder in Message Tree.

And fix some mistakes.
This commit is contained in:
Phenom 2020-05-21 15:30:02 +02:00
parent 0a4b191384
commit 60615e4532
3 changed files with 99 additions and 56 deletions

View File

@ -511,6 +511,7 @@ void MessageWidget::fill(const std::string &msgId)
ui.inviteFrame->hide(); ui.inviteFrame->hide();
ui.expandFilesButton->setChecked(false); ui.expandFilesButton->setChecked(false);
ui.downloadButton->setEnabled(false);
togglefileview(true); togglefileview(true);
ui.replyButton->setEnabled(false); ui.replyButton->setEnabled(false);
@ -566,6 +567,7 @@ void MessageWidget::fill(const std::string &msgId)
/* add the items in! */ /* add the items in! */
ui.msgList->insertTopLevelItems(0, items); ui.msgList->insertTopLevelItems(0, items);
ui.expandFilesButton->setChecked(expandFiles && (items.count()>0) ); ui.expandFilesButton->setChecked(expandFiles && (items.count()>0) );
ui.downloadButton->setEnabled(items.count()>0);
togglefileview(true); togglefileview(true);
/* iterate through the sources */ /* iterate through the sources */

View File

@ -487,15 +487,22 @@ void MessagesDialog::fillQuickView()
int MessagesDialog::getSelectedMessages(QList<QString>& mid) int MessagesDialog::getSelectedMessages(QList<QString>& mid)
{ {
//To check if the selection has more than one row. //To check if the selection has more than one row.
mid.clear(); mid.clear();
QModelIndexList qmil = ui.messageTreeWidget->selectionModel()->selectedRows(); QModelIndexList qmil = ui.messageTreeWidget->selectionModel()->selectedRows();
foreach(const QModelIndex& m, qmil) foreach(const QModelIndex& m, qmil)
mid.push_back(m.sibling(m.row(),RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString()) ; mid.push_back(m.sibling(m.row(),RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString()) ;
return mid.size(); if (mid.isEmpty())
{
const QModelIndex& m = ui.messageTreeWidget->currentIndex();
if (m.isValid())
mid.push_back(m.sibling(m.row(),RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString()) ;
}
return mid.size();
} }
int MessagesDialog::getSelectedMsgCount (QList<QModelIndex> *items, QList<QModelIndex> *itemsRead, QList<QModelIndex> *itemsUnread, QList<QModelIndex> *itemsStar, QList<QModelIndex> *itemsJunk) int MessagesDialog::getSelectedMsgCount (QList<QModelIndex> *items, QList<QModelIndex> *itemsRead, QList<QModelIndex> *itemsUnread, QList<QModelIndex> *itemsStar, QList<QModelIndex> *itemsJunk)
@ -786,65 +793,78 @@ void MessagesDialog::editmessage()
void MessagesDialog::changeBox(int box_row) void MessagesDialog::changeBox(int box_row)
{ {
if (inChange) { if (inChange) {
// already in change method // already in change method
return; return;
} }
inChange = true; inChange = true;
ui.quickViewWidget->setCurrentItem(NULL); QListWidgetItem* item = ui.listWidget->item(box_row);
changeQuickView(-1);
listMode = LIST_BOX;
switch(box_row) if (item)
{ {
case 0: mMessageModel->setCurrentBox(RsMessageModel::BOX_INBOX ); ui.quickViewWidget->setCurrentItem(NULL);
ui.tabWidget->setTabText(0, tr("Inbox")); changeQuickView(-1);
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_INBOX));
break; listMode = LIST_BOX;
case 1: mMessageModel->setCurrentBox(RsMessageModel::BOX_OUTBOX);
ui.tabWidget->setTabText(0, tr("Outbox")); QString placeholderText = tr("No message available in your %1.").arg(item->text());
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_OUTBOX)); switch(box_row)
break; {
case 2: mMessageModel->setCurrentBox(RsMessageModel::BOX_DRAFTS); case ROW_INBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_INBOX );
ui.tabWidget->setTabText(0, tr("Drafts")); break;
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_DRAFTS)); case ROW_OUTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_OUTBOX);
break; break;
case 3: mMessageModel->setCurrentBox(RsMessageModel::BOX_SENT ); case ROW_DRAFTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_DRAFTS);
ui.tabWidget->setTabText(0, tr("Sent")); break;
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_SENT)); case ROW_SENTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_SENT );
break; break;
case 4: mMessageModel->setCurrentBox(RsMessageModel::BOX_TRASH ); case ROW_TRASHBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_TRASH );
ui.tabWidget->setTabText(0, tr("Trash")); break;
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_TRASH)); default:
break; mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE);
default: }
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE); break;
} insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
inChange = false; ui.messageTreeWidget->setPlaceholderText(placeholderText);
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex()); }
else
{
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE);
}
inChange = false;
} }
void MessagesDialog::changeQuickView(int newrow) void MessagesDialog::changeQuickView(int newrow)
{ {
ui.listWidget->setCurrentItem(NULL);
changeBox(-1);
listMode = LIST_QUICKVIEW;
RsMessageModel::QuickViewFilter f = RsMessageModel::QUICK_VIEW_ALL ; RsMessageModel::QuickViewFilter f = RsMessageModel::QUICK_VIEW_ALL ;
QListWidgetItem* item = ui.quickViewWidget->item(newrow); QListWidgetItem* item = ui.quickViewWidget->item(newrow);
if(item ) if(item )
{ {
ui.listWidget->setCurrentItem(NULL);
changeBox(-1);
listMode = LIST_QUICKVIEW;
QString placeholderText;
switch (item->data(ROLE_QUICKVIEW_TYPE).toInt()) { switch (item->data(ROLE_QUICKVIEW_TYPE).toInt()) {
case QUICKVIEW_TYPE_TAG: case QUICKVIEW_TYPE_TAG:
{
placeholderText = tr("No message using %1 tag available.").arg(item->data(ROLE_QUICKVIEW_TEXT).toString());
f = RsMessageModel::QuickViewFilter( item->data(ROLE_QUICKVIEW_ID).toUInt()); f = RsMessageModel::QuickViewFilter( item->data(ROLE_QUICKVIEW_ID).toUInt());
}
break; break;
case QUICKVIEW_TYPE_STATIC: case QUICKVIEW_TYPE_STATIC:
{
placeholderText = tr("No %1 message available.").arg(item->data(ROLE_QUICKVIEW_TEXT).toString());
switch (item->data(ROLE_QUICKVIEW_ID).toInt()) { switch (item->data(ROLE_QUICKVIEW_ID).toInt()) {
case QUICKVIEW_STATIC_ID_STARRED: f = RsMessageModel::QUICK_VIEW_STARRED; case QUICKVIEW_STATIC_ID_STARRED:{
f = RsMessageModel::QUICK_VIEW_STARRED;
placeholderText = tr("No starred message available. Stars let you give messages a special status to make them easier to find. To star a message, click on the light gray star beside any message.");
}
break; break;
case QUICKVIEW_STATIC_ID_SYSTEM: f = RsMessageModel::QUICK_VIEW_SYSTEM; case QUICKVIEW_STATIC_ID_SYSTEM: f = RsMessageModel::QUICK_VIEW_SYSTEM;
break; break;
@ -852,16 +872,15 @@ void MessagesDialog::changeQuickView(int newrow)
break; break;
case QUICKVIEW_STATIC_ID_ATTACHMENT: f = RsMessageModel::QUICK_VIEW_ATTACHMENT; case QUICKVIEW_STATIC_ID_ATTACHMENT: f = RsMessageModel::QUICK_VIEW_ATTACHMENT;
} }
}
} }
ui.tabWidget->setTabText(0, item->data(ROLE_QUICKVIEW_TEXT).toString()); insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
ui.tabWidget->setTabIcon(0, item->icon()); ui.messageTreeWidget->setPlaceholderText(placeholderText);
} }
mMessageModel->setQuickViewFilter(f); mMessageModel->setQuickViewFilter(f);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
} }
void MessagesDialog::messagesTagsChanged() void MessagesDialog::messagesTagsChanged()
@ -1037,9 +1056,8 @@ void MessagesDialog::insertMsgTxtAndFiles(const QModelIndex& proxy_index)
else if ((msgInfo.msgflags & RS_MSG_UNREAD_BY_USER) && bSetToReadOnActive) // set to read else if ((msgInfo.msgflags & RS_MSG_UNREAD_BY_USER) && bSetToReadOnActive) // set to read
mMessageModel->setMsgReadStatus(real_index, true); mMessageModel->setMsgReadStatus(real_index, true);
updateInterface(); msgWidget->fill(mid);
updateMessageSummaryList(); updateMessageSummaryList();
msgWidget->fill(mid);
} }
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
@ -1367,6 +1385,7 @@ void MessagesDialog::updateMessageSummaryList()
break; break;
} }
} }
updateInterface();
} }
void MessagesDialog::tagAboutToShow() void MessagesDialog::tagAboutToShow()
@ -1500,12 +1519,12 @@ void MessagesDialog::updateInterface()
int tab = ui.tabWidget->currentIndex(); int tab = ui.tabWidget->currentIndex();
if (tab == 0) if (tab == 0)
{ {
QList<QString> msgs; QList<QString> msgs;
count = getSelectedMessages(msgs); count = getSelectedMessages(msgs);
} }
else else
{ {
MessageWidget *msg = dynamic_cast<MessageWidget*>(ui.tabWidget->widget(tab)); MessageWidget *msg = dynamic_cast<MessageWidget*>(ui.tabWidget->widget(tab));
if (msg && msg->msgId().empty() == false) if (msg && msg->msgId().empty() == false)
count = 1; count = 1;
@ -1515,4 +1534,20 @@ void MessagesDialog::updateInterface()
ui.actionPrintPreview->setEnabled(count == 1); ui.actionPrintPreview->setEnabled(count == 1);
ui.actionSaveAs->setEnabled(count == 1); ui.actionSaveAs->setEnabled(count == 1);
ui.tagButton->setEnabled(count >= 1); ui.tagButton->setEnabled(count >= 1);
if (ui.listWidget->currentItem())
{
ui.tabWidget->setTabText(0, ui.listWidget->currentItem()->text());
ui.tabWidget->setTabIcon(0, ui.listWidget->currentItem()->icon());
}
else if (ui.quickViewWidget->currentItem())
{
ui.tabWidget->setTabText(0, ui.quickViewWidget->currentItem()->text());
ui.tabWidget->setTabIcon(0, ui.quickViewWidget->currentItem()->icon());
}
else
{
ui.tabWidget->setTabText(0, tr("No Box selected."));
ui.tabWidget->setTabIcon(0, QIcon(":/icons/warning_yellow_128.png"));
}
} }

View File

@ -367,7 +367,7 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QTreeView" name="messageTreeWidget"> <widget class="RSTreeView" name="messageTreeWidget">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
@ -462,6 +462,12 @@
<header>gui/common/RSTabWidget.h</header> <header>gui/common/RSTabWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>RSTreeView</class>
<extends>QTreeView</extends>
<header>gui/common/RSTreeView.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>listWidget</tabstop> <tabstop>listWidget</tabstop>