Browse Source

DocumentsDir: some non-functional updates

tags/1.4
Sven Oliver Moll 10 months ago
parent
commit
079ba2c974
2 changed files with 40 additions and 9 deletions
  1. 3
    5
      src/fridgegrid/DocumentsDir.cpp
  2. 37
    4
      src/fridgegrid/DocumentsDir.hpp

+ 3
- 5
src/fridgegrid/DocumentsDir.cpp View File

@@ -25,7 +25,6 @@
#define SETTINGS_CREATETEMPLATESDIR "CreateTemplatesDir"

DocumentsDir::DocumentsDir()
: mDir()
{
QSettings settings;
QDir templatesDir( getTemplatesDirName() );
@@ -34,9 +33,9 @@ DocumentsDir::DocumentsDir()
{
settings.setValue( SETTINGS_CREATETEMPLATESDIR, true );
}
mUseDocDir = settings.value( SETTINGS_CREATETEMPLATESDIR ).toBool();

if( !templatesDir.exists() &&
settings.value( SETTINGS_CREATETEMPLATESDIR ).toBool() )
if( mUseDocDir && !templatesDir.exists() )
{
generateTemplateDir();
}
@@ -51,8 +50,7 @@ QFileInfoList DocumentsDir::getTemplates() const

QString DocumentsDir::getTemplatesDirName() const
{
QSettings settings;
if( settings.value( SETTINGS_CREATETEMPLATESDIR ).toBool() )
if( mUseDocDir )
{
return QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation ) +
"/" + QCoreApplication::applicationName() + "/Templates";

+ 37
- 4
src/fridgegrid/DocumentsDir.hpp View File

@@ -25,22 +25,55 @@
/* forward declaration of local classes */


/*!
\brief A small abstraction layer that copies the template data
to documents directory.


*/
class DocumentsDir
{
public:
/*!
\brief standard contructor

*/
DocumentsDir();

/*!
\brief get a list of template files (full path)

\return QFileInfoList
*/
QFileInfoList getTemplates() const;

private:
/*!
\brief prohibit copying
*/
DocumentsDir( const DocumentsDir &that );
/*!
\brief prohibit assigning
*/
DocumentsDir &operator=( const DocumentsDir &that );

QDir mDir;
QString getTemplatesDirName() const;
void generateTemplateDir();
/*!
\brief get the full path of the templates directory

This might be either a name pointing to somewhere inside
the Documents directory, or to the compiled-in data.

\return QString full path of templates directory
*/
QString getTemplatesDirName() const;

/*!
\brief get a list of template files (full path)

\return QFileInfoList
*/
void generateTemplateDir();

bool mUseDocDir; /*!< \brief copy internal files to documents */
};

#endif // DOCUMENTSDIR_HPP

Loading…
Cancel
Save