logic: polished status view

* click message in status bar to show status view
* renamed status tab to output
* renamed status column to message
* fixed list not properly updating when using filters
* scroll to first row after clearing
This commit is contained in:
Eberhard Graether
2016-12-12 11:08:07 +01:00
parent 9db99580d1
commit 5845a98095
18 changed files with 154 additions and 214 deletions
+13 -3
View File
@@ -4,6 +4,7 @@
#include "qt/utility/utilityQt.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageShowStatus.h"
#include "utility/ResourcePaths.h"
QtStatusBar::QtStatusBar()
@@ -23,8 +24,12 @@ QtStatusBar::QtStatusBar()
m_loader.hide();
addWidget(&m_loader);
m_text.setText("");
m_text.setFlat(true);
m_text.setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
addWidget(&m_text);
setText("", false, false);
connect(&m_text, SIGNAL(clicked()), this, SLOT(showStatus()));
m_errorButton.hide();
m_errorButton.setFlat(true);
@@ -47,11 +52,11 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader
{
if (isError)
{
m_text.setStyleSheet("QLabel { color: #D00000 }");
m_text.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }");
}
else
{
m_text.setStyleSheet("");
m_text.setStyleSheet("QPushButton { color: #000000; margin-right: 0; spacing: none; }");
}
if (showLoader)
@@ -81,6 +86,11 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
}
}
void QtStatusBar::showStatus()
{
MessageShowStatus().dispatch();
}
void QtStatusBar::showErrors()
{
SearchMatch match = SearchMatch::createCommand(SearchMatch::COMMAND_ERROR);
+2 -1
View File
@@ -22,10 +22,11 @@ public:
void setErrorCount(ErrorCountInfo errorCount);
private slots:
void showStatus();
void showErrors();
private:
QLabel m_text;
QPushButton m_text;
QLabel m_loader;
QPushButton m_errorButton;
};
+5
View File
@@ -107,6 +107,11 @@ int QtTable::getFilledRowCount()
return model()->rowCount();
}
void QtTable::showFirstRow()
{
verticalScrollBar()->setValue(verticalScrollBar()->minimum());
}
void QtTable::showLastRow()
{
if (m_rowsToFill <= getFilledRowCount())
+1
View File
@@ -16,6 +16,7 @@ public:
void setTableModel(QAbstractItemModel* model);
int getFilledRowCount();
void showFirstRow();
void showLastRow();
protected:
+36 -75
View File
@@ -7,15 +7,14 @@
#include <QPushButton>
#include <QStandardItemModel>
#include "qt/element/QtTable.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "utility/messaging/type/MessageClearStatusView.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageStatusFilterChanged.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
#include "qt/element/QtTable.h"
QtStatusView::QtStatusView(ViewLayout* viewLayout)
: StatusView(viewLayout)
@@ -46,8 +45,6 @@ void QtStatusView::initView()
QHBoxLayout* headerLayout = new QHBoxLayout();
headerLayout->addSpacing(10);
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
m_table = new QtTable(this);
m_model = new QStandardItemModel(this);
m_table->setModel(m_model);
@@ -57,7 +54,7 @@ void QtStatusView::initView()
//m_table->setColumnWidth(STATUSVIEW_COLUMN::STATUS, 150);
QStringList headers;
headers << "Type" << "Status";
headers << "Type" << "Message";
m_model->setHorizontalHeaderLabels(headers);
layout->addWidget(m_table);
@@ -65,10 +62,10 @@ void QtStatusView::initView()
QHBoxLayout* filters = new QHBoxLayout();
filters->addSpacing(15);
const StatusFilter filter = settings->getStatusFilter();
const StatusFilter filter = ApplicationSettings::getInstance()->getStatusFilter();
m_showErrors = createFilterCheckbox("error", filters, filter & STATUSTYPE::STATUS_ERROR);
m_showInfo = createFilterCheckbox("info", filters, filter & STATUSTYPE::STATUS_ERROR);
m_showInfo = createFilterCheckbox("info", filters, filter & StatusType::STATUS_INFO);
m_showErrors = createFilterCheckbox("error", filters, filter & StatusType::STATUS_ERROR);
filters->addStretch();
@@ -76,14 +73,13 @@ void QtStatusView::initView()
connect(clearButton, &QPushButton::clicked,
[=]()
{
//doClear();
MessageClearStatusView().dispatch();
});
}
);
filters->addWidget(clearButton);
filters->addSpacing(30);
updateMask();
layout->addLayout(filters);
doRefreshView();
@@ -98,8 +94,12 @@ QCheckBox* QtStatusView::createFilterCheckbox(const QString& name, QBoxLayout* l
[=](int)
{
m_table->selectionModel()->clearSelection();
updateMask();
updateTable();
const StatusFilter statusMask =
(m_showInfo->isChecked() ? StatusType::STATUS_INFO : 0) +
(m_showErrors->isChecked() ? StatusType::STATUS_ERROR : 0);
MessageStatusFilterChanged(statusMask).dispatch();
}
);
@@ -131,6 +131,8 @@ void QtStatusView::doClear()
m_model->removeRows(0, m_model->rowCount());
}
m_table->showFirstRow();
m_status.clear();
}
@@ -139,6 +141,24 @@ void QtStatusView::doRefreshView()
setStyleSheet();
}
void QtStatusView::doAddStatus(const std::vector<Status>& status)
{
for (Status s : status)
{
const int rowNumber = m_table->getFilledRowCount();
if (rowNumber < m_model->rowCount())
{
m_model->insertRow(rowNumber);
}
QString statusType = (s.type == StatusType::STATUS_ERROR ? "ERROR" : "INFO");
m_model->setItem(rowNumber, STATUSVIEW_COLUMN::TYPE, new QStandardItem(statusType));
m_model->setItem(rowNumber, STATUSVIEW_COLUMN::STATUS, new QStandardItem(s.message.c_str()));
}
m_table->updateRows();
}
void QtStatusView::setStyleSheet() const
{
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
@@ -146,14 +166,6 @@ void QtStatusView::setStyleSheet() const
QPalette palette(m_showErrors->palette());
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::Text, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::ButtonText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//m_showErrors->setAutoFillBackground(true);
//m_showErrors->setPalette(palette);
//m_showFatals->setPalette(palette);
//m_showNonIndexedErrors->setPalette(palette);
//m_showNonIndexedFatals->setPalette(palette);
widget->setStyleSheet(
utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str()
@@ -161,54 +173,3 @@ void QtStatusView::setStyleSheet() const
m_table->updateRows();
}
const char* QtStatusView::getStatusTypeAsString(STATUSTYPE type) const
{
switch (type)
{
case STATUSTYPE::STATUS_INFO:
return "INFO";
case STATUSTYPE::STATUS_ERROR:
return "ERROR";
}
}
void QtStatusView::updateTable()
{
if (!m_model->index(0, 0).data(Qt::DisplayRole).toString().isEmpty())
{
m_model->removeRows(0, m_model->rowCount());
}
}
void QtStatusView::updateMask()
{
const StatusFilter statusMask =
(m_showInfo->isChecked() ? STATUSTYPE::STATUS_INFO : 0) +
(m_showErrors->isChecked() ? STATUSTYPE::STATUS_ERROR : 0);
MessageStatusFilterChanged(statusMask).dispatch();
}
void QtStatusView::addStatusToTable(Status status)
{
const int rowNumber = m_table->getFilledRowCount();
if (rowNumber < m_model->rowCount())
{
m_model->insertRow(rowNumber);
}
m_model->setItem(rowNumber, STATUSVIEW_COLUMN::TYPE, new QStandardItem(status.isError ? "ERROR" : "INFO"));
m_model->setItem(rowNumber, STATUSVIEW_COLUMN::STATUS, new QStandardItem(status.message.c_str()));
m_table->updateRows();
}
void QtStatusView::doAddStatus(const std::vector<Status>& status)
{
//doClear();
for(Status s : status)
{
addStatusToTable(s);
}
}
+5 -12
View File
@@ -5,11 +5,9 @@
#include "component/view/StatusView.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "utility/logging/Logger.h"
class QBoxLayout;
class QCheckBox;
class QPalette;
class QStandardItemModel;
class QtTable;
@@ -41,26 +39,21 @@ private:
void doRefreshView();
void doAddStatus(const std::vector<Status>& status);
std::vector<Status> m_status;
const char* getStatusTypeAsString(STATUSTYPE type) const;
void addStatusToTable(Status status);
QCheckBox* createFilterCheckbox(const QString& name, QBoxLayout* layout, bool checked = false);
void setStyleSheet() const;
void updateMask();
void updateTable();
QtThreadedFunctor<const std::vector<Status>&> m_addStatusFunctor;
QtThreadedFunctor<void> m_clearFunctor;
QtThreadedFunctor<void> m_refreshFunctor;
QtTable* m_table;
QStandardItemModel* m_model;
std::vector<Status> m_status;
QCheckBox* m_showErrors;
QCheckBox* m_showInfo;
QtThreadedFunctor<const std::vector<Status>&> m_addStatusFunctor;
QtThreadedFunctor<void> m_clearFunctor;
QtThreadedFunctor<void> m_refreshFunctor;
};
#endif // QT_STATUS_VIEW_H