diff options
author | Saturn&Eric <[email protected]> | 2024-05-11 17:18:36 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-11 17:18:36 +0000 |
commit | f909f2c4c35b187eb165ec5545e35d54c6d92bf3 (patch) | |
tree | 428fe9e63ecae6bb93be6f20cd2b1ee9b29ffd8d /src/ui/widgets/FileTreeView.cpp | |
parent | Merge pull request #145 from jermanuts/jermanuts-wizard-links-update (diff) | |
parent | fix: remove qt5compat and redirect dll output path of modules (diff) | |
download | GpgFrontend-f909f2c4c35b187eb165ec5545e35d54c6d92bf3.tar.gz GpgFrontend-f909f2c4c35b187eb165ec5545e35d54c6d92bf3.zip |
Merge pull request #148 from saturneric/develop
Develop 2.1.3.1
Diffstat (limited to 'src/ui/widgets/FileTreeView.cpp')
-rw-r--r-- | src/ui/widgets/FileTreeView.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp index 7a725e10..de22ec83 100644 --- a/src/ui/widgets/FileTreeView.cpp +++ b/src/ui/widgets/FileTreeView.cpp @@ -54,6 +54,10 @@ FileTreeView::FileTreeView(QWidget* parent, const QString& target_path) &FileTreeView::slot_show_custom_context_menu); connect(this, &QTreeView::doubleClicked, this, &FileTreeView::slot_file_tree_view_item_double_clicked); + connect(dir_model_, &QFileSystemModel::layoutChanged, this, + &FileTreeView::slot_adjust_column_widths); + connect(dir_model_, &QFileSystemModel::dataChanged, this, + &FileTreeView::slot_adjust_column_widths); } void FileTreeView::selectionChanged(const QItemSelection& selected, @@ -82,9 +86,7 @@ void FileTreeView::SlotGoPath(const QString& target_path) { GF_UI_LOG_DEBUG("file tree view set target path: {}", current_path_); this->setRootIndex(dir_model_->index(file_info.filePath())); dir_model_->setRootPath(file_info.filePath()); - for (int i = 1; i < dir_model_->columnCount(); ++i) { - this->resizeColumnToContents(i); - } + slot_adjust_column_widths(); } else { QMessageBox::critical( this, tr("Error"), @@ -413,12 +415,21 @@ void FileTreeView::slot_compress_files() {} void FileTreeView::paintEvent(QPaintEvent* event) { QTreeView::paintEvent(event); - for (int i = 1; i < dir_model_->columnCount(); ++i) { - this->resizeColumnToContents(i); + + if (!initial_resize_done_) { + slot_adjust_column_widths(); + initial_resize_done_ = true; } } void FileTreeView::mousePressEvent(QMouseEvent* event) { QTreeView::mousePressEvent(event); } + +void FileTreeView::slot_adjust_column_widths() { + for (int i = 1; i < dir_model_->columnCount(); ++i) { + this->resizeColumnToContents(i); + } +} + } // namespace GpgFrontend::UI |