Skip to content

Commit

Permalink
Messages Pane: Copy any data of all issues to clip
Browse files Browse the repository at this point in the history
and consolidate redundant code
  • Loading branch information
octaeder committed Jan 21, 2024
1 parent 0f6372d commit df5965e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/latexlogwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ LatexLogWidget::LatexLogWidget(QWidget *parent) :
act = new QAction(tr("&Copy All With Line Numbers"), errorTable);
connect(act, SIGNAL(triggered()), SLOT(copyAllMessagesWithLineNumbers()));
errorTable->addAction(act);
act = new QAction(tr("&Copy All Rows And Columns"), errorTable);
connect(act, SIGNAL(triggered()), SLOT(copyAllRowsAndColumns()));
errorTable->addAction(act);
errorTable->setContextMenuPolicy(Qt::ActionsContextMenu);

log = new LogEditor(this);
Expand Down Expand Up @@ -244,18 +247,29 @@ void LatexLogWidget::copyMessage()

void LatexLogWidget::copyAllMessages()
{
QStringList result;
for (int i = 0; i < logModel->count(); i++)
result << logModel->data(logModel->index(i, 3), Qt::DisplayRole).toString();
REQUIRE(QApplication::clipboard());
QApplication::clipboard()->setText(result.join("\n"));
copyAllRowsWithColumnRange(3,3);
}

void LatexLogWidget::copyAllMessagesWithLineNumbers()
{
copyAllRowsWithColumnRange(2,3);
}

void LatexLogWidget::copyAllRowsAndColumns()
{
copyAllRowsWithColumnRange(0,3);
}

void LatexLogWidget::copyAllRowsWithColumnRange(int first, int last)
{
QStringList result;
for (int i = 0; i < logModel->count(); i++)
result << logModel->data(logModel->index(i, 2), Qt::DisplayRole).toString() + ": " + logModel->data(logModel->index(i, 3), Qt::DisplayRole).toString();
for (int i = 0; i < logModel->count(); i++) {
QString columns;
for (int j = first; j < last; j++) {
columns += logModel->data(logModel->index(i, j), Qt::DisplayRole).toString() + ": ";
}
result << columns + logModel->data(logModel->index(i, last), Qt::DisplayRole).toString();
}
REQUIRE(QApplication::clipboard());
QApplication::clipboard()->setText(result.join("\n"));
}
Expand Down
3 changes: 3 additions & 0 deletions src/latexlogwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private slots:
void copyMessage();
void copyAllMessages();
void copyAllMessagesWithLineNumbers();
void copyAllRowsAndColumns();
void setWidgetVisibleFromAction(bool visible);
void setInfo(const QString &message);
void filterChanged(bool);
Expand All @@ -56,6 +57,8 @@ private slots:
LogEditor *log;
QLabel *infoLabel;
QAction *displayTableAction, *displayLogAction, *filterErrorAction, *filterWarningAction, *filterBadBoxAction;

void copyAllRowsWithColumnRange(int first, int last);
};

#endif // LATEXLOGWIDGET_H

0 comments on commit df5965e

Please sign in to comment.