Merge pull request #1956 from PhenomRetroShare/Add_MessagePlaceHolder

Add PlaceHolder in Message Tree.
This commit is contained in:
defnax 2020-05-21 16:17:31 +02:00 committed by GitHub
commit ad1672a0a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.expandFilesButton->setChecked(false);
ui.downloadButton->setEnabled(false);
togglefileview(true);
ui.replyButton->setEnabled(false);
@ -566,6 +567,7 @@ void MessageWidget::fill(const std::string &msgId)
/* add the items in! */
ui.msgList->insertTopLevelItems(0, items);
ui.expandFilesButton->setChecked(expandFiles && (items.count()>0) );
ui.downloadButton->setEnabled(items.count()>0);
togglefileview(true);
/* iterate through the sources */

View File

@ -495,6 +495,13 @@ int MessagesDialog::getSelectedMessages(QList<QString>& mid)
foreach(const QModelIndex& m, qmil)
mid.push_back(m.sibling(m.row(),RsMessageModel::COLUMN_THREAD_MSGID).data(RsMessageModel::MsgIdRole).toString()) ;
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();
}
@ -793,58 +800,71 @@ void MessagesDialog::changeBox(int box_row)
inChange = true;
QListWidgetItem* item = ui.listWidget->item(box_row);
if (item)
{
ui.quickViewWidget->setCurrentItem(NULL);
changeQuickView(-1);
listMode = LIST_BOX;
QString placeholderText = tr("No message available in your %1.").arg(item->text());
switch(box_row)
{
case 0: mMessageModel->setCurrentBox(RsMessageModel::BOX_INBOX );
ui.tabWidget->setTabText(0, tr("Inbox"));
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_INBOX));
case ROW_INBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_INBOX );
break;
case 1: mMessageModel->setCurrentBox(RsMessageModel::BOX_OUTBOX);
ui.tabWidget->setTabText(0, tr("Outbox"));
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_OUTBOX));
case ROW_OUTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_OUTBOX);
break;
case 2: mMessageModel->setCurrentBox(RsMessageModel::BOX_DRAFTS);
ui.tabWidget->setTabText(0, tr("Drafts"));
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_DRAFTS));
case ROW_DRAFTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_DRAFTS);
break;
case 3: mMessageModel->setCurrentBox(RsMessageModel::BOX_SENT );
ui.tabWidget->setTabText(0, tr("Sent"));
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_SENT));
case ROW_SENTBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_SENT );
break;
case 4: mMessageModel->setCurrentBox(RsMessageModel::BOX_TRASH );
ui.tabWidget->setTabText(0, tr("Trash"));
ui.tabWidget->setTabIcon(0, QIcon(IMAGE_TRASH));
case ROW_TRASHBOX: mMessageModel->setCurrentBox(RsMessageModel::BOX_TRASH );
break;
default:
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE); break;
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE);
}
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
ui.messageTreeWidget->setPlaceholderText(placeholderText);
}
else
{
mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE);
}
inChange = false;
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
}
void MessagesDialog::changeQuickView(int newrow)
{
ui.listWidget->setCurrentItem(NULL);
changeBox(-1);
listMode = LIST_QUICKVIEW;
RsMessageModel::QuickViewFilter f = RsMessageModel::QUICK_VIEW_ALL ;
QListWidgetItem* item = ui.quickViewWidget->item(newrow);
if(item )
{
ui.listWidget->setCurrentItem(NULL);
changeBox(-1);
listMode = LIST_QUICKVIEW;
QString placeholderText;
switch (item->data(ROLE_QUICKVIEW_TYPE).toInt()) {
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());
}
break;
case QUICKVIEW_TYPE_STATIC:
{
placeholderText = tr("No %1 message available.").arg(item->data(ROLE_QUICKVIEW_TEXT).toString());
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;
case QUICKVIEW_STATIC_ID_SYSTEM: f = RsMessageModel::QUICK_VIEW_SYSTEM;
break;
@ -853,15 +873,14 @@ void MessagesDialog::changeQuickView(int newrow)
case QUICKVIEW_STATIC_ID_ATTACHMENT: f = RsMessageModel::QUICK_VIEW_ATTACHMENT;
}
}
}
ui.tabWidget->setTabText(0, item->data(ROLE_QUICKVIEW_TEXT).toString());
ui.tabWidget->setTabIcon(0, item->icon());
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
ui.messageTreeWidget->setPlaceholderText(placeholderText);
}
mMessageModel->setQuickViewFilter(f);
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
}
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
mMessageModel->setMsgReadStatus(real_index, true);
updateInterface();
updateMessageSummaryList();
msgWidget->fill(mid);
updateMessageSummaryList();
}
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
@ -1367,6 +1385,7 @@ void MessagesDialog::updateMessageSummaryList()
break;
}
}
updateInterface();
}
void MessagesDialog::tagAboutToShow()
@ -1515,4 +1534,20 @@ void MessagesDialog::updateInterface()
ui.actionPrintPreview->setEnabled(count == 1);
ui.actionSaveAs->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">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTreeView" name="messageTreeWidget">
<widget class="RSTreeView" name="messageTreeWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
@ -462,6 +462,12 @@
<header>gui/common/RSTabWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RSTreeView</class>
<extends>QTreeView</extends>
<header>gui/common/RSTreeView.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>listWidget</tabstop>