Ejemplo n.º 1
0
/*
 * createSearchList
 * Function: Creates a binary search tree list from the EncodingTree passed
 * Parameters: The head of the search list; The EncodingTree to create the search tree list with; the current running code; the current running code length
 * Return: The binary search tree list
 */
SearchTreeList * createSearchList(SearchTreeList * head, EncodingTree * eTree, char * currentCode, int currentLength)
{
    SearchTree * temp;
    EncodingTree * tempETree;
    char * letterCode;
    int codeLength;

    temp = NULL;
    tempETree = eTree;
    letterCode = NULL;
    codeLength = currentLength;

    letterCode = malloc(sizeof(char) * (codeLength + 1));
    if(letterCode == NULL)
    {
        printf("Error: not enough memory\n");
        exit(0);
    }
    if(currentCode == NULL)
    {
        strcpy(letterCode, "");
    }
    else
    {
        /*printf("First Run\n");*/
        strcpy(letterCode, currentCode);
    }
    if(tempETree->lChild == NULL && tempETree->rChild == NULL)
    {
        temp = createSearchNode(tempETree, letterCode);
        head = insertSearchNode(head, temp);
    }
    else
    {
        codeLength++;
        /*printf("CodeLength: %d\n", codeLength);*/
        letterCode = realloc(letterCode, (sizeof(char) * (codeLength + 1)));
        letterCode[codeLength - 1] = '0';
        /*printf("CurrentLetterCode: %s\n", letterCode);*/
        head = createSearchList(head, tempETree->lChild, letterCode, codeLength);
        letterCode[codeLength - 1] = '1';
        /*printf("CurrentLetterCode: %s\n", letterCode);*/
        head = createSearchList(head, tempETree->rChild, letterCode, codeLength);
    }

    return(head);
}
Ejemplo n.º 2
0
PlistsGroup::PlistsGroup(QObject *parent) :
    QObject(parent)
{
    if(m_instance)
            qFatal("Only one instance of PlistsGroup object is allowed");

    m_instance = this;

    m_Settings = Settings::instance();

    m_Auth = Auth::instance();

    // Create new widget for playlist
    m_widget = new PlistsGroupWidget();

    // init vars
    m_LastList = 0;
    m_LastTrack = 0;

    m_bLoadMeta = false;
    m_bUseMeta = false;

    m_shuffleMode = m_Settings->getValue("player/shuffle").toInt();
    m_repeatMode  = m_Settings->getValue("player/repeat").toInt();

    connect(m_widget, SIGNAL(createSearchList()), SLOT(createSearchList()));
    connect(m_widget, SIGNAL(createLibraryList()), SLOT(createLibraryList()));
    connect(m_widget, SIGNAL(createLocalList()), SLOT(createLocalList()));
    connect(m_widget, SIGNAL(createSuggestionsList()), SLOT(createSuggestionsList()));
    connect(m_widget, SIGNAL(createDbSearch()), SLOT(createDbSearch()));

    connect(m_widget, SIGNAL(tabMoved(int,int)), SLOT(listSwap(int,int)));
    connect(m_widget, SIGNAL(removeTab(int)), SLOT(deleteList(int)));
    connect(m_widget, SIGNAL(renameTab(int, QString)), SLOT(renameList(int, QString)));

    loadLists();

    if(m_LastList)
        connect(this, SIGNAL(playLast()), m_LastList, SLOT(playLast()));

    if(m_Settings->getValue("playing/play_on_start").toBool() && m_LastList)
        QTimer::singleShot(200, m_LastList, SLOT(playLast()));
}