Changeset View
Changeset View
Standalone View
Standalone View
src/statistics/lessonstatisticsview.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 51 | { | |||
---|---|---|---|---|---|
52 | QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0); | 52 | QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0); | ||
53 | 53 | | |||
54 | // empty lesson? If so, paint nothing. | 54 | // empty lesson? If so, paint nothing. | ||
55 | if (!index.data(StatisticsModel::TotalCount).toInt()) { | 55 | if (!index.data(StatisticsModel::TotalCount).toInt()) { | ||
56 | return; | 56 | return; | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | // Draw the colored bar. | 59 | // Draw the colored bar. | ||
60 | KEduVocContainer *container = index.data(StatisticsModel::Container).value<KEduVocContainer*>(); | 60 | KEduVocContainer *container = index.data(StatisticsModel::Container) | ||
61 | .value<KEduVocContainer*>(); | ||||
62 | QStringList activeConjugationTenses = index.data(StatisticsModel::ActiveConjugationTenses) | ||||
63 | .toStringList(); | ||||
61 | WordCount wordCount; | 64 | WordCount wordCount; | ||
62 | wordCount.fillFromContainer(*container, index.column() - ContainerModel::FirstDataColumn); | 65 | wordCount.fillFromContainerForPracticeMode( | ||
66 | *container, | ||||
67 | index.column() - ContainerModel::FirstDataColumn, | ||||
68 | activeConjugationTenses | ||||
69 | ); | ||||
63 | ConfidenceColors colors(ConfidenceColors::ProgressiveColorScheme); | 70 | ConfidenceColors colors(ConfidenceColors::ProgressiveColorScheme); | ||
64 | 71 | | |||
65 | paintColorBar(*painter, option.rect, wordCount, colors); // in utils | 72 | paintColorBar(*painter, option.rect, wordCount, colors); // in utils | ||
66 | 73 | | |||
67 | // Draw the text telling the percentage on top of the bar. | 74 | // Draw the text telling the percentage on top of the bar. | ||
68 | painter->drawText(option.rect, Qt::AlignCenter, | 75 | painter->drawText(option.rect, Qt::AlignCenter, | ||
69 | QStringLiteral("%1%").arg(index.data(StatisticsModel::TotalPercent).toInt())); | 76 | QStringLiteral("%1%").arg(index.data(StatisticsModel::TotalPercent).toInt())); | ||
70 | } | 77 | } | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 138 | { | |||
132 | if (index < ContainerModel::FirstDataColumn) { | 139 | if (index < ContainerModel::FirstDataColumn) { | ||
133 | adjustColumnWidths(); | 140 | adjustColumnWidths(); | ||
134 | } | 141 | } | ||
135 | } | 142 | } | ||
136 | 143 | | |||
137 | void LessonStatisticsView::adjustColumnWidths() | 144 | void LessonStatisticsView::adjustColumnWidths() | ||
138 | { | 145 | { | ||
139 | int firstWidth = columnWidth(0) + columnWidth(1); | 146 | int firstWidth = columnWidth(0) + columnWidth(1); | ||
140 | // Subtract 5 here otherwise we get a horizontal scrollbar. | 147 | int totalWidth = viewport()->width() - firstWidth; | ||
141 | int totalWidth = width() - firstWidth - 5; | | |||
142 | int columnCount = model()->columnCount(QModelIndex()); | 148 | int columnCount = model()->columnCount(QModelIndex()); | ||
143 | int visibleColumns = 0; | 149 | int visibleColumns = 0; | ||
144 | for (int i = ContainerModel::FirstDataColumn; i < columnCount; ++i) { | 150 | for (int i = ContainerModel::FirstDataColumn; i < columnCount; ++i) { | ||
145 | if (!isColumnHidden(i)) | 151 | if (!isColumnHidden(i)) | ||
146 | visibleColumns++; | 152 | visibleColumns++; | ||
147 | } | 153 | } | ||
148 | int columnWidth = visibleColumns > 0 ? totalWidth / visibleColumns : 150; | 154 | int columnWidth = visibleColumns > 0 ? totalWidth / visibleColumns : 150; | ||
149 | for (int i = ContainerModel::FirstDataColumn; i < model()->columnCount(QModelIndex()); i++) { | 155 | for (int i = ContainerModel::FirstDataColumn; i < model()->columnCount(QModelIndex()); i++) { | ||
Show All 20 Lines |