Esempio n. 1
0
int addZeros(char *string,USINT len,size_t buff) {
    int i=0;
    if ((strlen(string)<len)&&(strlen(string)<buff-1)) {
        i=1;
        strncat(string,"0",1);
        return addZeros(string,len,buff);
    }
    return i; /* Return 1 if the function added at least one zero. 0 otherwise. */
}
Esempio n. 2
0
void SchedulerForm::on_listWidget_itemSelectionChanged(){

    ui->rmTaskBtn->setEnabled(ui->listWidget->selectedItems().length() > 0);
    ui->editTaskBtn->setEnabled(ui->listWidget->selectedItems().length() > 0);


    if(ui->listWidget->selectedItems().length() < 1){
        _currentID.clear();
        return;
    }

    QListWidgetItem *item = ui->listWidget->selectedItems().first();
    ui->labelName->setText(item->data(50).toString());
    _currentID = item->data(50).toString();

    QString executed;

    if(!item->data(57).toString().isEmpty()){
        executed = "Executed on event: "+item->data(57).toString();
    }else{
        if(item->data(51).toBool()){
            if(item->data(52).toBool()){
                executed = tr("Once, already done: %1").arg(QDateTime::fromTime_t(item->data(53).toUInt()).toString(Qt::ISODate));
            }else{
                executed = tr("Once, not done yet: %1").arg(QDateTime::fromTime_t(item->data(53).toUInt()).toString(Qt::ISODate));
            }
        }else{
            uint seconds = item->data(53).toUInt();
            executed = tr("Executed every %1, done %2 times").arg(
                            addZeros(QString::number(qFloor(seconds / 3600)),2) + ":" +
                            addZeros(QString::number(qFloor((seconds % 3600) / 60)),2) + ":" +
                            addZeros(QString::number(seconds % 60),2),
                            QString::number(item->data(54).toUInt())
                        );
        }
    }

    ui->labelExecuted->setText(executed);
    ui->scriptCodeDisplay->setPlainText(item->data(55).toString());
}
Esempio n. 3
0
void strEncodeSoundX(char *string,USINT len,size_t buff) {
    const char CAT1[]="BPFV";
    const char CAT2[]="CSKGJQXZ";
    const char CAT3[]="DT";
    const char CAT4[]="L";
    const char CAT5[]="MN";
    const char CAT6[]="R";
    if(addZeros(string,len,buff)==0) *(string+len)='\0';
    rplSpecific(string,CAT1,'1',buff);
    rplSpecific(string,CAT2,'2',buff);
    rplSpecific(string,CAT3,'3',buff);
    rplSpecific(string,CAT4,'4',buff);
    rplSpecific(string,CAT5,'5',buff);
    rplSpecific(string,CAT6,'6',buff);
}