Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 7353f34

Browse files
committed
Add step item count by state
1 parent a95a5e3 commit 7353f34

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

src/duqf-app/app-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define VERSION_MAJOR 0
55
#define VERSION_MINOR 9
6-
#define VERSION_BUILD 3
6+
#define VERSION_BUILD 4
77
#define VERSION_SUFFIX "Beta"
88

99
#define STRINGIFY_VERSION(A, B, C) CONCAT(A, B, C )

src/rameditwidgets/stepeditwidget.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ RamStep *StepEditWidget::step() const
2828
void StepEditWidget::reInit(RamObject *obj)
2929
{
3030
m_step = qobject_cast<RamStep*>( obj );
31+
32+
while(ui_statesLayout->rowCount() > 0)
33+
ui_statesLayout->removeRow(0);
34+
3135
if (m_step)
3236
{
3337
ui_colorSelector->setColor(m_step->color());
@@ -60,6 +64,37 @@ void StepEditWidget::reInit(RamObject *obj)
6064
}
6165

6266
updateEstimationSuffix();
67+
68+
RamStep::Type stepType = m_step->type();
69+
if (stepType == RamStep::AssetProduction || stepType == RamStep::ShotProduction) {
70+
QHash<RamState*, int> states = m_step->stateCount();
71+
RamState *noState = Ramses::instance()->noState();
72+
DBTableModel *allStates = Ramses::instance()->states();
73+
int total = 0;
74+
for (int i = 0; i < allStates->count(); i++) {
75+
auto s = qobject_cast<RamState*>( allStates->get(i) );
76+
if (s->is(noState))
77+
continue;
78+
int c = states.value( s, 0 );
79+
if (c > 0) {
80+
QString cStr = "<b>"+QString::number(c)+"</b> ";
81+
if (stepType == RamStep::AssetProduction) cStr += "assets";
82+
else cStr += "shots";
83+
84+
auto l = new QLabel(s->name(), this);
85+
l->setStyleSheet("QLabel { color: "+s->color().name() + "; }");
86+
ui_statesLayout->addRow( l, new QLabel(cStr, this) );
87+
total += c;
88+
}
89+
}
90+
if (total > 0) {
91+
QString cStr = "<b>"+QString::number(total)+"</b> ";
92+
if (stepType == RamStep::AssetProduction) cStr += "assets";
93+
else cStr += "shots";
94+
95+
ui_statesLayout->addRow( "Total", new QLabel(cStr, this) );
96+
}
97+
}
6398
}
6499
else
65100
{
@@ -254,6 +289,14 @@ void StepEditWidget::setupUi()
254289
ui_estimationWidget->setProperty("class", "duBlock");
255290
estimLayout->addWidget(ui_estimationWidget);
256291

292+
estimLayout->addWidget(new QLabel(
293+
"<b>"+tr("Status")+"</b>"
294+
));
295+
296+
ui_statesWidget = new QWidget(ui_tabWidget);
297+
ui_statesLayout = new QFormLayout(ui_statesWidget);
298+
estimLayout->addWidget(ui_statesWidget);
299+
257300
estimLayout->addStretch(1);
258301

259302
QFormLayout *estimationLayout = new QFormLayout(ui_estimationWidget);

src/rameditwidgets/stepeditwidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ private slots:
5151

5252
DuComboBox *ui_typeBox;
5353
QWidget *ui_estimationWidget;
54+
QWidget *ui_statesWidget;
55+
QFormLayout *ui_statesLayout;
5456
DuComboBox *ui_estimationTypeBox;
5557
QLabel *ui_estimationTypeLabel;
5658
DuQFTextEdit *ui_publishSettingsEdit;

src/ramobjects/ramstep.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,23 @@ float RamStep::neededDays()
179179
return estimation() - daysSpent();
180180
}
181181

182+
QHash<RamState *, int> RamStep::stateCount()
183+
{
184+
QHash<RamState *, int> states;
185+
186+
RamProject *proj = project();
187+
if (!proj) return states;
188+
189+
const QSet<RamStatus*> status = proj->stepStatus(this);
190+
for(auto st: status) {
191+
RamState *s = st->state();
192+
int c = states.value(s, 0);
193+
states.insert(s, c+1);
194+
}
195+
196+
return states;
197+
}
198+
182199
QVector<float> RamStep::stats(RamUser *user)
183200
{
184201
float estim = estimation();

src/ramobjects/ramstep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class RamFileType;
1212
class RamUser;
1313
class RamWorkingFolder;
1414
class RamObjectList;
15+
class RamState;
1516

1617
class RamStep : public RamTemplateStep
1718
{
@@ -40,6 +41,8 @@ class RamStep : public RamTemplateStep
4041
float daysSpent() ;
4142
float neededDays() ;
4243

44+
QHash<RamState*, int> stateCount();
45+
4346
/**
4447
* @brief stats
4548
* @return a list of number of days <estimation, completed, scheduled, scheduled in the future>

0 commit comments

Comments
 (0)