void BaseSqlTableModel::search(const QString& searchText, const QString& extraFilter) { if (sDebug) { qDebug() << this << "search" << searchText; } setSearch(searchText, extraFilter); select(); }
void LibraryTableModel::setTableModel(int id){ Q_UNUSED(id); QStringList columns; columns << "library."+LIBRARYTABLE_ID << "'' as preview"; QString tableName = "library_view"; QSqlQuery query(m_pTrackCollection->getDatabase()); QString queryString = "CREATE TEMPORARY VIEW IF NOT EXISTS "+tableName+" AS " "SELECT " + columns.join(", ") + " FROM library INNER JOIN track_locations " "ON library.location = track_locations.id " "WHERE (" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")"; query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query); } QStringList tableColumns; tableColumns << LIBRARYTABLE_ID; tableColumns << "preview"; setTable(tableName, LIBRARYTABLE_ID, tableColumns, m_pTrackCollection->getTrackSource("default")); // BaseSqlTabelModel will setup the header info initHeaderData(); setSearch(""); setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder); }
Pal::Pal() { // do not init and exit GEOS - we do it inside QGIS //initGEOS( geosNotice, geosError ); layers = new std::list<Layer*>(); lyrsMutex = new SimpleMutex(); ejChainDeg = 50; tenure = 10; candListSize = 0.2; tabuMinIt = 3; tabuMaxIt = 4; searchMethod = POPMUSIC_CHAIN; popmusic_r = 30; searchMethod = CHAIN; setSearch( CHAIN ); dpi = 72; point_p = 8; line_p = 8; poly_p = 8; this->map_unit = pal::METER; std::cout.precision( 12 ); std::cerr.precision( 12 ); }
void MissingTableModel::setTableModel(int id) { Q_UNUSED(id); QSqlQuery query(m_database); //query.prepare("DROP VIEW " + playlistTableName); //query.exec(); QString tableName("missing_songs"); QStringList columns; columns << "library." + LIBRARYTABLE_ID; query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS " "SELECT " + columns.join(",") + " FROM library " "INNER JOIN track_locations " "ON library.location=track_locations.id " "WHERE " + MissingTableModel::MISSINGFILTER); if (!query.exec()) { qDebug() << query.executedQuery() << query.lastError(); } //Print out any SQL error, if there was one. if (query.lastError().isValid()) { qDebug() << __FILE__ << __LINE__ << query.lastError(); } QStringList tableColumns; tableColumns << LIBRARYTABLE_ID; setTable(tableName, LIBRARYTABLE_ID, tableColumns, m_pTrackCollection->getTrackSource()); setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder); setSearch(""); }
AnalysisLibraryTableModel::AnalysisLibraryTableModel(QObject* parent, TrackCollection* pTrackCollection) : LibraryTableModel(parent, pTrackCollection, "mixxx.db.model.prepare") { m_bShowRecentSongs = true; setSearch("", RECENT_FILTER); }
void BaseExternalPlaylistModel::setPlaylist(QString playlist_path) { QSqlQuery finder_query(m_database); finder_query.prepare(QString("SELECT id from %1 where name=:name").arg(m_playlistsTable)); finder_query.bindValue(":name", playlist_path); if (!finder_query.exec()) { LOG_FAILED_QUERY(finder_query) << "Error getting id for playlist:" << playlist_path; return; } // TODO(XXX): Why not last-insert id? int playlistId = -1; QSqlRecord finder_query_record = finder_query.record(); while (finder_query.next()) { playlistId = finder_query.value( finder_query_record.indexOf("id")).toInt(); } if (playlistId == -1) { qDebug() << "ERROR: Could not get the playlist ID for playlist:" << playlist_path; return; } QString playlistViewTable = QString("%1_%2").arg(m_playlistTracksTable, QString::number(playlistId)); QStringList columns; columns << "track_id"; columns << "position"; columns << "'' AS " + LIBRARYTABLE_PREVIEW; QSqlQuery query(m_database); FieldEscaper f(m_database); QString queryString = QString( "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " "SELECT %2 FROM %3 WHERE playlist_id = %4") .arg(f.escapeString(playlistViewTable), columns.join(","), m_playlistTracksTable, QString::number(playlistId)); query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query) << "Error creating temporary view for playlist."; return; } columns[2] = LIBRARYTABLE_PREVIEW; setTable(playlistViewTable, columns[0], columns, m_trackSource); setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder); setSearch(""); }
void PlaylistTableModel::setTableModel(int playlistId) { //qDebug() << "PlaylistTableModel::setTableModel" << playlistId; if (m_iPlaylistId == playlistId) { qDebug() << "Already focused on playlist " << playlistId; return; } m_iPlaylistId = playlistId; QString playlistTableName = "playlist_" + QString::number(m_iPlaylistId); QSqlQuery query(m_database); FieldEscaper escaper(m_database); QStringList columns; columns << PLAYLISTTRACKSTABLE_TRACKID + " AS " + LIBRARYTABLE_ID << PLAYLISTTRACKSTABLE_POSITION << PLAYLISTTRACKSTABLE_DATETIMEADDED << "'' AS " + LIBRARYTABLE_PREVIEW // For sorting the cover art column we give LIBRARYTABLE_COVERART // the same value as the cover hash. << LIBRARYTABLE_COVERART_HASH + " AS " + LIBRARYTABLE_COVERART; // We drop files that have been explicitly deleted from mixxx // (mixxx_deleted=0) from the view. There was a bug in <= 1.9.0 where // removed files were not removed from playlists, so some users will have // libraries where this is the case. QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " "SELECT %2 FROM PlaylistTracks " "INNER JOIN library ON library.id = PlaylistTracks.track_id " "WHERE PlaylistTracks.playlist_id = %3") .arg(escaper.escapeString(playlistTableName), columns.join(","), QString::number(playlistId)); if (!m_showAll) { queryString.append(" AND library.mixxx_deleted = 0"); } query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query); } columns[0] = LIBRARYTABLE_ID; // columns[1] = PLAYLISTTRACKSTABLE_POSITION from above // columns[2] = PLAYLISTTRACKSTABLE_DATETIMEADDED from above columns[3] = LIBRARYTABLE_PREVIEW; columns[4] = LIBRARYTABLE_COVERART; setTable(playlistTableName, LIBRARYTABLE_ID, columns, m_pTrackCollection->getTrackSource()); setSearch(""); setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder); setSort(defaultSortColumn(), defaultSortOrder()); connect(&m_playlistDao, SIGNAL(changed(int)), this, SLOT(playlistChanged(int))); }
void CrateTableModel::setTableModel(int crateId) { //qDebug() << "CrateTableModel::setCrate()" << crateId; if (crateId == m_iCrateId) { qDebug() << "Already focused on crate " << crateId; return; } m_iCrateId = crateId; QString tableName = QString("crate_%1").arg(m_iCrateId); QSqlQuery query(m_database); FieldEscaper escaper(m_database); QString filter = "library.mixxx_deleted = 0"; QStringList columns; columns << "crate_tracks." + CRATETRACKSTABLE_TRACKID + " AS " + LIBRARYTABLE_ID << "'' AS " + LIBRARYTABLE_PREVIEW // For sorting the cover art column we give LIBRARYTABLE_COVERART // the same value as the cover hash. << LIBRARYTABLE_COVERART_HASH + " AS " + LIBRARYTABLE_COVERART; // We drop files that have been explicitly deleted from mixxx // (mixxx_deleted=0) from the view. There was a bug in <= 1.9.0 where // removed files were not removed from crates, so some users will have // libraries where this is the case. QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " "SELECT %2 FROM %3 " "INNER JOIN library ON library.id = %3.%4 " "WHERE %3.%5 = %6 AND %7") .arg(escaper.escapeString(tableName), columns.join(","), CRATE_TRACKS_TABLE, CRATETRACKSTABLE_TRACKID, CRATETRACKSTABLE_CRATEID, QString::number(crateId), filter); query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query); } columns[0] = LIBRARYTABLE_ID; columns[1] = LIBRARYTABLE_PREVIEW; columns[2] = LIBRARYTABLE_COVERART; setTable(tableName, columns[0], columns, m_pTrackCollection->getTrackSource()); setSearch(""); setDefaultSort(fieldIndex("artist"), Qt::AscendingOrder); }
QList<QObject*> NotesManager::getNotes(const QString& search) { m_notes.clear(); setSearch(search); QString queryString = "SELECT * FROM todolist"; if (m_search != "") queryString += " WHERE notes LIKE '%" + m_search + "%'"; queryString += " ORDER BY date"; QSqlQuery query(queryString); while (query.next()) { Note *entry = new Note(this); entry->setIndex(query.value(0).toInt()); entry->setMessage(query.value(1).toString()); entry->setAlarm(QDateTime::fromString(query.value(2).toString(), "yyyy-MM-dd HH:mm:ss")); m_notes << entry; } return m_notes; }
Settings::Settings(QMap<QString, QVariant> language, QMap<QString, QString> settings, QWidget *parent) : QDialog(parent), ui(new Ui::Settings) { ui->setupUi(this); setLanguageChoice(language); setLanguage(settings); setNewData(settings); setLoadData(settings); setSaveAsData(settings); setSaveData(settings); setQuit(settings); setUsers(settings); setSearch(settings); setSeeCategory(settings); setAddCategory(settings); setRemoveCategory(settings); setSeeMedia(settings); setAddMedia(settings); setRemoveMedia(settings); setSettings(settings); }
/* * BIG MACHINE */ std::list<LabelPosition*>* Pal::labeller( int nbLayers, char **layersName , double *layersFactor, double scale, double bbox[4], PalStat **stats, bool displayAll ) { #ifdef _DEBUG_ std::cout << "LABELLER (selection)" << std::endl; #endif Problem *prob; SearchMethod old_searchMethod = searchMethod; if ( displayAll ) { setSearch( POPMUSIC_TABU ); } #ifdef _VERBOSE_ clock_t start = clock(); double create_time; std::cout << std::endl << "bbox: " << bbox[0] << " " << bbox[1] << " " << bbox[2] << " " << bbox[3] << std::endl; #endif #ifdef _EXPORT_MAP_ // TODO this is not secure std::ofstream svgmap( "pal-map.svg" ); svgmap << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl << "<svg" << std::endl << "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"" << std::endl << "xmlns:cc=\"http://creativecommons.org/ns#\"" << std::endl << "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" << std::endl << "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl << "xmlns=\"http://www.w3.org/2000/svg\"" << std::endl << "xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl << "xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl << "width=\"" << convert2pt( bbox[2] - bbox[0], scale, dpi ) << "\"" << std::endl << "height=\"" << convert2pt( bbox[3] - bbox[1], scale, dpi ) << "\">" << std::endl; // TODO xmax ymax #endif QTime t; t.start(); // First, extract the problem // TODO which is the minimum scale ? (> 0, >= 0, >= 1, >1 ) if ( scale < 1 || ( prob = extract( nbLayers, layersName, layersFactor, bbox[0], bbox[1], bbox[2], bbox[3], scale, #ifdef _EXPORT_MAP_ & svgmap #else NULL #endif ) ) == NULL ) { #ifdef _VERBOSE_ if ( scale < 1 ) std::cout << "Scale is 1:" << scale << std::endl; else std::cout << "empty problem... finishing" << std::endl; #endif #ifdef _EXPORT_MAP_ svgmap << "</svg>" << std::endl; svgmap.close(); #endif // nothing to be done => return an empty result set if ( stats ) ( *stats ) = new PalStat(); return new std::list<LabelPosition*>(); } std::cout << "PAL EXTRACT: " << t.elapsed() / 1000.0 << " s" << std::endl; t.restart(); // reduce number of candidates // (remove candidates which surely won't be used) prob->reduce(); #ifdef _VERBOSE_ std::cerr << prob->nblp << "\t" << prob->nbOverlap; #endif prob->displayAll = displayAll; #ifdef _VERBOSE_ create_time = double( clock() - start ) / double( CLOCKS_PER_SEC ); std::cout << std::endl << "Problem : " << prob->nblp << " candidates for " << prob->nbft << " features makes " << prob->nbOverlap << " overlaps" << std::endl; std::cout << std::endl << "Times:" << std::endl << " to create problem: " << create_time << std::endl; #endif // search a solution if ( searchMethod == FALP ) prob->init_sol_falp(); else if ( searchMethod == CHAIN ) prob->chain_search(); else prob->popmusic(); std::cout << "PAL SEARCH (" << searchMethod << "): " << t.elapsed() / 1000.0 << " s" << std::endl; t.restart(); // Post-Optimization //prob->post_optimization(); std::list<LabelPosition*> * solution = prob->getSolution( displayAll ); if ( stats ) *stats = prob->getStats(); #ifdef _EXPORT_MAP_ prob->drawLabels( svgmap ); svgmap << "</svg>" << std::endl; svgmap.close(); #endif #ifdef _VERBOSE_ clock_t total_time = clock() - start; std::cout << " Total time: " << double( total_time ) / double( CLOCKS_PER_SEC ) << std::endl; std::cerr << "\t" << create_time << "\t" << double( total_time ) / double( CLOCKS_PER_SEC ) << std::endl; #endif delete prob; if ( displayAll ) { setSearch( old_searchMethod ); } return solution; }