Exemple #1
0
void CmdBox::initList(){    
    getCmdList()->setIconSize(QSize(iconSize, iconSize));

    for(int i=0; i<getItemCount(); ++i){
        QListWidgetItem *item = new QListWidgetItem("", getCmdList());
        item->setIcon(QIcon::fromTheme(WARNING_ICON));
        item->setData(Qt::UserRole, i);
    }
    QListWidgetItem *item = new QListWidgetItem("", getCmdList());
    item->setIcon(QIcon::fromTheme(RUN_ICON));
    item->setData(Qt::UserRole, getItemCount());

    getCmdList()->item(0)->setSelected(true);    
    updateList("");
}
Exemple #2
0
CmdBox::CmdBox(QWidget *parent) :
    QDialog(parent), ui(new Ui::CmdBox), itemCount(4), selectedItem(0),iconSize(50),
    FOLDER_ICON("folder"), INTERNET_ICON("applications-internet"),
    PLAY_ICON("media-playback-start"), RUN_ICON("system-run"),
    WARNING_ICON("dialog-warning"),
    DEFAULT_WEB_BROWSER("google-chrome"), DEFAULT_FOLDER_EXPLORER("nautilus"),
    cmdManager(new CmdManager())
{
    ui->setupUi(this);
    initList();
    initSlotsAndSignals();

    getCmdList()->setMinimumHeight(iconSize*(itemCount+1) + iconSize/2);
    setMinimumHeight(getCmdList()->height() + 80);
    setMaximumHeight(getCmdList()->height() + 80);
}
Exemple #3
0
/******************** processCommands **************************************
    void processCommands(FILE *pfileCommand)
Purpose:
    Reads the Command file to process commands.  There are several types of
    records (see the program header for more information).
Parameters:
    I FILE *pfileCommand    command stream input
Notes:
    This calls:
        split
        getCmdList
        concCmd
        pipeCmd
**************************************************************************/
void processCommands(FILE *pfileCommand)
{
    // variables for command processing
    char szInputBuffer[MAX_BUFFER_SZ+1];    // input buffer for a single text line
    // variables for tokenizing
    int iTokenCnt;
    Token tokenM[MAX_TOKENS];
    // variables to understand the commands in the input text
    int iCmdCnt;
    Cmd cmdM[MAX_COMMANDS];
    // misc
    int rc;
    
    //  get command data until EOF
    while (fgets(szInputBuffer, MAX_BUFFER_SZ, pfileCommand) != NULL)
    {
        // if the line is just a line feed, ignore it
        if (szInputBuffer[0] == '\n')
            continue;
        // see if the command is a comment
        if (szInputBuffer[0]== '*')
        {
            printf("%s", szInputBuffer);
            continue;       // it was just a comment
        }
        printf(">>> %s", szInputBuffer);
        // split the line based on spaces
        iTokenCnt = split(tokenM, MAX_TOKENS, szInputBuffer, ' ');
        // print the tokens
        int i;
        printf("%3s %s\n", "Seq", "Token");
        for (i = 0; i < iTokenCnt; i++)
            printf("  %3d '%s'\n", i, tokenM[i]);
        if (iTokenCnt <= 0)
            errExit("Command was blank");
        // get the command list for this command
        memset(cmdM, 0, sizeof(cmdM));
        iCmdCnt = getCmdList(cmdM, tokenM, iTokenCnt);
        prtCmdList(cmdM, iCmdCnt);
        // process the particular command
        if (strcmp(tokenM[0], "conc")==0)
        {   // conc command
            rc = concCmd(cmdM, iCmdCnt, tokenM, iTokenCnt);
            if (rc != 0)
                printf("*** concCmd returned %d\n", rc);
        }
        else if (strcmp(tokenM[0], "pipe")==0)
        {   // pipe command
            rc = pipeCmd(cmdM, iCmdCnt, tokenM, iTokenCnt);
            if (rc != 0)
                printf("*** pipeCmd returned %d\n", rc);
        }
        else
            errExit("Invalid command: '%s'", tokenM[0]);
    }
    printf("\n");   // good place for a breakpoint
}
Exemple #4
0
QListWidgetItem *CmdBox::getItem(int row){
    return getCmdList()->item(row);
}