当前位置: 首页>>代码示例>>C++>>正文


C++ Book::getAuthors方法代码示例

本文整理汇总了C++中Book::getAuthors方法的典型用法代码示例。如果您正苦于以下问题:C++ Book::getAuthors方法的具体用法?C++ Book::getAuthors怎么用?C++ Book::getAuthors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


在下文中一共展示了Book::getAuthors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateItemInfo

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("");
    }
}
开发者ID:Blurred-9L,项目名称:SharedEntertainmentLibrary,代码行数:82,代码来源:SELMainLibraryWidget.cpp


注:本文中的Book::getAuthors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。