188
188
this,SLOT (dbusInfo(const QString&)) );
189
189
connect(dbusObject,SIGNAL (dbusInsertMarkerLine()),
190
190
mainWindow,SIGNAL(insertMarkerLine()));
191
connect(dbusObject, SIGNAL(connectTo(Konversation::ConnectionFlag, const QString&, uint, const QString&, const QString&, const QString&, bool)),
192
m_connectionManager, SLOT(connectTo(Konversation::ConnectionFlag, const QString&, uint, const QString&, const QString&, const QString&, bool)));
191
connect(dbusObject, SIGNAL(connectTo(Konversation::ConnectionFlag, const QString&, const QString&, const QString&, const QString&, const QString&, bool)),
192
m_connectionManager, SLOT(connectTo(Konversation::ConnectionFlag, const QString&, const QString&, const QString&, const QString&, const QString&, bool)));
195
195
m_notificationHandler = new Konversation::NotificationHandler(this);
464
464
KConfigGroup cgAutoreplace(KGlobal::config()->group("Autoreplace List"));
465
465
// Read all default entries
466
QStringList autoreplaceList(Preferences::autoreplaceList());
466
QList<QStringList> autoreplaceList(Preferences::autoreplaceList());
467
467
// Read all entries
469
while (cgAutoreplace.hasKey(QString("Autoreplace%1").arg(index)))
469
// legacy code for old autoreplace format 4/6/09
470
QString autoReplaceString("Autoreplace");
471
while (cgAutoreplace.hasKey(autoReplaceString + QString::number(index)))
471
473
// read entry and get length of the string
472
QString entry=cgAutoreplace.readEntry(QString("Autoreplace%1").arg(index++));
473
unsigned int length=entry.length()-1;
474
QString entry=cgAutoreplace.readEntry(autoReplaceString + QString::number(index++));
475
int length=entry.length()-1;
474
476
// if there's a "#" in the end, strip it (used to preserve blanks at the end of the replacement text)
475
477
// there should always be one, but older versions did not do it, so we check first
476
478
if (entry.at(length)=='#')
477
479
entry=entry.left(length);
480
QString regex = entry.section(',',0,0);
481
QString direction = entry.section(',',1,1);
482
QString pattern = entry.section(',',2,2);
483
QString replace = entry.section(',',3);
478
484
// add entry to internal list
479
autoreplaceList.append(entry);
485
autoreplaceList.append(QStringList() << regex << direction << pattern << replace);
487
//end legacy code for old autoreplace format
488
index=0; //new code for autoreplace config
489
QString indexString(QString::number(index));
490
QString regexString("Regex");
491
QString directString("Direction");
492
QString patternString("Pattern");
493
QString replaceString("Replace");
494
while (cgAutoreplace.hasKey(patternString + indexString))
496
QString pattern = cgAutoreplace.readEntry(patternString + indexString);
497
QString regex = cgAutoreplace.readEntry(regexString + indexString, QString("0"));
498
QString direction = cgAutoreplace.readEntry(directString + indexString, QString("o"));
499
QString replace = cgAutoreplace.readEntry(replaceString + indexString, QString());
500
if (replace.length()>0)
502
int repLen=replace.length()-1;
503
if (replace.at(repLen)=='#')
504
replace=replace.left(repLen);
506
if (pattern.length()>0)
508
int patLen=pattern.length()-1;
509
if (pattern.at(patLen)=='#')
510
pattern=pattern.left(patLen);
513
indexString = QString::number(index);
514
autoreplaceList.append(QStringList() << regex << direction << pattern << replace);
481
516
// Put back the changed autoreplace list
482
517
Preferences::setAutoreplaceList(autoreplaceList);
782
817
void KonversationApplication::openQuickConnectDialog()
784
819
quickConnectDialog = new QuickConnectDialog(mainWindow);
785
connect(quickConnectDialog, SIGNAL(connectClicked(Konversation::ConnectionFlag, const QString&, uint,
786
const QString&, const QString&, const QString&, bool)),
787
m_connectionManager, SLOT(connectTo(Konversation::ConnectionFlag, const QString&, uint,
820
connect(quickConnectDialog, SIGNAL(connectClicked(Konversation::ConnectionFlag, const QString&,
821
const QString&, const QString&, const QString&, const QString&, bool)),
822
m_connectionManager, SLOT(connectTo(Konversation::ConnectionFlag, const QString&, const QString&,
788
823
const QString&, const QString&, const QString&, bool)));
789
824
quickConnectDialog->show();
802
837
//kaddresbook uses the utf separator 0xE120, so treat that as a separator as well
803
838
QString nickServer = nick_server;
804
839
nickServer.replace(QChar(0xE120), "@");
805
ircnick = nickServer.section("@",0,0);
806
serverOrGroup = nickServer.section("@",1);
840
ircnick = nickServer.section('@',0,0);
841
serverOrGroup = nickServer.section('@',1);
809
844
NickInfoPtr KonversationApplication::getNickInfo(const QString &ircnick, const QString &serverOrGroup)
837
872
for (int index=0;index<autoreplaceList.count();index++)
839
874
// get autoreplace definition
840
QString definition=autoreplaceList[index];
875
QStringList definition=autoreplaceList[index];
841
876
// split definition in parts
842
QString regex=definition.section(',',0,0);
843
QString direction=definition.section(',',1,1);
844
QString pattern=definition.section(',',2,2);
845
QString replacement=definition.section(',',3);
877
QString regex=definition.at(0);
878
QString direction=definition.at(1);
879
QString pattern=definition.at(2);
880
QString replacement=definition.at(3);
847
882
QString isDirection=output ? "o" : "i";
874
908
replacement.replace(QString("%%1").arg(capture),captures[capture]);
876
replacement.replace(QRegExp("%[0-9]"),QString());
910
replacement.remove(QRegExp("%[0-9]"));
877
911
// replace input with replacement
878
912
line.replace(index, captures[0].length(), replacement);
879
913
index += replacement.length();
885
QRegExp needleReg("\\b" + QRegExp::escape(pattern) + "\\b");
886
needleReg.setCaseSensitivity(Qt::CaseInsensitive);
887
line.replace(needleReg,replacement);
919
QRegExp needleReg(pattern);
920
needleReg.setPatternSyntax(QRegExp::FixedString);
921
int index=line.indexOf(needleReg);
924
int length,nextLength,patLen,repLen;
925
patLen=pattern.length();
926
repLen=replacement.length();
930
//nextlength is used to account for the replacement taking up less space
932
if (index!=0) before = line.at(index-1);
933
if (line.length() > length) after = line.at(length);
935
if (index==0 || before.isSpace() || before.isPunct())
937
if (line.length() == length || after.isSpace() || after.isPunct())
939
line.replace(index,patLen,replacement);
940
nextLength = index+repLen;
943
index=line.indexOf(needleReg,nextLength);