Ejemplo n.º 1
0
main() {
	Song allSongs[3];

	allSongs[0] = createSong ( "Hey Jude", 210, 2004 );
	allSongs[1] = createSong ( "Jambi", 256, 1992 );
	allSongs[2] = createSong ( "Lightning Crashes", 223, 1997 );
}
Ejemplo n.º 2
0
bool SqlModelFactory::getSong(const QString& filepath, Song::Ptr& song)
{
    if(!mDBManager.db()->isOpen())
        mDBManager.db()->open();

    QSqlQuery query(QString("SELECT id FROM songs WHERE filepath='%1'").arg(filepath));
    if(query.next())
    {
        if(query.isValid())
        {
            song = createSong(query.value(0).toUInt());
            return true;
        }
    }

    song = Song::Ptr(static_cast<Song*>(create("song")));
    song->setFilepath(filepath);
    try {
        song->save();
        mSongs[song->key()] = song; // Add the song to the map, for a future usage
    }
    catch(SqlInsertFailedException& e)
    {
        std::cerr << "The saving of a song failed in " << __FILE__ << ". If the song already exists in database, check the logic of the code that leads here." << std::endl;
    }

    return false;
}
void CMoodMgr::displayMenu(menuType m)
{
	actionType action = menu.display(m);
	while(action != ACTION_EXIT) {
		switch(action) {
			case ACTION_NEW_SECURE:
				displayMessage("CREATE SECURE SONG"); createSong(SONG_SECURE);
				break;
			case ACTION_NEW_PROMO:
				displayMessage("CREATE PROMO SONG"); createSong(SONG_PROMO);
				break;
			case ACTION_EDIT_SONG:
				displayMessage("EDIT SONG"); editSong();
				break;
			case ACTION_DELETE_SONG:
				displayMessage("DELETE SONG"); deleteSong();
				break;
			case ACTION_READ_FILE:
				displayMessage("READ FILE"); input();
				break;
			case ACTION_WRITE_FILE:
				displayMessage("WRITE FILE"); output();
				break;
			case ACTION_LIST_ALL:
				displayMessage("LIST ALL SONGS"); list();
				break;
			case ACTION_LIST_SECURE:
				displayMessage("LIST SECURE SONGS"); listSecure();
				break;
			case ACTION_LIST_PROMO:
				displayMessage("LIST PROMO SONGS"); listPromo();
				break;
			case ACTION_SORT_ARTIST:
				displayMessage("SORT BY ARTIST NAME"); sortArtist();
				break;
			case ACTION_SORT_SONGNAME:
				displayMessage("SORT BY SONG NAME"); sortSongName();
				break;
			case ACTION_SORT_DURATION:
				displayMessage("SORT BY DURATION");	sortDuration();
				break;
			case ACTION_MODIFY_POPULARITY:
				displayMessage("MODIFY SONG POPULARITY"); editPopularity();
				break;
			case ACTION_SORT_SONGS_POPULARITY:
				displayMessage("SORT SONGS BY POPULARITY"); sortSongPopularity();
				break;
			case ACTION_SORT_ARTISTS_POPULARITY:
				displayMessage("SORT ARTISTS BY POPULARITY"); sortArtistPopularity();
				break;
			case ACTION_MENU_TOP:
				m = MENU_TOP;
				break;
			case ACTION_MENU_NEW:
				m = MENU_NEW;
				break;
			case ACTION_MENU_EDIT:
				m = MENU_EDIT;
				break;
			case ACTION_MENU_FILE:
				m = MENU_FILE;
				break;
			case ACTION_MENU_LIST:
				m = MENU_LIST;
				break;
			case ACTION_MENU_SORT:
				m = MENU_SORT;
				break;
			case ACTION_MENU_POPULARITY:
				m = MENU_POPULARITY;
				break;
			default:
				break;
		}
		action = menu.display(m);

	}
}