I fixed the slow issue, but theres a new problem.
My custom model has a reimplemented setData() :
if(index.isValid() && role == Qt::DisplayRole ) {
if(index.column() == 4) {
int row = index.row();
tmp.
replace(4,
QString::number(value.
toInt()));
ROMs.replace(row, tmp.join(";"));
emit dataChanged(index, index);
return true;
} else {
return false;
}
}
return false;
}
bool RomList::setData(const QModelIndex &index, const QVariant &value, int role) {
if(index.isValid() && role == Qt::DisplayRole ) {
if(index.column() == 4) {
int row = index.row();
QStringList tmp = ROMs.at(row).split(";");
tmp.replace(4, QString::number(value.toInt()));
ROMs.replace(row, tmp.join(";"));
emit dataChanged(index, index);
return true;
} else {
return false;
}
}
return false;
}
To copy to clipboard, switch view to plain text mode
All the table data loads from ROMs QstringList, so if i change some cell of column 4, it will be updated, but only works with some cells, some works, some doesn't work, its trange.
Here is the data change:
void RetroGC
::incPlayed(QString stipo,
QString sid,
int num,
int row
) {
qint32 xt = gameList->index(row, 4).data(Qt::DisplayRole).toInt();
xt++;
tmp.
replace(4,
QString::number(xt
));
romList.
setValue(QString("ROMS/%1").
arg(num
), tmp.
join(";"));
gameList->setData( gameList->index(row, 4), xt, Qt::DisplayRole );
}
void RetroGC::incPlayed(QString stipo, QString sid, int num, int row) {
QSettings romList(QString("Data/ROMLists/%1/%2.rgl").arg(stipo).arg(sid), QSettings::IniFormat);
QStringList tmp = romList.value(QString("ROMS/%1").arg(num)).toString().split(";");
qint32 xt = gameList->index(row, 4).data(Qt::DisplayRole).toInt();
xt++;
tmp.replace(4, QString::number(xt));
romList.setValue(QString("ROMS/%1").arg(num), tmp.join(";"));
gameList->setData( gameList->index(row, 4), xt, Qt::DisplayRole );
}
To copy to clipboard, switch view to plain text mode
i've been 2 hours stucked and investigating, but i can't find where is the problem.
Bookmarks