Hey
In MyModel i have a list m_MSGList
If I add a item to the model I do the following:
m_MSGList.append(new MyMSGItem(this,...));
m_MSGList.append(new MyMSGItem(this,...));
To copy to clipboard, switch view to plain text mode
bool MyModel
::importTrace(QString Filename
){ bool ret=false;
QRegExp WData
("s([0-9a-fA-F]*)w([0-9a-fA-F]*).*");
QRegExp RData
("\\*([0-9a-fA-F]*)r([0-9a-fA-F]*).*");
while(!File.atEnd()){
CMD=File.readLine();
if(WData.indexIn(CMD) !=-1){
//qDebug()<<"W.Adr:"<<WData.cap(1)<<"W.Data:"<<WData.cap(2);
WString.append(WData.cap(1));
WString.append(WData.cap(2));
}
if(RData.indexIn(CMD) !=-1){
//qDebug()<<"R.Adr:"<<RData.cap(1)<<"R.Data:"<<RData.cap(2);
RString.append(RData.cap(1));
RString.append(RData.cap(2));
}
this
->addMSG
(QTime::currentTime(),WString,RString
);
WString.clear();
RString.clear();
}
ret=true;
}
return ret;
}
bool MyModel::importTrace(QString Filename){
bool ret=false;
QFile File(Filename);
QString CMD;
QByteArray WString, RString;
QRegExp WData("s([0-9a-fA-F]*)w([0-9a-fA-F]*).*");
QRegExp RData("\\*([0-9a-fA-F]*)r([0-9a-fA-F]*).*");
if(File.open(QIODevice::ReadOnly)){
while(!File.atEnd()){
CMD=File.readLine();
if(WData.indexIn(CMD) !=-1){
//qDebug()<<"W.Adr:"<<WData.cap(1)<<"W.Data:"<<WData.cap(2);
WString.append(WData.cap(1));
WString.append(WData.cap(2));
}
if(RData.indexIn(CMD) !=-1){
//qDebug()<<"R.Adr:"<<RData.cap(1)<<"R.Data:"<<RData.cap(2);
RString.append(RData.cap(1));
RString.append(RData.cap(2));
}
this->addMSG(QTime::currentTime(),WString,RString);
WString.clear();
RString.clear();
}
ret=true;
}
return ret;
}
To copy to clipboard, switch view to plain text mode
MyMSGItem is a MyVirtualDataItem:
class MyMSGItem: public MyVirtualDataItem
{
explicit MyMSGItem(MyModel *root,...);
};
class MyVirtualDataItem
{
MyVirtualDataItem *m_Root;
MyRowItem *m_StdItem;
QList<MyVirtualDataItem *>m_Data;
};
class MyRowItem
{
public:
};
{
Parent->appendRow(QList<QStandardItem *>()<<m_Tree<<m_Value<<m_Description<<m_Timestamp<<m_Type<<m_WData<<m_RData);
}
class MyMSGItem: public MyVirtualDataItem
{
explicit MyMSGItem(MyModel *root,...);
};
class MyVirtualDataItem
{
MyVirtualDataItem *m_Root;
MyRowItem *m_StdItem;
QList<MyVirtualDataItem *>m_Data;
};
class MyRowItem
{
public:
MyRowItem(QStandardItem* Parent);
QStandardItem *m_Tree;
QStandardItem *m_Value;
QStandardItem *m_Description;
QStandardItem *m_Timestamp;
QStandardItem *m_Type;
QStandardItem *m_WData;
QStandardItem *m_RData;
};
MyRowItem::MyRowItem(QStandardItem *Parent)
{
m_Tree=new QStandardItem();
m_Value=new QStandardItem();
m_Description=new QStandardItem();
m_Timestamp=new QStandardItem();
m_Type=new QStandardItem();
m_WData=new QStandardItem();
m_RData=new QStandardItem();
Parent->appendRow(QList<QStandardItem *>()<<m_Tree<<m_Value<<m_Description<<m_Timestamp<<m_Type<<m_WData<<m_RData);
}
To copy to clipboard, switch view to plain text mode
Bookmarks