Changeset View
Changeset View
Standalone View
Standalone View
src/viewer/channeloptionsdialog.cpp
Show All 15 Lines | |||||
16 | #include "channel.h" | 16 | #include "channel.h" | ||
17 | #include "topichistorymodel.h" | 17 | #include "topichistorymodel.h" | ||
18 | 18 | | |||
19 | #include <KColorScheme> | 19 | #include <KColorScheme> | ||
20 | 20 | | |||
21 | #include <QCheckBox> | 21 | #include <QCheckBox> | ||
22 | #include <QHeaderView> | 22 | #include <QHeaderView> | ||
23 | #include <QPushButton> | 23 | #include <QPushButton> | ||
24 | #include <QRegExp> | 24 | #include <QRegularExpression> | ||
25 | #include <QStandardItemModel> | 25 | #include <QStandardItemModel> | ||
26 | #include <QKeyEvent> | 26 | #include <QKeyEvent> | ||
27 | #include <QItemSelectionModel> | 27 | #include <QItemSelectionModel> | ||
28 | #include <QTreeWidget> | 28 | #include <QTreeWidget> | ||
29 | #include <KSharedConfig> | 29 | #include <KSharedConfig> | ||
30 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
31 | #include <QDialogButtonBox> | 31 | #include <QDialogButtonBox> | ||
32 | #include <QVBoxLayout> | 32 | #include <QVBoxLayout> | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 175 | { | |||
178 | { | 178 | { | ||
179 | if (!oldTopic.isEmpty()) | 179 | if (!oldTopic.isEmpty()) | ||
180 | m_channel->sendText(Preferences::self()->commandChar() + "TOPIC " + m_channel->getName() + " \x01"); | 180 | m_channel->sendText(Preferences::self()->commandChar() + "TOPIC " + m_channel->getName() + " \x01"); | ||
181 | } | 181 | } | ||
182 | else | 182 | else | ||
183 | m_channel->sendText(Preferences::self()->commandChar() + "TOPIC " + m_channel->getName() + ' ' + newTopic); | 183 | m_channel->sendText(Preferences::self()->commandChar() + "TOPIC " + m_channel->getName() + ' ' + newTopic); | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | QStringList newModeList = modes(); | 186 | const QStringList newModeList = modes(); | ||
187 | QStringList currentModeList = m_channel->getModeList(); | 187 | const QStringList currentModeList = m_channel->getModeList(); | ||
188 | QStringList rmModes; | 188 | | ||
189 | QStringList addModes; | | |||
190 | QStringList tmp; | | |||
191 | QString modeString; | | |||
192 | bool plus; | | |||
193 | QString command(QStringLiteral("MODE %1 %2%3 %4")); | 189 | QString command(QStringLiteral("MODE %1 %2%3 %4")); | ||
194 | 190 | | |||
195 | for(QStringList::ConstIterator it = newModeList.constBegin(); it != newModeList.constEnd(); ++it) | 191 | for (const QString &mode : newModeList) | ||
196 | { | 192 | { | ||
197 | modeString = (*it).mid(1); | 193 | const QString modeString = mode.mid(1); | ||
198 | plus = ((*it)[0] == '+'); | 194 | const bool plus = mode.at(0) == QLatin1Char('+'); | ||
199 | tmp = currentModeList.filter(QRegExp('^' + modeString)); | 195 | const QStringList tmp = currentModeList.filter(QRegularExpression(QLatin1Char('^') + modeString)); | ||
200 | 196 | | |||
201 | if(tmp.isEmpty() && plus) | 197 | if(tmp.isEmpty() && plus) | ||
202 | { | 198 | { | ||
203 | m_channel->getServer()->queue(command.arg(m_channel->getName()).arg(QStringLiteral("+")).arg(modeString[0]).arg(modeString.mid(1))); | 199 | m_channel->getServer()->queue(command.arg(m_channel->getName(), QStringLiteral("+"), | ||
200 | modeString.at(0), modeString.mid(1))); | ||||
204 | } | 201 | } | ||
205 | else if(!tmp.isEmpty() && !plus) | 202 | else if(!tmp.isEmpty() && !plus) | ||
206 | { | 203 | { | ||
207 | //FIXME: Bahamuth requires the key parameter for -k, but ircd breaks on -l with limit number. | 204 | //FIXME: Bahamuth requires the key parameter for -k, but ircd breaks on -l with limit number. | ||
208 | //Hence two versions of this. | 205 | //Hence two versions of this. | ||
209 | if (modeString[0] == 'k') | 206 | if (modeString.at(0) == QLatin1Char('k')) { | ||
210 | m_channel->getServer()->queue(command.arg(m_channel->getName()).arg(QStringLiteral("-")).arg(modeString[0]).arg(modeString.mid(1))); | 207 | m_channel->getServer()->queue(command.arg(m_channel->getName(), QStringLiteral("-"), | ||
211 | else | 208 | modeString.at(0), modeString.mid(1))); | ||
212 | m_channel->getServer()->queue(command.arg(m_channel->getName()).arg(QStringLiteral("-")).arg(modeString[0]).arg(QString())); | 209 | } else { | ||
210 | m_channel->getServer()->queue(command.arg(m_channel->getName(), QStringLiteral("-"), | ||||
211 | modeString.at(0), QString())); | ||||
212 | } | ||||
213 | } | 213 | } | ||
214 | } | 214 | } | ||
215 | hide(); | 215 | hide(); | ||
216 | } | 216 | } | ||
217 | 217 | | |||
218 | void ChannelOptionsDialog::toggleAdvancedModes() | 218 | void ChannelOptionsDialog::toggleAdvancedModes() | ||
219 | { | 219 | { | ||
220 | bool ison = m_ui.toggleAdvancedModes->isChecked(); | 220 | bool ison = m_ui.toggleAdvancedModes->isChecked(); | ||
▲ Show 20 Lines • Show All 417 Lines • Show Last 20 Lines |