forked from qt-creator/qt-creator
debugger: trigger column resizing by clicks on header or background
Change-Id: I702f9fc32310b01021bf3389c9c8cb88d9a1738a Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -59,11 +59,14 @@ BaseWindow::BaseWindow(QWidget *parent)
|
||||
setUniformRowHeights(true);
|
||||
|
||||
header()->setDefaultAlignment(Qt::AlignLeft);
|
||||
header()->setClickable(true);
|
||||
|
||||
connect(act, SIGNAL(toggled(bool)),
|
||||
SLOT(setAlternatingRowColorsHelper(bool)));
|
||||
connect(this, SIGNAL(activated(QModelIndex)),
|
||||
SLOT(rowActivatedHelper(QModelIndex)));
|
||||
connect(header(), SIGNAL(sectionClicked(int)),
|
||||
SLOT(headerSectionClicked(int)));
|
||||
|
||||
m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0);
|
||||
m_alwaysAdjustColumnsAction = 0;
|
||||
@@ -110,6 +113,13 @@ void BaseWindow::setModel(QAbstractItemModel *model)
|
||||
setAlwaysResizeColumnsToContents(m_alwaysAdjustColumnsAction->isChecked());
|
||||
}
|
||||
|
||||
void BaseWindow::mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
QTreeView::mousePressEvent(ev);
|
||||
if (!indexAt(ev->pos()).isValid())
|
||||
resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void BaseWindow::resizeColumnsToContents()
|
||||
{
|
||||
const int columnCount = model()->columnCount();
|
||||
@@ -124,6 +134,11 @@ void BaseWindow::setAlwaysResizeColumnsToContents(bool on)
|
||||
header()->setResizeMode(0, mode);
|
||||
}
|
||||
|
||||
void BaseWindow::headerSectionClicked(int logicalIndex)
|
||||
{
|
||||
resizeColumnToContents(logicalIndex);
|
||||
}
|
||||
|
||||
void BaseWindow::reset()
|
||||
{
|
||||
QTreeView::reset();
|
||||
|
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
void setModel(QAbstractItemModel *model);
|
||||
virtual void rowActivated(const QModelIndex &) {}
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
|
||||
public slots:
|
||||
void resizeColumnsToContents();
|
||||
@@ -59,6 +60,7 @@ public slots:
|
||||
private slots:
|
||||
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
|
||||
void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); }
|
||||
void headerSectionClicked(int logicalIndex);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user