Skip to content

Commit 4bb2988

Browse files
Refactoring of Files list for more versatility
1 parent 1b1eef0 commit 4bb2988

File tree

2 files changed

+104
-52
lines changed

2 files changed

+104
-52
lines changed

Source/GUI/FilesList.cpp

Lines changed: 103 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
#include <sstream>
1919
//---------------------------------------------------------------------------
2020

21+
enum statstype
22+
{
23+
StatsType_None,
24+
StatsType_Average,
25+
StatsType_Count,
26+
StatsType_Count2,
27+
StatsType_Percent,
28+
};
29+
30+
struct percolumn
31+
{
32+
statstype Stats_Type;
33+
PlotName Stats_PlotName;
34+
PlotName Stats_PlotName2;
35+
const char* HeaderName;
36+
const char* ToolTip;
37+
};
38+
2139
enum col_names
2240
{
2341
Col_Processed,
@@ -36,21 +54,54 @@ enum col_names
3654
Col_StreamCount,
3755
Col_Duration,
3856
Col_FileSize,
39-
//Col_Encoder,
57+
//Col_Encoder,
4058
Col_VideoFormat,
4159
Col_Width,
4260
Col_Height,
4361
Col_DAR,
4462
Col_PixFormat,
4563
Col_FrameRate,
4664
Col_AudioFormat,
47-
//Col_SampleFormat,
65+
//Col_SampleFormat,
4866
Col_SamplingRate,
49-
//Col_ChannelLayout,
50-
//Col_BitDepth,
67+
//Col_ChannelLayout,
68+
//Col_BitDepth,
5169
Col_Max
5270
};
5371

72+
percolumn PerColumn[Col_Max]=
73+
{
74+
{ StatsType_None, PlotName_Max, PlotName_Max, "Processed", NULL, },
75+
{ StatsType_Average, PlotName_YAVG, PlotName_Max, "Yav", "average of Y values", },
76+
{ StatsType_Average, PlotName_YHIGH, PlotName_YLOW, "Yrang", "average of ( YHIGH - YLOW ), indicative of contrast range", },
77+
{ StatsType_Average, PlotName_UAVG, PlotName_Max, "Uav", NULL, },
78+
{ StatsType_Average, PlotName_VAVG, PlotName_Max, "Vav", "average of V values", },
79+
{ StatsType_Average, PlotName_TOUT, PlotName_Max, "TOUTav", "average of TOUT values", },
80+
{ StatsType_Count, PlotName_TOUT, PlotName_Max, "TOUTc", "count of TOUT > 0.005", },
81+
{ StatsType_Count, PlotName_SATMAX, PlotName_Max, "SATb", "count of frames with MAXSAT > 88.7, outside of broadcast color levels", },
82+
{ StatsType_Count2, PlotName_SATMAX, PlotName_Max, "SATi", "count of frames with MAXSAT > 118.2, illegal YUV color", },
83+
{ StatsType_Percent, PlotName_BRNG, PlotName_Max, "BRNGav", "percent of frames with BRNG > 0", },
84+
{ StatsType_Count, PlotName_BRNG, PlotName_Max, "BRNGc", "count of frames with BRNG > 0", },
85+
{ StatsType_Count, PlotName_MSE_y, PlotName_Max, "MSEfY", "count of frames with MSEfY over 1000", },
86+
{ StatsType_None, PlotName_Max, PlotName_Max, "Format", NULL, },
87+
{ StatsType_None, PlotName_Max, PlotName_Max, "Streams count", NULL, },
88+
{ StatsType_None, PlotName_Max, PlotName_Max, "Duration", NULL, },
89+
{ StatsType_None, PlotName_Max, PlotName_Max, "File size", NULL, },
90+
//{ StatsType_None, PlotName_Max, PlotName_Max, "Encoder", NULL, },
91+
{ StatsType_None, PlotName_Max, PlotName_Max, "V. Format", NULL, },
92+
{ StatsType_None, PlotName_Max, PlotName_Max, "Width", NULL, },
93+
{ StatsType_None, PlotName_Max, PlotName_Max, "Height", NULL, },
94+
{ StatsType_None, PlotName_Max, PlotName_Max, "DAR", NULL, },
95+
{ StatsType_None, PlotName_Max, PlotName_Max, "Pix Format", NULL, },
96+
{ StatsType_None, PlotName_Max, PlotName_Max, "Frame rate", NULL, },
97+
{ StatsType_None, PlotName_Max, PlotName_Max, "A. Format", NULL, },
98+
//{ StatsType_None, PlotName_Max, PlotName_Max, "Sample format", NULL, },
99+
{ StatsType_None, PlotName_Max, PlotName_Max, "Sampling rate", NULL, },
100+
//{ StatsType_None, PlotName_Max, PlotName_Max, "Channel layout", NULL, },
101+
//{ StatsType_None, PlotName_Max, PlotName_Max, "Bit depth", NULL, },
102+
};
103+
104+
54105
//***************************************************************************
55106
// Constructor / Desructor
56107
//***************************************************************************
@@ -82,34 +133,13 @@ void FilesList::showEvent(QShowEvent * Event)
82133
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
83134

84135
setColumnCount(Col_Max);
85-
setHorizontalHeaderItem(Col_Processed, new QTableWidgetItem("Processed"));
86-
setHorizontalHeaderItem(Col_Format, new QTableWidgetItem("Format"));
87-
setHorizontalHeaderItem(Col_StreamCount, new QTableWidgetItem("Streams count"));
88-
setHorizontalHeaderItem(Col_Duration, new QTableWidgetItem("Duration"));
89-
setHorizontalHeaderItem(Col_FileSize, new QTableWidgetItem("File size"));
90-
//setHorizontalHeaderItem(Col_Encoder, new QTableWidgetItem("Encoder"));
91-
setHorizontalHeaderItem(Col_VideoFormat, new QTableWidgetItem("V. Format"));
92-
setHorizontalHeaderItem(Col_Width, new QTableWidgetItem("Width"));
93-
setHorizontalHeaderItem(Col_Height, new QTableWidgetItem("Height"));
94-
setHorizontalHeaderItem(Col_DAR, new QTableWidgetItem("DAR"));
95-
setHorizontalHeaderItem(Col_PixFormat, new QTableWidgetItem("Pix Format"));
96-
setHorizontalHeaderItem(Col_FrameRate, new QTableWidgetItem("Frame rate"));
97-
setHorizontalHeaderItem(Col_AudioFormat, new QTableWidgetItem("A. Format"));
98-
//setHorizontalHeaderItem(Col_SampleFormat, new QTableWidgetItem("Sample format"));
99-
setHorizontalHeaderItem(Col_SamplingRate, new QTableWidgetItem("Sampling rate"));
100-
//setHorizontalHeaderItem(Col_ChannelLayout, new QTableWidgetItem("Channel layout"));
101-
//setHorizontalHeaderItem(Col_BitDepth, new QTableWidgetItem("Bit depth"));
102-
setHorizontalHeaderItem(Col_Yav, new QTableWidgetItem("Yav")); horizontalHeaderItem(Col_Yav)->setToolTip("average of Y values");
103-
setHorizontalHeaderItem(Col_Yrang, new QTableWidgetItem("Yrang")); horizontalHeaderItem(Col_Yrang)->setToolTip("average of ( YHIGH - YLOW ), indicative of contrast range");
104-
setHorizontalHeaderItem(Col_Uav, new QTableWidgetItem("Uav")); horizontalHeaderItem(Col_Uav)->setToolTip("average of U values");
105-
setHorizontalHeaderItem(Col_Vav, new QTableWidgetItem("Vav")); horizontalHeaderItem(Col_Vav)->setToolTip("average of V values");
106-
setHorizontalHeaderItem(Col_TOUTav, new QTableWidgetItem("TOUTav")); horizontalHeaderItem(Col_TOUTav)->setToolTip("average of TOUT values");
107-
setHorizontalHeaderItem(Col_TOUTc, new QTableWidgetItem("TOUTc")); horizontalHeaderItem(Col_TOUTc)->setToolTip("count of TOUT > 0.005");
108-
setHorizontalHeaderItem(Col_SATb, new QTableWidgetItem("SATb")); horizontalHeaderItem(Col_SATb)->setToolTip("count of frames with MAXSAT > 88.7, outside of broadcast color levels");
109-
setHorizontalHeaderItem(Col_SATi, new QTableWidgetItem("SATi")); horizontalHeaderItem(Col_SATi)->setToolTip("count of frames with MAXSAT > 118.2, illegal YUV color");
110-
setHorizontalHeaderItem(Col_BRNGav, new QTableWidgetItem("BRNGav")); horizontalHeaderItem(Col_BRNGav)->setToolTip("percent of frames with BRNG > 0");
111-
setHorizontalHeaderItem(Col_BRNGc, new QTableWidgetItem("BRNGc")); horizontalHeaderItem(Col_BRNGc)->setToolTip("count of frames with BRNG > 0");
112-
setHorizontalHeaderItem(Col_MSEfY, new QTableWidgetItem("MSEfY")); horizontalHeaderItem(Col_MSEfY)->setToolTip("count of frames with MSEfY over 1000");
136+
for (size_t Col=0; Col<Col_Max; Col++)
137+
{
138+
QTableWidgetItem* Item=new QTableWidgetItem(PerColumn[Col].HeaderName);
139+
if (PerColumn[Col].ToolTip)
140+
Item->setToolTip(PerColumn[Col].ToolTip);
141+
setHorizontalHeaderItem(Col, Item);
142+
}
113143

114144
UpdateAll();
115145
}
@@ -235,30 +265,51 @@ void FilesList::UpdateAll()
235265
void FilesList::Update()
236266
{
237267
for (size_t Files_Pos=0; Files_Pos<Main->Files.size(); Files_Pos++)
238-
if (Main->Files[Files_Pos]->Glue->VideoFrameCount_Get())
239-
{
240-
stringstream Message;
241-
Message<<(int)(Main->Files[Files_Pos]->Glue->State_Get()*100)<<"%";
242-
setItem((int)Files_Pos, 0, new QTableWidgetItem(QString::fromStdString(Message.str())));
243-
setItem((int)Files_Pos, Col_Yav, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PlotName_YAVG).c_str()));
244-
setItem((int)Files_Pos, Col_Yrang, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PlotName_YHIGH, PlotName_YLOW).c_str()));
245-
setItem((int)Files_Pos, Col_Uav, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PlotName_UAVG).c_str()));
246-
setItem((int)Files_Pos, Col_Vav, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PlotName_VAVG).c_str()));
247-
setItem((int)Files_Pos, Col_TOUTav, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PlotName_TOUT).c_str()));
248-
setItem((int)Files_Pos, Col_TOUTc, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Count_Get(PlotName_TOUT).c_str()));
249-
setItem((int)Files_Pos, Col_SATb, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Count_Get(PlotName_SATMAX).c_str()));
250-
setItem((int)Files_Pos, Col_SATi, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Count2_Get(PlotName_SATMAX).c_str()));
251-
setItem((int)Files_Pos, Col_BRNGav, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Percent_Get(PlotName_BRNG).c_str()));
252-
setItem((int)Files_Pos, Col_BRNGc, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Count_Get(PlotName_BRNG).c_str()));
253-
setItem((int)Files_Pos, Col_MSEfY, new QTableWidgetItem(Main->Files[Files_Pos]->Glue->Stats_Count_Get(PlotName_MSE_y).c_str()));
254-
QTableWidgetItem* Item=item((int)Files_Pos, 0);
255-
if (Item)
256-
Item->setFlags(Item->flags()&((Qt::ItemFlags)-1-Qt::ItemIsEditable));
257-
}
268+
{
269+
QTableWidgetItem* Item=item((int)Files_Pos, 0);
270+
if (!Item || Item->text()!="100%")
271+
Update(Files_Pos);
272+
}
258273

259274
resizeColumnsToContents();
260275
}
261276

277+
//---------------------------------------------------------------------------
278+
void FilesList::Update(size_t Files_Pos)
279+
{
280+
stringstream Message;
281+
Message<<(int)(Main->Files[Files_Pos]->Glue->State_Get()*100)<<"%";
282+
setItem((int)Files_Pos, Col_Processed, new QTableWidgetItem(QString::fromStdString(Message.str())));
283+
284+
// Stats
285+
for (size_t Col=0; Col<Col_Max; Col++)
286+
if (PerColumn[Col].Stats_Type!=StatsType_None)
287+
{
288+
QTableWidgetItem* Item=new QTableWidgetItem();
289+
switch (PerColumn[Col].Stats_Type)
290+
{
291+
case StatsType_Average :
292+
if (PerColumn[Col].Stats_PlotName2==PlotName_Max)
293+
Item->setText(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PerColumn[Col].Stats_PlotName).c_str());
294+
else
295+
Item->setText(Main->Files[Files_Pos]->Glue->Stats_Average_Get(PerColumn[Col].Stats_PlotName, PerColumn[Col].Stats_PlotName2).c_str());
296+
break;
297+
case StatsType_Count :
298+
Item->setText(Main->Files[Files_Pos]->Glue->Stats_Count_Get(PerColumn[Col].Stats_PlotName).c_str());
299+
break;
300+
case StatsType_Count2 :
301+
Item->setText(Main->Files[Files_Pos]->Glue->Stats_Count2_Get(PerColumn[Col].Stats_PlotName).c_str());
302+
break;
303+
case StatsType_Percent :
304+
Item->setText(Main->Files[Files_Pos]->Glue->Stats_Percent_Get(PerColumn[Col].Stats_PlotName).c_str());
305+
break;
306+
default: ;
307+
}
308+
Item->setFlags(Item->flags()&((Qt::ItemFlags)-1-Qt::ItemIsEditable));
309+
setItem((int)Files_Pos, Col, Item);
310+
}
311+
}
312+
262313
//***************************************************************************
263314
// Events
264315
//***************************************************************************

Source/GUI/FilesList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class FilesList : public QTableWidget
2424

2525
// Commands
2626
void Update ();
27+
void Update (size_t File_Pos);
2728
void UpdateAll ();
2829

2930
protected:

0 commit comments

Comments
 (0)