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);
|
setUniformRowHeights(true);
|
||||||
|
|
||||||
header()->setDefaultAlignment(Qt::AlignLeft);
|
header()->setDefaultAlignment(Qt::AlignLeft);
|
||||||
|
header()->setClickable(true);
|
||||||
|
|
||||||
connect(act, SIGNAL(toggled(bool)),
|
connect(act, SIGNAL(toggled(bool)),
|
||||||
SLOT(setAlternatingRowColorsHelper(bool)));
|
SLOT(setAlternatingRowColorsHelper(bool)));
|
||||||
connect(this, SIGNAL(activated(QModelIndex)),
|
connect(this, SIGNAL(activated(QModelIndex)),
|
||||||
SLOT(rowActivatedHelper(QModelIndex)));
|
SLOT(rowActivatedHelper(QModelIndex)));
|
||||||
|
connect(header(), SIGNAL(sectionClicked(int)),
|
||||||
|
SLOT(headerSectionClicked(int)));
|
||||||
|
|
||||||
m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0);
|
m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0);
|
||||||
m_alwaysAdjustColumnsAction = 0;
|
m_alwaysAdjustColumnsAction = 0;
|
||||||
@@ -110,6 +113,13 @@ void BaseWindow::setModel(QAbstractItemModel *model)
|
|||||||
setAlwaysResizeColumnsToContents(m_alwaysAdjustColumnsAction->isChecked());
|
setAlwaysResizeColumnsToContents(m_alwaysAdjustColumnsAction->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWindow::mousePressEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
QTreeView::mousePressEvent(ev);
|
||||||
|
if (!indexAt(ev->pos()).isValid())
|
||||||
|
resizeColumnsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWindow::resizeColumnsToContents()
|
void BaseWindow::resizeColumnsToContents()
|
||||||
{
|
{
|
||||||
const int columnCount = model()->columnCount();
|
const int columnCount = model()->columnCount();
|
||||||
@@ -124,6 +134,11 @@ void BaseWindow::setAlwaysResizeColumnsToContents(bool on)
|
|||||||
header()->setResizeMode(0, mode);
|
header()->setResizeMode(0, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWindow::headerSectionClicked(int logicalIndex)
|
||||||
|
{
|
||||||
|
resizeColumnToContents(logicalIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWindow::reset()
|
void BaseWindow::reset()
|
||||||
{
|
{
|
||||||
QTreeView::reset();
|
QTreeView::reset();
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
|
|
||||||
void setModel(QAbstractItemModel *model);
|
void setModel(QAbstractItemModel *model);
|
||||||
virtual void rowActivated(const QModelIndex &) {}
|
virtual void rowActivated(const QModelIndex &) {}
|
||||||
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void resizeColumnsToContents();
|
void resizeColumnsToContents();
|
||||||
@@ -59,6 +60,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
|
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
|
||||||
void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); }
|
void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); }
|
||||||
|
void headerSectionClicked(int logicalIndex);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user