Debugger: Resize columns correctly in Threads Window.

This commit is contained in:
Friedemann Kleint
2009-10-20 16:44:42 +02:00
parent 29475a0d27
commit a02f8cb496
2 changed files with 16 additions and 34 deletions

View File

@@ -30,18 +30,11 @@
#include "threadswindow.h" #include "threadswindow.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "stackhandler.h"
#include <utils/qtcassert.h> #include <QtGui/QAction>
#include <QtGui/QContextMenuEvent>
#include <QAction> #include <QtGui/QHeaderView>
#include <QComboBox> #include <QtGui/QMenu>
#include <QDebug>
#include <QHeaderView>
#include <QMenu>
#include <QResizeEvent>
#include <QTreeView>
#include <QVBoxLayout>
using Debugger::Internal::ThreadsWindow; using Debugger::Internal::ThreadsWindow;
@@ -63,46 +56,38 @@ ThreadsWindow::ThreadsWindow(QWidget *parent)
this, SLOT(setAlternatingRowColorsHelper(bool))); this, SLOT(setAlternatingRowColorsHelper(bool)));
} }
void ThreadsWindow::resizeEvent(QResizeEvent *event)
{
//QHeaderView *hv = header();
//int totalSize = event->size().width() - 120;
//hv->resizeSection(0, 45);
//hv->resizeSection(1, totalSize);
//hv->resizeSection(2, 55);
QTreeView::resizeEvent(event);
}
void ThreadsWindow::rowActivated(const QModelIndex &index) void ThreadsWindow::rowActivated(const QModelIndex &index)
{ {
//qDebug() << "ACTIVATED: " << index.row() << index.column();
emit threadSelected(index.row()); emit threadSelected(index.row());
} }
void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev) void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu menu; QMenu menu;
QAction *act1 = menu.addAction(tr("Adjust column widths to contents")); QAction *adjustColumnAction = menu.addAction(tr("Adjust column widths to contents"));
QAction *act2 = menu.addAction(tr("Always adjust column widths to contents")); QAction *alwaysAdjustColumnAction = menu.addAction(tr("Always adjust column widths to contents"));
act2->setCheckable(true); alwaysAdjustColumnAction->setCheckable(true);
act2->setChecked(m_alwaysResizeColumnsToContents); alwaysAdjustColumnAction->setChecked(m_alwaysResizeColumnsToContents);
menu.addSeparator(); menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog)); menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos()); QAction *act = menu.exec(ev->globalPos());
if(!act)
return;
if (act == act1) if (act == adjustColumnAction) {
resizeColumnsToContents(); resizeColumnsToContents();
else if (act == act2) } else if (act == alwaysAdjustColumnAction) {
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
} }
}
void ThreadsWindow::resizeColumnsToContents() void ThreadsWindow::resizeColumnsToContents()
{ {
resizeColumnToContents(0); const int columnCount = model()->columnCount();
//resizeColumnToContents(1); for (int c = 0 ; c < columnCount; c++)
resizeColumnToContents(c);
} }
void ThreadsWindow::setAlwaysResizeColumnsToContents(bool on) void ThreadsWindow::setAlwaysResizeColumnsToContents(bool on)
@@ -111,6 +96,4 @@ void ThreadsWindow::setAlwaysResizeColumnsToContents(bool on)
QHeaderView::ResizeMode mode = on QHeaderView::ResizeMode mode = on
? QHeaderView::ResizeToContents : QHeaderView::Interactive; ? QHeaderView::ResizeToContents : QHeaderView::Interactive;
header()->setResizeMode(0, mode); header()->setResizeMode(0, mode);
//header()->setResizeMode(1, mode);
} }

View File

@@ -54,7 +54,6 @@ private slots:
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); } void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
private: private:
void resizeEvent(QResizeEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
bool m_alwaysResizeColumnsToContents; bool m_alwaysResizeColumnsToContents;