Change header of MessageComposer when title edit has modified - like ThunderBird

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3267 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-07-07 23:03:34 +00:00
parent 7eba601144
commit f452304b5c
2 changed files with 22 additions and 8 deletions

View File

@ -69,6 +69,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
connect(ui.actionAttach, SIGNAL(triggered()), this, SLOT(attachFile())); connect(ui.actionAttach, SIGNAL(triggered()), this, SLOT(attachFile()));
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect(ui.titleEdit, SIGNAL(textChanged(const QString &)), this, SLOT(titleChanged()));
connect(ui.sizeincreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeIncrease())); connect(ui.sizeincreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeIncrease()));
connect(ui.sizedecreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeDecrease())); connect(ui.sizedecreaseButton, SIGNAL (clicked()), this, SLOT (fontSizeDecrease()));
@ -409,14 +410,21 @@ void MessageComposer::insertFileList(const std::list<FileInfo>& files_info)
tree->update(); /* update display */ tree->update(); /* update display */
} }
/* title changed */
void MessageComposer::titleChanged()
{
calculateTitle();
ui.msgText->document()->setModified(true);
}
void MessageComposer::calculateTitle()
{
setWindowTitle(tr("Compose: ") + ui.titleEdit->text());
}
void MessageComposer::newMsg(std::string msgId /*= ""*/) void MessageComposer::newMsg(std::string msgId /*= ""*/)
{ {
/* clear all */ /* clear all */
QString titlestring = ui.titleEdit->text();
setWindowTitle(tr("Compose: ") + titlestring );
ui.titleEdit->setText("No Title");
ui.msgText->setText(""); ui.msgText->setText("");
/* worker fns */ /* worker fns */
@ -437,7 +445,6 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
m_nBox = msgInfo.msgflags & RS_MSG_BOXMASK; m_nBox = msgInfo.msgflags & RS_MSG_BOXMASK;
insertTitleText( QString::fromStdWString(msgInfo.title).toStdString()); insertTitleText( QString::fromStdWString(msgInfo.title).toStdString());
setWindowTitle( tr ("Compose: ") + QString::fromStdWString(msgInfo.title));
insertMsgText(QString::fromStdWString(msgInfo.msg).toStdString()); insertMsgText(QString::fromStdWString(msgInfo.msg).toStdString());
@ -449,7 +456,11 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
} }
ui.msgText->document()->setModified(false); ui.msgText->document()->setModified(false);
} else {
insertTitleText(tr("No Title").toStdString());
} }
calculateTitle();
} }
void MessageComposer::insertTitleText(std::string title) void MessageComposer::insertTitleText(std::string title)

View File

@ -123,6 +123,7 @@ private slots:
void filterRegExpChanged(); void filterRegExpChanged();
void clearFilter(); void clearFilter();
void titleChanged();
private: private:
void setTextColor(const QColor& col) ; void setTextColor(const QColor& col) ;
@ -147,6 +148,8 @@ private:
void FilterItems(); void FilterItems();
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern); bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
void calculateTitle();
/** Define the popup menus for the Context menu */ /** Define the popup menus for the Context menu */
QMenu* contextMnu; QMenu* contextMnu;