1016,3 → 1016,55 |
} |
|
} |
|
|
|
|
QMap <QString, QPixmap> MainWindow::getClassesIcons(){ // ïîëó÷àåì ñïèñîê èêîíîê äëÿ êëàññîâ |
// â êà÷åñòâå êëþ÷à ïîëó÷èì ID êëàññà, à â êà÷åñòâå çíà÷åíèé - èçîáðàæåíèÿ èêîíîê |
|
QMap <QString, QPixmap> result_map; |
QSqlQuery q; |
QString sql_str; |
QString str_tmp; |
QString field; |
QString result; |
int field_id, field_icon; |
bool ok; |
sql_str = tr("select * " |
" from `ListOfClasses` " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
); |
|
q.prepare(sql_str); |
|
ok = q.exec(); |
if (!ok) { |
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
this, // Ðîäèòåëüñêèé âèäæåò. |
QObject::tr("Database Error"), // Çàãîëîâîê. |
q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
return result_map; |
} |
field_id = q.record().indexOf(tr("ID")); |
field_icon = q.record().indexOf(tr("Icon")); |
while(q.next()){ |
QString classID; |
QByteArray loadimage = q.value(field_icon).toByteArray(); |
classID = q.value(field_id).toString(); |
if( !loadimage.isEmpty() ) |
{ |
QPixmap pixmap; |
pixmap.loadFromData(loadimage); |
result_map.insert(classID, pixmap); |
|
} |
else continue; |
|
|
|
} |
|
return result_map; |
|
|
} |