qBittorrent
Profile Class Reference

#include <profile.h>

Collaboration diagram for Profile:

Public Member Functions

QString location (SpecialFolder folder) const
 
SettingsPtr applicationSettings (const QString &name) const
 
QString rootPath () const
 
QString configurationName () const
 
QString profileName () const
 
QString toPortablePath (const QString &absolutePath) const
 
QString fromPortablePath (const QString &portablePath) const
 

Static Public Member Functions

static void initInstance (const QString &rootProfilePath, const QString &configurationName, bool convertPathsToProfileRelative)
 
static void freeInstance ()
 
static const Profileinstance ()
 

Private Member Functions

 Profile (const QString &rootProfilePath, const QString &configurationName, bool convertPathsToProfileRelative)
 
 ~Profile ()=default
 
void ensureDirectoryExists (SpecialFolder folder) const
 

Private Attributes

std::unique_ptr< Private::Profilem_profileImpl
 
std::unique_ptr< Private::PathConverterm_pathConverterImpl
 

Static Private Attributes

static Profilem_instance = nullptr
 

Detailed Description

Definition at line 54 of file profile.h.

Constructor & Destructor Documentation

◆ Profile()

Profile::Profile ( const QString &  rootProfilePath,
const QString &  configurationName,
bool  convertPathsToProfileRelative 
)
private

Definition at line 36 of file profile.cpp.

37 {
38  if (rootProfilePath.isEmpty())
39  m_profileImpl = std::make_unique<Private::DefaultProfile>(configurationName);
40  else
41  m_profileImpl = std::make_unique<Private::CustomProfile>(rootProfilePath, configurationName);
42 
46 
47  if (convertPathsToProfileRelative)
48  m_pathConverterImpl = std::make_unique<Private::Converter>(m_profileImpl->basePath());
49  else
50  m_pathConverterImpl = std::make_unique<Private::NoConvertConverter>();
51 }
std::unique_ptr< Private::Profile > m_profileImpl
Definition: profile.h:81
std::unique_ptr< Private::PathConverter > m_pathConverterImpl
Definition: profile.h:82
void ensureDirectoryExists(SpecialFolder folder) const
Definition: profile.cpp:114
QString configurationName() const
Definition: profile.cpp:99

References Cache, Config, configurationName(), Data, ensureDirectoryExists(), m_pathConverterImpl, and m_profileImpl.

Referenced by initInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Profile()

Profile::~Profile ( )
privatedefault

Member Function Documentation

◆ applicationSettings()

SettingsPtr Profile::applicationSettings ( const QString &  name) const

◆ configurationName()

QString Profile::configurationName ( ) const

Definition at line 99 of file profile.cpp.

100 {
101  return m_profileImpl->configurationName();
102 }

References m_profileImpl.

Referenced by initInstance(), and Profile().

Here is the caller graph for this function:

◆ ensureDirectoryExists()

void Profile::ensureDirectoryExists ( SpecialFolder  folder) const
private

Definition at line 114 of file profile.cpp.

115 {
116  const QString locationPath = location(folder);
117  if (!locationPath.isEmpty() && !QDir().mkpath(locationPath))
118  qFatal("Could not create required directory '%s'", qUtf8Printable(locationPath));
119 }
QString location(SpecialFolder folder) const
Definition: profile.cpp:72

References location().

Referenced by Profile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeInstance()

void Profile::freeInstance ( )
static

Definition at line 61 of file profile.cpp.

62 {
63  delete m_instance;
64  m_instance = nullptr;
65 }
static Profile * m_instance
Definition: profile.h:83

References m_instance.

Referenced by Application::cleanup().

Here is the caller graph for this function:

◆ fromPortablePath()

QString Profile::fromPortablePath ( const QString &  portablePath) const

Definition at line 126 of file profile.cpp.

127 {
128  return m_pathConverterImpl->fromPortablePath(portablePath);
129 }

References m_pathConverterImpl.

Referenced by BitTorrent::DBResumeDataStorage::load(), and BitTorrent::BencodeResumeDataStorage::loadTorrentResumeData().

Here is the caller graph for this function:

◆ initInstance()

void Profile::initInstance ( const QString &  rootProfilePath,
const QString &  configurationName,
bool  convertPathsToProfileRelative 
)
static

Definition at line 53 of file profile.cpp.

55 {
56  if (m_instance)
57  return;
58  m_instance = new Profile(rootProfilePath, configurationName, convertPathsToProfileRelative);
59 }
Profile(const QString &rootProfilePath, const QString &configurationName, bool convertPathsToProfileRelative)
Definition: profile.cpp:36

References configurationName(), m_instance, and Profile().

Referenced by Application::Application().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instance()

◆ location()

QString Profile::location ( SpecialFolder  folder) const

Definition at line 72 of file profile.cpp.

73 {
74  QString result;
75  switch (folder)
76  {
78  result = m_profileImpl->cacheLocation();
79  break;
81  result = m_profileImpl->configLocation();
82  break;
84  result = m_profileImpl->dataLocation();
85  break;
87  result = m_profileImpl->downloadLocation();
88  break;
89  }
90 
91  return result;
92 }

References Cache, Config, Data, Downloads, and m_profileImpl.

Referenced by Application::Application(), ensureDirectoryExists(), and specialFolderLocation().

Here is the caller graph for this function:

◆ profileName()

QString Profile::profileName ( ) const

Returns either default name for configuration file (QCoreApplication::applicationName()) or the value, supplied via parameters

Definition at line 104 of file profile.cpp.

105 {
106  return m_profileImpl->profileName();
107 }

References m_profileImpl.

◆ rootPath()

QString Profile::rootPath ( ) const

Definition at line 94 of file profile.cpp.

95 {
96  return m_profileImpl->rootPath();
97 }

References m_profileImpl.

◆ toPortablePath()

QString Profile::toPortablePath ( const QString &  absolutePath) const

Definition at line 121 of file profile.cpp.

122 {
123  return m_pathConverterImpl->toPortablePath(absolutePath);
124 }

References m_pathConverterImpl.

Referenced by BitTorrent::BencodeResumeDataStorage::Worker::store(), and BitTorrent::DBResumeDataStorage::Worker::store().

Here is the caller graph for this function:

Member Data Documentation

◆ m_instance

Profile * Profile::m_instance = nullptr
staticprivate

Definition at line 83 of file profile.h.

Referenced by freeInstance(), initInstance(), and instance().

◆ m_pathConverterImpl

std::unique_ptr<Private::PathConverter> Profile::m_pathConverterImpl
private

Definition at line 82 of file profile.h.

Referenced by fromPortablePath(), Profile(), and toPortablePath().

◆ m_profileImpl

std::unique_ptr<Private::Profile> Profile::m_profileImpl
private

The documentation for this class was generated from the following files: