mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
Fix Message Delete Button.
Now, frame is cleared and next message selected.
This commit is contained in:
parent
b6c5e2f188
commit
2dc2b3598d
@ -132,6 +132,7 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
|
||||
isControlled = controlled;
|
||||
isWindow = false;
|
||||
currMsgFlags = 0;
|
||||
expandFiles = false;
|
||||
|
||||
ui.actionTextBesideIcon->setData(Qt::ToolButtonTextBesideIcon);
|
||||
ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
|
||||
@ -281,10 +282,7 @@ void MessageWidget::processSettings(const QString &settingsGroup, bool load)
|
||||
// load settings
|
||||
|
||||
// expandFiles
|
||||
bool value = Settings->value("expandFiles", false).toBool();
|
||||
ui.expandFilesButton->setChecked(value);
|
||||
ui.msgList->setVisible(value);
|
||||
togglefileview();
|
||||
expandFiles = Settings->value("expandFiles", false).toBool();
|
||||
|
||||
// toolbar button style
|
||||
Qt::ToolButtonStyle style = (Qt::ToolButtonStyle) Settings->value("ToolButon_Style", Qt::ToolButtonTextBesideIcon).toInt();
|
||||
@ -293,7 +291,7 @@ void MessageWidget::processSettings(const QString &settingsGroup, bool load)
|
||||
// save settings
|
||||
|
||||
// expandFiles
|
||||
Settings->setValue("expandFiles", ui.expandFilesButton->isChecked());
|
||||
Settings->setValue("expandFiles", expandFiles);
|
||||
|
||||
//toolbar button style
|
||||
Settings->setValue("ToolButon_Style", ui.replyButton->toolButtonStyle());
|
||||
@ -322,7 +320,7 @@ void MessageWidget::msgfilelistWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void MessageWidget::togglefileview()
|
||||
void MessageWidget::togglefileview(bool noUpdate/*=false*/)
|
||||
{
|
||||
/* if msg header visible -> change icon and tooltip
|
||||
* three widgets...
|
||||
@ -335,6 +333,10 @@ void MessageWidget::togglefileview()
|
||||
ui.expandFilesButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png")));
|
||||
ui.expandFilesButton->setToolTip(tr("Show the attachment pane"));
|
||||
}
|
||||
if (!noUpdate)
|
||||
expandFiles = ui.expandFilesButton->isChecked();
|
||||
|
||||
ui.msgList->setVisible(ui.expandFilesButton->isChecked());
|
||||
}
|
||||
|
||||
/* download the recommendations... */
|
||||
@ -426,13 +428,10 @@ void MessageWidget::messagesChanged()
|
||||
void MessageWidget::clearTagLabels()
|
||||
{
|
||||
/* clear all tags */
|
||||
while (tagLabels.size()) {
|
||||
delete tagLabels.front();
|
||||
tagLabels.pop_front();
|
||||
}
|
||||
while (ui.tagLayout->count()) {
|
||||
delete ui.tagLayout->takeAt(0);
|
||||
}
|
||||
qDeleteAll(tagLabels);
|
||||
tagLabels.clear();
|
||||
|
||||
misc::clearLayout(ui.tagLayout);
|
||||
|
||||
ui.tagsLabel->setVisible(false);
|
||||
}
|
||||
@ -510,6 +509,16 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
|
||||
clearTagLabels();
|
||||
|
||||
ui.inviteFrame->hide();
|
||||
ui.expandFilesButton->setChecked(false);
|
||||
togglefileview(true);
|
||||
|
||||
ui.replyButton->setEnabled(false);
|
||||
ui.replyallButton->setEnabled(false);
|
||||
ui.forwardButton->setEnabled(false);
|
||||
ui.deleteButton->setEnabled(false);
|
||||
ui.moreButton->setEnabled(false);
|
||||
|
||||
currMsgFlags = 0;
|
||||
|
||||
return;
|
||||
@ -517,6 +526,13 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
|
||||
clearTagLabels();
|
||||
|
||||
|
||||
ui.replyButton->setEnabled(true);
|
||||
ui.replyallButton->setEnabled(true);
|
||||
ui.forwardButton->setEnabled(true);
|
||||
ui.deleteButton->setEnabled(true);
|
||||
ui.moreButton->setEnabled(true);
|
||||
|
||||
MessageInfo msgInfo;
|
||||
if (rsMail->getMessage(currMsgId, msgInfo) == false) {
|
||||
std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl;
|
||||
@ -549,6 +565,8 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
|
||||
/* add the items in! */
|
||||
ui.msgList->insertTopLevelItems(0, items);
|
||||
ui.expandFilesButton->setChecked(expandFiles && (items.count()>0) );
|
||||
togglefileview(true);
|
||||
|
||||
/* iterate through the sources */
|
||||
RetroShareLink link;
|
||||
@ -688,8 +706,15 @@ void MessageWidget::remove()
|
||||
if (isWindow) {
|
||||
window()->close();
|
||||
} else {
|
||||
deleteLater();
|
||||
if (isControlled) {
|
||||
currMsgId.clear();
|
||||
fill(currMsgId);
|
||||
} else {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
emit messageRemoved();
|
||||
}
|
||||
|
||||
void MessageWidget::print()
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
|
||||
QString subject(bool noEmpty);
|
||||
|
||||
signals:
|
||||
void messageRemoved();
|
||||
|
||||
private slots:
|
||||
void reply();
|
||||
@ -75,7 +77,7 @@ private slots:
|
||||
void messagesTagsChanged();
|
||||
void messagesChanged();
|
||||
|
||||
void togglefileview();
|
||||
void togglefileview(bool noUpdate = false);
|
||||
void getcurrentrecommended();
|
||||
void getallrecommended();
|
||||
|
||||
@ -94,6 +96,7 @@ private:
|
||||
bool isWindow;
|
||||
std::string currMsgId;
|
||||
unsigned int currMsgFlags;
|
||||
bool expandFiles;
|
||||
|
||||
QList<QLabel*> tagLabels;
|
||||
|
||||
|
@ -124,9 +124,11 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
inProcessSettings = false;
|
||||
inChange = false;
|
||||
lockUpdate = 0;
|
||||
lastSelectedIndex = QModelIndex();
|
||||
|
||||
msgWidget = new MessageWidget(true, this);
|
||||
ui.msgLayout->addWidget(msgWidget);
|
||||
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
|
||||
|
||||
connectActions();
|
||||
|
||||
@ -695,6 +697,7 @@ void MessagesDialog::openAsWindow()
|
||||
}
|
||||
|
||||
msgWidget->activateWindow();
|
||||
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
@ -714,6 +717,7 @@ void MessagesDialog::openAsTab()
|
||||
|
||||
ui.tabWidget->addTab(msgWidget, msgWidget->subject(true));
|
||||
ui.tabWidget->setCurrentWidget(msgWidget);
|
||||
connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved()));
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
@ -860,7 +864,8 @@ void MessagesDialog::clicked(const QModelIndex& proxy_index)
|
||||
case RsMessageModel::COLUMN_THREAD_READ:
|
||||
{
|
||||
mMessageModel->setMsgReadStatus(real_index, !isMessageRead(proxy_index));
|
||||
insertMsgTxtAndFiles(proxy_index);
|
||||
//Already updated by currentChanged
|
||||
//insertMsgTxtAndFiles(proxy_index);
|
||||
updateMessageSummaryList();
|
||||
return;
|
||||
}
|
||||
@ -871,8 +876,9 @@ void MessagesDialog::clicked(const QModelIndex& proxy_index)
|
||||
}
|
||||
}
|
||||
|
||||
// show current message directly
|
||||
insertMsgTxtAndFiles(proxy_index);
|
||||
// show current message directly
|
||||
//Already updated by currentChanged
|
||||
//insertMsgTxtAndFiles(proxy_index);
|
||||
}
|
||||
|
||||
// double click in messageTreeWidget
|
||||
@ -953,14 +959,20 @@ void MessagesDialog::insertMsgTxtAndFiles(const QModelIndex& proxy_index)
|
||||
|
||||
QModelIndex real_index = mMessageProxyModel->mapToSource(proxy_index);
|
||||
|
||||
if(!real_index.isValid())
|
||||
if(!real_index.isValid())
|
||||
{
|
||||
mCurrMsgId.clear();
|
||||
msgWidget->fill(mCurrMsgId);
|
||||
updateInterface();
|
||||
lastSelectedIndex = QModelIndex();
|
||||
return;
|
||||
}
|
||||
mid = real_index.data(RsMessageModel::MsgIdRole).toString().toStdString();
|
||||
|
||||
lastSelectedIndex = proxy_index;
|
||||
if (!ui.messageTreeWidget->indexBelow(proxy_index).isValid())
|
||||
lastSelectedIndex = ui.messageTreeWidget->indexAbove(proxy_index);
|
||||
|
||||
mid = real_index.data(RsMessageModel::MsgIdRole).toString().toStdString();
|
||||
|
||||
/* Save the Data.... for later */
|
||||
|
||||
@ -1025,6 +1037,12 @@ void MessagesDialog::removemessage()
|
||||
|
||||
mMessageModel->updateMessages();
|
||||
updateMessageSummaryList();
|
||||
messageRemoved();
|
||||
}
|
||||
|
||||
void MessagesDialog::messageRemoved()
|
||||
{
|
||||
ui.messageTreeWidget->setCurrentIndex(lastSelectedIndex);
|
||||
}
|
||||
|
||||
void MessagesDialog::undeletemessage()
|
||||
|
@ -57,10 +57,6 @@ public:
|
||||
|
||||
void setTextColorInbox(QColor color) { mTextColorInbox = color; }
|
||||
|
||||
signals:
|
||||
void messagesAboutToLoad();
|
||||
void messagesLoaded();
|
||||
|
||||
protected:
|
||||
virtual UserNotify *createUserNotify(QObject *parent) override;
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
@ -69,6 +65,7 @@ protected:
|
||||
public slots:
|
||||
//void insertMessages();
|
||||
void messagesTagsChanged();
|
||||
void messageRemoved();
|
||||
void preModelUpdate();
|
||||
void postModelUpdate();
|
||||
|
||||
@ -156,6 +153,7 @@ private:
|
||||
Ui::MessagesDialog ui;
|
||||
|
||||
QList<QString> mTmpSavedSelectedIds;
|
||||
QModelIndex lastSelectedIndex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -405,3 +405,23 @@ QString misc::getExistingDirectory(QWidget *parent, const QString &caption, cons
|
||||
return QFileDialog::getExistingDirectory(parent, caption, dir, QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* Clear a Layout content
|
||||
* \param layout: Layout to Clear
|
||||
*/
|
||||
void misc::clearLayout(QLayout * layout) {
|
||||
if (! layout)
|
||||
return;
|
||||
|
||||
while (auto item = layout->takeAt(0))
|
||||
{
|
||||
if (auto *widget = item->widget())
|
||||
widget->deleteLater();
|
||||
if (auto *spacer = item->spacerItem())
|
||||
delete spacer;
|
||||
|
||||
clearLayout(item->layout());
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QPair>
|
||||
#include <QThread>
|
||||
#include <QFileDialog>
|
||||
#include <QLayout>
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
@ -182,6 +183,10 @@ class misc : public QObject
|
||||
static QString getExistingDirectory(QWidget *parent = nullptr
|
||||
, const QString &caption = QString()
|
||||
, const QString &dir = QString());
|
||||
|
||||
//Clear QLayout
|
||||
static void clearLayout(QLayout *layout);
|
||||
|
||||
};
|
||||
|
||||
// Trick to get a portable sleep() function
|
||||
|
Loading…
Reference in New Issue
Block a user