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())
59 return recipient.trimmed().toLower();
69 QDir dir(networkDirPath(entity));
70 return dir.mkpath(
".");
75 return QString(
"%1/%2").arg(d->rootPath(), entity.
description().trimmed().toLower());
78 bool ChatLogs::renameNetwork(QWidget *parentUi, QString oldName, QString newName)
80 oldName = oldName.trimmed().toLower();
81 newName = newName.trimmed().toLower();
82 if (oldName == newName)
86 QDir dir(d->rootPath());
87 if (!dir.exists(oldName))
93 QMessageBox::StandardButton result = QMessageBox::Ok;
95 if (dir.exists(newName))
97 error = tr(
"Won't transfer chat logs from \"%1\" to \"%2\" as directory \"%2\"" 98 "already exists.").arg(oldName, newName);
100 else if (!dir.rename(oldName, newName))
102 error = tr(
"Failed to transfer chat from \"%1\" to \"%2\"").arg(oldName, newName);
109 result = QMessageBox::warning(parentUi, tr(
"Chat logs transfer"), error,
110 QMessageBox::Ignore | QMessageBox::Retry | QMessageBox::Abort);
111 if (result != QMessageBox::Retry)
113 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.