Skip to content

Commit f335946

Browse files
committed
Segments info, feedback on segments saves
1 parent d6f2c68 commit f335946

11 files changed

Lines changed: 66 additions & 22 deletions

cffflashdatablock.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void CFFFlashDataBlock::readCFFData(QFile * cff, long baseAddress)
111111
qDbg() << "BlockLength " << this->BlockLength();
112112
qDbg() << "FlashData " << this->FlashData();
113113
qDbg() << "FileName " << this->FileName();
114+
qDbg() << "LongName " << this->LongName();
114115

115116
}
116117

@@ -120,7 +121,7 @@ void CFFFlashDataBlock::updateModel(CFFFlashSegmentModel * model)
120121
model->addFlashSegments(this->m_FlashSegments);
121122
}
122123

123-
void CFFFlashDataBlock::exportSegments(QString fpath)
124+
QString CFFFlashDataBlock::exportSegments(QString fpath, QString prefix)
124125
{
125126
if(fpath.startsWith(QStringLiteral("file:")))
126127
{
@@ -135,12 +136,14 @@ void CFFFlashDataBlock::exportSegments(QString fpath)
135136

136137
foreach(auto segment, this->FlashSegments())
137138
{
138-
qDbg() << "Segment: " << fpath+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment";
139-
QFile seg_file(fpath+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment");
139+
qDbg() << "Segment: " << fpath+prefix+"_"+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment";
140+
QFile seg_file(fpath+prefix+"_"+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment");
140141
if(seg_file.open(QIODevice::WriteOnly))
141142
{
142143
seg_file.write(segment->readFlashSegment());
143144
seg_file.close();
144145
}
145146
}
147+
148+
return fpath;
146149
}

cffflashdatablock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CFFFlashDataBlock : public QObject
4444
Q_PROPERTY(long BaseAddress READ BaseAddress WRITE setBaseAddress NOTIFY BaseAdressChanged);
4545

4646
Q_INVOKABLE void updateModel(CFFFlashSegmentModel * model);
47-
Q_INVOKABLE void exportSegments(QString fpath);
47+
Q_INVOKABLE QString exportSegments(QString fpath, QString prefix = QLatin1String());
4848

4949
QString Qualifier(){return this->m_Qualifier;}
5050
int32_t LongName(){return this->m_LongName;}

cffflashdescriptionheader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ void CFFFlashDescriptionHeader::readCFFData(QFile * cff, long baseAddress)
5050
qDbg() << this->BaseAddress();
5151
qDbg() << this->Qualifier();
5252
qDbg() << this->FlashAreaName();
53+
qDbg() << UniqueObjectID;
5354
}

cffflashheader.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void CFFFlashHeader::readFlash()
5151

5252

5353
this->setFileAuthor(CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress));
54-
this->m_FileCreationTime = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
54+
this->setFileCreationTime(CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress));
5555
this->m_AuthoringToolVersion = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
5656
this->m_FTRAFOVersionString = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
5757

@@ -135,3 +135,8 @@ void CFFFlashHeader::updateModel(CFFFlashDataBlocksModel * model)
135135
qDbg() << "update blocks model!";
136136
model->addFlashDataBlocks(this->m_flash_data_blocks);
137137
}
138+
139+
QString CFFFlashHeader::FileCreationTime()
140+
{
141+
return QDateTime::fromString(this->m_FileCreationTime, Qt::ISODateWithMs).toString("dd.MM.yyyy hh:mm:ss");
142+
}

cffflashheader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class CFFFlashHeader : public QObject
2121

2222
Q_PROPERTY(QString FlashName READ FlashName WRITE setFlashName NOTIFY FlashNameChanged);
2323
Q_PROPERTY(QString FileAuthor READ FileAuthor WRITE setFileAuthor NOTIFY FileAuthorChanged);
24+
Q_PROPERTY(QString FileCreationTime READ FileCreationTime WRITE setFileCreationTime NOTIFY FileCreationTimeChanged);
2425

2526
Q_PROPERTY(int32_t CTFHeaderTable READ CTFHeaderTable NOTIFY CTFHeaderTableChanged);
2627
Q_PROPERTY(int32_t CffHeaderSize READ CffHeaderSize NOTIFY CffHeaderSizeChanged);
@@ -37,9 +38,11 @@ class CFFFlashHeader : public QObject
3738
long BaseAddress(){return this->m_BaseAddress;}
3839
QString FlashName(){return this->m_FlashName;}
3940
QString FileAuthor(){return this->m_FileAuthor;}
41+
QString FileCreationTime();
4042

4143
void setFlashName(QString data){this->m_FlashName = data;}
4244
void setFileAuthor(QString data){this->m_FileAuthor = data;}
45+
void setFileCreationTime(QString data){this->m_FileCreationTime = data;}
4346

4447

4548
private:
@@ -54,6 +57,7 @@ class CFFFlashHeader : public QObject
5457
void BaseAddressChanged();
5558
void FileAuthorChanged();
5659
void FlashNameChanged();
60+
void FileCreationTimeChanged();
5761

5862
private:
5963
QFile * m_cff_file;

cffflashsegment.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ QByteArray CFFFlashSegment::readFlashSegment()
7474
return data;
7575
}
7676

77-
void CFFFlashSegment::saveToFile(QString fpath)
77+
QString CFFFlashSegment::saveToFile(QString fpath)
7878
{
7979
if(fpath.startsWith(QStringLiteral("file:")))
8080
{
@@ -90,4 +90,6 @@ void CFFFlashSegment::saveToFile(QString fpath)
9090
seg_file.write(this->readFlashSegment());
9191
seg_file.close();
9292
}
93+
94+
return fpath;
9395
}

cffflashsegment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CFFFlashSegment : public QObject
2222
Q_PROPERTY(long BaseAddress READ BaseAddress WRITE setBaseAddress NOTIFY BaseAddressChanged);
2323

2424
Q_INVOKABLE QByteArray readFlashSegment();
25-
Q_INVOKABLE void saveToFile(QString fpath);
25+
Q_INVOKABLE QString saveToFile(QString fpath);
2626

2727
QString SegmentName(){return this->m_SegmentName;}
2828
uint32_t FromAdress(){return this->m_FromAdress;}

qml/FlashDataBlockDelegate.qml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import QtQuick.Layouts
33
import QtQuick.Controls
44
import Qt.labs.platform
55

6+
import xplatforms.cffflashcontainer.flashheader 1.0
67
import xplatforms.cffflashcontainer.flashblock 1.0
78
import xplatforms.cffflashcontainer.flashsegment 1.0
89
import xplatforms.cffflashcontainer.flashsegmentmodel 1.0
910

1011

1112
ColumnLayout
1213
{
14+
property CFFFlashHeader header;
1315
property CFFFlashDataBlock block;
1416
property CFFFlashSegmentModel segments_model: CFFFlashSegmentModel{}
1517
Component.onCompleted: {
@@ -24,7 +26,7 @@ ColumnLayout
2426
{
2527
Label{
2628
font.bold: true
27-
text: "Qualifier: "
29+
text: "qualifier: "
2830
}
2931
Label{text: block.Qualifier}
3032
//Label{text: "test"}
@@ -46,7 +48,8 @@ ColumnLayout
4648
}
4749
Button
4850
{
49-
//Layout.fillWidth: true
51+
id: btn_export_all
52+
5053
text: " Export all segments... "
5154
onClicked:
5255
{
@@ -80,7 +83,7 @@ ColumnLayout
8083
//height: 200
8184
model: segments_model
8285
//block.getSegmentsModel()//segments_model.addFlashSegments(block.FlashSegments)
83-
delegate: FlashSegmentModel{idk: block.FlashDataInfo_Idk; segment: FlashSegment}
86+
delegate: FlashSegmentModel{flash_name: header.FlashName; idk: block.FlashDataInfo_Idk; segment: FlashSegment}
8487
}
8588

8689
FolderDialog
@@ -94,17 +97,22 @@ ColumnLayout
9497

9598
onAccepted: {
9699
console.log("You chose: " + export_dialog.folder)
97-
block.exportSegments(export_dialog.folder);
98-
//FlashSegment.saveToFile(FlashSegment.SegmentName+"_"+idk+".segment");
99-
//loadCFF(fileDialog.currentFile);
100-
//Qt.quit()
100+
ttip_id.show("Segments saved to: " +block.exportSegments(export_dialog.folder, header.FlashName), 2500);
101101
}
102102
onRejected: {
103103
console.log("Canceled")
104104
//Qt.quit()
105105
}
106106
//Component.onCompleted: visible = true
107107
}
108+
109+
ToolTip
110+
{
111+
id: ttip_id
112+
//parent: parent//btn_export_all
113+
anchors.centerIn: parent
114+
margins: 20
115+
}
108116
}
109117

110118

qml/FlashInfoScreen.qml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Page {
4444
{
4545
Label
4646
{
47-
text: qsTr("Flash Name:")
47+
text: qsTr("flash name:")
4848
font: window.headerFont12
4949
}
5050
Label
@@ -73,14 +73,26 @@ Page {
7373
{
7474
Label
7575
{
76-
text: qsTr("Flash Author:")
76+
text: qsTr("author:")
7777
font: window.headerFont12
7878

7979
}
8080
Label
8181
{
8282
text: flash_header.FileAuthor
8383
}
84+
85+
Label
86+
{
87+
Layout.leftMargin: 10
88+
text: qsTr("creation date:")
89+
font: window.headerFont12
90+
91+
}
92+
Label
93+
{
94+
text: flash_header.FileCreationTime
95+
}
8496
}
8597

8698
Rectangle
@@ -107,7 +119,7 @@ Page {
107119
Layout.fillWidth: true
108120
//anchors.fill: parent
109121
model: blocks_model
110-
delegate: FlashDataBlockDelegate{block: FlashDataBlock; width: parent.width}
122+
delegate: FlashDataBlockDelegate{header: flash_header; block: FlashDataBlock; width: parent.width}
111123
}
112124
}
113125

qml/FlashSegmentModel.qml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import xplatforms.cffflashcontainer.flashsegmentmodel 1.0
1010

1111
ColumnLayout
1212
{
13-
property string idk
13+
property string flash_name;
14+
property string idk;
1415
property CFFFlashSegment segment;
1516

1617
width: parent.width
@@ -25,15 +26,15 @@ ColumnLayout
2526
}
2627
Label
2728
{
28-
text: "FromAdress "
29+
text: "Address: "
2930
}
3031
Label
3132
{
3233
text: segment.FromAdress
3334
}
3435
Label
3536
{
36-
text: "SegmentLength "
37+
text: "Length (byte): "
3738
}
3839
Label
3940
{
@@ -69,7 +70,7 @@ ColumnLayout
6970

7071
onAccepted: {
7172
console.log("You chose: " + file_save_dialog.folder)
72-
segment.saveToFile(file_save_dialog.folder+"/"+segment.SegmentName+"_"+idk+".segment");
73+
ttip_id.show("Segment saved to: " +segment.saveToFile(file_save_dialog.folder+"/"+flash_name+"_"+idk+"_"+segment.SegmentName+".segment"), 2500);
7374
//loadCFF(fileDialog.currentFile);
7475
//Qt.quit()
7576
}
@@ -80,6 +81,14 @@ ColumnLayout
8081
//Component.onCompleted: visible = true
8182
}
8283

84+
ToolTip
85+
{
86+
id: ttip_id
87+
//parent: parent//btn_export_all
88+
anchors.centerIn: parent
89+
margins: 20
90+
}
91+
8392
}
8493

8594

0 commit comments

Comments
 (0)