/***************************************************************************
- * Copyright (C) 2005/06 by the Quassel Project *
+ * Copyright (C) 2005-2014 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "topicwidget.h"
#include "iconloader.h"
#include "networkmodel.h"
#include "uisettings.h"
+#include "graphicalui.h"
+#include "uistyle.h"
TopicWidget::TopicWidget(QWidget *parent)
: AbstractItemView(parent)
}
}
- _topic = newtopic;
+ _topic = sanitizeTopic(newtopic);
_readonly = readonly;
ui.topicEditButton->setVisible(!_readonly);
- ui.topicLabel->setText(newtopic);
- ui.topicLineEdit->setPlainText(newtopic);
+ ui.topicLabel->setText(_topic);
+ ui.topicLineEdit->setPlainText(_topic);
switchPlain();
}
void TopicWidget::clickableActivated(const Clickable &click)
{
NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value<NetworkId>();
- click.activate(networkId, _topic);
+ UiStyle::StyledString sstr = GraphicalUi::uiStyle()->styleString(GraphicalUi::uiStyle()->mircToInternal(_topic), UiStyle::PlainMsg);
+ click.activate(networkId, sstr.plainText);
}
return false;
}
+
+QString TopicWidget::sanitizeTopic(const QString& topic)
+{
+ // Normally, you don't have new lines in topic messages
+ // But the use of "plain text" functionnality from Qt replaces
+ // some unicode characters with a new line, which then triggers
+ // a stack overflow later
+ QString result(topic);
+ result.replace(QChar::ParagraphSeparator, " ");
+ result.replace(QChar::LineSeparator, " ");
+
+ return result;
+}