Skip to content
Permalink
Browse files

add secondary sort type to Settings.(refs #54)

  • Loading branch information...
haraki committed Jun 21, 2019
1 parent ea4714d commit 97975a44d972bdd6ad8712e3a1a35c2c57c6c08a
Showing with 39 additions and 0 deletions.
  1. +1 −0 default_settings.h
  2. +29 −0 settings.cpp
  3. +8 −0 settings.h
  4. +1 −0 types.h
@@ -28,6 +28,7 @@ static Q_DECL_CONSTEXPR FolderAtStartup DEFAULT_FOLDER_AT_STARTUP_TYPE = FolderA
static Q_DECL_CONSTEXPR char DEFAULT_FOLDER_PATH_AT_STARTUP[] = "";

static Q_DECL_CONSTEXPR SectionType DEFAULT_SORT_SECTION_TYPE = SectionType::FileName;
static Q_DECL_CONSTEXPR SectionType DEFAULT_SORT_SECTION_TYPE_2ND = SectionType::NoSpecify;
static Q_DECL_CONSTEXPR SortDirsType DEFAULT_SORT_DIRS_TYPE = SortDirsType::NoSpecify;
static Q_DECL_CONSTEXPR bool DEFAULT_SORT_DOT_FIRST = true;
static Q_DECL_CONSTEXPR Qt::CaseSensitivity DEFAULT_SORT_CASE_SENSITIVITY = Qt::CaseInsensitive;
@@ -91,13 +91,15 @@ void Settings::initialize()

// Left side Sort settings
m_leftSortSectionType = getValueSortSectionType("left");
m_leftSortSectionType2nd = getValueSortSectionType2nd("left");
m_leftSortDirsType = getValueSortDirsType("left");
m_leftSortDotFirst = getValueSortDotFirst("left");
m_leftSortCaseSensitivity = getValueSortCaseSensitivity("left");
m_leftSortOrder = getValueSortOrder("left");

// Right side Sort settings
m_rightSortSectionType = getValueSortSectionType("right");
m_rightSortSectionType2nd = getValueSortSectionType2nd("right");
m_rightSortDirsType = getValueSortDirsType("right");
m_rightSortDotFirst = getValueSortDotFirst("right");
m_rightSortCaseSensitivity = getValueSortCaseSensitivity("right");
@@ -318,13 +320,15 @@ void Settings::flush()

// Left side Sort settings
setValueSortSectionType(m_leftSortSectionType, "left");
setValueSortSectionType2nd(m_leftSortSectionType2nd, "left");
setValueSortDirsType(m_leftSortDirsType, "left");
setValueSortDotFirst(m_leftSortDotFirst, "left");
setValueSortCaseSensitivity(m_leftSortCaseSensitivity, "left");
setValueSortOrder(m_leftSortOrder, "left");

// Right side Sort settings
setValueSortSectionType(m_rightSortSectionType, "right");
setValueSortSectionType2nd(m_rightSortSectionType2nd, "right");
setValueSortDirsType(m_rightSortDirsType, "right");
setValueSortDotFirst(m_rightSortDotFirst, "right");
setValueSortCaseSensitivity(m_rightSortCaseSensitivity, "right");
@@ -595,6 +599,21 @@ SectionType Settings::getValueSortSectionType(const QString& prefix)
return ret;
}

SectionType Settings::getValueSortSectionType2nd(const QString& prefix)
{
SectionType ret = DEFAULT_SORT_SECTION_TYPE_2ND;

QString sortTypeValue = value("main/" + prefix + "SortType2nd").toString();
ret = (sortTypeValue == "lastModified") ? SectionType::LastModified :
(sortTypeValue == "size") ? SectionType::FileSize :
(sortTypeValue == "type") ? SectionType::FileType :
(sortTypeValue == "name") ? SectionType::FileName :
(sortTypeValue == "none") ? SectionType::NoSpecify :
DEFAULT_SORT_SECTION_TYPE_2ND;

return ret;
}

SortDirsType Settings::getValueSortDirsType(const QString& prefix)
{
SortDirsType ret = DEFAULT_SORT_DIRS_TYPE;
@@ -646,6 +665,16 @@ void Settings::setValueSortSectionType(SectionType sectionType, const QString& p
setValue("main/" + prefix + "SortType", sortTypeValue);
}

void Settings::setValueSortSectionType2nd(SectionType sectionType2nd, const QString& prefix)
{
QString sortTypeValue = (sectionType2nd == SectionType::LastModified) ? "lastModified" :
(sectionType2nd == SectionType::FileSize) ? "size" :
(sectionType2nd == SectionType::FileType) ? "type" :
(sectionType2nd == SectionType::FileName) ? "name" :
"none";
setValue("main/" + prefix + "SortType2nd", sortTypeValue);
}

void Settings::setValueSortDirsType(SortDirsType dirsType, const QString& prefix)
{
QString sortDirsValue = (dirsType == SortDirsType::First) ? "first" :
@@ -62,22 +62,26 @@ class Settings : public QSettings
void setRightFolderPath(const QString& rightFolderPath) { m_rightFolderPath = rightFolderPath; }

SectionType getLeftSortSectionType() { return m_leftSortSectionType; }
SectionType getLeftSortSectionType2nd() { return m_leftSortSectionType2nd; }
SortDirsType getLeftSortDirsType() { return m_leftSortDirsType; }
bool getLeftSortDotFirst() { return m_leftSortDotFirst; }
Qt::CaseSensitivity getLeftSortCaseSensitivity() { return m_leftSortCaseSensitivity; }
Qt::SortOrder getLeftSortOrder() { return m_leftSortOrder; }
void setLeftSortSectionType(SectionType sectionType) { m_leftSortSectionType = sectionType; }
void setLeftSortSectionType2nd(SectionType sectionType2nd) { m_leftSortSectionType2nd = sectionType2nd; }
void setLeftSortDirsType(SortDirsType dirsType) { m_leftSortDirsType = dirsType; }
void setLeftSortDotFirst(bool dotFirst) { m_leftSortDotFirst = dotFirst; }
void setLeftSortCaseSensitivity(Qt::CaseSensitivity caseSensitivity) { m_leftSortCaseSensitivity = caseSensitivity; }
void setLeftSortOrder(Qt::SortOrder order) { m_leftSortOrder = order; }

SectionType getRightSortSectionType() { return m_rightSortSectionType; }
SectionType getRightSortSectionType2nd() { return m_rightSortSectionType2nd; }
SortDirsType getRightSortDirsType() { return m_rightSortDirsType; }
bool getRightSortDotFirst() { return m_rightSortDotFirst; }
Qt::CaseSensitivity getRightSortCaseSensitivity() { return m_rightSortCaseSensitivity; }
Qt::SortOrder getRightSortOrder() { return m_rightSortOrder; }
void setRightSortSectionType(SectionType sectionType) { m_rightSortSectionType = sectionType; }
void setRightSortSectionType2nd(SectionType sectionType2nd) { m_rightSortSectionType2nd = sectionType2nd; }
void setRightSortDirsType(SortDirsType dirsType) { m_rightSortDirsType = dirsType; }
void setRightSortDotFirst(bool dotFirst) { m_rightSortDotFirst = dotFirst; }
void setRightSortCaseSensitivity(Qt::CaseSensitivity caseSensitivity) { m_rightSortCaseSensitivity = caseSensitivity; }
@@ -192,11 +196,13 @@ class Settings : public QSettings
QColor getValueColorSetting(const QString& key, const QColor& defColor);

SectionType getValueSortSectionType(const QString& prefix);
SectionType getValueSortSectionType2nd(const QString& prefix);
SortDirsType getValueSortDirsType(const QString& prefix);
bool getValueSortDotFirst(const QString& prefix);
Qt::CaseSensitivity getValueSortCaseSensitivity(const QString& prefix);
Qt::SortOrder getValueSortOrder(const QString& prefix);
void setValueSortSectionType(SectionType sectionType, const QString& prefix);
void setValueSortSectionType2nd(SectionType sectionType2nd, const QString& prefix);
void setValueSortDirsType(SortDirsType dirsType, const QString& prefix);
void setValueSortDotFirst(bool dotFirst, const QString& prefix);
void setValueSortCaseSensitivity(Qt::CaseSensitivity caseSensitivity, const QString& prefix);
@@ -226,11 +232,13 @@ class Settings : public QSettings
QString m_rightFolderPath = DEFAULT_FOLDER_PATH_AT_STARTUP;

SectionType m_leftSortSectionType = DEFAULT_SORT_SECTION_TYPE;
SectionType m_leftSortSectionType2nd = DEFAULT_SORT_SECTION_TYPE_2ND;
SortDirsType m_leftSortDirsType = DEFAULT_SORT_DIRS_TYPE;
bool m_leftSortDotFirst = DEFAULT_SORT_DOT_FIRST;
Qt::CaseSensitivity m_leftSortCaseSensitivity = DEFAULT_SORT_CASE_SENSITIVITY;
Qt::SortOrder m_leftSortOrder = DEFAULT_SORT_ORDER;
SectionType m_rightSortSectionType = DEFAULT_SORT_SECTION_TYPE;
SectionType m_rightSortSectionType2nd = DEFAULT_SORT_SECTION_TYPE_2ND;
SortDirsType m_rightSortDirsType = DEFAULT_SORT_DIRS_TYPE;
bool m_rightSortDotFirst = DEFAULT_SORT_DOT_FIRST;
Qt::CaseSensitivity m_rightSortCaseSensitivity = DEFAULT_SORT_CASE_SENSITIVITY;
@@ -61,6 +61,7 @@ enum class SectionType : int
FileType,
FileSize,
LastModified,
NoSpecify,

SectionTypeNum
};

0 comments on commit 97975a4

Please sign in to comment.
You can’t perform that action at this time.