src/viewer/*: mark methods const when possible and semantically sensible

parent ce0931f0
......@@ -237,7 +237,7 @@ namespace Konversation
m_ui.topicHistoryView->setTextSelectable(edited);
}
QString ChannelOptionsDialog::topic()
QString ChannelOptionsDialog::topic() const
{
return m_ui.topicEdit->toPlainText().replace(QLatin1Char('\n'), QLatin1Char(' '));
}
......@@ -415,7 +415,7 @@ namespace Konversation
refreshEnableModes(true);
}
QStringList ChannelOptionsDialog::modes()
QStringList ChannelOptionsDialog::modes() const
{
QStringList modes;
QString mode;
......
......@@ -33,8 +33,8 @@ namespace Konversation
explicit ChannelOptionsDialog(Channel *channel);
~ChannelOptionsDialog() override;
QString topic();
QStringList modes();
QString topic() const;
QStringList modes() const;
/**
* Return the whatsThis string for a mode-change button.
......
......@@ -72,7 +72,7 @@ class ChatWindow : public QWidget
void setTextView(IRCView* newView);
IRCView* getTextView() const;
void setInputBar(IRCInput* newInputBar) { m_inputBar = newInputBar; }
IRCInput* getInputBar() { return m_inputBar; }
IRCInput* getInputBar() const { return m_inputBar; }
virtual bool log();
QString getName() const;
......@@ -110,7 +110,7 @@ class ChatWindow : public QWidget
bool eventFilter(QObject* watched, QEvent* e) override;
QString logFileName() { return logfile.fileName(); }
QString logFileName() const { return logfile.fileName(); }
virtual void setChannelEncoding(const QString& /* encoding */) {}
virtual QString getChannelEncoding() { return QString(); }
......
......@@ -26,10 +26,10 @@ class IgnoreListViewItem : public QTreeWidgetItem
~IgnoreListViewItem() override;
void setFlag(int flag,bool active);
bool getFlag(int flag) { return m_flags & flag; };
QString getName() { return text(0); };
bool getFlag(int flag) const { return m_flags & flag; };
QString getName() const { return text(0); };
void setName(const QString &name) { setText(0, name); };
int getFlags() { return m_flags; };
int getFlags() const { return m_flags; };
void setFlags(int flags);
protected:
......
......@@ -203,7 +203,7 @@ void Images::initializeNickIcons()
}
}
QIcon Images::getLed(const QColor& col,bool state)
QIcon Images::getLed(const QColor& col,bool state) const
{
Q_UNUSED(col)
Q_UNUSED(state)
......@@ -211,7 +211,7 @@ QIcon Images::getLed(const QColor& col,bool state)
return QIcon(new LedIconEngine(col, state));
}
QIcon Images::getServerLed(bool state)
QIcon Images::getServerLed(bool state) const
{
if (state)
return m_serverLedOn;
......@@ -219,7 +219,7 @@ QIcon Images::getServerLed(bool state)
return m_serverLedOff;
}
QIcon Images::getSystemLed(bool state)
QIcon Images::getSystemLed(bool state) const
{
if (Preferences::self()->tabNotificationsSystemColor()!=m_systemColor)
{
......@@ -237,7 +237,7 @@ QIcon Images::getSystemLed(bool state)
}
}
QIcon Images::getMsgsLed(bool state)
QIcon Images::getMsgsLed(bool state) const
{
if (Preferences::self()->tabNotificationsMsgsColor()!=m_msgsColor)
{
......@@ -255,7 +255,7 @@ QIcon Images::getMsgsLed(bool state)
}
}
QIcon Images::getPrivateLed(bool state)
QIcon Images::getPrivateLed(bool state) const
{
if (Preferences::self()->tabNotificationsPrivateColor()!=m_privateColor)
{
......@@ -273,7 +273,7 @@ QIcon Images::getPrivateLed(bool state)
}
}
QIcon Images::getEventsLed()
QIcon Images::getEventsLed() const
{
if (Preferences::self()->tabNotificationsEventsColor()!=m_eventsColor)
return getLed(Preferences::self()->tabNotificationsEventsColor(),true);
......@@ -281,7 +281,7 @@ QIcon Images::getEventsLed()
return m_eventsLedOn;
}
QIcon Images::getNickLed()
QIcon Images::getNickLed() const
{
if (Preferences::self()->tabNotificationsNickColor()!=m_nickColor)
return getLed(Preferences::self()->tabNotificationsNickColor(),true);
......@@ -289,7 +289,7 @@ QIcon Images::getNickLed()
return m_nickLedOn;
}
QIcon Images::getHighlightsLed()
QIcon Images::getHighlightsLed() const
{
if (Preferences::self()->tabNotificationsHighlightsColor()!=m_highlightsColor)
return getLed(Preferences::self()->tabNotificationsHighlightsColor(),true);
......
......@@ -46,15 +46,15 @@ class Images : public QObject
Images();
~Images() override;
QIcon getLed(const QColor& col, bool state = true);
QIcon getServerLed(bool state);
QIcon getSystemLed(bool state);
QIcon getMsgsLed(bool state);
QIcon getPrivateLed(bool state);
QIcon getEventsLed();
QIcon getNickLed();
QIcon getHighlightsLed();
QIcon getLed(const QColor& col, bool state = true) const;
QIcon getServerLed(bool state) const;
QIcon getSystemLed(bool state) const;
QIcon getMsgsLed(bool state) const;
QIcon getPrivateLed(bool state) const;
QIcon getEventsLed() const;
QIcon getNickLed() const;
QIcon getHighlightsLed() const;
QIcon getNickIcon(NickPrivilege privilege,bool isAway=false) const;
QIcon getNickIconAwayOverlay() const;
......
......@@ -57,7 +57,7 @@ namespace Konversation
m_charTable->setFont(font.family());
}
uint InsertCharDialog::chr()
uint InsertCharDialog::chr() const
{
return m_charTable->currentCodePoint();
}
......
......@@ -30,7 +30,7 @@ namespace Konversation
~InsertCharDialog();
void setFont(const QFont &font);
uint chr();
uint chr() const;
protected Q_SLOTS:
void charSelected();
......
......@@ -43,7 +43,7 @@ IRCColorChooser::IRCColorChooser(QWidget* parent)
updatePreview();
}
QString IRCColorChooser::color()
QString IRCColorChooser::color() const
{
QString s;
s = QLatin1String("%C") + QString::number(m_ui.m_fgColorCBox->currentIndex()).rightJustified(2, QLatin1Char('0'));
......
......@@ -27,7 +27,7 @@ class IRCColorChooser : public QDialog
Q_OBJECT
public:
explicit IRCColorChooser(QWidget* parent);
QString color();
QString color() const;
protected Q_SLOTS:
void updatePreview();
......
......@@ -560,8 +560,8 @@ void IRCInput::doInlineAutoreplace()
// Accessor methods
void IRCInput::setCompletionMode(char mode) { completionMode=mode; }
char IRCInput::getCompletionMode() { return completionMode; }
char IRCInput::getCompletionMode() const { return completionMode; }
void IRCInput::setOldCursorPosition(int pos) { oldPos=pos; }
int IRCInput::getOldCursorPosition() { return oldPos; }
int IRCInput::getOldCursorPosition() const { return oldPos; }
......@@ -28,9 +28,9 @@ class IRCInput : public KTextEdit
~IRCInput() override;
void setCompletionMode(char mode);
char getCompletionMode();
char getCompletionMode() const;
void setOldCursorPosition(int pos);
int getOldCursorPosition();
int getOldCursorPosition() const;
QString lastCompletion() const { return m_lastCompletion; }
void doInlineAutoreplace();
......
......@@ -121,7 +121,7 @@ void SearchBar::showEvent(QShowEvent *e)
m_searchEdit->selectAll();
}
bool SearchBar::focusedChild()
bool SearchBar::focusedChild() const
{
QList<QWidget *> l = findChildren<QWidget *>();
......
......@@ -43,7 +43,6 @@ class SearchBar : public QWidget, private Ui::SearchBarBase
protected:
void showEvent(QShowEvent* e) override;
void hideEvent(QHideEvent* e) override;
bool focusedChild();
private Q_SLOTS:
void slotTextChanged();
......@@ -60,6 +59,9 @@ class SearchBar : public QWidget, private Ui::SearchBarBase
void signalSearchPrevious();
void hidden();
private:
bool focusedChild() const;
private:
QTimer* m_timer;
......
......@@ -235,7 +235,7 @@ namespace Konversation
updateSqueezedText();
}
QString TopicLabel::rPixelSqueeze(const QString& text, int maxPixels)
QString TopicLabel::rPixelSqueeze(const QString& text, int maxPixels) const
{
int tw = textWidth(text);
......@@ -269,9 +269,9 @@ namespace Konversation
return text;
}
int TopicLabel::textWidth(const QString& text)
int TopicLabel::textWidth(const QString& text) const
{
QTextDocument document(this);
QTextDocument document;
document.setDefaultFont(font());
document.setHtml(QLatin1String("<qt>") + text + QLatin1String("</qt>"));
......
......@@ -47,8 +47,8 @@ namespace Konversation
protected:
void updateSqueezedText();
QString rPixelSqueeze(const QString& text, int maxPixels);
int textWidth(const QString& text);
QString rPixelSqueeze(const QString& text, int maxPixels) const;
int textWidth(const QString& text) const;
void leaveEvent (QEvent*) override;
void contextMenuEvent(QContextMenuEvent* ev) override;
void resizeEvent(QResizeEvent*) override;
......
......@@ -2276,7 +2276,7 @@ void ViewContainer::showViewContextMenu(QWidget* tab, const QPoint& pos)
updateViewActions(m_tabWidget->currentIndex());
}
QString ViewContainer::currentViewTitle()
QString ViewContainer::currentViewTitle() const
{
if (m_frontServer)
{
......@@ -2305,17 +2305,17 @@ QString ViewContainer::currentViewURL(bool passNetwork)
return url;
}
int ViewContainer::getViewIndex(QWidget* widget)
int ViewContainer::getViewIndex(QWidget* widget) const
{
return m_tabWidget->indexOf(widget);
}
ChatWindow* ViewContainer::getViewAt(int index)
ChatWindow* ViewContainer::getViewAt(int index) const
{
return qobject_cast<ChatWindow*>(m_tabWidget->widget(index));
}
QList<QPair<QString,QString> > ViewContainer::getChannelsURI()
QList<QPair<QString,QString> > ViewContainer::getChannelsURI() const
{
QList<QPair<QString,QString> > URIList;
......@@ -2653,7 +2653,7 @@ void ViewContainer::deleteDccPanel()
}
}
ChatWindow* ViewContainer::getDccPanel()
ChatWindow* ViewContainer::getDccPanel() const
{
return m_dccPanel;
}
......
......@@ -90,12 +90,12 @@ class ViewContainer : public QAbstractItemModel
explicit ViewContainer(MainWindow* window);
~ViewContainer() override;
QSplitter* getWidget() { return m_viewTreeSplitter; }
MainWindow* getWindow() { return m_window; }
KActionCollection* actionCollection() { return m_window->actionCollection(); }
QSplitter* getWidget() const { return m_viewTreeSplitter; }
MainWindow* getWindow() const { return m_window; }
KActionCollection* actionCollection() const { return m_window->actionCollection(); }
QPointer<ChatWindow> getFrontView() { return m_frontView; }
Server* getFrontServer() { return m_frontServer; }
QPointer<ChatWindow> getFrontView() const { return m_frontView; }
Server* getFrontServer() const { return m_frontServer; }
void prepareShutdown();
......@@ -118,7 +118,7 @@ class ViewContainer : public QAbstractItemModel
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
QString currentViewTitle();
QString currentViewTitle() const;
QString currentViewURL(bool passNetwork = true);
void appendToFrontmost(const QString& type,const QString& message,ChatWindow* serverView,
......@@ -126,10 +126,10 @@ class ViewContainer : public QAbstractItemModel
void showQueueTuner(bool);
int getViewIndex(QWidget* widget);
ChatWindow* getViewAt(int index);
int getViewIndex(QWidget* widget) const;
ChatWindow* getViewAt(int index) const;
QList<QPair<QString,QString> > getChannelsURI();
QList<QPair<QString,QString> > getChannelsURI() const;
public Q_SLOTS:
void updateAppearance();
......@@ -203,7 +203,7 @@ class ViewContainer : public QAbstractItemModel
void addDccPanel();
void closeDccPanel();
void deleteDccPanel();
ChatWindow* getDccPanel();
ChatWindow* getDccPanel() const;
void addDccChat(Konversation::DCC::Chat* myNick);
......
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