ChatWindow: mark virtual methods const when possible and semantically correct

parent 58fe3d90
......@@ -157,7 +157,7 @@ namespace Konversation
return m_chat->ownNick();
}
bool ChatContainer::canBeFrontView()
bool ChatContainer::canBeFrontView() const
{
return true;
}
......@@ -212,17 +212,17 @@ namespace Konversation
emit updateInfo(info);
}
QString ChatContainer::getChannelEncoding()
QString ChatContainer::getChannelEncoding() const
{
return m_chat->getEncoding();
}
QString ChatContainer::getChannelEncodingDefaultDesc()
QString ChatContainer::getChannelEncodingDefaultDesc() const
{
return i18nc("%1=Encoding","Default ( %1 )", Konversation::IRCCharsets::self()->encodingForLocale());
}
bool ChatContainer::searchView()
bool ChatContainer::searchView() const
{
return true;
}
......
......@@ -35,12 +35,12 @@ namespace Konversation
// ChatWindow
bool closeYourself(bool askForConfirmation=true) override;
bool canBeFrontView() override;
bool searchView() override;
bool canBeFrontView() const override;
bool searchView() const override;
void setChannelEncoding(const QString &encoding) override;
QString getChannelEncoding() override;
QString getChannelEncodingDefaultDesc() override;
QString getChannelEncoding() const override;
QString getChannelEncodingDefaultDesc() const override;
void emitUpdateInfo() override;
QString ownNick() const;
......
......@@ -425,7 +425,7 @@ void Channel::rejoin()
m_server->sendJoinCommand(getName(), getPassword());
}
bool Channel::log()
bool Channel::log() const
{
return ChatWindow::log() && !Preferences::self()->privateOnly();
}
......@@ -2390,12 +2390,12 @@ void Channel::fadeActivity()
}
}
bool Channel::canBeFrontView()
bool Channel::canBeFrontView() const
{
return true;
}
bool Channel::searchView()
bool Channel::searchView() const
{
return true;
}
......@@ -2570,14 +2570,14 @@ void Channel::setChannelEncoding(const QString& encoding) // virtual
Preferences::setChannelEncoding(m_server->getDisplayName(), getName(), encoding);
}
QString Channel::getChannelEncoding() // virtual
QString Channel::getChannelEncoding() const // virtual
{
if(m_server->getServerGroup())
return Preferences::channelEncoding(m_server->getServerGroup()->id(), getName());
return Preferences::channelEncoding(m_server->getDisplayName(), getName());
}
QString Channel::getChannelEncodingDefaultDesc() // virtual
QString Channel::getChannelEncodingDefaultDesc() const // virtual
{
return i18n("Identity Default ( %1 )", getServer()->getIdentity()->getCodecName());
}
......
......@@ -76,8 +76,8 @@ class Channel : public ChatWindow
~Channel() override;
//META
bool canBeFrontView() override;
bool searchView() override;
bool canBeFrontView() const override;
bool searchView() const override;
void append(const QString& nickname, const QString& message, const QHash<QString, QString> &messageTags = QHash<QString, QString>(), const QString& label = QString()) override;
void appendAction(const QString& nickname, const QString& message, const QHash<QString, QString> &messageTags = QHash<QString, QString>()) override;
......@@ -102,10 +102,10 @@ class Channel : public ChatWindow
int numberOfNicks() const { return nicks; }
int numberOfOps() const { return ops; }
void setChannelEncoding(const QString& encoding) override;
QString getChannelEncoding() override;
QString getChannelEncodingDefaultDesc() override;
QString getChannelEncoding() const override;
QString getChannelEncodingDefaultDesc() const override;
bool log() override;
bool log() const override;
protected:
// use with caution! does not check for duplicates
......
......@@ -92,8 +92,8 @@ class ChannelListPanel : public ChatWindow, private Ui::ChannelListWidgetUI
virtual bool closeYourself();
void emitUpdateInfo() override;
bool isInsertSupported() override { return true; }
QString getTextInLine() override { return m_filterLine->text(); }
bool isInsertSupported() const override { return true; }
QString getTextInLine() const override { return m_filterLine->text(); }
Q_SIGNALS:
void refreshChannelList();
......
......@@ -53,7 +53,7 @@ class NicksOnline : public ChatWindow
QTreeWidget* getNickListView() const;
NickInfoPtr getNickInfo(const QTreeWidgetItem* item) const;
bool canBeFrontView() override { return true; }
bool canBeFrontView() const override { return true; }
Q_SIGNALS:
/**
......
......@@ -388,8 +388,8 @@ NickInfoPtr Query::getNickInfo() const
return m_nickInfo;
}
bool Query::canBeFrontView() { return true; }
bool Query::searchView() { return true; }
bool Query::canBeFrontView() const { return true; }
bool Query::searchView() const { return true; }
// virtual
void Query::setChannelEncoding(const QString& encoding)
{
......@@ -399,14 +399,14 @@ void Query::setChannelEncoding(const QString& encoding)
Preferences::setChannelEncoding(m_server->getDisplayName(), getName(), encoding);
}
QString Query::getChannelEncoding() // virtual
QString Query::getChannelEncoding() const // virtual
{
if(m_server->getServerGroup())
return Preferences::channelEncoding(m_server->getServerGroup()->id(), getName());
return Preferences::channelEncoding(m_server->getDisplayName(), getName());
}
QString Query::getChannelEncodingDefaultDesc() // virtual
QString Query::getChannelEncodingDefaultDesc() const // virtual
{
return i18n("Identity Default ( %1 )",getServer()->getIdentity()->getCodecName());
}
......
......@@ -57,12 +57,12 @@ class Query : public ChatWindow
*/
NickInfoPtr getNickInfo() const;
bool closeYourself(bool askForConfirmation=true) override;
bool canBeFrontView() override;
bool searchView() override;
bool canBeFrontView() const override;
bool searchView() const override;
void setChannelEncoding(const QString& encoding) override;
QString getChannelEncoding() override;
QString getChannelEncodingDefaultDesc() override;
QString getChannelEncoding() const override;
QString getChannelEncodingDefaultDesc() const override;
void emitUpdateInfo() override;
/** call this when you see a nick quit from the server.
......
......@@ -560,13 +560,13 @@ IRCView* ChatWindow::getTextView() const
return textView;
}
bool ChatWindow::log()
bool ChatWindow::log() const
{
return Preferences::self()->log();
}
// reimplement this in all panels that have user input
QString ChatWindow::getTextInLine()
QString ChatWindow::getTextInLine() const
{
if (m_inputBar)
return m_inputBar->toPlainText();
......@@ -574,12 +574,12 @@ QString ChatWindow::getTextInLine()
return QString();
}
bool ChatWindow::canBeFrontView()
bool ChatWindow::canBeFrontView() const
{
return false;
}
bool ChatWindow::searchView()
bool ChatWindow::searchView() const
{
return false;
}
......
......@@ -73,7 +73,7 @@ class ChatWindow : public QWidget
IRCView* getTextView() const;
void setInputBar(IRCInput* newInputBar) { m_inputBar = newInputBar; }
IRCInput* getInputBar() const { return m_inputBar; }
virtual bool log();
virtual bool log() const;
QString getName() const;
QString getTitle() const;
......@@ -97,14 +97,14 @@ class ChatWindow : public QWidget
void clear();
virtual QString getTextInLine();
virtual QString getTextInLine() const;
/** Reimplement this to return true in all classes that /can/ become front view.
*/
virtual bool canBeFrontView();
virtual bool canBeFrontView() const;
/** Reimplement this to return true in all classes that you can search in - i.e. use "Edit->Find Text" in.
*/
virtual bool searchView();
virtual bool searchView() const;
bool notificationsEnabled() const { return m_notificationsEnabled; }
......@@ -113,8 +113,8 @@ class ChatWindow : public QWidget
QString logFileName() const { return logfile.fileName(); }
virtual void setChannelEncoding(const QString& /* encoding */) {}
virtual QString getChannelEncoding() { return QString(); }
virtual QString getChannelEncodingDefaultDesc() { return QString(); }
virtual QString getChannelEncoding() const { return QString(); }
virtual QString getChannelEncodingDefaultDesc() const { return QString(); }
bool isChannelEncodingSupported() const;
/** Force updateInfo(info) to be emitted.
......@@ -125,12 +125,12 @@ class ChatWindow : public QWidget
/** child classes have to override this and return true if they want the
* "insert character" item on the menu to be enabled.
*/
virtual bool isInsertSupported() { return m_inputBar != nullptr; }
virtual bool isInsertSupported() const { return m_inputBar != nullptr; }
/** child classes have to override this and return true if they want the
* "irc color" item on the menu to be enabled.
*/
virtual bool areIRCColorsSupported() {return false; }
virtual bool areIRCColorsSupported() const {return false; }
Konversation::TabNotifyType currentTabNotification() const { return m_currentTabNotify; }
QColor highlightColor();
......
......@@ -196,4 +196,4 @@ int LogfileReader::spacing()
return style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal);
}
bool LogfileReader::searchView() { return true; }
bool LogfileReader::searchView() const { return true; }
......@@ -34,7 +34,7 @@ class LogfileReader : public ChatWindow
using ChatWindow::closeYourself;
virtual bool closeYourself() { closeLog(); return true; }
bool searchView() override;
bool searchView() const override;
bool eventFilter(QObject* watched, QEvent* e) override;
......
......@@ -51,9 +51,9 @@ bool RawLog::closeYourself()
return true;
}
bool RawLog::searchView() { return true; }
bool RawLog::searchView() const { return true; }
bool RawLog::log() { return false; }
bool RawLog::log() const { return false; }
// The QByteArray implementation of this uses the unintelligent q_strchr for its "exclude" list.
// Additionally, we need to escape certain values for the IrcView, so rather than letting it loop
......
......@@ -31,8 +31,8 @@ class RawLog : public ChatWindow
using ChatWindow::closeYourself;
virtual bool closeYourself();
bool searchView() override;
bool log() override;
bool searchView() const override;
bool log() const override;
using ChatWindow::appendRaw;
virtual void appendRaw(MessageDirection dir, const QByteArray& message);
public Q_SLOTS:
......
......@@ -213,8 +213,8 @@ void StatusPanel::showEvent(QShowEvent*)
}
}
bool StatusPanel::canBeFrontView() { return true; }
bool StatusPanel::searchView() { return true; }
bool StatusPanel::canBeFrontView() const { return true; }
bool StatusPanel::searchView() const { return true; }
void StatusPanel::setNotificationsEnabled(bool enable)
{
......@@ -298,7 +298,7 @@ void StatusPanel::setChannelEncoding(const QString& encoding)
Preferences::setChannelEncoding(m_server->getDisplayName(), QStringLiteral(":server"), encoding);
}
QString StatusPanel::getChannelEncoding() // virtual
QString StatusPanel::getChannelEncoding() const // virtual
{
if(m_server->getServerGroup())
return Preferences::channelEncoding(m_server->getServerGroup()->id(), QStringLiteral(":server"));
......@@ -306,7 +306,7 @@ QString StatusPanel::getChannelEncoding() // virtual
}
// virtual
QString StatusPanel::getChannelEncodingDefaultDesc()
QString StatusPanel::getChannelEncodingDefaultDesc() const
{
return i18n("Identity Default ( %1 )", getServer()->getIdentity()->getCodecName());
}
......
......@@ -36,12 +36,12 @@ class StatusPanel : public ChatWindow
void setName(const QString& newName) override;
bool closeYourself(bool askForConfirmation=true) override;
bool canBeFrontView() override;
bool searchView() override;
bool canBeFrontView() const override;
bool searchView() const override;
void setChannelEncoding(const QString& encoding) override;
QString getChannelEncoding() override;
QString getChannelEncodingDefaultDesc() override;
QString getChannelEncoding() const override;
QString getChannelEncodingDefaultDesc() const override;
void emitUpdateInfo() override;
void setServer(Server* newServer) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment