From b79341503e8d9f069960cc5838b5b9ee975f6302 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 9 Nov 2010 19:57:05 +0000 Subject: [PATCH] Removed new lines of the QLineEdit input fields after input in forum, channel, message and group. Removed size hint of he trees to show erroneous texts. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3768 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChannelFeed.cpp | 2 -- retroshare-gui/src/gui/ForumsDialog.cpp | 3 +-- retroshare-gui/src/gui/PeersDialog.cpp | 5 +++-- .../src/gui/channels/CreateChannel.cpp | 3 ++- .../src/gui/channels/CreateChannelMsg.cpp | 14 +++----------- .../src/gui/channels/EditChanDetails.cpp | 5 +++-- retroshare-gui/src/gui/common/GroupDefs.cpp | 3 ++- retroshare-gui/src/gui/forums/CreateForum.cpp | 4 +++- .../src/gui/forums/CreateForumMsg.cpp | 18 ++++++++++-------- .../src/gui/forums/EditForumDetails.cpp | 4 +++- retroshare-gui/src/gui/groups/CreateGroup.cpp | 10 ++++++---- .../src/gui/msgs/MessageComposer.cpp | 6 +++--- retroshare-gui/src/util/misc.h | 15 +++++++++++++++ 13 files changed, 54 insertions(+), 38 deletions(-) diff --git a/retroshare-gui/src/gui/ChannelFeed.cpp b/retroshare-gui/src/gui/ChannelFeed.cpp index e340e9369..b77c4a405 100644 --- a/retroshare-gui/src/gui/ChannelFeed.cpp +++ b/retroshare-gui/src/gui/ChannelFeed.cpp @@ -511,8 +511,6 @@ void ChannelFeed::fillChannelList(int channelItem, std::list &chann chNameItem = new QChannelItem(); chPopItem = new QStandardItem(); - chNameItem->setSizeHint(QSize(22, 22)); - channel.append(chNameItem); channel.append(chPopItem); groupItem->appendRow(channel); diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index b621c8bae..4a63c9089 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -1019,7 +1019,6 @@ void ForumsDialog::insertThreads() } item->setText(COLUMN_THREAD_TITLE, QString::fromStdWString(tit->title)); - item->setSizeHint(COLUMN_THREAD_TITLE, QSize( 18,18 ) ); if (rsPeers->getPeerName(msginfo.srcId) !="") { @@ -1126,7 +1125,7 @@ void ForumsDialog::insertThreads() } child->setText(COLUMN_THREAD_TITLE, QString::fromStdWString(mit->title)); - child->setSizeHint(COLUMN_THREAD_TITLE, QSize( 17,17 ) ); + if (rsPeers->getPeerName(msginfo.srcId) !="") { diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 05eb57c12..26f63d4a0 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -1050,9 +1050,10 @@ void PeersDialog::insertPeers() // there are some dead id's assigned groupItem->setHidden(true); } else { - groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(GroupDefs::name(*groupInfo)).arg(onlineCount).arg(availableCount)); + QString groupName = GroupDefs::name(*groupInfo); + groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount)); // show first the standard groups, than the user groups - groupItem->setData(COLUMN_NAME, ROLE_SORT, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + QString::fromUtf8(groupInfo->name.c_str())); + groupItem->setData(COLUMN_NAME, ROLE_SORT, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + groupName); } } diff --git a/retroshare-gui/src/gui/channels/CreateChannel.cpp b/retroshare-gui/src/gui/channels/CreateChannel.cpp index e9bda921a..4ddca74c1 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannel.cpp @@ -27,6 +27,7 @@ #include "CreateChannel.h" #include "gui/common/PeerDefs.h" +#include "util/misc.h" #include #include @@ -154,7 +155,7 @@ void CreateChannel::newChannel() void CreateChannel::createChannel() { - QString name = ui.channelName->text(); + QString name = misc::removeNewLine(ui.channelName->text()); QString desc = ui.channelDesc->toPlainText(); uint32_t flags = 0; diff --git a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp index b097137d3..86867a100 100644 --- a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp @@ -28,6 +28,7 @@ #include "CreateChannelMsg.h" #include "gui/feeds/SubFileItem.h" +#include "util/misc.h" #include #include @@ -407,9 +408,6 @@ void CreateChannelMsg::newChannelMsg() } channelName->setText(QString::fromStdWString(ci.channelName)); - - - } @@ -419,7 +417,7 @@ void CreateChannelMsg::sendMsg() std::cerr << std::endl; /* construct message bits */ - std::wstring subject = subjectEdit->text().toStdWString(); + std::wstring subject = misc::removeNewLine(subjectEdit->text()).toStdWString(); std::wstring msg = msgEdit->toPlainText().toStdWString(); std::list files; @@ -456,7 +454,7 @@ void CreateChannelMsg::sendMsg() void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::list &files) { - QString name = subjectEdit->text(); + QString name = misc::removeNewLine(subjectEdit->text()); if(name.isEmpty()) { /* error message */ @@ -467,12 +465,6 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std:: return; //Don't add an empty Subject!! } else - - - - - - /* rsChannels */ if (rsChannels) { diff --git a/retroshare-gui/src/gui/channels/EditChanDetails.cpp b/retroshare-gui/src/gui/channels/EditChanDetails.cpp index e08099957..ae4cfc375 100644 --- a/retroshare-gui/src/gui/channels/EditChanDetails.cpp +++ b/retroshare-gui/src/gui/channels/EditChanDetails.cpp @@ -24,6 +24,8 @@ #include +#include "util/misc.h" + #include #include #include @@ -89,7 +91,6 @@ void EditChanDetails::loadChannel() // Set Channel Name ui.nameline->setText(QString::fromStdWString(ci.channelName)); - // Set Channel Description ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc)); @@ -120,7 +121,7 @@ void EditChanDetails::applyDialog() ChannelInfo ci; - ci.channelName = ui.nameline->text().toStdWString(); + ci.channelName = misc::removeNewLine(ui.nameline->text()).toStdWString(); ci.channelDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); diff --git a/retroshare-gui/src/gui/common/GroupDefs.cpp b/retroshare-gui/src/gui/common/GroupDefs.cpp index 80b70fae5..2b493124e 100644 --- a/retroshare-gui/src/gui/common/GroupDefs.cpp +++ b/retroshare-gui/src/gui/common/GroupDefs.cpp @@ -26,12 +26,13 @@ #include #include "GroupDefs.h" +#include "util/misc.h" const QString GroupDefs::name(const RsGroupInfo &groupInfo) { if ((groupInfo.flag & RS_GROUP_FLAG_STANDARD) == 0) { /* no need to be translated */ - return QString::fromUtf8(groupInfo.name.c_str()); + return misc::removeNewLine(groupInfo.name); } if (groupInfo.id == RS_GROUP_ID_FRIENDS) { diff --git a/retroshare-gui/src/gui/forums/CreateForum.cpp b/retroshare-gui/src/gui/forums/CreateForum.cpp index 5386c5740..305637859 100644 --- a/retroshare-gui/src/gui/forums/CreateForum.cpp +++ b/retroshare-gui/src/gui/forums/CreateForum.cpp @@ -21,6 +21,8 @@ #include +#include "util/misc.h" + #include "CreateForum.h" #include @@ -67,7 +69,7 @@ void CreateForum::newForum() void CreateForum::createForum() { - QString name = ui.forumName->text(); + QString name = misc::removeNewLine(ui.forumName->text()); QString desc = ui.forumDesc->toPlainText(); //toHtml(); uint32_t flags = 0; diff --git a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp index 728dec3eb..7aa0c07b4 100644 --- a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp +++ b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp @@ -28,7 +28,6 @@ #include #include - #include #include @@ -37,6 +36,8 @@ #include "gui/feeds/AttachFileItem.h" #include "gui/common/Emoticons.h" +#include "util/misc.h" + #include @@ -97,24 +98,25 @@ void CreateForumMsg::newMsg() QString subj; if ((mParentId != "") && (rsForums->getForumMessage(mForumId, mParentId, msg))) { + QString title = QString::fromStdWString(msg.title); name += " " + tr("In Reply to") + ": "; - name += QString::fromStdWString(msg.title); + name += title; - QString text = QString::fromStdWString(msg.title); + QString text = title; if (text.startsWith("Re:", Qt::CaseInsensitive)) { - subj = QString::fromStdWString(msg.title); + subj = title; } else { - subj = "Re: " + QString::fromStdWString(msg.title); + subj = "Re: " + title; } } - ui.forumName->setText(name); - ui.forumSubject->setText(subj); + ui.forumName->setText(misc::removeNewLine(name)); + ui.forumSubject->setText(misc::removeNewLine(subj)); if (!ui.forumSubject->text().isEmpty()) { @@ -141,7 +143,7 @@ void CreateForumMsg::newMsg() void CreateForumMsg::createMsg() { - QString name = ui.forumSubject->text(); + QString name = misc::removeNewLine(ui.forumSubject->text()); QString desc = ui.forumMessage->toHtml(); if(name.isEmpty()) diff --git a/retroshare-gui/src/gui/forums/EditForumDetails.cpp b/retroshare-gui/src/gui/forums/EditForumDetails.cpp index 1323f19ed..87221b6f0 100644 --- a/retroshare-gui/src/gui/forums/EditForumDetails.cpp +++ b/retroshare-gui/src/gui/forums/EditForumDetails.cpp @@ -23,6 +23,8 @@ #include +#include "util/misc.h" + #include #include #include @@ -69,7 +71,7 @@ void EditForumDetails::applyDialog() ForumInfo info; - info.forumName = ui.nameline->text().toStdWString(); + info.forumName = misc::removeNewLine(ui.nameline->text()).toStdWString(); info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); rsForums->setForumInfo(m_forumId, info); diff --git a/retroshare-gui/src/gui/groups/CreateGroup.cpp b/retroshare-gui/src/gui/groups/CreateGroup.cpp index 605c11a5e..64c2ea2c6 100644 --- a/retroshare-gui/src/gui/groups/CreateGroup.cpp +++ b/retroshare-gui/src/gui/groups/CreateGroup.cpp @@ -23,6 +23,8 @@ #include +#include "util/misc.h" + #include "CreateGroup.h" #include "gui/common/GroupDefs.h" @@ -39,7 +41,7 @@ CreateGroup::CreateGroup(const std::string groupId, QWidget *parent, Qt::WFlags /* edit exisiting group */ RsGroupInfo groupInfo; if (rsPeers->getGroupInfo(m_groupId, groupInfo)) { - ui.groupname->setText(QString::fromUtf8(groupInfo.name.c_str())); + ui.groupname->setText(misc::removeNewLine(groupInfo.name)); setWindowTitle(tr("Edit Group")); ui.headerLabel->setText(tr("" @@ -73,7 +75,7 @@ CreateGroup::~CreateGroup() void CreateGroup::on_groupname_textChanged(QString text) { - if (text.isEmpty() || usedGroupNames.contains(text)) { + if (text.isEmpty() || usedGroupNames.contains(misc::removeNewLine(text))) { ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } else { ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); @@ -86,13 +88,13 @@ void CreateGroup::on_buttonBox_accepted() if (m_groupId.empty()) { // add new group - groupInfo.name = ui.groupname->text().toUtf8().constData(); + groupInfo.name = misc::removeNewLine(ui.groupname->text()).toUtf8().constData(); if (rsPeers->addGroup(groupInfo)) { close(); } } else { if (rsPeers->getGroupInfo(m_groupId, groupInfo) == true) { - groupInfo.name = ui.groupname->text().toUtf8().constData(); + groupInfo.name = misc::removeNewLine(ui.groupname->text()).toUtf8().constData(); if (rsPeers->editGroup(m_groupId, groupInfo)) { close(); } diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 108c10b83..7b53d45bd 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -727,7 +727,7 @@ void MessageComposer::titleChanged() void MessageComposer::calculateTitle() { - setWindowTitle(tr("Compose") + ": " + ui.titleEdit->text()); + setWindowTitle(tr("Compose") + ": " + misc::removeNewLine(ui.titleEdit->text())); } static void calculateGroupsOfSslIds(std::list &existingGroupInfos, std::list &checkSslIds, std::list &checkGroupIds) @@ -998,7 +998,7 @@ void MessageComposer::insertTitleText(const QString &title, enumMessageType typ break; } - ui.titleEdit->setText(titleText); + ui.titleEdit->setText(misc::removeNewLine(titleText)); } void MessageComposer::insertPastedText(QString msg) @@ -1063,7 +1063,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) /* construct a message */ MessageInfo mi; - mi.title = ui.titleEdit->text().toStdWString(); + mi.title = misc::removeNewLine(ui.titleEdit->text()).toStdWString(); mi.msg = ui.msgText->toHtml().toStdWString(); /* check for existing title */ diff --git a/retroshare-gui/src/util/misc.h b/retroshare-gui/src/util/misc.h index d9054827f..850990e3d 100644 --- a/retroshare-gui/src/util/misc.h +++ b/retroshare-gui/src/util/misc.h @@ -364,6 +364,21 @@ class misc : public QObject{ return QString("%1 %2").arg(count, 0, 'f', decimal).arg(unit); } + + static QString removeNewLine(const QString &text) + { + return QString(text).replace("\n", " "); + } + + static QString removeNewLine(const std::string &text) + { + return QString::fromUtf8(text.c_str()).replace("\n", " "); + } + + static QString removeNewLine(const std::wstring &text) + { + return QString::fromStdWString(text).replace("\n", " "); + } }; // Trick to get a portable sleep() function