25 #include "irc/configuration/chatlogscfg.h"
26 #include "irc/entities/ircnetworkentity.h"
27 #include "templatedpathresolver.h"
29 #include <QMessageBox>
34 QString rootPath()
const
51 QString ChatLogs::logFilePath(
const IRCNetworkEntity &entity,
const QString &recipient)
const
53 return QString(
"%1/%2.txt").arg(networkDirPath(entity), logFileName(recipient));
56 QString ChatLogs::logFileName(
const QString &recipient)
const
58 if (!recipient.trimmed().isEmpty())
59 return recipient.trimmed().toLower();
66 QDir dir(networkDirPath(entity));
67 return dir.mkpath(
".");
72 return QString(
"%1/%2").arg(d->rootPath(), entity.
description().trimmed().toLower());
75 bool ChatLogs::renameNetwork(QWidget *parentUi, QString oldName, QString newName)
77 oldName = oldName.trimmed().toLower();
78 newName = newName.trimmed().toLower();
79 if (oldName == newName)
81 QDir dir(d->rootPath());
82 if (!dir.exists(oldName))
86 QMessageBox::StandardButton result = QMessageBox::Ok;
88 if (dir.exists(newName))
90 error = tr(
"Won't transfer chat logs from \"%1\" to \"%2\" as directory \"%2\""
91 " already exists.").arg(oldName, newName);
93 else if (!dir.rename(oldName, newName))
94 error = tr(R
"(Failed to transfer chat from "%1" to "%2")").arg(oldName, newName);
98 result = QMessageBox::warning(parentUi, tr(
"Chat logs transfer"), error,
99 QMessageBox::Ignore | QMessageBox::Retry | QMessageBox::Abort);
100 if (result != QMessageBox::Retry)
101 return result == QMessageBox::Ignore;