Changeset View
Changeset View
Standalone View
Standalone View
src/kdefrontend/generalTest/GeneralTestView.cpp
Context not available. | |||||
41 | #include <QLabel> | 41 | #include <QLabel> | ||
---|---|---|---|---|---|
42 | #include <QTableView> | 42 | #include <QTableView> | ||
43 | #include <QHeaderView> | 43 | #include <QHeaderView> | ||
44 | #include <QPushButton> | ||||
45 | #include <QStandardItemModel> | ||||
44 | 46 | | |||
45 | #include <KLocalizedString> | 47 | #include <KLocalizedString> | ||
46 | 48 | | |||
Context not available. | |||||
56 | m_testName(new QLabel()), | 58 | m_testName(new QLabel()), | ||
57 | m_statsTable(new MyTextEdit()), | 59 | m_statsTable(new MyTextEdit()), | ||
58 | m_summaryResults(new QWidget()), | 60 | m_summaryResults(new QWidget()), | ||
61 | m_inputStatsWidget(new QWidget()), | ||||
62 | m_labelInputStatsTable(new QLabel()), | ||||
59 | m_inputStatsTable(new QTableView()), | 63 | m_inputStatsTable(new QTableView()), | ||
60 | m_labelInputStatsTable(new QLabel()) { | 64 | m_clearInputStats(new QPushButton()) { | ||
65 | | ||||
66 | QVBoxLayout * inputStatsLayout = new QVBoxLayout(m_inputStatsWidget); | ||||
67 | inputStatsLayout->addWidget(m_labelInputStatsTable); | ||||
68 | inputStatsLayout->addWidget(m_inputStatsTable); | ||||
69 | inputStatsLayout->addWidget(m_clearInputStats); | ||||
61 | 70 | | |||
62 | m_statsTable->setReadOnly(true); | 71 | m_statsTable->setReadOnly(true); | ||
63 | 72 | | |||
64 | m_testName->setStyleSheet("background-color: white"); | 73 | m_testName->setStyleSheet("background-color: white"); | ||
65 | m_statsTable->setStyleSheet("background-color: white"); | 74 | m_statsTable->setStyleSheet("background-color: white"); | ||
66 | m_summaryResults->setStyleSheet("QToolTip { color: black; background-color: yellow; border: 0px; }"); | 75 | m_summaryResults->setStyleSheet("QToolTip { color: black; background-color: yellow; border: 0px; }"); | ||
67 | m_inputStatsTable->setStyleSheet("background-color: white"); | 76 | m_inputStatsWidget->setStyleSheet("background-color: white"); | ||
68 | m_labelInputStatsTable->setStyleSheet("backgroud-color: white"); | | |||
69 | 77 | | |||
70 | m_testName->hide(); | 78 | m_testName->hide(); | ||
71 | m_statsTable->hide(); | 79 | m_statsTable->hide(); | ||
72 | m_summaryResults->hide(); | 80 | m_summaryResults->hide(); | ||
73 | m_inputStatsTable->hide(); | 81 | m_inputStatsWidget->hide(); | ||
74 | 82 | | |||
75 | auto* layout = new QVBoxLayout(this); | 83 | auto* layout = new QVBoxLayout(this); | ||
76 | 84 | | |||
Context not available. | |||||
79 | "<br><br>" + | 87 | "<br><br>" + | ||
80 | i18n("You can leave one or more columns empty if you feel they are not useful") + | 88 | i18n("You can leave one or more columns empty if you feel they are not useful") + | ||
81 | "</h3>"); | 89 | "</h3>"); | ||
82 | m_labelInputStatsTable->hide(); | 90 | m_clearInputStats->setText(i18n("Clear")); | ||
91 | m_clearInputStats->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
83 | 92 | | |||
84 | layout->addWidget(m_labelInputStatsTable); | 93 | layout->addWidget(m_inputStatsWidget); | ||
85 | layout->addWidget(m_inputStatsTable); | | |||
86 | layout->addWidget(m_testName); | 94 | layout->addWidget(m_testName); | ||
87 | layout->addWidget(m_statsTable); | 95 | layout->addWidget(m_statsTable); | ||
88 | layout->addWidget(m_summaryResults); | 96 | layout->addWidget(m_summaryResults); | ||
Context not available. | |||||
97 | initActions(); | 105 | initActions(); | ||
98 | initMenus(); | 106 | initMenus(); | ||
99 | 107 | | |||
100 | QHeaderView* horizontalHeaderView = m_inputStatsTable->horizontalHeader(); | | |||
101 | horizontalHeaderView->setSectionResizeMode(QHeaderView::ResizeToContents); | | |||
102 | horizontalHeaderView->setSectionsClickable(true); | | |||
103 | horizontalHeaderView->setStyleSheet("backgroud-color: red"); | | |||
104 | | ||||
105 | m_inputStatsTable->setModel(m_generalTest->inputStatsTableModel()); | 108 | m_inputStatsTable->setModel(m_generalTest->inputStatsTableModel()); | ||
106 | 109 | | |||
110 | m_inputStatsTable->horizontalHeader()->setVisible(false); | ||||
111 | m_inputStatsTable->verticalHeader()->setVisible(false); | ||||
112 | m_inputStatsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | ||||
113 | | ||||
107 | m_statsTable->setMouseTracking(true); | 114 | m_statsTable->setMouseTracking(true); | ||
108 | connect(m_generalTest, &GeneralTest::changed, this, &GeneralTestView::changed); | 115 | connect(m_generalTest, &GeneralTest::changed, this, &GeneralTestView::changed); | ||
116 | connect(m_clearInputStats, &QPushButton::clicked, m_generalTest, &GeneralTest::clearInputStatsTable); | ||||
109 | } | 117 | } | ||
110 | 118 | | |||
111 | void GeneralTestView::initActions() { | 119 | void GeneralTestView::initActions() { | ||
Context not available. | |||||
187 | m_summaryResults->setLayout(m_generalTest->summaryLayout()); | 195 | m_summaryResults->setLayout(m_generalTest->summaryLayout()); | ||
188 | 196 | | |||
189 | if (m_inputStatsTable->model()->rowCount() > 0 && | 197 | if (m_inputStatsTable->model()->rowCount() > 0 && | ||
190 | m_inputStatsTable->model()->columnCount() > 0) { | 198 | m_inputStatsTable->model()->columnCount() > 0) | ||
191 | m_inputStatsTable->show(); | 199 | m_inputStatsWidget->show(); | ||
192 | m_labelInputStatsTable->show(); | 200 | else | ||
193 | } | 201 | m_inputStatsWidget->hide(); | ||
194 | else { | | |||
195 | m_inputStatsTable->hide(); | | |||
196 | m_labelInputStatsTable->hide(); | | |||
197 | } | | |||
198 | } | 202 | } | ||
199 | 203 | | |||
200 | void GeneralTestView::exportToFile(const QString& path, const bool exportHeader, const QString& separator, QLocale::Language language) const { | 204 | void GeneralTestView::exportToFile(const QString& path, const bool exportHeader, const QString& separator, QLocale::Language language) const { | ||
Context not available. |