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


C++ Media::uid方法代码示例

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


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

示例1: rate

void User::rate(Wt::Dbo::ptr< User > userPtr, const Media& media, int rating, Wt::Dbo::Transaction& transaction) {
  MediaRatingPtr previousRating = transaction.session().find<MediaRating>()
    .where("user_id = ?").bind(userPtr.id())
    .where("media_id = ?").bind(media.uid());
  if(!previousRating) {
    transaction.session().add(new MediaRating{userPtr, media.uid(), rating});
    return;
  }
  previousRating.modify()->setRating(rating);
}
开发者ID:geolffrey,项目名称:Pandorica,代码行数:10,代码来源:user.cpp

示例2: it

void MediaCollection::Private::listDirectory( boost::filesystem::path path, shared_ptr< MediaDirectory > rootDirectory )
{
  vector<fs::directory_entry> v;

  try
  {
    fs::recursive_directory_iterator it( path, fs::symlink_option::recurse );
    while(it != fs::recursive_directory_iterator()) {
      if(it.level() > 20)
        it.pop();
      try {
        v.push_back(*it++);
      } catch(std::exception &e) {
        log("notice") << "Error scanning for path " << *it  << ": " << e.what();
        it.pop();
      }
    }
    //copy( fs::recursive_directory_iterator( path, fs::symlink_option::recurse, ec ), fs::recursive_directory_iterator(), back_inserter( v ) );
//     sort( v.begin(), v.end() ); // TODO: not needed?

    for( fs::directory_entry entry : v )
    {
      Media media = resolveMedia( entry.path() );

      if( media.valid() && isAllowed( entry.path() ) )
      {
        Media media {entry.path()};
        collection[media.uid()] = media;
        rootDirectory->add(media);
      }
    }
  }
  catch
    ( std::exception &e )
  {
    log( "error" ) << "Error trying to add path " << path << ": " << e.what();
  }
}
开发者ID:GuLinux,项目名称:Pandorica,代码行数:38,代码来源:mediacollection.cpp

示例3: uid

bool Media::operator==( const Media &other ) const
{
  return other.uid() == uid();
}
开发者ID:GuLinux,项目名称:Pandorica,代码行数:4,代码来源:media.cpp

示例4: info

void MediaInfoPanel::info( Media &media )
{
  clear();
  WContainerWidget *header = WW<WContainerWidget>().setContentAlignment( AlignCenter );
  Dbo::Transaction t( *d->session );
  WString title = media.title( t );
  header->addWidget( WW<WText>( title ).css( "media-title" ) );
  Dbo::ptr<MediaAttachment> previewAttachment = media.preview( t, Media::PreviewPlayer );

  if( previewAttachment )
  {
    WLink previewLink = previewAttachment->link( previewAttachment, t, header );
    WLink fullImage = previewLink;

    Dbo::ptr<MediaAttachment> fullImageAttachment = media.preview( t, Media::PreviewFull );

    if( fullImageAttachment )
      fullImage = fullImageAttachment->link( fullImageAttachment, t, header );

    WAnchor *fullImageLink = new WAnchor {fullImage, WW<WImage>(previewLink, title).css("img-responsive img-rounded")};
    fullImageLink->setTarget( Wt::AnchorTarget::TargetNewWindow );
    header->addWidget( fullImageLink );
  }
  else
  {
    auto iconType = ( media.mimetype().find( "video" ) == string::npos ) ? Settings::AudioFile : Settings::VideoFile;
    WImage *icon = new WImage { d->settings->icon( iconType ) };
    header->addWidget( icon );
  }

  auto mediaMediaInfoPanel = d->createPanel( "mediabrowser.information" );
  WTable *table = new WTable( mediaMediaInfoPanel.second );
  table->setWidth( WLength( 100, WLength::Percentage ) );
  d->labelValueBox( "mediabrowser.filename", WString::fromUTF8(media.filename()), table );
  d->labelValueBox( "mediabrowser.filesize", Utils::formatFileSize( fs::file_size( media.path() ) ), table );

  MediaPropertiesPtr mediaProperties = media.properties( t );

  if( mediaProperties )
  {
    d->labelValueBox( "mediabrowser.creation_time", mediaProperties->creationTime().toString(), table );
    d->labelValueBox( "mediabrowser.medialength", WTime( 0, 0, 0 ).addSecs( mediaProperties->duration() ).toString(), table );

    if( media.mimetype().find( "video" ) != string::npos && mediaProperties->width() > 0 && mediaProperties->height() > 0 )
      d->labelValueBox( "mediabrowser.resolution", WString( "{1}x{2}" ).arg( mediaProperties->width() ).arg( mediaProperties->height() ), table );
  }

  Ratings rating = MediaRating::ratingFor( media, t );

  if( rating.users > 0 )
  {
    WContainerWidget *avgRatingWidget = new WContainerWidget;

    for( int i = 1; i <= 5; i++ )
    {
      avgRatingWidget->addWidget( WW<WImage>( Settings::staticPath( "/icons/rating_small.png" ) ).css( rating.ratingAverage < i ? "rating-unrated" : "" ) );
    }

    d->labelValueBox( "mediabrowser.rating", avgRatingWidget, table );
  }

  auto actions = d->createPanel( "mediabrowser.actions" );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.play" ) ).css( "btn btn-block btn-sm btn-primary" ).onClick( [ = ]( WMouseEvent )
  {
    d->play.emit( media );
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.queue" ) ).css( "btn btn-block btn-sm" ).onClick( [ = ]( WMouseEvent )
  {
    d->queue.emit( media );
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "mediabrowser.share" ) ).css( "btn btn-block btn-sm" ).onClick( [ = ]( WMouseEvent )
  {
    Wt::Dbo::Transaction t( *d->session );
    WW<WMessageBox>(wtr( "mediabrowser.share" ),
                    wtr( "mediabrowser.share.dialog" )
                      .arg( media.title( t ) )
                      .arg( d->settings->shareLink( media.uid() ).url() ),
                    Wt::Information, Ok)
    .button(Ok, [=](WMessageBox *msgBox){ msgBox->accept(); }).get()->show();
  } ) );
  addWidget( WW<WPushButton>( wtr( "button.close.info" ) ).css( "btn btn-primary btn-block hidden-lg hidden-md" )
             .onClick( [ = ]( WMouseEvent )
  {
    wasResetted().emit();
  } ) );
  actions.second->addWidget( WW<WPushButton>( wtr( "player.downloadlink" ) ).css( "btn btn-block btn-sm btn-success" ).onClick( [ = ]( WMouseEvent )
  {
    WDialog *downloadDialog = new WDialog(wtr("player.downloadlink"));
    downloadDialog->contents()->addWidget(new WText{wtr("player.downloadlink.message").arg(d->settings->linkFor( media.path() , d->session).url()), XHTMLUnsafeText});
    downloadDialog->footer()->addWidget(WW<WPushButton>(wtr("button.ok")).css("btn btn-primary").onClick([=](WMouseEvent){ downloadDialog->accept(); }));
    downloadDialog->show();
  } ) );
  addWidget( WW<WPushButton>( wtr( "button.close.info" ) ).css( "btn btn-primary btn-block hidden-lg hidden-md" )
             .onClick( [ = ]( WMouseEvent )
  {
    wasResetted().emit();
  } ) );
  addWidget( header );
  addWidget( mediaMediaInfoPanel.first );
  addWidget( actions.first );
//.........这里部分代码省略.........
开发者ID:geolffrey,项目名称:Pandorica,代码行数:101,代码来源:mediainfopanel.cpp


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