diff --git a/src/dialogs/XrefsDialog.cpp b/src/dialogs/XrefsDialog.cpp index b372ddd0..ed5195a5 100644 --- a/src/dialogs/XrefsDialog.cpp +++ b/src/dialogs/XrefsDialog.cpp @@ -2,6 +2,7 @@ #include "ui_XrefsDialog.h" #include "utils/TempConfig.h" +#include "utils/Helpers.h" #include "MainWindow.h" @@ -48,10 +49,7 @@ void XrefsDialog::fillRefs(QList refs, QList x ui->fromTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content - int count = ui->fromTreeWidget->columnCount(); - for (int i = 0; i != count; ++i) { - ui->fromTreeWidget->resizeColumnToContents(i); - } + qhelpers::adjustColumns(ui->fromTreeWidget, 0); /* Fill Xrefs */ ui->toTreeWidget->clear(); @@ -66,10 +64,7 @@ void XrefsDialog::fillRefs(QList refs, QList x ui->toTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content - int count2 = ui->toTreeWidget->columnCount(); - for (int i = 0; i != count2; ++i) { - ui->toTreeWidget->resizeColumnToContents(i); - } + qhelpers::adjustColumns(ui->toTreeWidget, 0); } void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) diff --git a/src/widgets/ClassesWidget.cpp b/src/widgets/ClassesWidget.cpp index 4804b7fb..09102d9e 100644 --- a/src/widgets/ClassesWidget.cpp +++ b/src/widgets/ClassesWidget.cpp @@ -260,9 +260,7 @@ void ClassesWidget::refreshClasses() : CutterCore::getInstance()->getAllClassesFromFlags(); model->endReload(); - ui->classesTreeView->resizeColumnToContents(0); - ui->classesTreeView->resizeColumnToContents(1); - ui->classesTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->classesTreeView, 3, 0); ui->classesTreeView->setColumnWidth(0, 200); } diff --git a/src/widgets/ExportsWidget.cpp b/src/widgets/ExportsWidget.cpp index c2b2c53f..f0e539a4 100644 --- a/src/widgets/ExportsWidget.cpp +++ b/src/widgets/ExportsWidget.cpp @@ -151,9 +151,7 @@ void ExportsWidget::refreshExports() exports = CutterCore::getInstance()->getAllExports(); exports_model->endReloadExports(); - ui->exportsTreeView->resizeColumnToContents(0); - ui->exportsTreeView->resizeColumnToContents(1); - ui->exportsTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->exportsTreeView, 3, 0); } diff --git a/src/widgets/FlagsWidget.cpp b/src/widgets/FlagsWidget.cpp index bc44f015..2b5dca82 100644 --- a/src/widgets/FlagsWidget.cpp +++ b/src/widgets/FlagsWidget.cpp @@ -227,8 +227,7 @@ void FlagsWidget::refreshFlags() flags = CutterCore::getInstance()->getAllFlags(flagspace); flags_model->endReloadFlags(); - ui->flagsTreeView->resizeColumnToContents(0); - ui->flagsTreeView->resizeColumnToContents(1); + qhelpers::adjustColumns(ui->flagsTreeView, 2, 0); // TODO: this is not a very good place for the following: diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index 67d3cc87..fcacdb74 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -397,9 +397,7 @@ void FunctionsWidget::refreshTree() functionModel->endReloadFunctions(); // resize offset and size columns - ui->functionsTreeView->resizeColumnToContents(0); - ui->functionsTreeView->resizeColumnToContents(1); - ui->functionsTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->functionsTreeView, 3, 0); } void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index) diff --git a/src/widgets/SdbDock.cpp b/src/widgets/SdbDock.cpp index f0d18747..8d7567b2 100644 --- a/src/widgets/SdbDock.cpp +++ b/src/widgets/SdbDock.cpp @@ -2,6 +2,7 @@ #include "ui_SdbDock.h" #include "MainWindow.h" +#include "utils/Helpers.h" #include #include @@ -40,8 +41,7 @@ void SdbDock::reload(QString _path) Qt::ItemIsDragEnabled | Qt::ItemIsEditable); ui->treeWidget->insertTopLevelItem(0, tempItem); } - ui->treeWidget->resizeColumnToContents(0); - ui->treeWidget->resizeColumnToContents(1); + qhelpers::adjustColumns(ui->treeWidget, 0); /* namespaces */ keys = CutterCore::getInstance()->sdbList(path); keys.append(".."); @@ -51,8 +51,7 @@ void SdbDock::reload(QString _path) tempItem->setText(1, ""); ui->treeWidget->insertTopLevelItem(0, tempItem); } - ui->treeWidget->resizeColumnToContents(0); - ui->treeWidget->resizeColumnToContents(1); + qhelpers::adjustColumns(ui->treeWidget, 0); } diff --git a/src/widgets/SearchWidget.cpp b/src/widgets/SearchWidget.cpp index 153367be..c23d22aa 100644 --- a/src/widgets/SearchWidget.cpp +++ b/src/widgets/SearchWidget.cpp @@ -189,9 +189,7 @@ void SearchWidget::refreshSearch() search = Core()->getAllSearch(search_for, searchspace); search_model->endReloadSearch(); - ui->searchTreeView->resizeColumnToContents(0); - ui->searchTreeView->resizeColumnToContents(1); - ui->searchTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->searchTreeView, 3, 0); } void SearchWidget::setScrollMode() diff --git a/src/widgets/SidebarWidget.cpp b/src/widgets/SidebarWidget.cpp index 517a404f..a5a2ceee 100644 --- a/src/widgets/SidebarWidget.cpp +++ b/src/widgets/SidebarWidget.cpp @@ -141,10 +141,7 @@ void SidebarWidget::fillRefs(QList refs, QList ui->xrefFromTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content - int count = ui->xrefFromTreeWidget->columnCount(); - for (int i = 0; i != count; ++i) { - ui->xrefFromTreeWidget->resizeColumnToContents(i); - } + qhelpers::adjustColumns(ui->xrefFromTreeWidget, 0); ui->xrefToTreeWidget->clear(); for (int i = 0; i < xrefs.size(); ++i) { @@ -163,10 +160,7 @@ void SidebarWidget::fillRefs(QList refs, QList ui->xrefToTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content - int count2 = ui->xrefToTreeWidget->columnCount(); - for (int i = 0; i != count2; ++i) { - ui->xrefToTreeWidget->resizeColumnToContents(i); - } + qhelpers::adjustColumns(ui->xrefToTreeWidget, 0); } void SidebarWidget::fillOffsetInfo(QString off) @@ -187,10 +181,7 @@ void SidebarWidget::fillOffsetInfo(QString off) } // Adjust column to contents - int count = ui->offsetTreeWidget->columnCount(); - for (int i = 0; i != count; ++i) { - ui->offsetTreeWidget->resizeColumnToContents(i); - } + qhelpers::adjustColumns(ui->offsetTreeWidget, 0); // Add opcode description QStringList description = Core()->cmd("?d. @ " + off).split(": "); diff --git a/src/widgets/StringsWidget.cpp b/src/widgets/StringsWidget.cpp index 084df857..cc0dc489 100644 --- a/src/widgets/StringsWidget.cpp +++ b/src/widgets/StringsWidget.cpp @@ -174,11 +174,7 @@ void StringsWidget::refreshStrings() strings = CutterCore::getInstance()->getAllStrings(); model->endReload(); - ui->stringsTreeView->resizeColumnToContents(0); - ui->stringsTreeView->resizeColumnToContents(1); + qhelpers::adjustColumns(ui->stringsTreeView, 5, 0); if (ui->stringsTreeView->columnWidth(1) > 300) ui->stringsTreeView->setColumnWidth(1, 300); - ui->stringsTreeView->resizeColumnToContents(2); - ui->stringsTreeView->resizeColumnToContents(3); - ui->stringsTreeView->resizeColumnToContents(4); } diff --git a/src/widgets/TypesWidget.cpp b/src/widgets/TypesWidget.cpp index 88ecf8e1..302edfa6 100644 --- a/src/widgets/TypesWidget.cpp +++ b/src/widgets/TypesWidget.cpp @@ -132,9 +132,7 @@ void TypesWidget::refreshTypes() types = CutterCore::getInstance()->getAllTypes(); types_model->endReloadTypes(); - ui->typesTreeView->resizeColumnToContents(0); - ui->typesTreeView->resizeColumnToContents(1); - ui->typesTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->typesTreeView, 3, 0); } void TypesWidget::setScrollMode() diff --git a/src/widgets/VTablesWidget.cpp b/src/widgets/VTablesWidget.cpp index 2fc92237..2da2fd07 100644 --- a/src/widgets/VTablesWidget.cpp +++ b/src/widgets/VTablesWidget.cpp @@ -2,6 +2,8 @@ #include #include "MainWindow.h" +#include "utils/Helpers.h" + #include "VTablesWidget.h" #include "ui_VTablesWidget.h" @@ -173,9 +175,7 @@ void VTablesWidget::refreshVTables() vtables = CutterCore::getInstance()->getAllVTables(); model->endReload(); - ui->vTableTreeView->resizeColumnToContents(0); - ui->vTableTreeView->resizeColumnToContents(1); - ui->vTableTreeView->resizeColumnToContents(2); + qhelpers::adjustColumns(ui->vTableTreeView, 3, 0); ui->vTableTreeView->setColumnWidth(0, 200); }