#include <QAbstractItemView>
#include <QMimeData>
-#if QT_VERSION < 0x050000
#include <QTextDocument> // for Qt::escape()
-#endif
#include "buffermodel.h"
#include "buffersettings.h"
{
Q_UNUSED(column);
-#if QT_VERSION < 0x050000
QStringList toolTip(QString("<b>%1</b>").arg(Qt::escape(networkName())));
toolTip.append(i18n("Server: %1").arg(Qt::escape(currentServer())));
-#else
- QStringList toolTip(QString("<b>%1</b>").arg(networkName().toHtmlEscaped()));
- toolTip.append(i18n("Server: %1").arg(currentServer().toHtmlEscaped()));
-#endif
toolTip.append(i18n("Users: %1").arg(nickCount()));
if (_network) {
Q_UNUSED(column);
QStringList toolTip;
-#if QT_VERSION < 0x050000
toolTip.append(i18n("<b>Channel %1</b>").arg(Qt::escape(bufferName())));
-#else
- toolTip.append(i18n("<b>Channel %1</b>").arg(bufferName().toHtmlEscaped()));
-#endif
if (isActive()) {
//TODO: add channel modes
toolTip.append(i18n("<b>Users:</b> %1").arg(nickCount()));
QString _topic = topic();
if (_topic != "") {
_topic = stripFormatCodes(_topic);
-#if QT_VERSION < 0x050000
_topic = Qt::escape(_topic);
-#else
- _topic = _topic.toHtmlEscaped();
-#endif
toolTip.append(QString("<font size='-2'> </font>"));
toolTip.append(i18n("<b>Topic:</b> %1").arg(_topic));
}
{
if (!_initDone) {
for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) {
-#if QT_VERSION >= 0x050000
- QString methodSignature = metaObject()->method(i).methodSignature();
-#else
QString methodSignature = metaObject()->method(i).signature();
-#endif
if (methodSignature.startsWith("defaultHandler")) {
_defaultHandler = i;
continue;
void EventManager::registerObject(QObject *object, Priority priority, const QString &methodPrefix, const QString &filterPrefix)
{
for (int i = object->metaObject()->methodOffset(); i < object->metaObject()->methodCount(); i++) {
-#if QT_VERSION >= 0x050000
- QString methodSignature = object->metaObject()->method(i).methodSignature();
-#else
QString methodSignature = object->metaObject()->method(i).signature();
-#endif
int eventType = findEventType(methodSignature, methodPrefix);
if (eventType > 0) {
void RemotePeer::handle(const HeartBeatReply &heartBeatReply)
{
_heartBeatCount = 0;
-#if QT_VERSION >= 0x040700
emit lagUpdated(heartBeatReply.timestamp.msecsTo(QDateTime::currentDateTime().toUTC()) / 2);
-#else
- emit lagUpdated(heartBeatReply.timestamp.time().msecsTo(QDateTime::currentDateTime().toUTC().time()) / 2);
-#endif
}
}
else {
fn = SIGNAL(fakeMethodSignature());
-#if QT_VERSION >= 0x050000
- fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).methodSignature());
-#else
fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature());
-#endif
}
_slots[slotId] = Signal(sender, signalId, fn);
const QList<int> &argTypes = eMeta->argTypes(signal.signalId);
for (int i = 0; i < argTypes.size(); i++) {
if (argTypes[i] == 0) {
-#if QT_VERSION >= 0x050000
- kWarning(300000) << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(_id).methodSignature().constData());
-#else
kWarning(300000) << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(_id).signature());
-#endif
kWarning(300000) << " - make sure all your data types are known by the Qt MetaSystem";
return _id;
}
// check for argument compatibility and build params array
for (int i = 0; i < numArgs; i++) {
if (!params[i].isValid()) {
-#if QT_VERSION >= 0x050000
- kWarning(300000) << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).methodSignature().constData());
-#else
kWarning(300000) << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).signature());
-#endif
kWarning(300000) << " - make sure all your data types are known by the Qt MetaSystem";
return false;
}
if (_meta->method(i).methodType() != QMetaMethod::Slot)
continue;
-#if QT_VERSION >= 0x050000
- if (_meta->method(i).methodSignature().contains('*'))
-#else
if (QByteArray(_meta->method(i).signature()).contains('*'))
-#endif
continue; // skip methods with ptr params
QByteArray method = methodName(_meta->method(i));
}
if (checkConflicts) {
kWarning(300000) << "class" << meta->className() << "contains overloaded methods which is currently not supported!";
-#if QT_VERSION >= 0x050000
- kWarning(300000) << " - " << _meta->method(i).methodSignature() << "conflicts with" << _meta->method(_methodIds[method]).methodSignature();
-#else
kWarning(300000) << " - " << _meta->method(i).signature() << "conflicts with" << _meta->method(_methodIds[method]).signature();
-#endif
}
continue;
}
if (QMetaType::Void == (QMetaType::Type)returnType(i))
continue;
-#if QT_VERSION >= 0x050000
- signature = requestSlot.methodSignature();
-#else
signature = QByteArray(requestSlot.signature());
-#endif
if (!signature.startsWith("request"))
continue;
QByteArray SignalProxy::ExtendedMetaObject::methodName(const QMetaMethod &method)
{
-#if QT_VERSION >= 0x050000
- QByteArray sig(method.methodSignature());
-#else
QByteArray sig(method.signature());
-#endif
return sig.left(sig.indexOf("("));
}
QString SignalProxy::ExtendedMetaObject::methodBaseName(const QMetaMethod &method)
{
-#if QT_VERSION >= 0x050000
- QString methodname = QString(method.methodSignature()).section("(", 0, 0);
-#else
QString methodname = QString(method.signature()).section("(", 0, 0);
-#endif
// determine where we have to chop:
int upperCharPos;
_argTypes = argTypes;
// determine minArgCount
-#if QT_VERSION >= 0x050000
- QString signature(method.methodSignature());
-#else
QString signature(method.signature());
-#endif
_minArgCount = method.parameterTypes().count() - signature.count("=");
_receiverMode = (_methodName.startsWith("request"))
QVariant::Type variantType = QVariant::nameToType(method.typeName());
if (variantType == QVariant::Invalid && !QByteArray(method.typeName()).isEmpty()) {
-#if QT_VERSION >= 0x050000
- kWarning(300000) << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.methodSignature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName());
-#else
kWarning(300000) << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.signature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName());
-#endif
continue;
}
else if (s.endsWith("\n"))
s.chop(1);
NetworkDataEvent *event = new NetworkDataEvent(EventManager::NetworkIncoming, this, s);
-#if QT_VERSION >= 0x040700
event->setTimestamp(QDateTime::currentDateTimeUtc());
-#else
- event->setTimestamp(QDateTime::currentDateTime().toUTC());
-#endif
emit newEvent(event);
}
}
if (server.useSsl && !socket.isEncrypted())
return;
#endif
-#if QT_VERSION >= 0x040600
socket.setSocketOption(QAbstractSocket::KeepAliveOption, true);
-#endif
emit socketInitialized(identity, localAddress(), localPort(), peerAddress(), peerPort());
QString verboseMessage = i18n("sending CTCP-%1 request to %2").arg(ctcpTag).arg(nick);
if (ctcpTag == "PING") {
-#if QT_VERSION >= 0x040700
message = QString::number(QDateTime::currentMSecsSinceEpoch());
-#else
- message = QString::number(QDateTime::currentDateTime().toTime_t());
-#endif
}
// FIXME make this a proper event
if (e->ctcpType() == CtcpEvent::Query)
defaultHandler(e->ctcpCmd(), e);
else {
-#if QT_VERSION >= 0x040700
displayMsg(e, Message::Server, i18n("Received CTCP-PING answer from %1 with %2 milliseconds round trip time")
.arg(nickFromMask(e->prefix())).arg(QDateTime::fromMSecsSinceEpoch(e->param().toULongLong()).msecsTo(e->timestamp())));
-#else
- displayMsg(e, Message::Server, i18n("Received CTCP-PING answer from %1 with %2 seconds round trip time")
- .arg(nickFromMask(e->prefix())).arg(QDateTime::fromTime_t(e->param().toInt()).secsTo(e->timestamp())));
-#endif
}
}
return _pendingConnections.takeFirst();
}
-#if QT_VERSION >= 0x050000
-void SslServer::incomingConnection(qintptr socketDescriptor)
-#else
void SslServer::incomingConnection(int socketDescriptor)
-#endif
{
QSslSocket *serverSocket = new QSslSocket(this);
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
kWarning(300000) << "SslServer: Certificate expired on" << _cert.expiryDate().toString();
else { // Qt4's isValid() checks for time range and blacklist; avoid a double warning, hence the else block
-#if QT_VERSION < 0x050000
if (!_cert.isValid())
-#else
- if (_cert.isBlacklisted())
-#endif
kWarning(300000) << "SslServer: Certificate blacklisted";
}
if (_key.isNull()) {
virtual inline bool isCertValid() const { return _isCertValid; }
protected:
-#if QT_VERSION >= 0x050000
- virtual void incomingConnection(qintptr socketDescriptor);
-#else
virtual void incomingConnection(int socketDescriptor);
-#endif
virtual bool setCertificate(const QString &path);
class SearchHighlightItem : public QObject, public QGraphicsItem
{
Q_OBJECT
-#if QT_VERSION >= 0x040600
Q_INTERFACES(QGraphicsItem)
-#endif
public :
SearchHighlightItem(QRectF wordRect, QGraphicsItem *parent = 0);
type = "PrivMsgFocused"; break;
}
-#if QT_VERSION < 0x050000
QString message = QString("<b><%1></b> %2").arg(n.sender, Qt::escape(n.message));
-#else
- QString message = QString("<b><%1></b> %2").arg(n.sender, n.message.toHtmlEscaped());
-#endif
KNotification *notification = KNotification::event(type, message, KIcon("dialog-information").pixmap(48), QtUi::mainWindow(),
KNotification::RaiseWidgetOnActivation
|KNotification::CloseWhenWidgetActivated
ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setToolTip("<b>Channel</b>: This regular expression determines for which <b>channels</b> the highlight rule works. Leave blank to match any channel. Put <b>!</b> in the beginning to negate. Case insensitive.");
ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setWhatsThis("<b>Channel</b>: This regular expression determines for which <b>channels</b> the highlight rule works. Leave blank to match any channel. Put <b>!</b> in the beginning to negate. Case insensitive.");
-#if QT_VERSION < 0x050000
ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::NameColumn, QHeaderView::Stretch);
ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents);
ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents);
ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents);
ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents);
-#else
- ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::NameColumn, QHeaderView::Stretch);
- ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::RegExColumn, QHeaderView::ResizeToContents);
- ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::CsColumn, QHeaderView::ResizeToContents);
- ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::EnableColumn, QHeaderView::ResizeToContents);
- ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents);
-#endif
connect(ui.add, SIGNAL(clicked(bool)), this, SLOT(addNewRow()));
connect(ui.remove, SIGNAL(clicked(bool)), this, SLOT(removeSelectedRows()));
// in Qt5, subjectInfo returns a QStringList(); turn this into a comma-separated string instead
QString SslInfoDlg::subjectInfo(const QSslCertificate &cert, QSslCertificate::SubjectInfo subjectInfo) const
{
-#if QT_VERSION < 0x050000
return cert.subjectInfo(subjectInfo);
-#else
- return cert.subjectInfo(subjectInfo).join(", ");
-#endif
}
// same here
QString SslInfoDlg::issuerInfo(const QSslCertificate &cert, QSslCertificate::SubjectInfo subjectInfo) const
{
-#if QT_VERSION < 0x050000
return cert.issuerInfo(subjectInfo);
-#else
- return cert.issuerInfo(subjectInfo).join(", ");
-#endif
}
virtual QString iconNameForAction(QAction *action) // TODO Qt 4.7: fixme when we have converted our iconloader
{
QIcon icon(action->icon());
-#if QT_VERSION >= 0x040701
// QIcon::name() is in the 4.7 git branch, but it is not in 4.7 TP.
// If you get a build error here, you need to update your pre-release
// of Qt 4.7.
return icon.isNull() ? QString() : icon.name();
-#else
- return QString();
-#endif
}
};
QString message = message_;
if (_notificationsClient->isValid()) {
if (_notificationsClientSupportsMarkup)
-#if QT_VERSION < 0x050000
message = Qt::escape(message);
-#else
- message = message.toHtmlEscaped();
-#endif
QStringList actions;
if (_notificationsClientSupportsActions)
switch (Client::networkModel()->bufferType(id)) {
case BufferInfo::StatusBuffer:
if (network) {
-#if QT_VERSION < 0x050000
newtopic = QString("%1 (%2) | %3 | %4")
.arg(Qt::escape(network->networkName()))
.arg(Qt::escape(network->currentServer()))
.arg(i18n("Users: %1").arg(network->ircUsers().count()))
.arg(i18n("Lag: %1 msecs").arg(network->latency()));
-#else
- newtopic = QString("%1 (%2) | %3 | %4")
- .arg(network->networkName().toHtmlEscaped())
- .arg(network->currentServer().toHtmlEscaped())
- .arg(i18n("Users: %1").arg(network->ircUsers().count()))
- .arg(i18n("Lag: %1 msecs").arg(network->latency()));
-#endif
}
else {
newtopic = index0.data(Qt::DisplayRole).toString();
storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state
}
-#if QT_VERSION < 0x050000
void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
QTreeView::dataChanged(topLeft, bottomRight);
-#else
-void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
-{
- QTreeView::dataChanged(topLeft, bottomRight, roles);
-#endif
// determine how many items have been changed and if any of them is a networkitem
// which just swichted from active to inactive or vice versa
virtual void focusInEvent(QFocusEvent *event) { QAbstractScrollArea::focusInEvent(event); }
virtual void contextMenuEvent(QContextMenuEvent *event);
-#if QT_VERSION < 0x050000
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-#else
- virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
-#endif
private slots:
void joinChannel(const QModelIndex &index);
_emacsMode(false),
_lastDocumentHeight(-1)
{
-#if QT_VERSION >= 0x040500
document()->setDocumentMargin(0); // new in Qt 4.5 and we really don't want it here
-#endif
setAcceptRichText(false);
enableFindReplace(false);
void MultiLineEdit::keyPressEvent(QKeyEvent *event)
{
// Workaround the fact that Qt < 4.5 doesn't know InsertLineSeparator yet
-#if QT_VERSION >= 0x040500
if (event == QKeySequence::InsertLineSeparator) {
-#else
-
- if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::SHIFT) {
-#endif
if (_mode == SingleLine) {
event->accept();
QString msg = i18n("Do you really want to paste %n line(s)?", lines.count());
msg += "<p>";
for (int i = 0; i < 4; i++) {
-#if QT_VERSION < 0x050000
msg += Qt::escape(lines[i].left(40));
-#else
- msg += lines[i].left(40).toHtmlEscaped();
-#endif
if (lines[i].count() > 40)
msg += "...";
msg += "<br />";
void StyledLabel::updateToolTip()
{
if (frameRect().width() - 2*frameWidth() < _layout.minimumWidth())
-#if QT_VERSION < 0x050000
setToolTip(QString("<qt>%1</qt>").arg(Qt::escape(_layout.text()))); // only rich text gets wordwrapped!
-#else
- setToolTip(QString("<qt>%1</qt>").arg(_layout.text().toHtmlEscaped())); // only rich text gets wordwrapped!
-#endif
else
setToolTip(QString());
}
void StyledLabel::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() == Qt::NoButton) {
-#if QT_VERSION < 0x050000
Clickable click = _clickables.atCursorPos(posToCursor(event->posF()));
-#else
- Clickable click = _clickables.atCursorPos(posToCursor(event->localPos()));
-#endif
if (click.isValid())
setHoverMode(click.start(), click.length());
else
void StyledLabel::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
-#if QT_VERSION < 0x050000
Clickable click = _clickables.atCursorPos(posToCursor(event->posF()));
-#else
- Clickable click = _clickables.atCursorPos(posToCursor(event->localPos()));
-#endif
if (click.isValid())
emit clickableActivated(click);
}