void OptionsWindow::SaveAConfig(int step, bool nomesseage = true) {
    QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // создание нового объекта
    // Функция сохраения конфигурационных файлов по маске
    // №1 - что сохраняем - 0 = только HOSTAPD; 1 - DNSMASQ
    QString temp;
    QDateTime TimeNow;
    QString dateUNIXNow;
    if(step == 0) {
        //  Сохраняем только HOSTAPD
        temp = getMaskToConfig(0);
        QFile::remove("/etc/hostapd/hostapd.conf");
        QFile hostapd_config("/etc/hostapd/hostapd.conf");
        hostapd_config.open(QIODevice::WriteOnly);
        QTextStream out(&hostapd_config);
        out << temp;
        hostapd_config.close();


        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd config succesfully update."), QString("1")));

        // Hostapd
        if(!nomesseage) {
            QMessageBox msgBoxHostapd;
            msgBoxHostapd.setText(tr("Конфигурационный файл обновлён"));
            msgBoxHostapd.setIcon(QMessageBox::Information);
            msgBoxHostapd.setInformativeText(tr("Настройки Hostapd успешно сохранены. Для вступления их в силу, пожалуйста, перезапустите точку доступа."));
            msgBoxHostapd.setStandardButtons(QMessageBox::Ok);
            msgBoxHostapd.setDefaultButton(QMessageBox::Ok);
            msgBoxHostapd.exec(); }
        temp.clear();
    } else {
        //  Сохраняемфайл DNSMASQ
        // 1
        temp = getMaskToConfig(1);
        QFile::remove("/etc/dnsmasq.conf");
        QFile firstDHCPConfig("/etc/dnsmasq.conf");
        firstDHCPConfig.open(QIODevice::WriteOnly);
        QTextStream out1(&firstDHCPConfig);
        out1 << temp;
        firstDHCPConfig.close();
        temp.clear();
        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ config succesfully update."), QString("1")));

        // DHCP
        if(!nomesseage) {
            QMessageBox msgBoxDHCP;
            msgBoxDHCP.setText(tr("Конфигурационный файл обновлён"));
            msgBoxDHCP.setIcon(QMessageBox::Information);
            msgBoxDHCP.setInformativeText(tr("Настройки DHCP успешно сохранены. Для вступления их в силу, пожалуйста, перезапустите точку доступа."));
            msgBoxDHCP.setStandardButtons(QMessageBox::Ok);
            msgBoxDHCP.setDefaultButton(QMessageBox::Ok);
            msgBoxDHCP.exec(); }
        temp.clear();
    }
    delete GlobalSettings;
}
void OptionsWindow::SaveAConfig(int step, bool nomesseage = true) {
	QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // creating a new object
	// Функция сохраения конфигурационных файлов по маске
	// №1 - что сохраняем - 0 = только HOSTAPD; 1 - DNSMASQ
		QString temp;
		QDateTime TimeNow;
		QString dateUNIXNow;
	if(step == 0) {
		//  Save only HOSTAPD
		temp = getMaskToConfig(0);
		QFile::remove("/etc/hostapd/hostapd.conf");
		QFile hostapd_config("/etc/hostapd/hostapd.conf");
		hostapd_config.open(QIODevice::WriteOnly);
		QTextStream out(&hostapd_config);
		out << temp;
		hostapd_config.close();


		dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
		emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd config succesfully update."), QString("1")));

		// Hostapd
		if(!nomesseage) {
		QMessageBox msgBoxHostapd;
		msgBoxHostapd.setText(tr("The configuration file is updated"));
		msgBoxHostapd.setIcon(QMessageBox::Information);
		msgBoxHostapd.setInformativeText(tr("Hostapd Settings saved successfully. To enter into force, please restart the access point."));
		msgBoxHostapd.setStandardButtons(QMessageBox::Ok);
		msgBoxHostapd.setDefaultButton(QMessageBox::Ok);
		msgBoxHostapd.exec(); }
		temp.clear();
	} else {
		//  Сохраняемфайл DNSMASQ
		// 1
		temp = getMaskToConfig(1);
		QFile::remove("/etc/dnsmasq.conf");
		QFile firstDHCPConfig("/etc/dnsmasq.conf");
		firstDHCPConfig.open(QIODevice::WriteOnly);
		QTextStream out1(&firstDHCPConfig);
		out1 << temp;
		firstDHCPConfig.close();
		temp.clear();
		dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
		emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ config succesfully update."), QString("1")));

		// DHCP
		if(!nomesseage) {
		QMessageBox msgBoxDHCP;
		msgBoxDHCP.setText(tr("The configuration file is updated"));
		msgBoxDHCP.setIcon(QMessageBox::Information);
		msgBoxDHCP.setInformativeText(tr("DHCP Settings saved successfully. To enter into force, please restart the access point."));
		msgBoxDHCP.setStandardButtons(QMessageBox::Ok);
		msgBoxDHCP.setDefaultButton(QMessageBox::Ok);
		msgBoxDHCP.exec(); }
		temp.clear();
	}
	delete GlobalSettings;
}
void OptionsWindow::on_RestoreDHCP_clicked()
{
    /* Обнуляем все значения на вкладке "DHCP" */
    QMessageBox msgBox;
    msgBox.setText(tr("Сброс данных"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();
    switch (ret) {
    case QMessageBox::Ok:

        ui->IP_CLIENT1->setText("192.168.0.2");
        ui->IP_CLIENT2->setText("192.168.0.255");
        ui->Internet_iface->setCurrentIndex(0);
        ui->ip_time->setCurrentIndex(2);
        ui->UseGoogle->setChecked(true);
        QDateTime TimeNow;
        QString dateUNIXNow;
        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ settings set to default."), QString("1")));

        on_DHCPSave_clicked(false);
        break;
    }
}
void slm_client::sendMessagetoBuddy()
{
    if(m_ui->slm_client_outgoingTextArea->text() != "")
    {
        QDateTime currentTime;
        QString shownMessage;

        outGoingTextString = m_ui->slm_client_outgoingTextArea->text();

        if(!m_isLastMessageSendByMe || (isCleared == 1))
        {
             shownMessage += "(" + currentTime.currentDateTime().toString(DATE_FORMAT) + ") " + MY_NAME + ":";
             echo(HEADER,shownMessage);
             isCleared = 0;
        }

        echo(MESSAGE,outGoingTextString);

        m_isLastMessageSendByMe = true;

        outGoingTextString = encryptionObject.dencrypt(outGoingTextString, this->EncryptionKey);

        outGoingTextArray = outGoingTextString.toUtf8();
        outgoingSocket->write(outGoingTextArray);

        //clear the text field after writing the text
        m_ui->slm_client_outgoingTextArea->clear();
    }
}
void OptionsWindow::on_RestoreProg_clicked()
{
    /* Обнуляем все значения на вкладке "Приложение" */
    QMessageBox msgBox;
    msgBox.setText(tr("Сброс данных"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();

    switch (ret) {
    case QMessageBox::Ok:
        ui->UpdateTraffic->setValue(1);
        ui->Language->setCurrentIndex(0);
        ui->ClientPriceUpdate->setValue(5);

        QDateTime TimeNow;
        QString dateUNIXNow;
        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Programm settings set to default."), QString("1")));

        on_ProgSave_clicked();
        break;
    }
    OptionsWindow::on_ProgSave_clicked();
}
void OptionsWindow::on_RestoreDHCP_clicked()
{
    /* Resets all values tab "DHCP" */
    QMessageBox msgBox;
    msgBox.setText(tr("factory reset"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Caution All settings will be reset to the original. proceed?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();
	switch (ret) {
		case QMessageBox::Ok:

		ui->IP_CLIENT1->setText("192.168.0.2");
		ui->IP_CLIENT2->setText("192.168.0.255");
		ui->Internet_iface->setCurrentIndex(0);
		ui->ip_time->setCurrentIndex(2);
		ui->UseGoogle->setChecked(true);
		QDateTime TimeNow;
		QString dateUNIXNow;
		dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
		emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ settings set to default."), QString("1")));

		on_DHCPSave_clicked(false);
		break;
	}
}
void OptionsWindow::on_RestoreProg_clicked()
{
/* Resets all values in the "application" */
    QMessageBox msgBox;
    msgBox.setText(tr("factory reset"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Caution All settings will be reset to the original. proceed?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();

    switch (ret) {
		case QMessageBox::Ok:
			ui->UpdateTraffic->setValue(1);
			ui->Language->setCurrentIndex(0);
			ui->ClientPriceUpdate->setValue(5);

			QDateTime TimeNow;
			QString dateUNIXNow;
			dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
			emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Programm settings set to default."), QString("1")));

			on_ProgSave_clicked();
			break;
    }
    OptionsWindow::on_ProgSave_clicked();
}
void cLogFile::openLog()
{
    QString date = myLocaltime.currentDateTime().toLocalTime().toString("yyyyMMddhhmmss");
    QString fileName = "logs/osiBS_"+date+".csv";
    file.setFileName(fileName);
    file.open(QIODevice::WriteOnly);
}
void slm_client::readMessagefromBuddy(QString incomingMessage, QHostAddress peerAddress)
{
    QDateTime currentTime;
    QString shownMessage;

    //decrypt the message
    incomingMessage = encryptionObject.dencrypt(incomingMessage, this->EncryptionKey);

    // check if the message gui is open or not and open if it is not.
    if(this->getGuiKey() == 0)
    {
        this->show();
        this->setGuiKey(1);// set the gui key to one to indicate it is opened
        isFirstMessage = 1;
    }
    else
    {
        this->activateWindow();// if it is already opened, activate it before writing the message
    }

    //show the message to the by formatting
    if(m_isLastMessageSendByMe || (isFirstMessage == 1) || (isCleared == 1))
    {
         shownMessage += "(" + currentTime.currentDateTime().toString(DATE_FORMAT) + ") " + m_slmclientName + ":";
         echo(HEADER,shownMessage);
         isFirstMessage = 0;
         isCleared = 0;
    }
    echo(MESSAGE,incomingMessage);

    m_isLastMessageSendByMe = false;
}
void OptionsWindow::on_RestoreAP_clicked()
{
    /* Обнуляем все значения на вкладке "Hostapd" */
    QMessageBox msgBox;
    msgBox.setText(tr("Сброс данных"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();

    switch (ret) {
    case QMessageBox::Ok:
        ui->IP_SERVER->setText("192.168.0.1");
        ui->MASKA->setText("255.255.255.0");
        ui->SSID->setText("MyWiFI_AP");
        ui->ShowSSID->setChecked(false);
        ui->driver->setCurrentIndex(1);
        ui->Iface->setCurrentIndex(0);
        ui->TypeAP->setCurrentIndex(0);
        ui->Protection->setCurrentIndex(1);
        ui->CountryCode->setCurrentIndex(0);
        ui->Channels->setCurrentIndex(6);

        QDateTime TimeNow;
        QString dateUNIXNow;
        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd settings set to default."), QString("1")));

        on_APSave_clicked(false);
        break; }
}
Exemple #11
0
void CDatabaseModule::f_store_ibp(int chanel,int ss,int sz,int pj)
{
    QSqlQuery query;
    if(chanel  == 1)
    {
    query.prepare("INSERT INTO para_ibp1 (para_id, para_value1,para_value2,para_value3,para_time,para_date,para_datetime ) "
                  "VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_time,:para_date,:para_datetime )");
       query.bindValue(":para_id",DB_PARA_TYPE_IBP1);
    }
    else if(chanel == 2)
    {
        query.prepare("INSERT INTO para_ibp2 (para_id, para_value1,para_value2,para_value3,para_time,para_alm_flg1,para_alm_flg2,para_alm_flg3 ) "
                      "VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_time,:para_alm_flg1,:para_alm_flg2,:para_alm_flg3 )");
       query.bindValue(":para_id",DB_PARA_TYPE_IBP2);
    }


    query.bindValue(":para_value1",ss);
    query.bindValue(":para_value2",sz);
    query.bindValue(":para_value3",pj);
    bool flg = false;
    query.bindValue(":para_alm_flg1",ss);
    query.bindValue(":para_alm_flg2",sz);
    query.bindValue(":para_alm_flg3",pj);
    QDateTime time = QDateTime::currentDateTime();

    QString datetime = time.currentDateTime().toString(Qt::TextDate);
    QString sdate = time.toString("yyyy-MM-dd");
    QString stime = time.toString("hh:mm:ss");
    query.bindValue(":para_date",sdate);
    query.bindValue(":para_time",stime);
    query.bindValue(":para_datetime",datetime);
    query.exec();
}
void MainWindow::updateDate()
{
    QDateTime date;
    date = date.currentDateTime();
    qDebug() << date.toString("yyyy-MM-dd");
    dateSequence << date.toString("yyyy-MM-dd");
}
Exemple #13
0
CMoonCal::CMoonCal(QWidget *parent, mapView_t *view) :
  QDialog(parent),
///////////////////////////////////////////////////////
  ui(new Ui::CMoonCal)
{
  m_img = NULL;

  ui->setupUi(this);

  m_moon = new QPixmap(":/res/moon_small.png");
  m_sun  = new QPixmap(":/res/sun_small.png");

  m_isMoon = true;

  QDateTime t;

  t = t.currentDateTime();

  m_curDay = t.date().day();
  m_curMonth = t.date().month();
  m_curYear = t.date().year();

  jdConvertJDTo_DateTime(view->jd + view->geo.tz, &t);
  m_year = t.date().year();
  m_month = t.date().month();

  m_img = new QImage(1, 1, QImage::Format_ARGB32);
  m_view = *view;

  ui->comboBox->addItem(tr("Moon"));
  ui->comboBox->addItem(tr("Sun2", "Sun (not Sunday)"));
  ui->comboBox->setCurrentIndex(0);

  updateTime();
}
Exemple #14
0
void CDatabaseModule::f_store_nibp(int ss,int sz,int pj)
{
    QSqlQuery query;
    query.prepare("INSERT INTO para_nibp (para_id, para_value1,para_value2,para_value3,para_date,para_time,para_datetime,para_alm_flg1,para_alm_flg2,para_alm_flg3 ) "
                  "VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_date,:para_time,:para_datetime,:para_alm_flg1,:para_alm_flg2,:para_alm_flg3 )");

    query.bindValue(":para_id",DB_PARA_TYPE_NIBP);
    query.bindValue(":para_value1",ss);
    query.bindValue(":para_value2",sz);
    query.bindValue(":para_value3",pj);

    bool warningflg = true;

    query.bindValue(":para_alm_flg1",warningflg);
    warningflg = false;
    query.bindValue(":para_alm_flg2",warningflg);
    warningflg = true;
    query.bindValue(":para_alm_flg3",warningflg);

    QDateTime time = QDateTime::currentDateTime();

    QString datetime = time.currentDateTime().toString(Qt::TextDate);
    QString sdate = time.toString("yyyy-MM-dd");
    QString stime = time.toString("hh:mm:ss");
    query.bindValue(":para_date",sdate);
    query.bindValue(":para_time",stime);
    query.bindValue(":para_datetime",datetime);
    query.exec();
}
Exemple #15
0
bool phrase::showyourphrase(int number)//当用户点击词组学习的时候调用这个函数,提供用户选择的个数
{
    QSqlDatabase db=createConnection();
    if(!db.isValid())return false;
    QSqlQuery sql16(db);
    sql16.exec("select Chinese,English from phrase where note ='unlearned' and time ='unsure'");
    myphrase q;
    int t=number;
    int c=0;
    while(sql16.next())
    {
        q.English=sql16.value(0).toString();
        q.Chinese=sql16.value(1).toString();
        q1.append(q);//直接访问这个list得到需要的数据
        QDateTime time;
        QString a=time.currentDateTime().toString("yyyy-MM-dd");
        sql16.exec("update words set time = '"+a+"' where English='"+q.English+"'");
        c=c+1;
        if(c>t)//保证传给你的词组个数是用户要求的个数
        {
            break;
        }
    }
    return true;
}
MainWindow::~MainWindow()
{
    QDateTime TimeNow;
    QString dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
    LogSystemAppend(QString("%1|%2|%3|%4").arg(tr("WiFi Hostapd AP"), dateUNIXNow, tr("Programm closed"), QString("0")));
    delete ui;
}
Exemple #17
0
void OptionsWindow::on_RestoreAP_clicked()
{
    /* Resets all values tab "Hostapd" */
    QMessageBox msgBox;
    msgBox.setText(tr("factory reset"));
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setInformativeText(tr("Caution All settings will be reset to the original. proceed?"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Cancel);
    int ret = msgBox.exec();

    switch (ret) {
		case QMessageBox::Ok:
			ui->IP_SERVER->setText("192.168.0.1");
			ui->MASKA->setText("255.255.255.0");
			ui->SSID->setText("MyWiFI_AP");
			ui->ShowSSID->setChecked(false);
			ui->driver->setCurrentIndex(1);
			ui->Iface->setCurrentIndex(0);
			ui->TypeAP->setCurrentIndex(0);
			ui->Protection->setCurrentIndex(1);
			ui->CountryCode->setCurrentIndex(0);
			ui->Channels->setCurrentIndex(6);

			QDateTime TimeNow;
			QString dateUNIXNow;
			dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
			emit  toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd settings set to default."), QString("1")));

			on_APSave_clicked(false);
			break; 
    }
}
void DatePickerDialog::setupUi(QDialog *DatePickerDialog)
{
    if (DatePickerDialog->objectName().isEmpty())
        DatePickerDialog->setObjectName(QString::fromUtf8("DatePickerDialog"));
    DatePickerDialog->setWindowModality(Qt::WindowModal);
    DatePickerDialog->setAcceptDrops(false);
    DatePickerDialog->setModal(true);

    QGridLayout *mainGrid = new QGridLayout(this); // a 2 x n grid
    lblOccur = new QLabel("When did this ride occur?", this);
    mainGrid->addWidget(lblOccur, 0,0);
    dateTimeEdit = new QDateTimeEdit(this);

	// preset dialog to today's date  -thm
	QDateTime *dt = new QDateTime;
	date = dt->currentDateTime();
	dateTimeEdit->setDateTime(date);

    mainGrid->addWidget(dateTimeEdit,0,1);
    lblBrowse = new QLabel("Choose a CSV file to upload", this);
    mainGrid->addWidget(lblBrowse, 1,0);
    btnBrowse = new QPushButton(this);
    mainGrid->addWidget(btnBrowse,2,0);
    txtBrowse = new QLineEdit(this);
    mainGrid->addWidget(txtBrowse,2,1);

    btnOK = new QPushButton(this);
    mainGrid->addWidget(btnOK, 3,0);
    btnCancel = new QPushButton(this);
    mainGrid->addWidget(btnCancel, 3,1);

    DatePickerDialog->setWindowTitle(
        QApplication::translate("DatePickerDialog", "Import CSV file", 0,
                                QApplication::UnicodeUTF8));

    btnBrowse->setText(
        QApplication::translate("DatePickerDialog", "File to import...", 0,
                                QApplication::UnicodeUTF8));
    btnOK->setText(
        QApplication::translate("DatePickerDialog", "OK", 0,
                                QApplication::UnicodeUTF8));
    btnCancel->setText(
        QApplication::translate("DatePickerDialog", "Cancel", 0,
                                QApplication::UnicodeUTF8));

    connect(btnOK, SIGNAL(clicked()), this, SLOT(on_btnOK_clicked()));
    connect(btnBrowse, SIGNAL(clicked()), this, SLOT(on_btnBrowse_clicked()));
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(on_btnCancel_clicked()));

	// disable date picker and OK button until a file has been selected
	dateTimeEdit->setEnabled(FALSE);
	lblOccur->setEnabled(FALSE);
	btnOK->setEnabled(FALSE);

    Q_UNUSED(DatePickerDialog);
}
Exemple #19
0
void AddWLController::addWaitingList(Patient * aPatient,Facility * aLTC)
{
    QDateTime today;

    today.currentDateTime();
    qDebug() << today;
    QDateTime anowDate(today);
    aPatient->setdateWL(anowDate);
    aLTC->addWaitingList(aPatient);
}
void cLogFile::writeLog(QString msg)
{

    QString date = myLocaltime.currentDateTime().toLocalTime().toString( "yyyy.MM.dd_hh:mm:ss" );
    QByteArray log;
    log = QByteArray((date+";"+msg+"\n").toUtf8());
    file.write(log);
    file.flush();

}
void MainWindow::updateProgressBar(QString str, bool show)
{
    QMutexLocker locker(&this->progress_mutex);
    if (str.isEmpty() == false) {
        QDateTime now;
        if (show == true)
            emit log_changed(str);
        str.prepend(now.currentDateTime().toString("yyyy-MM-dd hh:mm "));
        log.append(str);
    }
}
Exemple #22
0
void AddWLController::addWaitingListXML(QString aHealthCardNum,QString aFName,QString aLName,QString aDateAdmitted,QString aDateWL,QString aReqCare,QString anOccCare,QString area)
{
    QDateTime today;

    Facility * aFacility ;
    int idFacility;
    QString idFacilityString;

    today = today.currentDateTime();
    QDateTime anowDate(today);
    QDateTime dateWL = QDateTime::fromString(aDateWL,"yyyy-MM-dThh:mm:ss");
    QDateTime dateadmitted =QDateTime::fromString("1.30.1","M.d.s");//Default one
    Patient * aPatient = new Patient(aHealthCardNum,aFName,aLName,dateadmitted,dateWL, aReqCare.toInt(),anOccCare.toInt());

  //  idFacility = MapWinCtrl::getInstance()->getWlArray(area.toInt()); //Get facility id of the facility that has the WL for that area
    //WILL WORK WHEN WE HAVE MORE DATA AND PROTOCOL

    idFacility=7;
    idFacilityString.setNum(idFacility);
    aFacility = MapWinCtrl::getInstance()->getFacilityFromid(idFacilityString);
    aFacility->addWaitingList(aPatient); //Add patient to the WL

    if (idFacilityString.toInt() == MapWinCtrl::getInstance()->getId())
    {
        QSqlQuery query;
        QString queryText;

        //the main insert script
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        queryText = "INSERT INTO waitinglist (areaID,patientID,wlRecordID,dte_added,dte_admitted)"
                    "VALUES (:areaID,:patientID,:wlRecordID,:dte_added ,:dte_admitted)";
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        query.prepare(queryText);

        //binding the variables from the form to the query
        int anArea,patientid,wlrecordid;
        anArea = area.toInt();
        patientid = aHealthCardNum.toInt();
        wlrecordid = aHealthCardNum.toInt();

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        query.bindValue(":areaID", anArea);
        query.bindValue(":patientID", patientid);
        query.bindValue(":wlRecordID", wlrecordid); //TO CHANGE TO REAL STUFF
        query.bindValue(":dte_added", aDateWL);
        query.bindValue(":dte_admitted", "2");
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        query.exec(); //executing the query
    }
}
void MainWindow::detect() {
  string sFileName, sFullPath;
  vector<FaceObject> faceObjects;

  // parse arguments
  string sClassifier = ui->dropDownDetect->currentText().toUtf8().data();
  string sPath = ui->inputPath->text().toUtf8().constData();

  // create subfolder with a timestamp and chosen classifiern
  QString path = ui->inputPath->text();
  QDir dir = path;
  QString fullPath = dir.absolutePath();
  if (!QDir(path + "/metaface").exists()) {
    QDir().mkdir("metaface");
  }
  QDateTime dateTime;
  QString date = dateTime.currentDateTime().toString();
  sTimestamp = dateTime.currentDateTime().toString().toUtf8().constData();
  sTimestamp = sTimestamp + "_" + sClassifier;
  QDir dirr = QDir::root();
  QString timestamp = QString::fromStdString(sTimestamp);
  dirr.mkpath(fullPath + "/metaface/" + timestamp +"/");

  // iterate through image folder and run detection on each image
  dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDot | QDir::NoDotDot | QDir::NoSymLinks);
  // add QDirIterator::Subdirectories as argument if you want to iterate trough subfolders
  QDirIterator it(dir);
  while(it.hasNext()) {
    it.next();
    sFileName = it.fileName().toUtf8().constData();
    faceObjects = detectFaces(sPath, sFileName, sClassifier);
    writeObjectFile(faceObjects, sPath + "/metaface/" + sTimestamp + "/"  + sFileName + ".txt");
    
  }

  ui->outputText->append("Detection done!");
}
Exemple #24
0
void CDatabaseModule::f_store_warning(int iWarningType,double value)
{
    QSqlQuery query;
    query.prepare("INSERT INTO warning_list (warning_typeid, warning_value,warning_time ) "
                  "VALUES (:warning_typeid, :warning_value, :warning_time )");

    query.bindValue(":warning_typeid",iWarningType);
    query.bindValue(":warning_value",value);

    QDateTime time = QDateTime();

    QString datetime = time.currentDateTime().toString(Qt::TextDate);
    query.bindValue(":warning_time",datetime);
    query.exec();
}
void MainWindow::FirsStartDetector() {
    QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat);
    QDateTime TimeNow;
    QString dateUNIXNow;

    if(GlobalSettings->value("Programm/FirstLoad", true).toBool()) {
        OptionsWindow options;
        options.on_APSave_clicked(true);
        options.on_DHCPSave_clicked(true);

        dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
        LogSystemAppend(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Configs created succesfully."), QString("1")));
        GlobalSettings->setValue("Programm/FirstLoad", false);
    }
    delete GlobalSettings;
}
Exemple #26
0
void databaseMain::purgeStuff() {

    QSqlQuery databaseEntry;
    QDateTime dateTime;
    dateTime = dateTime.currentDateTime();
    if(purgeUnits == "Minutes")
    {
        dateTime = dateTime.addSecs(-purgeNum*60);
    }
    if(purgeUnits == "Hours")
    {
        dateTime = dateTime.addSecs(-purgeNum*3600);
    }
    if(purgeUnits == "Days")
    {
        dateTime = dateTime.addDays(-purgeNum);
    }
    if(purgeUnits == "Months")
    {
        dateTime = dateTime.addMonths(-purgeNum);
    }
    if(purgeUnits == "Years")
    {
        dateTime = dateTime.addYears(-purgeNum);
    }

    QString testString = dateTime.toString();

    //qDebug() << "Purgetime!!!!!!!" << testString;

    databaseEntry.exec("SELECT Timestamp FROM packets");
    while(databaseEntry.next()){
        if(databaseEntry.value(0).toString() < testString)
        {
            qDebug() << "DatabaseTimeStamp: " << databaseEntry.value(0).toString();

            databaseEntry.prepare("DELETE FROM packets WHERE Timestamp = :Time");
            databaseEntry.bindValue(":Time",databaseEntry.value(0).toString());
            qDebug() << dataBase.lastError() << "---------------";
            databaseEntry.exec();
            qDebug() << databaseEntry.lastError() << "---------------";
        }

    }

}
void OSCLoginWindow::onLoginRequestResult(QNetworkReply* reply)
{
    if (reply->error() != QNetworkReply::NoError) {
        ui->prompt->setText(RICH_TEXT(RED_COLOR,"貌似红薯又爆菊了"));
        return;
    }

    QString data = (QString) reply->readAll();
    if (OSC_HTTPS_LOGIN_URL == reply->url()) {
        //parse xml
        xml->setData(data);
        if (xml->isErrored()) {
            ui->prompt->setText(RICH_TEXT(RED_COLOR,CONVERT_TO_C_CHAR(xml->getErrorMessage())));
            //reopen
            changeState();
            //update focus
            ui->loginname->setFocus();
            return;
        }
        //login success and update the login flag
        loginSuccess = true;
        QMovie *loadingMovie = new QMovie(":/login/loading");
        ui->prompt->setMovie(loadingMovie);
        loadingMovie->start();
       OSCUser* user = xml->getOSCUser();

       QWebView *web = new QWebView;
       web->load(QUrl(user->getPortrait()));
       web->show();
       manager->get(QNetworkRequest(QUrl("http://farm5.static.flickr.com/4101/4798839454_725882374d_b.jpg")));
    }else{
        qDebug() << "get avatar";
        QPixmap currentPicture;
        currentPicture.loadFromData(reply->readAll());
        QDateTime now;
        QString filename = now.currentDateTime().toString("yyMMddhhmmss.jpg");
        currentPicture.save(QString("/Users/BruceZCQ/Downloads/").append(filename));
        QLabel *ImageLabel = new QLabel();
//        QMovie *move = new QMovie(filename);
//        ImageLabel->setMovie(move);
//        move->start();

        ImageLabel->setPixmap(currentPicture);
        ImageLabel->show();
    }
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat);
    ui->setupUi(this);

    if(GlobalSettings->value("Programm/version", "").toString() != ProgrammVersion)
        GlobalSettings->setValue("Programm/version", ProgrammVersion); // Обновляем версию в конфиге
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if(Platform.DisableDNSMASQinUbuntuPreciseInNM)
        CheckUbuntuPrecsisNM(); // Проверяем, не Ubuntu 12.04 ли это, где у меня забрали управление DNSMASQ?
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if(Platform.CheckHOSTAPDscript)
        CheckHostapdInitdScript(); // Проверяем, не Ubuntu ли это, где поломали скрипт запуска Hostapd?
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    FirsStartDetector(); // Проверяем, не первый ли это запуск это программы? Может надо восстановить конфиги?
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////

    QDateTime TimeNow;
    QString dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
    LogSystemAppend(QString("%1|%2|%3|%4").arg(tr("WiFi Hostapd AP"), dateUNIXNow, tr("Programm loaded and ready"), QString("0")));
    checkStatus();

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(TrafficUpdate()));
    timer->start(GlobalSettings->value("Programm/UpdateTraffic", 1).toInt() * 1000);

    QTimer *ClientUpdate = new QTimer(this);
    connect(ClientUpdate, SIGNAL(timeout()), this, SLOT(ClientPriseUpdate()));
    ClientUpdate->start(GlobalSettings->value("Programm/ClientsPriceUpdateTime", 5).toInt() * 1000);
    // иконки?

    ui->Activate->setIcon(iconReturn("system-run"));
    ui->Disactive->setIcon(iconReturn("dialog-close"));
    ui->Exit->setIcon(iconReturn("application-exit"));
    ui->OptW->setIcon(iconReturn("configure"));
    ui->Log->setIcon(iconReturn("applications-system"));
    ui->EditorW->setIcon(iconReturn("document-edit"));
    ui->AboutW->setIcon(iconReturn("dialog-information"));
    delete GlobalSettings;
}
Exemple #29
0
void CDatabaseModule::f_store_anaes(int value)
{
    QSqlQuery query;
    query.prepare("INSERT INTO para_anaes (para_id, para_value1,para_time,para_alm_flg1,para_date,para_datetime ) "
                  "VALUES (:para_id, :para_value1, :para_time,:para_alm_flg1,:para_date,:para_datetime )");

    query.bindValue(":para_id",DB_PARA_TYPE_ANAES);
    query.bindValue(":para_value1",value);

    QDateTime time = QDateTime::currentDateTime();

    QString datetime = time.currentDateTime().toString(Qt::TextDate);
    QString sdate = time.toString("yyyy-MM-dd");
    QString stime = time.toString("hh:mm:ss");
    query.bindValue(":para_date",sdate);
    query.bindValue(":para_time",stime);
    query.bindValue(":para_datetime",datetime);
    query.exec();
}
Exemple #30
0
int main(int argc, char *argv[])
{

    /* 设置随机数种子 */
    qsrand(time(NULL));

    /* 打印当前时间 */
    QDateTime abc;
    qDebug()  << abc.currentDateTime().toString();

    /* 启动线程调度循环 */
    QApplication a(argc, argv);

    /* 显示桌面 */
    Desktop d;
    d.show();

    return a.exec();
}