Skip to content

Commit

Permalink
resize multiple (selected) cols in Browse Data tab
Browse files Browse the repository at this point in the history
  • Loading branch information
schdub authored and rp- committed Apr 20, 2015
1 parent 1393e8e commit 029f016
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/ExtendedTableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ int ExtendedTableWidget::numVisibleRows()
// Calculate the number of visible rows
return row_bottom - row_top;
}

QSet<int> ExtendedTableWidget::selectedCols()
{
QSet<int> selectedCols;
foreach(const QModelIndex & idx, selectedIndexes())
selectedCols.insert(idx.column());
return selectedCols;
}
4 changes: 4 additions & 0 deletions src/ExtendedTableWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QTableView>
#include "FilterTableHeader.h"
#include <QSet>

class ExtendedTableWidget : public QTableView
{
Expand All @@ -13,6 +14,9 @@ class ExtendedTableWidget : public QTableView

FilterTableHeader* filterHeader() { return m_tableHeader; }

public:
QSet<int> selectedCols();

private:
void copy();
int numVisibleRows();
Expand Down
17 changes: 16 additions & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,22 @@ void MainWindow::on_actionWebsite_triggered()

void MainWindow::updateBrowseDataColumnWidth(int section, int /*old_size*/, int new_size)
{
browseTableColumnWidths[ui->comboBrowseTable->currentText()][section] = new_size;
QSet<int> selectedCols(ui->dataTable->selectedCols());
QString tableName(ui->comboBrowseTable->currentText());
if (!selectedCols.contains(section))
{
browseTableColumnWidths[tableName][section] = new_size;
}
else
{
ui->dataTable->blockSignals(true);
foreach (int col, selectedCols)
{
ui->dataTable->setColumnWidth(col, new_size);
browseTableColumnWidths[tableName][col] = new_size;
}
ui->dataTable->blockSignals(false);
}
}

bool MainWindow::loadProject(QString filename)
Expand Down

0 comments on commit 029f016

Please sign in to comment.