Skip to content
Permalink
Browse files

refs #76

Fixed a bug that crashes when changing filter settings while it is selected.
  • Loading branch information...
haraki committed Jun 5, 2019
1 parent 1530922 commit a4074d1debaecaadfe461f8f05002b51dfcadc62
Showing with 63 additions and 63 deletions.
  1. +58 −54 doublefolderpanel.cpp
  2. +4 −8 folderform.cpp
  3. +1 −1 folderform.h
@@ -328,74 +328,78 @@ void DoubleFolderPanel::onSetPaneMode(PaneMode paneMode)
void DoubleFolderPanel::onChangeSortSettings()
{
FolderForm* activeForm = getActiveFolderForm();
if(activeForm != Q_NULLPTR)
if(activeForm == Q_NULLPTR)
{
SectionType sectionType = activeForm->getSortSectionType();
SortDirsType dirsType = activeForm->getSortDirsType();
bool dotFirst = activeForm->getSortDotFirst();
Qt::CaseSensitivity caseSensitivity = activeForm->getSortCaseSensitivity();
Qt::SortOrder order = activeForm->getSortOrder();
return;
}

SortDialog dialog(sectionType, dirsType, dotFirst, caseSensitivity, order, parentWidget());
if(dialog.exec())
{
sectionType = dialog.getSortSectionType();
dirsType = dialog.getSortDirsType();
dotFirst = dialog.getSortDotFirst();
caseSensitivity = dialog.getSortCaseSensitivity();
order = dialog.getSortOrder();

activeForm->setSortSettings(sectionType, dirsType, dotFirst, caseSensitivity, order);
if(activeForm->objectName() == "l_folderForm")
{
Settings::getInstance()->setLeftSortSectionType(sectionType);
Settings::getInstance()->setLeftSortDirsType(dirsType);
Settings::getInstance()->setLeftSortDotFirst(dotFirst);
Settings::getInstance()->setLeftSortCaseSensitivity(caseSensitivity);
Settings::getInstance()->setLeftSortOrder(order);
}
else
{
Settings::getInstance()->setRightSortSectionType(sectionType);
Settings::getInstance()->setRightSortDirsType(dirsType);
Settings::getInstance()->setRightSortDotFirst(dotFirst);
Settings::getInstance()->setRightSortCaseSensitivity(caseSensitivity);
Settings::getInstance()->setRightSortOrder(order);
}
SectionType sectionType = activeForm->getSortSectionType();
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());
if(dialog.exec())
{
sectionType = dialog.getSortSectionType();
dirsType = dialog.getSortDirsType();
dotFirst = dialog.getSortDotFirst();
caseSensitivity = dialog.getSortCaseSensitivity();
order = dialog.getSortOrder();

activeForm->refresh();
activeForm->setSortSettings(sectionType, dirsType, dotFirst, caseSensitivity, order);
if(activeForm->objectName() == "l_folderForm")
{
Settings::getInstance()->setLeftSortSectionType(sectionType);
Settings::getInstance()->setLeftSortDirsType(dirsType);
Settings::getInstance()->setLeftSortDotFirst(dotFirst);
Settings::getInstance()->setLeftSortCaseSensitivity(caseSensitivity);
Settings::getInstance()->setLeftSortOrder(order);
}
else
{
Settings::getInstance()->setRightSortSectionType(sectionType);
Settings::getInstance()->setRightSortDirsType(dirsType);
Settings::getInstance()->setRightSortDotFirst(dotFirst);
Settings::getInstance()->setRightSortCaseSensitivity(caseSensitivity);
Settings::getInstance()->setRightSortOrder(order);
}

activeForm->refresh();
}
}

void DoubleFolderPanel::onChangeFilterSettings()
{
FolderForm* activeForm = getActiveFolderForm();
if(activeForm != Q_NULLPTR)
if(activeForm == Q_NULLPTR)
{
FilterFlags filterFlags = activeForm->getFilterFlags();
QStringList nameMaskFilters = activeForm->getNameMaskFilters();
return;
}

FilterDialog dialog(filterFlags, nameMaskFilters, parentWidget());
if(dialog.exec())
{
filterFlags = dialog.getFilterFlags();
nameMaskFilters = dialog.getNameMaskFilters();
activeForm->setFilterFlags(filterFlags);
activeForm->setNameMaskFilters(nameMaskFilters);
if(activeForm->objectName() == "l_folderForm")
{
Settings::getInstance()->setLeftFilterSettings(filterFlags);
Settings::getInstance()->setLeftNameMaskFilterSettings(nameMaskFilters);
}
else
{
Settings::getInstance()->setRightFilterSettings(filterFlags);
Settings::getInstance()->setRightNameMaskFilterSettings(nameMaskFilters);
}
FilterFlags filterFlags = activeForm->getFilterFlags();
QStringList nameMaskFilters = activeForm->getNameMaskFilters();

activeForm->refresh();
FilterDialog dialog(filterFlags, nameMaskFilters, parentWidget());
if(dialog.exec())
{
filterFlags = dialog.getFilterFlags();
nameMaskFilters = dialog.getNameMaskFilters();
activeForm->setFilterFlags(filterFlags);
activeForm->setNameMaskFilters(nameMaskFilters);
if(activeForm->objectName() == "l_folderForm")
{
Settings::getInstance()->setLeftFilterSettings(filterFlags);
Settings::getInstance()->setLeftNameMaskFilterSettings(nameMaskFilters);
}
else
{
Settings::getInstance()->setRightFilterSettings(filterFlags);
Settings::getInstance()->setRightNameMaskFilterSettings(nameMaskFilters);
}

activeForm->refresh(true); // 選択状態のファイルがあると refresh でクラッシュするので選択状態を解除する
}
}

@@ -338,18 +338,14 @@ int FolderForm::onGoToParentDir()
return setPath(newPath);
}

void FolderForm::refresh()
void FolderForm::refresh(bool clearSelected/* = false */)
{
m_folderModel->refresh();
#if 0
QModelIndex cursorIndex = ui->folderView->currentIndex();
if(!cursorIndex.isValid() || cursorIndex.parent() != ui->folderView->rootIndex() || cursorIndex.row() < 0)
if(clearSelected)
{
cursorIndex = m_folderModel->index(0, 0, ui->folderView->rootIndex());
m_folderModel->clearSelected();
}

ui->folderView->setCursor(cursorIndex);
#endif
m_folderModel->refresh();
}

int FolderForm::getTotalColumnWidth(int withOutColumn)
@@ -66,7 +66,7 @@ class FolderForm : public QWidget

int onGoToChildDir();
int onGoToParentDir();
void refresh();
void refresh(bool clearSelected = false);

Q_SIGNALS:
void currentChanged(const QFileInfo& newFileInfo, const QFileInfo& oldFileInfo);

0 comments on commit a4074d1

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