ui: Wrap lines in status and error table (issue #658)
This commit is contained in:
@@ -55,6 +55,8 @@ QtTable::QtTable(QWidget* parent)
|
||||
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
connect(horizontalHeader(), &QHeaderView::sectionResized, this, &QtTable::columnResized);
|
||||
}
|
||||
|
||||
QtTable::~QtTable()
|
||||
@@ -91,6 +93,8 @@ void QtTable::updateRows()
|
||||
{
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
resizeRowsToContents();
|
||||
}
|
||||
|
||||
int QtTable::getFilledRowCount()
|
||||
@@ -124,6 +128,11 @@ bool QtTable::hasSelection() const
|
||||
return this->selectionModel()->hasSelection();
|
||||
}
|
||||
|
||||
void QtTable::columnResized(int column, int oldWidth, int newWidth)
|
||||
{
|
||||
resizeRowsToContents();
|
||||
}
|
||||
|
||||
void QtTable::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QTableView::resizeEvent(event);
|
||||
@@ -134,13 +143,28 @@ void QtTable::resizeEvent(QResizeEvent* event)
|
||||
this->model()->insertRow(0);
|
||||
}
|
||||
|
||||
m_rowsToFill = (float)tableHeight / this->rowHeight(0);
|
||||
m_rowsToFill = 0;
|
||||
for (int row = 0; row < this->model()->rowCount(); row++)
|
||||
{
|
||||
tableHeight -= this->rowHeight(row);
|
||||
m_rowsToFill++;
|
||||
|
||||
if (tableHeight <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_rowsToFill += (float)tableHeight / this->rowHeight(this->model()->rowCount() - 1);
|
||||
|
||||
updateRows();
|
||||
}
|
||||
|
||||
void QtTable::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_colIndex = -1;
|
||||
m_lastPos = -1;
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
for (auto i = 1; i < this->model()->columnCount(); i++)
|
||||
@@ -149,11 +173,15 @@ void QtTable::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_colIndex = i - 1;
|
||||
m_lastPos = event->pos().x();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTableView::mousePressEvent(event);
|
||||
if (m_colIndex == -1)
|
||||
{
|
||||
QTableView::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void QtTable::mouseMoveEvent(QMouseEvent* event)
|
||||
@@ -185,15 +213,18 @@ void QtTable::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
unsetCursor();
|
||||
}
|
||||
}
|
||||
|
||||
QTableView::mouseMoveEvent(event);
|
||||
QTableView::mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void QtTable::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (m_colIndex == -1)
|
||||
{
|
||||
QTableView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
m_colIndex = -1;
|
||||
m_lastPos = -1;
|
||||
|
||||
QTableView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ public:
|
||||
|
||||
bool hasSelection() const;
|
||||
|
||||
protected slots:
|
||||
void columnResized(int column, int oldWidth, int newWidth);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
@@ -25,34 +25,6 @@
|
||||
|
||||
QIcon QtErrorView::s_errorIcon;
|
||||
|
||||
class SelectableDelegate
|
||||
: public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
SelectableDelegate(QObject* parent = Q_NULLPTR);
|
||||
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
SelectableDelegate::SelectableDelegate(QObject* parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QWidget* SelectableDelegate::createEditor(
|
||||
QWidget* parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QWidget* editor = QStyledItemDelegate::createEditor(parent, option, index);
|
||||
QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(editor);
|
||||
if (lineEdit != nullptr)
|
||||
{
|
||||
lineEdit->setReadOnly(true);
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
QtErrorView::QtErrorView(ViewLayout* viewLayout)
|
||||
: ErrorView(viewLayout)
|
||||
, m_controllerProxy(this, TabId::app())
|
||||
@@ -82,7 +54,6 @@ void QtErrorView::initView()
|
||||
m_model = new QStandardItemModel(widget);
|
||||
m_table->setSortingEnabled(true);
|
||||
m_table->setModel(m_model);
|
||||
m_table->setItemDelegate(new SelectableDelegate(m_table));
|
||||
|
||||
// Setup Table Headers
|
||||
m_model->setColumnCount(COLUMN_MAX + 1);
|
||||
@@ -93,6 +64,8 @@ void QtErrorView::initView()
|
||||
m_table->setColumnWidth(Column::LINE, 50);
|
||||
m_table->setColumnWidth(Column::TRANSLATION_UNIT, 300);
|
||||
|
||||
m_table->setColumnHidden(Column::ID, true);
|
||||
|
||||
QStringList headers;
|
||||
headers << "ID" << "Type" << "Message" << "File" << "Line" << "Indexed" << "Translation Unit";
|
||||
m_model->setHorizontalHeaderLabels(headers);
|
||||
|
||||
Reference in New Issue
Block a user