25 #include "irc/configuration/chatlogscfg.h" 26 #include "irc/entities/ircnetworkentity.h" 28 #include <QMessageBox> 33 QString rootPath()
const 50 QString ChatLogs::logFilePath(
const IRCNetworkEntity &entity,
const QString &recipient)
const 52 return QString(
"%1/%2.txt").arg(networkDirPath(entity), logFileName(recipient));
55 QString ChatLogs::logFileName(
const QString &recipient)
const 57 if (!recipient.trimmed().isEmpty())
58 return recipient.trimmed().toLower();
65 QDir dir(networkDirPath(entity));
66 return dir.mkpath(
".");
71 return QString(
"%1/%2").arg(d->rootPath(), entity.
description().trimmed().toLower());
74 bool ChatLogs::renameNetwork(QWidget *parentUi, QString oldName, QString newName)
76 oldName = oldName.trimmed().toLower();
77 newName = newName.trimmed().toLower();
78 if (oldName == newName)
80 QDir dir(d->rootPath());
81 if (!dir.exists(oldName))
85 QMessageBox::StandardButton result = QMessageBox::Ok;
87 if (dir.exists(newName))
89 error = tr(
"Won't transfer chat logs from \"%1\" to \"%2\" as directory \"%2\"" 90 "already exists.").arg(oldName, newName);
92 else if (!dir.rename(oldName, newName))
93 error = tr(R
"(Failed to transfer chat from "%1" to "%2")").arg(oldName, newName); 97 result = QMessageBox::warning(parentUi, tr(
"Chat logs transfer"), error,
98 QMessageBox::Ignore | QMessageBox::Retry | QMessageBox::Abort);
99 if (result != QMessageBox::Retry)
100 return result == QMessageBox::Ignore;
const QString & description() const
A short, human-readable description for the network. (Preferably a single word).
Data structure that describes and defines a connection to an IRC network or server.