Пример #1
0
void 
TrackDashboard::onCoverClicked()
{
    Album album = m_track.album();
    if (!album.isNull())
        QDesktopServices::openUrl( album.www() );
}
Пример #2
0
Album ParserAlbum::getAlbumFromFile(const QString &_name)
{
    m_pFile->close();
    if(!m_pFile->open(QIODevice::ReadOnly))
    {
        qDebug() << "Can`t open file : " << m_pFile->fileName();
    }
    Album newAlbum;
    newAlbum.setName(_name);
    QDomElement element = m_pDoc->documentElement();
    QDomNode node = element.firstChild();
    while(!node.isNull())
    {
        if(node.isElement())
        {
            QDomElement domElement = node.toElement();
            if(domElement.nodeName() == "images")
            {
                if(domElement.hasChildNodes())
                {
                    getImages(newAlbum,domElement.childNodes());
                }
            }
            if(domElement.nodeName() == "current")
            {
                newAlbum.setCurrentIndex(domElement.text().toInt());
            }
            node = node.nextSibling().toElement();
        }
    } 
    m_pFile->close();
    return newAlbum;
}
Пример #3
0
Album* Album::forId(int albumId) {

    if (cache.contains(albumId)) {
        // get from cache
        // qDebug() << "Album was cached" << albumId;
        return cache.value(albumId);
    }

    QSqlDatabase db = Database::instance().getConnection();
    QSqlQuery query(db);
    query.prepare("select title, year, artist from albums where id=?");
    query.bindValue(0, albumId);
    bool success = query.exec();
    if (!success) qDebug() << query.lastQuery() << query.lastError().text();
    if (query.next()) {
        Album* album = new Album();
        album->setId(albumId);
        album->setTitle(query.value(0).toString());
        album->setYear(query.value(1).toInt());

        // relations
        int artistId = query.value(2).toInt();
        // TODO this could be made lazy
        album->setArtist(Artist::forId(artistId));

        // put into cache
        cache.insert(albumId, album);
        return album;
    }
    cache.insert(albumId, 0);
    return 0;
}
void AlbumCoversAssetService::getCover(Core::DataItem* item)
{
    Controller::InfoController* controller = ICore::infoController();
    Album* album = qobject_cast<Album*>(item);

    if(!item->getMediaCollection())
        return;

    QString path = item->getMediaCollection()->getAssetFolderPath("AlbumCoversPreview").toString()+"/"+QString::number(item->getID()) + ".jpg";
    if((!QFile::exists(path) ) | overwriteCovers)
    {
        if(album && album->getName() != "Unbekannt")
        {
            Core::InfoRequest* request;
            QString infoType;
            if (saveHiresCovers)
                infoType = "org.safri.audio.album.cover.hires";
            else
                infoType = "org.safri.audio.album.cover";

            request = controller->getInfoForItem(infoType, album);
            connect(request, SIGNAL(infoDataAvailable()), this, SLOT(infoSlot()));
        }
    }
    else
    {
        qDebug()<<"Cover already exists... (: ";
    }

}
Пример #5
0
	Album* Track::GetAlbum()
	{
		Album* pAlbum = m_pSession->CreateAlbum();
		pAlbum->Load( sp_track_album( m_pTrack ) );

		return pAlbum;
	}
Пример #6
0
void SearchDialog::showCover( int ind ){

    int aind = searchResults->currentRow();
    if(aind==-1){
        return;
    }
    Album album = albums_[searchResults->currentItem()->data(Qt::UserRole).toString()];

    QList<QUrl> images = album.images();
    int n = images.size();
    //qDebug()<<"Trying to set cover "<<ind<<" of "<<n;
    if( n==0 ){
        currentCoverInd=0;
        return;
    }
    if( ind<0 ){
        ind=0;
    }
    if( ind>=n ){
        ind=n-1;
    }
    setCover( images[ind] );
    //qDebug()<<"Set cover "<<ind<<" of "<<n;
    currentCoverInd = ind;
    coverLabel->setText("Cover "+QString::number(ind+1)+" of "+QString::number(n));
}
Пример #7
0
Album::Album (const Album& alb, QQuickItem *parent):QQuickItem(parent)
{
    a_artist = alb.artist();
    a_title = alb.title();
    a_cover = alb.cover();
    a_year = alb.year();
    a_ID = alb.albumID();
}
Пример #8
0
void AlbumListPrivate::loadAlbums(const QVariantList &albums) {
    Q_Q(AlbumList);

    foreach (QVariant album, albums) {
        Album *a = new Album;
        a->d_func()->loadAlbum(album.toMap());
        m_albums.append(a);
    }
Пример #9
0
int album_db::findAlbum(int album_id)
{
    for(int i=0;i<albums.size();i++)
    {
        Album temp = albums.at(i);
        if( temp.getAlbumID() == album_id )
            return i;
    }
}
Пример #10
0
void TestAlbum::album_76101()
      {
      Album album;
      album.setName("test");
      album.append(new AlbumItem(root + "/" + DIR + "album_76101-01.mscx"));
      album.append(new AlbumItem(root + "/" + DIR + "album_76101-02.mscx"));
      album.createScore("album_76101.mscx");
      QVERIFY(compareFiles("album_76101.mscx", DIR + "album_76101-ref.mscx"));
      }
Пример #11
0
bool album_db::isAvailable(int album_id)
{
    int index = findAlbum(album_id);

    Album temp = albums.at(index);

    if( temp.isAvailable() )
        return true;
    return false;
}
Пример #12
0
void TestAlbum::album_78521()
      {
      Album album;
      album.setName("test");
      album.append(new AlbumItem(root + "/" + DIR + "album_78521-vbox.mscx"));
      album.append(new AlbumItem(root + "/" + DIR + "album_78521-vbox.mscx"));
      album.append(new AlbumItem(root + "/" + DIR + "album_78521-empty.mscx"));
      album.createScore("album_78521-vbox-vbox-empty.mscx");
      QVERIFY(compareFiles("album_78521-vbox-vbox-empty.mscx", DIR + "album_78521-vbox-vbox-empty-ref.mscx"));
      }
Пример #13
0
int main( int argc, char **argv )
{

  if ( argc < 2 ) {
    Error( "Missing configuration file in options. (testing.conf)" );
    exit( -1 );
  }

  srand( 345645631 );


  env.parse( argv[1] );
  env.Summary();


  std::vector<std::string> imgList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
                                                                 env["list-file"].c_str())) );
  imgList = std::move( path::FFFL( env["dataset"], imgList, ".png" ) );
  
  for ( auto& ele : imgList ) {
    printf( "%s\n", ele.c_str() );
  }


  Info( "Loading Learning Album ..." );
  Album<float> album;
  for ( auto& ele : imgList ) {
    album.push( std::move( cvFeat<HOG>::gen( ele ) ) );
  }
  Done( "Learning Album Loaded" );
  
  
  Info( "Loading Forest ..." );
  Forest<SimpleKernel<float> > forest( env["forest-name"] );
  
  Info( "Learning ..." );
  
  forest.PrepareWeitghts();
  
  float feat[album(0).GetPatchDim()];

  for ( int k=0; k<album.size(); k++ ) {
    for ( int i=0; i<album(k).rows; i++ ) {
      for ( int j=0; j<album(k).cols; j++ ) {
        album(k).FetchPatch( i, j, feat );
        forest.learn( feat );
      }
    }
    Info( "%d / %d learned.", k + 1, album.size() );
  }
  
  forest.writeWeights( env["forest-name"] );
  
  return 0;
}
Пример #14
0
void HackingWidget::on_pushButton_12_clicked()
{
    Controller::InfoController* controller = Core::ICore::infoController();
    Album* album = new Album(4711, "By the way");
    Artist* artist = new Artist(12, "Red Hot Chili Peppers");
    album->addArtist(artist);

    Core::InfoRequest* request = controller->getInfoForItem("org.safri.audio.album.cover.hires", album);
    connect(request, SIGNAL(infoDataAvailable()), this, SLOT(infoSlot()));

}
Пример #15
0
string album_db::showAlbums()
{
    std::stringstream out;
    for(int i=0;i<albums.size();i++)
    {
        Album temp = albums.at(i);
        out<<temp.albumStatus();
    }

    return out.str();
}
Пример #16
0
string album_db::showAlbumDetails(int album_id)
{
    std::stringstream out;

    int index = findAlbum(album_id);

    Album temp = albums.at(index);
    out << temp.albumDetails();

    return out.str();
}
Пример #17
0
void SearchDialog::saveCoverFromReply(QNetworkReply* reply){
    //image to be saved must exist in albumLineEdit.images

    QByteArray data = reply->readAll();
    QImage p;
    p.loadFromData(data);
    p.convertToFormat(QImage::Format_RGB32);
    reply->deleteLater();


    int aind = searchResults->currentRow();
    if(aind==-1){
        return;
    }    
    Album album = albums_[searchResults->currentItem()->data(Qt::UserRole).toString()];

    QList<QUrl> images = album.images();
    QString url = reply->url().toString();
    int cInd=-1;
    for(int i=0;i<images.size();i++){
        if(url==images[i].toString()){
            cInd=i;
            break;
        }
    }
    if(cInd==-1){
        return;
    }

    QString name = images[cInd].toString();
    //qDebug()<<name;
    int ind = name.lastIndexOf("/");
    if(ind==-1){
        ind = name.lastIndexOf("\\");
    }
    name = name.remove(0,ind+1);
    if(coverFormatCheckBox->isChecked()){
        int suffInd = name.lastIndexOf(".");
        QString ext = name.right(name.size()-suffInd);
        name = createCoverName( cInd+1, ext );
    }
    //qDebug()<<name;
    QString path = items_[0]->fileInfo().absoluteDir().absolutePath();
    name = path+"/"+name;
    int quality = settings->value("SearchDialog/coverQuality",-1).toInt();
    bool ok = p.save( name, 0, quality );
    if(!ok){
        QMessageBox::critical(this, "Could not save cover",
                              "Could not save cover "+url+" as "+name, QMessageBox::Ok, QMessageBox::Ok);
    }else{
        qDebug()<<"saved"<<name;
    }
}
Пример #18
0
void SearchDialog::saveCoverNow(){
    int ind = searchResults->currentRow();
    if(ind==-1){
        return;
    }
    Album album = albums_[searchResults->currentItem()->data(Qt::UserRole).toString()];
    if(album.images().size()==0){
        return;
    }
    QList<QUrl> images = album.images();
    saveCover( images[currentCoverInd] );
}
Пример #19
0
int main( int argc, char **argv )
{

  if ( argc < 2 ) {
    Error( "Missing configuration file in options. (training.conf)" );
    exit( -1 );
  }
  
  srand( 345645631 );

  env.parse( argv[1] );
  env.Summary();
  
  std::vector<std::string> imgList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
                                                                 env["list-file"].c_str())) );
  imgList =  std::move( path::FFFL( env["dataset"], imgList, ".png" ) );

  for ( auto& ele : imgList ) {
    printf( "%s\n", ele.c_str() );
  }


  Info( "Loading Training Album ..." );

  Album<float> album;
  for ( auto& ele : imgList ) {
    album.push( std::move( cvFeat<HOG>::gen( ele ) ) );
  }
  Done( "Training Album Loaded" );
  
  std::vector<FeatImage<float>::PatchProxy> l;
  
  for ( int k=0; k<album.size(); k++ ) {
    auto& ref = album(k);
    for ( int i=7; i<ref.rows-7; i++ ) {
      for ( int j=7; j<ref.cols-7; j++ ) {
        l.push_back( ref.Spawn( i, j ) );
      }
    }
  }


  timer::tic();
  Forest<SimpleKernel<float> > forest( env["forest-size"], l, env["proportion-of-data-per-tree"].toDouble() );
  Done( "Tree built within %.5lf sec.", timer::utoc() );

  forest.write( env["forest-name"] );

  return 0;
}
Пример #20
0
void ParserAlbum::getImages(Album & alb, QDomNodeList list)
{
    for(int i = 0; i < list.count(); ++i)
    {
        alb.append(new Image(list.at(i).toElement().text()));
    }
}
Пример #21
0
void MP3Player::addAlbum(Album album, int songsInAlbum)
{
	if (this->countAlbums < capacityALLAlbumsInMP3)
	{
		if ((this->countSongs + songsInAlbum) < capacityALLSongsInMP3)
		{
			this->albumsArr[countAlbums] = album;
			this->countAlbums += 1;
			
			int counter = 0;
			for (int i = this->countSongs; i < (this->countSongs + songsInAlbum); ++i)
			{
				this->songsArr[i] = album.getSongsArr()[counter];
				counter += 1;
			}
			this->countSongs += songsInAlbum;
		}
		else
		{
			cout << "You have reached the capacity of the songs and cannot add so many song!" << endl;
		}
	}
	else
	{
		cout << "You have reached the capacity of the albums and cannot add a new album!" << endl;
	}
}
Пример #22
0
void GetClassInvDistribution( Album<int> &lblAlbum,
                              double *classWeight )
{
  int counts[LabelSet::classes];
  memset( counts, 0, sizeof(int) * LabelSet::classes );

  int n = lblAlbum.size();
  int j = 0;
  for ( auto& lblImg : lblAlbum ) {
    int area = lblImg.rows * lblImg.cols;
    for ( int i=0; i<area; i++ ) {
      counts[*lblImg(i)]++;
    }
    progress( ++j, n, "calculating inverse weights" );
  }
  printf( "\n" );

  int s = sum_vec( counts, LabelSet::classes );

  for ( int i=0; i<LabelSet::classes; i++ ) {
    classWeight[i] = static_cast<double>(s) / counts[i];
  }


  double t = sum_vec( classWeight, LabelSet::classes ) / static_cast<double>( LabelSet::classes );
  for ( int i=0; i<LabelSet::classes; i++ ) {
    classWeight[i] /= t;
  }
}
Пример #23
0
Album* ResponseDecoder::assembleAlbum(const QJsonObject& albumJson, Artist* artist)
{
	// Creating album from json
	Album* album = createAlbum(albumJson, artist);

	// Looking for tracks in json
	QJsonArray trackArray = albumJson["tracks"].toArray();

	foreach (const QJsonValue& trackJsonValue, trackArray) {

		// Creating track from json
		Track* track = createTrack(trackJsonValue.toObject(), album);

		// Adding track to album
		album->addTrack(track);
	}
Пример #24
0
QList< Album* > Album::childAlbums(bool recursive)
{
    QList<Album*> childList;

    for (Album* child = this->firstChild(); child; child = child->next())
    {
        childList += child;

        if (recursive)
        {
            childList += child->childAlbums(recursive);
        }
    }

    return childList;
}
Пример #25
0
QString AlbumItemType::getHash(Song *song)
{
    Album*  album = song->getAlbum();
    int id;

    if (album->getName() == "Unbekannt")
    {
        id = 0;
    }
    else
    {
        id = album->getID();
    }

    return QString::number(id) + album->getName();
}
Пример #26
0
string album_db::findAlbumInfo(int album_id)
{
    string name;
    double price;
    for(int i=0;i<albums.size();i++)
    {
        Album temp = albums.at(i);
        if( temp.getAlbumID() == album_id )
        {
            name = temp.getAlbumName();
            price = temp.getAlbumPrice();
            break;
        }
    }
    std::ostringstream s;
    s << "Album\t" << name << "\t" << price;
    return s.str();
}
Пример #27
0
bool Album::isAncestorOf(Album* album) const
{
    bool val = false;
    Album* a = album;

    while (a && !a->isRoot())
    {
        if (a == this)
        {
            val = true;
            break;
        }

        a = a->parent();
    }

    return val;
}
Пример #28
0
void ImageCategoryDrawer::viewHeaderText(const QModelIndex& index, QString* header, QString* subLine) const
{
    ImageModel* sourceModel = index.data(ImageModel::ImageModelPointerRole).value<ImageModel*>();

    if (!sourceModel)
    {
        return;
    }

    int count = d->view->categoryRange(index).height();

    // Add here further model subclasses in use with ImageCategoryDrawer.
    // Note you need a Q_OBJECT in the class's header for this to work.
    ImageAlbumModel* albumModel = qobject_cast<ImageAlbumModel*>(sourceModel);

    if (albumModel)
    {
        Album* album = albumModel->currentAlbum();

        if (!album)
        {
            return;
        }

        switch (album->type())
        {
            case Album::PHYSICAL:
                textForPAlbum(static_cast<PAlbum*>(album), albumModel->isRecursingAlbums(), count, header, subLine);
                break;
            case Album::TAG:
                textForTAlbum(static_cast<TAlbum*>(album), albumModel->isRecursingTags(), count, header, subLine);
                break;
            case Album::DATE:
                textForDAlbum(static_cast<DAlbum*>(album), count, header, subLine);
                break;
            case Album::SEARCH:
                textForSAlbum(static_cast<SAlbum*>(album), count, header, subLine);
                break;
            case Album::FACE:
            default:
                break;
        }
    }
}
Пример #29
0
void BatchFaceDetector::continueAlbumListing()
{
    kDebug() << d->albumListing.isRunning() << !d->pipeline.hasFinished();

    // we get here by the finished signal from both, and want both to have finished to continue
    if (d->albumListing.isRunning() || !d->pipeline.hasFinished())
    {
        return;
    }

    if (d->albumTodoList.isEmpty())
    {
        return complete();
    }

    Album* album = d->albumTodoList.takeFirst();
    kDebug() << "Album" << album->title();
    d->albumListing.allItemsFromAlbum(album);
}
Пример #30
0
void SearchDialog::showAlbumInfo( const Album &a ){

    albumInfo->showAlbumInfo(a);

    artistLineEdit->setText(a.artists().join(", "));
    albumLineEdit->setText(a.title());
    genreLineEdit->setText(a.genre());
    qDebug()<<"a.year()"<<a.year();
    yearLineEdit->setText(QString::number(a.year()));
    formatLineEdit->setText( a.format() );
    countryLineEdit->setText( a.country() );
    labelLineEdit->setText( a.label() );
    //if( databaseComboBox->itemData(databaseComboBox->currentIndex()).toInt() == SearchDialog::DISCOGS ){
    if( database_->type()==MusicDatabase::DISCOGS ){
        rolesTextEdit->setText( a.roles().join(". ") );
        notesTextEdit->setText( a.notes() );
    }

}