Additional parameters for adjustColumns

- Add columnCount and padding parameter
- Remove unnecessary functions
This commit is contained in:
ballessay 2017-04-13 18:18:56 +02:00 committed by C. Balles
parent 9931d6f484
commit ad0de05654
6 changed files with 9 additions and 27 deletions

View File

@ -44,12 +44,17 @@ namespace qhelpers
return QFileInfo(filename).fileName() + "_" + fullHash.toHex().left(10);
}
void adjustColumns(QTreeWidget *tw)
void adjustColumns(QTreeWidget *tw, int columnCount, int padding)
{
int count = tw->columnCount();
const int count = columnCount == 0 ? tw->columnCount() : columnCount;
for (int i = 0; i != count; ++i)
{
tw->resizeColumnToContents(i);
if (padding > 0)
{
int width = tw->columnWidth(i);
tw->setColumnWidth(i, width + padding);
}
}
}

View File

@ -15,7 +15,7 @@ namespace qhelpers
QString uniqueProjectName(const QString &filename);
void adjustColumns(QTreeWidget *tw);
void adjustColumns(QTreeWidget *tw, int columnCount = 0, int padding = 0);
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());

View File

@ -76,7 +76,7 @@ void ImportsWidget::fillImports()
qhelpers::appendRow(ui->importsTreeWidget, a[1], a[3], "", a[4]);
}
highlightUnsafe();
qhelpers::adjustColumns(ui->importsTreeWidget);
qhelpers::adjustColumns(ui->importsTreeWidget, 0, 10);
}
void ImportsWidget::highlightUnsafe()
@ -110,15 +110,3 @@ void ImportsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->importsTreeWidget);
}
void ImportsWidget::adjustColumns(QTreeWidget *tw)
{
// WARNING: was this ever called.. compare to master
int count = tw->columnCount();
for (int i = 0; i != count; ++i)
{
ui->importsTreeWidget->resizeColumnToContents(i);
int width = ui->importsTreeWidget->columnWidth(i);
ui->importsTreeWidget->setColumnWidth(i, width + 10);
}
}

View File

@ -31,7 +31,6 @@ private:
void fillImports();
void highlightUnsafe();
void setScrollMode();
void adjustColumns(QTreeWidget *tw);
};
class CMyDelegate : public QStyledItemDelegate

View File

@ -105,12 +105,3 @@ void SectionsWidget::fillSections(int row, const QString &str, const QString &st
tempItem->setData(0, Qt::DecorationRole, colors[row % colors.size()]);
this->tree->insertTopLevelItem(0, tempItem);
}
void SectionsWidget::adjustColumns()
{
int count = 4;
for (int i = 0; i != count; ++i)
{
this->tree->resizeColumnToContents(i);
}
}

View File

@ -33,7 +33,6 @@ private:
void fillSections(int row, const QString &str, const QString &str2 = QString(),
const QString &str3 = QString(), const QString &str4 = QString());
void adjustColumns();
};
#endif // SECTIONSWIDGET_H