Use qhelpers::adjustColumns in all widgets (#423)

This commit is contained in:
Abdel-Rahman A 2018-04-01 10:25:31 +02:00 committed by xarkes
parent 459aaf482f
commit c8fdf4b193
11 changed files with 19 additions and 49 deletions

View File

@ -2,6 +2,7 @@
#include "ui_XrefsDialog.h" #include "ui_XrefsDialog.h"
#include "utils/TempConfig.h" #include "utils/TempConfig.h"
#include "utils/Helpers.h"
#include "MainWindow.h" #include "MainWindow.h"
@ -48,10 +49,7 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
ui->fromTreeWidget->insertTopLevelItem(0, tempItem); ui->fromTreeWidget->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
int count = ui->fromTreeWidget->columnCount(); qhelpers::adjustColumns(ui->fromTreeWidget, 0);
for (int i = 0; i != count; ++i) {
ui->fromTreeWidget->resizeColumnToContents(i);
}
/* Fill Xrefs */ /* Fill Xrefs */
ui->toTreeWidget->clear(); ui->toTreeWidget->clear();
@ -66,10 +64,7 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
ui->toTreeWidget->insertTopLevelItem(0, tempItem); ui->toTreeWidget->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
int count2 = ui->toTreeWidget->columnCount(); qhelpers::adjustColumns(ui->toTreeWidget, 0);
for (int i = 0; i != count2; ++i) {
ui->toTreeWidget->resizeColumnToContents(i);
}
} }
void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)

View File

@ -260,9 +260,7 @@ void ClassesWidget::refreshClasses()
: CutterCore::getInstance()->getAllClassesFromFlags(); : CutterCore::getInstance()->getAllClassesFromFlags();
model->endReload(); model->endReload();
ui->classesTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->classesTreeView, 3, 0);
ui->classesTreeView->resizeColumnToContents(1);
ui->classesTreeView->resizeColumnToContents(2);
ui->classesTreeView->setColumnWidth(0, 200); ui->classesTreeView->setColumnWidth(0, 200);
} }

View File

@ -151,9 +151,7 @@ void ExportsWidget::refreshExports()
exports = CutterCore::getInstance()->getAllExports(); exports = CutterCore::getInstance()->getAllExports();
exports_model->endReloadExports(); exports_model->endReloadExports();
ui->exportsTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->exportsTreeView, 3, 0);
ui->exportsTreeView->resizeColumnToContents(1);
ui->exportsTreeView->resizeColumnToContents(2);
} }

View File

@ -227,8 +227,7 @@ void FlagsWidget::refreshFlags()
flags = CutterCore::getInstance()->getAllFlags(flagspace); flags = CutterCore::getInstance()->getAllFlags(flagspace);
flags_model->endReloadFlags(); flags_model->endReloadFlags();
ui->flagsTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->flagsTreeView, 2, 0);
ui->flagsTreeView->resizeColumnToContents(1);
// TODO: this is not a very good place for the following: // TODO: this is not a very good place for the following:

View File

@ -397,9 +397,7 @@ void FunctionsWidget::refreshTree()
functionModel->endReloadFunctions(); functionModel->endReloadFunctions();
// resize offset and size columns // resize offset and size columns
ui->functionsTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->functionsTreeView, 3, 0);
ui->functionsTreeView->resizeColumnToContents(1);
ui->functionsTreeView->resizeColumnToContents(2);
} }
void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index) void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index)

View File

@ -2,6 +2,7 @@
#include "ui_SdbDock.h" #include "ui_SdbDock.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "utils/Helpers.h"
#include <QDebug> #include <QDebug>
#include <QTreeWidget> #include <QTreeWidget>
@ -40,8 +41,7 @@ void SdbDock::reload(QString _path)
Qt::ItemIsDragEnabled | Qt::ItemIsEditable); Qt::ItemIsDragEnabled | Qt::ItemIsEditable);
ui->treeWidget->insertTopLevelItem(0, tempItem); ui->treeWidget->insertTopLevelItem(0, tempItem);
} }
ui->treeWidget->resizeColumnToContents(0); qhelpers::adjustColumns(ui->treeWidget, 0);
ui->treeWidget->resizeColumnToContents(1);
/* namespaces */ /* namespaces */
keys = CutterCore::getInstance()->sdbList(path); keys = CutterCore::getInstance()->sdbList(path);
keys.append(".."); keys.append("..");
@ -51,8 +51,7 @@ void SdbDock::reload(QString _path)
tempItem->setText(1, ""); tempItem->setText(1, "");
ui->treeWidget->insertTopLevelItem(0, tempItem); ui->treeWidget->insertTopLevelItem(0, tempItem);
} }
ui->treeWidget->resizeColumnToContents(0); qhelpers::adjustColumns(ui->treeWidget, 0);
ui->treeWidget->resizeColumnToContents(1);
} }

View File

@ -189,9 +189,7 @@ void SearchWidget::refreshSearch()
search = Core()->getAllSearch(search_for, searchspace); search = Core()->getAllSearch(search_for, searchspace);
search_model->endReloadSearch(); search_model->endReloadSearch();
ui->searchTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->searchTreeView, 3, 0);
ui->searchTreeView->resizeColumnToContents(1);
ui->searchTreeView->resizeColumnToContents(2);
} }
void SearchWidget::setScrollMode() void SearchWidget::setScrollMode()

View File

@ -141,10 +141,7 @@ void SidebarWidget::fillRefs(QList<XrefDescription> refs, QList<XrefDescription>
ui->xrefFromTreeWidget->insertTopLevelItem(0, tempItem); ui->xrefFromTreeWidget->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
int count = ui->xrefFromTreeWidget->columnCount(); qhelpers::adjustColumns(ui->xrefFromTreeWidget, 0);
for (int i = 0; i != count; ++i) {
ui->xrefFromTreeWidget->resizeColumnToContents(i);
}
ui->xrefToTreeWidget->clear(); ui->xrefToTreeWidget->clear();
for (int i = 0; i < xrefs.size(); ++i) { for (int i = 0; i < xrefs.size(); ++i) {
@ -163,10 +160,7 @@ void SidebarWidget::fillRefs(QList<XrefDescription> refs, QList<XrefDescription>
ui->xrefToTreeWidget->insertTopLevelItem(0, tempItem); ui->xrefToTreeWidget->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
int count2 = ui->xrefToTreeWidget->columnCount(); qhelpers::adjustColumns(ui->xrefToTreeWidget, 0);
for (int i = 0; i != count2; ++i) {
ui->xrefToTreeWidget->resizeColumnToContents(i);
}
} }
void SidebarWidget::fillOffsetInfo(QString off) void SidebarWidget::fillOffsetInfo(QString off)
@ -187,10 +181,7 @@ void SidebarWidget::fillOffsetInfo(QString off)
} }
// Adjust column to contents // Adjust column to contents
int count = ui->offsetTreeWidget->columnCount(); qhelpers::adjustColumns(ui->offsetTreeWidget, 0);
for (int i = 0; i != count; ++i) {
ui->offsetTreeWidget->resizeColumnToContents(i);
}
// Add opcode description // Add opcode description
QStringList description = Core()->cmd("?d. @ " + off).split(": "); QStringList description = Core()->cmd("?d. @ " + off).split(": ");

View File

@ -174,11 +174,7 @@ void StringsWidget::refreshStrings()
strings = CutterCore::getInstance()->getAllStrings(); strings = CutterCore::getInstance()->getAllStrings();
model->endReload(); model->endReload();
ui->stringsTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->stringsTreeView, 5, 0);
ui->stringsTreeView->resizeColumnToContents(1);
if (ui->stringsTreeView->columnWidth(1) > 300) if (ui->stringsTreeView->columnWidth(1) > 300)
ui->stringsTreeView->setColumnWidth(1, 300); ui->stringsTreeView->setColumnWidth(1, 300);
ui->stringsTreeView->resizeColumnToContents(2);
ui->stringsTreeView->resizeColumnToContents(3);
ui->stringsTreeView->resizeColumnToContents(4);
} }

View File

@ -132,9 +132,7 @@ void TypesWidget::refreshTypes()
types = CutterCore::getInstance()->getAllTypes(); types = CutterCore::getInstance()->getAllTypes();
types_model->endReloadTypes(); types_model->endReloadTypes();
ui->typesTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->typesTreeView, 3, 0);
ui->typesTreeView->resizeColumnToContents(1);
ui->typesTreeView->resizeColumnToContents(2);
} }
void TypesWidget::setScrollMode() void TypesWidget::setScrollMode()

View File

@ -2,6 +2,8 @@
#include <QModelIndex> #include <QModelIndex>
#include "MainWindow.h" #include "MainWindow.h"
#include "utils/Helpers.h"
#include "VTablesWidget.h" #include "VTablesWidget.h"
#include "ui_VTablesWidget.h" #include "ui_VTablesWidget.h"
@ -173,9 +175,7 @@ void VTablesWidget::refreshVTables()
vtables = CutterCore::getInstance()->getAllVTables(); vtables = CutterCore::getInstance()->getAllVTables();
model->endReload(); model->endReload();
ui->vTableTreeView->resizeColumnToContents(0); qhelpers::adjustColumns(ui->vTableTreeView, 3, 0);
ui->vTableTreeView->resizeColumnToContents(1);
ui->vTableTreeView->resizeColumnToContents(2);
ui->vTableTreeView->setColumnWidth(0, 200); ui->vTableTreeView->setColumnWidth(0, 200);
} }