void SELMainLibraryWidget::updateItemInfo(EntertainmentItem & item, unsigned long long type) { Book * bookItem = 0; Movie * movieItem = 0; MusicAlbum * musicItem = 0; Videogame * videogameItem = 0; int currentIndex = 4; unsigned size; /// Update title replaceLabelText(item.getTitle().c_str(), 0); /// Update genre replaceLabelText(item.getGenre().c_str(), 1); /// Update publisher replaceLabelText(item.getPublisher().c_str(), 2); /// Update year replaceLabelText(QString::number(item.getYear()), 3); /// Check type to write extra data. switch (type) { case 1: bookItem = dynamic_cast<Book *>(&item); if (bookItem != 0) { /// Write book data replaceLabelText("ISBN:", currentIndex++); replaceLabelText(bookItem->getIsbn().c_str(), currentIndex++); replaceLabelText("Authors:", currentIndex++); size = bookItem->getAuthors().size(); for (unsigned i = 0; i < size; i++) { replaceLabelText(bookItem->getAuthors()[i].c_str(), currentIndex++); } replaceLabelText("Num pages", currentIndex++); replaceLabelText(QString::number(bookItem->getNPages()), currentIndex++); } break; case 2: movieItem = dynamic_cast<Movie *>(&item); if (movieItem != 0) { /// Write movie data replaceLabelText("Director:", currentIndex++); replaceLabelText(movieItem->getDirector().c_str(), currentIndex++); replaceLabelText("Actors:", currentIndex++); size = movieItem->getMainActors().size(); for (unsigned i = 0; i < size; i++) { replaceLabelText(movieItem->getMainActors()[i].c_str(), currentIndex++); } replaceLabelText("Rating:", currentIndex++); replaceLabelText(Movie::getRatingString(movieItem->getRating()).c_str(), currentIndex++); } break; case 3: musicItem = dynamic_cast<MusicAlbum *>(&item); if (musicItem != 0) { /// Write music data replaceLabelText("Artist:", currentIndex++); replaceLabelText(musicItem->getArtist().c_str(), currentIndex++); replaceLabelText("Num tracks:", currentIndex++); replaceLabelText(QString::number(musicItem->getNTracks()), currentIndex++); replaceLabelText("Total duration:", currentIndex++); replaceLabelText(musicItem->getDuration().toString("hh:mm:ss"), currentIndex++); } break; case 4: videogameItem = dynamic_cast<Videogame *>(&item); if (videogameItem != 0) { replaceLabelText("Rating:", currentIndex++); replaceLabelText(Videogame::getRatingString(videogameItem->getEsrbRating()).c_str(), currentIndex++); replaceLabelText("Platform:", currentIndex++); replaceLabelText(Videogame::getPlatformString(videogameItem->getPlatform()).c_str(), currentIndex++); } break; default: Error::raiseError(Error::ERROR_UNKNOWN_ITEM_TYPE); break; } size = itemInfo.size(); while (currentIndex < (int)size) { itemInfo[currentIndex++]->setText(""); } }