void TrackDashboard::onCoverClicked() { Album album = m_track.album(); if (!album.isNull()) QDesktopServices::openUrl( album.www() ); }
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; }
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... (: "; } }
Album* Track::GetAlbum() { Album* pAlbum = m_pSession->CreateAlbum(); pAlbum->Load( sp_track_album( m_pTrack ) ); return pAlbum; }
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)); }
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(); }
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); }
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; } }
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")); }
bool album_db::isAvailable(int album_id) { int index = findAlbum(album_id); Album temp = albums.at(index); if( temp.isAvailable() ) return true; return false; }
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")); }
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; }
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())); }
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(); }
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(); }
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; } }
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] ); }
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; }
void ParserAlbum::getImages(Album & alb, QDomNodeList list) { for(int i = 0; i < list.count(); ++i) { alb.append(new Image(list.at(i).toElement().text())); } }
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; } }
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; } }
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); }
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; }
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(); }
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(); }
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; }
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; } } }
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); }
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() ); } }