Skip to content
Permalink
Browse files

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

  • Loading branch information...
haraki committed Jun 21, 2019
1 parent a237fff commit ace306ac1dbb7d7700e49396a3014839132cbcf8
Showing with 248 additions and 42 deletions.
  1. +10 −2 doublefolderpanel.cpp
  2. +9 −1 folderform.cpp
  3. +3 −0 folderform.h
  4. +100 −0 sortdialog.cpp
  5. +10 −0 sortdialog.h
  6. +116 −39 sortdialog.ui
@@ -45,6 +45,7 @@ DoubleFolderPanel::DoubleFolderPanel(QWidget* parent/* = Q_NULLPTR*/)
FilterFlags l_filterFlags = Settings::getInstance()->getLeftFilterSettings();
QStringList l_nameMaskfilters = Settings::getInstance()->getLeftNameMaskFilterSettings();
SectionType l_sortSectionType = Settings::getInstance()->getLeftSortSectionType();
SectionType l_sortSectionType2nd = Settings::getInstance()->getLeftSortSectionType2nd();
SortDirsType l_sortDirsType = Settings::getInstance()->getLeftSortDirsType();
bool l_sortDotFirst = Settings::getInstance()->getLeftSortDotFirst();
Qt::CaseSensitivity l_sortCaseSensitivity = Settings::getInstance()->getLeftSortCaseSensitivity();
@@ -58,6 +59,7 @@ DoubleFolderPanel::DoubleFolderPanel(QWidget* parent/* = Q_NULLPTR*/)
FolderForm* l_folderForm = new FolderForm(l_filterFlags,
l_nameMaskfilters,
l_sortSectionType,
l_sortSectionType2nd,
l_sortDirsType,
l_sortDotFirst,
l_sortCaseSensitivity,
@@ -107,6 +109,7 @@ DoubleFolderPanel::DoubleFolderPanel(QWidget* parent/* = Q_NULLPTR*/)
FilterFlags r_filterFlags = Settings::getInstance()->getRightFilterSettings();
QStringList r_nameMaskfilters = Settings::getInstance()->getRightNameMaskFilterSettings();
SectionType r_sortSectionType = Settings::getInstance()->getRightSortSectionType();
SectionType r_sortSectionType2nd = Settings::getInstance()->getRightSortSectionType2nd();
SortDirsType r_sortDirsType = Settings::getInstance()->getRightSortDirsType();
bool r_sortDotFirst = Settings::getInstance()->getRightSortDotFirst();
Qt::CaseSensitivity r_sortCaseSensitivity = Settings::getInstance()->getRightSortCaseSensitivity();
@@ -120,6 +123,7 @@ DoubleFolderPanel::DoubleFolderPanel(QWidget* parent/* = Q_NULLPTR*/)
FolderForm* r_folderForm = new FolderForm(r_filterFlags,
r_nameMaskfilters,
r_sortSectionType,
r_sortSectionType2nd,
r_sortDirsType,
r_sortDotFirst,
r_sortCaseSensitivity,
@@ -374,27 +378,30 @@ void DoubleFolderPanel::onChangeSortSettings()
}

SectionType sectionType = activeForm->getSortSectionType();
SectionType sectionType2nd = activeForm->getSortSectionType2nd();
SortDirsType dirsType = activeForm->getSortDirsType();
bool dotFirst = activeForm->getSortDotFirst();
Qt::CaseSensitivity caseSensitivity = activeForm->getSortCaseSensitivity();
Qt::SortOrder order = activeForm->getSortOrder();

SortDialog dialog(sectionType, dirsType, dotFirst, caseSensitivity, order, parentWidget());
SortDialog dialog(sectionType, sectionType2nd, dirsType, dotFirst, caseSensitivity, order, parentWidget());
if(dialog.exec() != QDialog::Accepted)
{
return;
}

sectionType = dialog.getSortSectionType();
sectionType2nd = dialog.getSortSectionType2nd();
dirsType = dialog.getSortDirsType();
dotFirst = dialog.getSortDotFirst();
caseSensitivity = dialog.getSortCaseSensitivity();
order = dialog.getSortOrder();

activeForm->setSortSettings(sectionType, dirsType, dotFirst, caseSensitivity, order);
activeForm->setSortSettings(sectionType, sectionType2nd, dirsType, dotFirst, caseSensitivity, order);
if(activeForm->objectName() == "l_folderForm")
{
Settings::getInstance()->setLeftSortSectionType(sectionType);
Settings::getInstance()->setLeftSortSectionType2nd(sectionType2nd);
Settings::getInstance()->setLeftSortDirsType(dirsType);
Settings::getInstance()->setLeftSortDotFirst(dotFirst);
Settings::getInstance()->setLeftSortCaseSensitivity(caseSensitivity);
@@ -403,6 +410,7 @@ void DoubleFolderPanel::onChangeSortSettings()
else
{
Settings::getInstance()->setRightSortSectionType(sectionType);
Settings::getInstance()->setRightSortSectionType2nd(sectionType2nd);
Settings::getInstance()->setRightSortDirsType(dirsType);
Settings::getInstance()->setRightSortDotFirst(dotFirst);
Settings::getInstance()->setRightSortCaseSensitivity(caseSensitivity);
@@ -14,6 +14,7 @@ namespace Farman
FolderForm::FolderForm(FilterFlags filterFlags,
const QStringList& nameMaskFilters,
SectionType sortSectionType,
SectionType sortSectionType2nd,
SortDirsType sortDirsType,
bool sortDotFirst,
Qt::CaseSensitivity sortCaseSensitivity,
@@ -33,7 +34,7 @@ FolderForm::FolderForm(FilterFlags filterFlags,

setFilterFlags(filterFlags);
setNameMaskFilters(nameMaskFilters);
setSortSettings(sortSectionType, sortDirsType, sortDotFirst, sortCaseSensitivity, sortOrder);
setSortSettings(sortSectionType, sortSectionType2nd, sortDirsType, sortDotFirst, sortCaseSensitivity, sortOrder);

ui->folderView->setModel(m_folderModel);

@@ -146,12 +147,14 @@ QStringList FolderForm::getNameMaskFilters() const
}

void FolderForm::setSortSettings(SectionType sectionType,
SectionType sectionType2nd,
SortDirsType dirsType,
bool dotFirst,
Qt::CaseSensitivity caseSensitivity,
Qt::SortOrder order)
{
m_folderModel->setSortSectionType(sectionType);
m_folderModel->setSortSectionType2nd(sectionType2nd);
m_folderModel->setSortDirsType(dirsType);
m_folderModel->setSortDotFirst(dotFirst);
m_folderModel->setSortCaseSensitivity(caseSensitivity);
@@ -163,6 +166,11 @@ SectionType FolderForm::getSortSectionType() const
return m_folderModel->sortSectionType();
}

SectionType FolderForm::getSortSectionType2nd() const
{
return m_folderModel->sortSectionType2nd();
}

int FolderForm::getSortColumn() const
{
return m_folderModel->sortColumn();
@@ -24,6 +24,7 @@ class FolderForm : public QWidget
explicit FolderForm(FilterFlags filterFlags,
const QStringList& nameMaskFilters,
SectionType sortSectionType,
SectionType sortSectionType2nd,
SortDirsType sortDirsType,
bool sortDotFirst,
Qt::CaseSensitivity sortCaseSensitivity,
@@ -43,11 +44,13 @@ class FolderForm : public QWidget
QStringList getNameMaskFilters() const;

void setSortSettings(SectionType sectionType,
SectionType sectionType2nd,
SortDirsType dirsType,
bool dotFirst,
Qt::CaseSensitivity caseSensitivity,
Qt::SortOrder order);
SectionType getSortSectionType() const;
SectionType getSortSectionType2nd() const;
int getSortColumn() const;
SortDirsType getSortDirsType() const;
bool getSortDotFirst() const;
@@ -6,6 +6,7 @@ namespace Farman
{

SortDialog::SortDialog(SectionType sectionType,
SectionType sectionType2nd,
SortDirsType dirsType,
bool dotFirst,
Qt::CaseSensitivity caseSensitivity,
@@ -14,28 +15,54 @@ SortDialog::SortDialog(SectionType sectionType,
QDialog(parent),
ui(new Ui::SortDialog),
m_sortSectionType(sectionType),
m_sortSectionType2nd(sectionType2nd),
m_sortDirsType(dirsType),
m_sortDotFirst(dotFirst),
m_sortCaseSensitivity(caseSensitivity),
m_sortOrder(order)
{
ui->setupUi(this);

if(sectionType2nd == SectionType::LastModified)
{
ui->sort2ndLastModifiedRadioButton->setChecked(true);
}
else if(sectionType2nd == SectionType::FileSize)
{
ui->sort2ndSizeRadioButton->setChecked(true);
}
else if(sectionType2nd == SectionType::FileType)
{
ui->sort2ndTypeRadioButton->setChecked(true);
}
else if(sectionType2nd == SectionType::FileName)
{
ui->sort2ndNameRadioButton->setChecked(true);
}
else
{
ui->sort2ndNoSpecifyRadioButton->setChecked(true);
}

if(sectionType == SectionType::LastModified)
{
ui->sortLastModifiedRadioButton->setChecked(true);
setSort2ndEnabled(true, true, true, false);
}
else if(sectionType == SectionType::FileSize)
{
ui->sortSizeRadioButton->setChecked(true);
setSort2ndEnabled(true, true, false, true);
}
else if(sectionType == SectionType::FileType)
{
ui->sortTypeRadioButton->setChecked(true);
setSort2ndEnabled(true, false, true, true);
}
else
{
ui->sortNameRadioButton->setChecked(true);
setSort2ndEnabled(false, true, true, true);
}

if(order == Qt::DescendingOrder)
@@ -80,6 +107,11 @@ SectionType SortDialog::getSortSectionType()
return m_sortSectionType;
}

SectionType SortDialog::getSortSectionType2nd()
{
return m_sortSectionType2nd;
}

SortDirsType SortDialog::getSortDirsType()
{
return m_sortDirsType;
@@ -100,6 +132,26 @@ Qt::SortOrder SortDialog::getSortOrder()
return m_sortOrder;
}

void SortDialog::on_sortNameRadioButton_clicked()
{
setSort2ndEnabled(false, true, true, true);
}

void SortDialog::on_sortTypeRadioButton_clicked()
{
setSort2ndEnabled(true, false, true, true);
}

void SortDialog::on_sortSizeRadioButton_clicked()
{
setSort2ndEnabled(true, true, false, true);
}

void SortDialog::on_sortLastModifiedRadioButton_clicked()
{
setSort2ndEnabled(true, true, true, false);
}

void SortDialog::accept()
{
if(ui->sortLastModifiedRadioButton->isChecked())
@@ -119,6 +171,27 @@ void SortDialog::accept()
m_sortSectionType = SectionType::FileName;
}

if(ui->sort2ndLastModifiedRadioButton->isChecked())
{
m_sortSectionType2nd = SectionType::LastModified;
}
else if(ui->sort2ndSizeRadioButton->isChecked())
{
m_sortSectionType2nd = SectionType::FileSize;
}
else if(ui->sort2ndTypeRadioButton->isChecked())
{
m_sortSectionType2nd = SectionType::FileType;
}
else if(ui->sort2ndNameRadioButton->isChecked())
{
m_sortSectionType2nd = SectionType::FileName;
}
else
{
m_sortSectionType2nd = SectionType::NoSpecify;
}

if(ui->orderDescendingRadioButton->isChecked())
{
m_sortOrder = Qt::DescendingOrder;
@@ -153,4 +226,31 @@ void SortDialog::accept()
QDialog::accept();
}

void SortDialog::setSort2ndEnabled(bool name, bool type, bool size, bool lastModified)
{
if(!name && ui->sort2ndNameRadioButton->isChecked())
{
ui->sort2ndNoSpecifyRadioButton->setChecked(true);
}
ui->sort2ndNameRadioButton->setEnabled(name);

if(!type && ui->sort2ndTypeRadioButton->isChecked())
{
ui->sort2ndNoSpecifyRadioButton->setChecked(true);
}
ui->sort2ndTypeRadioButton->setEnabled(type);

if(!size && ui->sort2ndSizeRadioButton->isChecked())
{
ui->sort2ndNoSpecifyRadioButton->setChecked(true);
}
ui->sort2ndSizeRadioButton->setEnabled(size);

if(!lastModified && ui->sort2ndLastModifiedRadioButton->isChecked())
{
ui->sort2ndNoSpecifyRadioButton->setChecked(true);
}
ui->sort2ndLastModifiedRadioButton->setEnabled(lastModified);
}

} // namespace Farman
@@ -18,6 +18,7 @@ class SortDialog : public QDialog

public:
explicit SortDialog(SectionType sectionType,
SectionType sectionType2nd,
SortDirsType dirsType,
bool dotFirst,
Qt::CaseSensitivity caseSensitivity,
@@ -26,17 +27,26 @@ class SortDialog : public QDialog
~SortDialog() Q_DECL_OVERRIDE;

SectionType getSortSectionType();
SectionType getSortSectionType2nd();
SortDirsType getSortDirsType();
bool getSortDotFirst();
Qt::CaseSensitivity getSortCaseSensitivity();
Qt::SortOrder getSortOrder();

private slots:
void on_sortNameRadioButton_clicked();
void on_sortTypeRadioButton_clicked();
void on_sortSizeRadioButton_clicked();
void on_sortLastModifiedRadioButton_clicked();

private:
void accept() Q_DECL_OVERRIDE;
void setSort2ndEnabled(bool name, bool type, bool size, bool lastModified);

Ui::SortDialog *ui;

SectionType m_sortSectionType;
SectionType m_sortSectionType2nd;
SortDirsType m_sortDirsType;
bool m_sortDotFirst;
Qt::CaseSensitivity m_sortCaseSensitivity;

0 comments on commit ace306a

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