DishInfoDialog::DishInfoDialog(CBEngine *engine, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DishInfoDialog),
    _menuItem(NULL)
{
    _engine = engine;

    ui->setupUi(this);
    QRegExp regx("[0-9]*[.]?[0-9]*");
    QValidator *validator = new QRegExpValidator(regx, this);
    ui->lineEditPrice->setValidator(validator);
    ui->lineEditScore->setValidator(validator);

    QPalette pe;
    pe.setColor(QPalette::WindowText,Qt::red);
    ui->labelWarning->setPalette(pe);

    ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("保存"));
    ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("应用"));
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("取消"));
    ui->buttonBox->button(QDialogButtonBox::Reset)->setText(tr("重置"));

    connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()),this,SLOT(slt_save()));
    connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()),this,SLOT(slt_apply()));
    connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),this,SLOT(slt_cancel()));
    connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()),this,SLOT(slt_reset()));

    // default dish id set here
    ui->lineEditId->setText(CBGlobal::getCurrentTimeStamp());
}
QImageNameGengerator::QImageNameGengerator(const QString &s)
{
    const QString &dbg_model=QGenieIface2ShareObject::sSingleInstance->mDBGRouteModel;
    if(
            //            qApp->arguments().contains("-dbg_ui")&&
            !dbg_model.isEmpty()
            )
    {
        mRouterName=dbg_model;
    }
    else
    {
        mRouterName=s;
    }

   // qDebug()<<"QImageNameGengerator:dbg_model=="<<dbg_model;
  //  qDebug()<<"QImageNameGengerator:mRouterName=="<<mRouterName;
    int i1=mRouterName.indexOf(QRegExp("-|_"));
    if(i1 >0)
    {
        mRouterName=mRouterName.left(i1);
    }
    QRegExp regx("v(\\d+)",Qt::CaseInsensitive);
    mRouterName.replace(regx,"");
    mRouterName = mRouterName.toUpper(); //yankai added
//qDebug()<<"QImageNameGengerator:mRouterName.replace(regx,"")=="<<mRouterName;

    if(mRouterName=="" || mRouterName=="N/A")
    {
        mRouterName="DEFAULT_NONETGEAR";
    }
}
Exemple #3
0
int
Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem)
{
    QString bd = Option::fixPathToLocalOS(d, TRUE);
    if(!QFile::exists(bd))
	return -1;
    if(!project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].isEmpty())
	return project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].first().toInt();

    QDir dir(bd);
    int biggest=-1;
    QStringList entries = dir.entryList();
    QString dllStem = stem + QTDLL_POSTFIX;
    QRegExp regx( "(" + dllStem + "([0-9]*)).lib", FALSE );
    for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
	if(regx.exactMatch((*it)))
	    biggest = QMAX(biggest, (regx.cap(1) == dllStem ||
				     regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
    }
    QMakeMetaInfo libinfo;
    if(libinfo.readLib(bd + dllStem)) {
	if(!libinfo.isEmpty("QMAKE_PRL_VERSION"))
	    biggest = QMAX(biggest, libinfo.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
    }
    return biggest;
}
KInfobarEdit::KInfobarEdit(QWidget *parent/* = 0*/)
: QLineEdit(parent)
{
    QRegExp regx("[0-9]+$");

    validator = NULL;
    QValidator *validator = new QRegExpValidator(regx, this);

    setValidator( validator );
    setMaxLength(3);
}
GridConfig::GridConfig(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::GridConfig)
    , m_num(0)
{
    ui->setupUi(this);

    QRegExp regx("[0-9]+$");
    QValidator *validator = new QRegExpValidator(regx, ui->lineEdit );
    ui->lineEdit->setValidator(validator);
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
   // chnNumChar[10] = new QString[]{"零","一","二","三","四","五","六","七","八","九"};
   // chnUnitSection[4] = new QString[]{"","万","亿","万亿"};
    ui->setupUi(this);
    QRegExp regx("[1-9][0-9]+$");
    QValidator *validator = new QRegExpValidator(regx, ui->lineEdit);
    ui->lineEdit->setValidator(validator);
    connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(mysetText(QString)));
    connect(ui->lineEdit_2,SIGNAL(textChanged(QString)),this,SLOT(setmynum(QString)));
}
ProjectConfigUI::ProjectConfigUI(ProjectConfig& projectConfig, QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::ProjectConfigUI)
{
    ui->setupUi(this);

    QRegExp regx("[0-9]+$");
    QValidator *validator = new QRegExpValidator(regx, this );
    ui->screenWidth->setValidator(validator);
    ui->screenHeight->setValidator(validator);

    setDataForUI(projectConfig);
}
Exemple #8
0
int
Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem, const QString &ext)
{
    QString bd = Option::fixPathToLocalOS(d, true);
    if(!exists(bd))
        return -1;

    QString dllStem = stem + QTDLL_POSTFIX;
    QMakeMetaInfo libinfo;
    bool libInfoRead = libinfo.readLib(bd + Option::dir_sep + dllStem);

    // If the library, for which we're trying to find the highest version
    // number, is a static library
    if (libInfoRead && libinfo.values("QMAKE_PRL_CONFIG").contains("staticlib"))
        return -1;

    if(!project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").isEmpty())
        return project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").first().toInt();

    int biggest=-1;
    if(!project->isActiveConfig("no_versionlink")) {
        static QHash<QString, QStringList> dirEntryListCache;
        QStringList entries = dirEntryListCache.value(bd);
        if (entries.isEmpty()) {
            QDir dir(bd);
            entries = dir.entryList();
            dirEntryListCache.insert(bd, entries);
        }

        QRegExp regx(QString("((lib)?%1([0-9]*)).(%2|prl)$").arg(dllStem).arg(ext), Qt::CaseInsensitive);
        for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
            if(regx.exactMatch((*it))) {
				if (!regx.cap(3).isEmpty()) {
					bool ok = true;
					int num = regx.cap(3).toInt(&ok);
					biggest = qMax(biggest, (!ok ? -1 : num));
				}
			}
        }
    }
    if(libInfoRead
       && !libinfo.values("QMAKE_PRL_CONFIG").contains("staticlib")
       && !libinfo.isEmpty("QMAKE_PRL_VERSION"))
       biggest = qMax(biggest, libinfo.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
    return biggest;
}
/*****************************************
 *Function: TimeEdit::TimeEdit
 *Brief: TimeEdit类的构造函数,在该类中设置一个只
 *能输入数字的正则表达式校验器
 *Param: TimeEditType type   指定该输入框的类型(天/小时)来初始化私有变量max_number
 *       QWidget *parent 父窗口的指针
 *Author: LiuBing
 *Data: 2013.11.25
*****************************************/
TimeEdit::TimeEdit(TimeEditType type, QWidget *parent)
    :QLineEdit(parent)
{
    max_number = 0;
    if(DayType == type){
        max_number = MAX_DAY_INPUT_NUM;
    }else if(HourType == type){
        max_number = MAX_HOUR_INPUT_NUM;
    }

    QRegExp regx("[0-9]+$");
    QValidator *validator = new QRegExpValidator(regx,this);
    this->setValidator(validator);

    this->setText("0");
    connect(this,SIGNAL(textChanged(QString)),this,SLOT(textChangeSlot(QString)));
}
Exemple #10
0
void urinalysis::init()
{
    this->setWindowTitle("安义县中医院");
    ui->titleLabel->setText("安义县中医院尿液分析ACR检测报告单");
    for(int index = 0; index < 120; ++index)
    {
        ui->ageComboBox->addItem(QString::number(index));
    }

    QRegExp regx("[0-9]+$");
    QValidator *validator = new QRegExpValidator(regx, this);
    ui->ALBLineEdit->setValidator(validator);
    ui->CRELineEdit->setValidator(validator);

    ui->tableWidget->setColumnCount(5);

    QStringList headers;
    headers << "姓名" << "性别" << "病员号" << "送检医生" << "报告时间";
    ui->tableWidget->setHorizontalHeaderLabels(headers);

    //设置不能多选, 选择行, 不能编辑, 内容自适应表格
    ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    m_port = new serialPort(this);

    ui->officeLineEdit->setCompleterFileName(QApplication::applicationDirPath() + "/keshi.txt");
    ui->senderDoctorLineEdit->setCompleterFileName(QApplication::applicationDirPath() + "/songjianyisheng.txt");
    ui->prooferLineEdit->setCompleterFileName(QApplication::applicationDirPath() + "/jianyan.txt");
    ui->auditorLineEdit->setCompleterFileName(QApplication::applicationDirPath() + "/shenhe.txt");
    ui->searchLineEdit->setCompleterFileName(QApplication::applicationDirPath() + "/songjianyisheng.txt");

    ui->autoGetData->setChecked(true);

    ui->remarksLineEdit->setText("本报告仅对此次送检标本负责。");
}
void TTKColorTableWidget::init()
{
    QFile file(":/res/rgb");
    if(file.open(QFile::ReadOnly))
    {
        QStringList items(QString(file.readAll()).split("\r\n"));
        foreach(const QString &item, items)
        {
            QListWidgetItem *it = new QListWidgetItem(this);
            it->setText(item);

            QRegExp regx("RGB\\[(\\d+),(\\d+),(\\d+)\\]");
            int pos = item.indexOf(regx);
            while(pos != -1)
            {
                it->setBackground(QColor(regx.cap(1).toInt(),
                                         regx.cap(2).toInt(),
                                         regx.cap(3).toInt()));
                pos += regx.matchedLength();
                pos = regx.indexIn(item, pos);
            }
            addItem(it);
        }
Exemple #12
0
EditProfile::EditProfile(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EditProfile)
{
    //初始化UI
    ui->setupUi(this);
    this->setProperty("Form", true);
    this->setProperty("CanMove", false);
    this->setWindowIcon(QIcon(":/image/icon"));
    this->setWindowTitle("云Doc信息管理系统");
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
    ui->lab_Title->installEventFilter(this);
    IconHelper::Instance()->SetIcon(ui->btnMenu_Close, QChar(0xf00d));
    IconHelper::Instance()->SetIcon(ui->btnMenu_Min, QChar(0xf068));
    connect(ui->btnMenu_Close, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->btnMenu_Min, SIGNAL(clicked()), this, SLOT(showMinimized()));

    user=UserDao::get_currentUser();
    QRegExp regx("[1-9][0-9]+$");
    QValidator *validator = new QRegExpValidator(regx, ui->phone );
    ui->phone->setValidator(validator);
    init();
}
/*****************************************
 *Function: SetTimeDelay::SetTimeDelay
 *Brief: SetTimeDelay的构造函数
 *Param: QWidget *parent 父窗口指针
 *Retval:
 *Author: LiuBing
 *Data: 2013.11.25
*****************************************/
SetTimeDelay::SetTimeDelay(QWidget *parent)
    :QWidget(parent)
{
    client_password_label = new QLabel("客户编码:",this);
    client_password_label->setGeometry(LEFT_MARGIN,TOP_MARGIN,70,20);

    client_password_edit = new QLineEdit(this);
    client_password_edit->setGeometry(LEFT_MARGIN + 70,TOP_MARGIN,MAIN_LENGTH - 2 * LEFT_MARGIN - 70 - 50 - HORIZONTAL_STRECH,20);
    client_password_edit->setEchoMode(QLineEdit::Password);
    client_password_edit->setMaxLength(CLIENT_PASSWORD_LENGTH);
    QRegExp regx("[0-9A-Za-z]+$");
    QValidator *validator = new QRegExpValidator(regx);
    client_password_edit->setValidator(validator);

    client_password_hint_label = new QLabel("(妥善保管,严防泄漏、丢失)",this);
    client_password_hint_label->setGeometry(LEFT_MARGIN + 70,TOP_MARGIN + 20 + VERTICAL_STRECH,client_password_edit->width(),20);
    plain_code_checkbox = new QCheckBox("明码",this);
    plain_code_checkbox->setGeometry(MAIN_LENGTH - 50 - RIGHT_MARGIN,TOP_MARGIN,50,20);
    connect(plain_code_checkbox,SIGNAL(toggled(bool)),this,SLOT(setClientPasswordEcho(bool)));

    set_time_delay_group = new QGroupBox("延时、解除限时保护",this);
    set_time_delay_group->setGeometry(LEFT_MARGIN,TOP_MARGIN + 40 + 2 * VERTICAL_STRECH,MAIN_LENGTH - 2 * LEFT_MARGIN,
                                      MAIN_WIDTH - (TOP_MARGIN + 40 + 2 * VERTICAL_STRECH) - 10 - BASE_MARGIN);

    unlock_code_label = new QLabel("限时保护检测码:",set_time_delay_group);
    unlock_code_label->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 2,90,20);
    unlock_code_edit = new QLineEdit(set_time_delay_group);
    unlock_code_edit->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 2,set_time_delay_group->width() - 90 - 2 * HORIZONTAL_STRECH,20);
    QRegExp number_regx("[0-9]+$");
    QValidator *number_validator = new QRegExpValidator(number_regx);
    unlock_code_edit->setValidator(number_validator);
    unlock_code_edit->setMaxLength(UNLOCK_CODE_LENGTH);

    time_delay_radio = new QRadioButton("延长限时",set_time_delay_group);
    time_delay_radio->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 3 + 20,80,20);
    time_delay_radio->setChecked(true);

    relieve_limit_time_radio = new QRadioButton("永久解锁",set_time_delay_group);
    relieve_limit_time_radio->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 4 + 40,80,20);
    time_delay_label = new QLabel("延长时间:",set_time_delay_group);
    time_delay_label->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 3 + 20,
                                  set_time_delay_group->width() - 90 - 2 * HORIZONTAL_STRECH - 150,20);
    time_delay_day_edit = new TimeEdit(DayType,set_time_delay_group);
    time_delay_day_edit->setGeometry(HORIZONTAL_STRECH + 90 + time_delay_label->width(),VERTICAL_STRECH * 3 + 20,50,20);
    time_delay_day_label = new QLabel("天",set_time_delay_group);
    time_delay_day_label->setGeometry(time_delay_day_edit->x() + time_delay_day_edit->width(),VERTICAL_STRECH * 3 + 20,25,20);
    time_delay_day_label->setAlignment(Qt::AlignCenter);
    time_delay_hour_edit = new TimeEdit(HourType,set_time_delay_group);
    time_delay_hour_edit->setGeometry(time_delay_day_label->x() + time_delay_day_label->width(),VERTICAL_STRECH * 3 + 20,50,20);
    time_delay_hour_label = new QLabel("小时",set_time_delay_group);
    time_delay_hour_label->setGeometry(time_delay_hour_edit->x() + time_delay_hour_edit->width(),VERTICAL_STRECH * 3 + 20,25,20);
    time_delay_hour_label->setAlignment(Qt::AlignCenter);
    build_password_button = new QPushButton("生成密码",set_time_delay_group);
    build_password_button->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 5 + 60 - 2,80,24);
    build_password_edit = new QLineEdit(set_time_delay_group);
    build_password_edit->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 5 + 60,unlock_code_edit->width() - 75 + 20,20);
    build_password_edit->setEnabled(false);
    copy_password_button = new QPushButton("复制",set_time_delay_group);
    copy_password_button->setGeometry(time_delay_hour_edit->x() + HORIZONTAL_STRECH + 20,VERTICAL_STRECH * 5 + 60 - 2,60 - 20,24);
    version_label = new QLabel("版本:",set_time_delay_group);
    version_label->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 6 + 80 - 2,40,24);
    version_box = new QComboBox(set_time_delay_group);
    version_box->setGeometry(HORIZONTAL_STRECH + 50,VERTICAL_STRECH * 6 + 80,60,20);
    version_box->addItem("V2.0");
    version_box->addItem("V2.1");

    connect(time_delay_radio,SIGNAL(toggled(bool)),time_delay_day_edit,SLOT(setEnabled(bool)));
    connect(time_delay_radio,SIGNAL(toggled(bool)),time_delay_hour_edit,SLOT(setEnabled(bool)));
    connect(build_password_button,SIGNAL(clicked()),this,SLOT(buildPasswordSlot()));
    connect(copy_password_button,SIGNAL(clicked()),this,SLOT(copyPassword()));
}
Exemple #14
0
void md5Fix::on_buttonStart_clicked()
{
	ui->buttonStart->setEnabled(false);

	// Check that directory exists
	QDir dir(ui->lineFolder->text());
	if (!dir.exists())
	{
		error(this, tr("This folder does not exist."));
		ui->buttonStart->setEnabled(true);
		return;
	}

	// Make sure the input is valid
	if (!ui->radioForce->isChecked() && !ui->lineFilename->text().contains("%md5%"))
	{
		error(this, tr("If you want to get the MD5 from the filename, you have to include the %md5% token in it."));
		ui->buttonStart->setEnabled(true);
		return;
	}

	// Suffixes
	QStringList suffixes = ui->lineSuffixes->text().split(',');
	for (QString &suffix : suffixes)
		suffix = suffix.trimmed();

	// Get all files from the destination directory
	auto files = listFilesFromDirectory(dir, suffixes);

	int count = 0;
	if (files.count() > 0)
	{
		// Show progress bar
		ui->progressBar->setValue(0);
		ui->progressBar->setMaximum(files.size());
		ui->progressBar->show();

		// Parse all files
		for (const auto &file : files)
		{
			QString fileName = file.first;
			QString path = dir.absoluteFilePath(fileName);

			QString md5;
			if (ui->radioForce->isChecked())
			{
				QFile fle(path);
				fle.open(QFile::ReadOnly);
				md5 = QCryptographicHash::hash(fle.readAll(), QCryptographicHash::Md5).toHex();
			}
			else
			{
				QRegExp regx("%([^%]*)%");
				QString reg = QRegExp::escape(ui->lineFilename->text());
				int pos = 0, cur = 0, id = -1;
				while ((pos = regx.indexIn(reg, pos)) != -1)
				{
					pos += 4;
					reg.replace(regx.cap(0), "(.+)");
					if (regx.cap(1) == QLatin1String("md5"))
					{ id = cur; }
					cur++;
				}
				QRegExp rx(reg);
				rx.setMinimal(true);
				pos = 0;
				while ((pos = rx.indexIn(fileName, pos)) != -1)
				{
					pos += rx.matchedLength();
					md5 = rx.cap(id + 1);
				}
			}

			if (!md5.isEmpty())
			{
				m_profile->addMd5(md5, path);
				count++;
			}

			ui->progressBar->setValue(ui->progressBar->value() + 1);
		}
	}

	// Hide progress bar
	ui->progressBar->hide();
	ui->progressBar->setValue(0);
	ui->progressBar->setMaximum(0);

	ui->buttonStart->setEnabled(true);

	QMessageBox::information(this, tr("Finished"), tr("%n MD5(s) loaded", "", count));
}
Exemple #15
0
void md5Fix::on_buttonStart_clicked()
{
	ui->buttonStart->setEnabled(false);

	QDir dir(ui->lineFolder->text());
	if (dir.exists())
	{
		if (ui->radioForce->isChecked() || ui->lineFilename->text().contains("%md5%"))
		{
		ui->progressBar->setValue(0);
		ui->progressBar->setMaximum(0);
		ui->progressBar->show();

		typedef QPair<QString,QString> QStringPair;
		QVector<QStringPair> files = QVector<QStringPair>();

		QDirIterator it(dir, QDirIterator::Subdirectories);
		while (it.hasNext())
		{
			it.next();
			if (!it.fileInfo().isDir())
			{
				files.append(QPair<QString,QString>(it.fileName(), it.filePath()));
			}
		}
		ui->progressBar->setMaximum(files.size());

		QFile f(savePath("md5s.txt"));
		f.open(QFile::WriteOnly | QFile::Truncate);
		for (QStringPair file : files)
		{
			QString md5 = "-";
			if (ui->radioForce->isChecked())
			{
				QFile fle(file.second);
				fle.open(QFile::ReadOnly);
				md5 = QCryptographicHash::hash(fle.readAll(), QCryptographicHash::Md5).toHex();
			}
			else
			{
				QRegExp regx("%([^%]*)%");
				QString reg = QRegExp::escape(ui->lineFilename->text());
				int pos = 0, cur = 0, id = -1;
				while ((pos = regx.indexIn(ui->lineFilename->text(), pos)) != -1)
				{
					pos += regx.matchedLength();
					reg.replace(regx.cap(0), "(.+)");
					if (regx.cap(1) == "md5")
					{ id = cur; }
					cur++;
				}
				QRegExp rx(reg);
				rx.setMinimal(true);
				pos = 0;
				while ((pos = rx.indexIn(file.first, pos)) != -1)
				{
					pos += rx.matchedLength();
					md5 = rx.cap(id + 1);
				}
			}
			f.write(QString(md5 + file.second + "\r\n").toUtf8());
			ui->progressBar->setValue(ui->progressBar->value() + 1);
		}
		f.close();
	}
	else
	{ error(this, tr("Ce dossier n'existe pas.")); }
}
else
{ error(this, tr("Ce dossier n'existe pas.")); }

	ui->buttonStart->setEnabled(true);
}
void RenameExisting1::on_buttonContinue_clicked()
{
	ui->buttonContinue->setEnabled(false);
	m_details.clear();
	m_getTags.clear();

	// Check that directory exists
	QDir dir(ui->lineFolder->text());
	if (!dir.exists())
	{
		error(this, tr("This folder does not exist."));
		ui->buttonContinue->setEnabled(true);
		return;
	}

	// Make sure the input is valid
	if (!ui->radioForce->isChecked() && !ui->lineFilenameOrigin->text().contains("%md5%"))
	{
		error(this, tr("If you want to get the MD5 from the filename, you have to include the %md5% token in it."));
		ui->buttonContinue->setEnabled(true);
		return;
	}

	// Get all files from the destination directory
	typedef QPair<QString,QString> QStringPair;
	QVector<QStringPair> files = QVector<QStringPair>();
	QDirIterator it(dir, QDirIterator::Subdirectories);
	while (it.hasNext())
	{
		it.next();
		if (!it.fileInfo().isDir())
		{
			int len = it.filePath().length() - dir.absolutePath().length() - 1;
			files.append(QPair<QString,QString>(it.filePath().right(len), it.filePath()));
		}
	}

	// Parse all files
	for (QStringPair file : files)
	{
		QString md5 = "";
		if (ui->radioForce->isChecked())
		{
			QFile fle(file.second);
			fle.open(QFile::ReadOnly);
			md5 = QCryptographicHash::hash(fle.readAll(), QCryptographicHash::Md5).toHex();
		}
		else
		{
			QRegExp regx("%([^%]*)%");
			QString reg = QRegExp::escape(ui->lineFilenameOrigin->text());
			int pos = 0, cur = 0, id = -1;
			while ((pos = regx.indexIn(ui->lineFilenameOrigin->text(), pos)) != -1)
			{
				pos += regx.matchedLength();
				reg.replace(regx.cap(0), "(.+)");
				if (regx.cap(1) == "md5")
				{ id = cur; }
				cur++;
			}
			QRegExp rx(reg);
			rx.setMinimal(true);
			pos = 0;
			while ((pos = rx.indexIn(file.first, pos)) != -1)
			{
				pos += rx.matchedLength();
				md5 = rx.cap(id + 1);
			}
		}

		if (!md5.isEmpty())
		{
			QMap<QString,QString> det;
			det.insert("md5", md5);
			det.insert("path", QDir::toNativeSeparators(file.first));
			det.insert("path_full", QDir::toNativeSeparators(file.second));
			m_details.append(det);
		}
	}

	// Check if filename requires details
	m_filename.setFormat(ui->lineFilenameDestination->text());
	m_needDetails = m_filename.needExactTags(m_sites.value(ui->comboSource->currentText()));

	int reponse = QMessageBox::question(this, tr("Rename existing images"), tr("You are about to download information from %n image(s). Are you sure you want to continue?", "", m_details.size()), QMessageBox::Yes | QMessageBox::No);
	if (reponse == QMessageBox::Yes)
	{
		// Show progresss bar
		ui->progressBar->setValue(0);
		ui->progressBar->setMaximum(m_details.size());
		ui->progressBar->show();

		loadNext();
	}
	else
	{
		ui->buttonContinue->setEnabled(true);
	}
}
Exemple #17
0
    explicit BlueConfig(const std::string& source_)
        : source(source_)
    {
        std::ifstream file(source.c_str());
        if (!file.is_open())
            LBTHROW(
                std::runtime_error("Cannot open BlueConfig file " + source));
        std::stringstream buffer;
        buffer << file.rdbuf();

        boost::regex commentregx("#.*?\\n");
        const std::string fileString =
            boost::regex_replace(buffer.str(), commentregx, "\n");

        boost::regex regx(
            "(?<type>[a-zA-Z0-9_-]+) (?<name>[a-zA-Z0-9_-]+?)"
            "\\s+\\{(?<contents>.*?)\\}");
        const int subs[] = {1, 2, 3};
        boost::sregex_token_iterator i(fileString.begin(), fileString.end(),
                                       regx, subs);
        for (boost::sregex_token_iterator end; i != end;)
        {
            const std::string& typeStr = *i++;
            const std::string& name = *i++;
            const std::string& content = *i++;
            if (content.empty())
            {
                LBWARN << "Found empty section '" << typeStr << " " << name
                       << "' in BlueConfig file " << source << std::endl;
                continue;
            }

            const BlueConfigSection type =
                boost::lexical_cast<BlueConfigSection>(typeStr);
            if (type == brion::CONFIGSECTION_UNKNOWN)
            {
                LBDEBUG << "Found unknown section '" << typeStr
                        << "' in BlueConfig file " << source << std::endl;
                continue;
            }

            names[type].push_back(name);

            Strings lines;
            boost::split(lines, content, boost::is_any_of("\n"),
                         boost::token_compress_on);

            for (std::string line : lines)
            {
                boost::trim(line);
                if (line.empty())
                    continue;

                const std::string::size_type pos = line.find(' ', 0);
                if (pos == std::string::npos)
                {
                    LBWARN << "Found invalid key-value pair '" << line
                           << "' in BlueConfig file " << source << std::endl;
                    continue;
                }

                std::string value = line.substr(pos + 1);
                boost::trim(value);
                table[type][name].insert(
                    std::make_pair(line.substr(0, pos), value));
            }
        }

        if (table[CONFIGSECTION_RUN].empty())
            LBTHROW(
                std::runtime_error(source + " not a valid BlueConfig file"));
    }
Exemple #18
0
bool date::validate(const std::string& date, const char* str_regex)
{
    REGEX_NS::regex regx(str_regex);
    return REGEX_NS::regex_match(date, regx);
}
/*****************************************
 *Function: SetLimitTime::SetLimitTime
 *Brief: SetLimitTime类的构造函数
 *Param: QWidget *parent    父窗口指针
 *Author: LiuBing
 *Data: 2013.11.22
*****************************************/
SetLimitTime::SetLimitTime(QWidget *parent)
    :QWidget(parent)
{
    client_password_label = new QLabel("客户编码:",this);
    client_password_label->setGeometry(LEFT_MARGIN,TOP_MARGIN,70,20);

    client_password_edit = new QLineEdit(this);
    client_password_edit->setGeometry(LEFT_MARGIN + 70,TOP_MARGIN,MAIN_LENGTH - 2 * LEFT_MARGIN - 70 - 50 - HORIZONTAL_STRECH,20);
    client_password_edit->setEchoMode(QLineEdit::Password);
    client_password_edit->setMaxLength(CLIENT_PASSWORD_LENGTH);
    QRegExp regx("[0-9A-Za-z]+$");
    QValidator *validator = new QRegExpValidator(regx,client_password_edit);
    client_password_edit->setValidator(validator);

    client_password_hint_label = new QLabel("(妥善保管,严防泄漏、丢失)",this);
    client_password_hint_label->setGeometry(LEFT_MARGIN + 70,TOP_MARGIN + 20 + VERTICAL_STRECH,client_password_edit->width(),20);
    plain_code_checkbox = new QCheckBox("明码",this);
    plain_code_checkbox->setGeometry(MAIN_LENGTH - 50 - RIGHT_MARGIN,TOP_MARGIN,50,20);
    connect(plain_code_checkbox,SIGNAL(toggled(bool)),this,SLOT(setClientPasswordEcho(bool)));

    set_limit_time_group = new QGroupBox("限时保护设置",this);
    set_limit_time_group->setGeometry(LEFT_MARGIN,TOP_MARGIN + 40 + 2 * VERTICAL_STRECH,MAIN_LENGTH - 2 * LEFT_MARGIN,
                                      MAIN_WIDTH - (TOP_MARGIN + 40 + 2 * VERTICAL_STRECH) - 10 - BASE_MARGIN);

    service_time_label = new QLabel("允许使用时间:",set_limit_time_group);
    service_time_label->setGeometry((set_limit_time_group->width() - 250) / 2,VERTICAL_STRECH * 2,100,20);
    service_time_day_label = new QLabel("天",set_limit_time_group);
    service_time_day_label->setGeometry((set_limit_time_group->width() - 250) / 2 + 150,VERTICAL_STRECH * 2,25,20);
    service_time_day_label->setAlignment(Qt::AlignCenter);
    service_time_hour_label = new QLabel("小时",set_limit_time_group);
    service_time_hour_label->setGeometry((set_limit_time_group->width() - 250) / 2 + 225,VERTICAL_STRECH * 2,25,20);
    service_time_hour_label->setAlignment(Qt::AlignCenter);
    service_time_day_edit = new TimeEdit(DayType,set_limit_time_group);
    service_time_day_edit->setGeometry((set_limit_time_group->width() - 250) / 2 + 100,VERTICAL_STRECH * 2,50,20);
    service_time_hour_edit = new TimeEdit(HourType,set_limit_time_group);
    service_time_hour_edit->setGeometry((set_limit_time_group->width() - 250) / 2 + 175,VERTICAL_STRECH * 2,50,20);

    early_warning_time_label = new QLabel("提前报警时间:",set_limit_time_group);
    early_warning_time_label->setGeometry((set_limit_time_group->width() - 250) / 2,VERTICAL_STRECH * 3 + 20,100,20);
    early_warning_day_label = new QLabel("天",set_limit_time_group);
    early_warning_day_label->setGeometry((set_limit_time_group->width() - 250) / 2 + 150,VERTICAL_STRECH * 3 + 20,25,20);
    early_warning_day_label->setAlignment(Qt::AlignCenter);
    //early_warning_hour_label = new QLabel("小时",set_limit_time_group);
    //early_warning_hour_label->setGeometry((set_limit_time_group->width() - 250) / 2 + 225,VERTICAL_STRECH * 5 + 20,25,20);
    //early_warning_hour_label->setAlignment(Qt::AlignCenter);
    early_warning_day_edit = new TimeEdit(DayType,set_limit_time_group);
    early_warning_day_edit->setGeometry((set_limit_time_group->width() - 250) / 2 + 100,VERTICAL_STRECH * 3 + 20,50,20);
    //early_warning_hour_edit = new TimeEdit(HourType,set_limit_time_group);
    //early_warning_hour_edit->setGeometry((set_limit_time_group->width() - 250) / 2 + 175,VERTICAL_STRECH * 5 + 20,50,20);

    radio_file_mode = new QRadioButton("文件加密",set_limit_time_group);
    radio_file_mode->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 4 + 40,80,20);
    radio_file_mode->setChecked(true);
    build_file_button = new QPushButton("生成设置文件",set_limit_time_group);
    build_file_button->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 4 + 40,90,20);

    radio_key_mode = new QRadioButton("密码加密",set_limit_time_group);
    radio_key_mode->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 5 + 60,80,20);
    key_mode_label = new QLabel("请输入验证码:",set_limit_time_group);
    key_mode_label->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 5 + 60,80,20);
    key_edit = new QLineEdit(set_limit_time_group);
    key_edit->setGeometry(HORIZONTAL_STRECH + 90 + 80,VERTICAL_STRECH * 5 + 60,120,20);
    key_edit->setEnabled(false);
    QRegExp number_regx("[0-9]+$");
    QValidator *number_validator = new QRegExpValidator(number_regx);
    key_edit->setValidator(number_validator);
    key_edit->setMaxLength(6);

    build_password_btn = new QPushButton("生成密码",set_limit_time_group);
    build_password_btn->setGeometry(HORIZONTAL_STRECH,VERTICAL_STRECH * 6 + 80,80,20);
    build_password_btn->setEnabled(false);
    password_edit = new QLineEdit(set_limit_time_group);
    password_edit->setGeometry(HORIZONTAL_STRECH + 90,VERTICAL_STRECH * 6 + 80,160,20);
    password_edit->setEnabled(false);
    copy_btn = new QPushButton("复制",set_limit_time_group);
    copy_btn->setGeometry(HORIZONTAL_STRECH + 260,VERTICAL_STRECH * 6 + 80,40,20);

    connect(build_file_button,SIGNAL(clicked()),this,SLOT(buildFileButtonSlot()));
    connect(build_password_btn,SIGNAL(clicked()),this,SLOT(buildPasswordSlot()));

    connect(radio_file_mode,SIGNAL(toggled(bool)),build_file_button,SLOT(setEnabled(bool)));
    connect(radio_key_mode,SIGNAL(toggled(bool)),key_edit,SLOT(setEnabled(bool)));
    connect(radio_key_mode,SIGNAL(toggled(bool)),build_password_btn,SLOT(setEnabled(bool)));
    connect(copy_btn,SIGNAL(clicked()),SLOT(copyPassword()));
}
Exemple #20
0
UIInput::UIInput(QString title, QString showMsg, QString regExp, int length, QDialog *parent, Qt::WindowFlags f):
    QDialog(parent,f)
{

    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(20,FRAME420_THVALUE+50,FRAME420_WIDTH,FRAME420_HEIGHT-50);
    this->setFixedSize(FRAME420_WIDTH-40,FRAME420_HEIGHT-80);
    this->setStyleSheet("QDialog{border: 6px solid silver;}");

    //--------------define--------------------//
    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    lbHead->setText(title);
    lbHead->setStyleSheet("background-color: rgb(0, 153, 255);");

    lbMsg=new QLabel();
    QFont fontL("Helvetica",14,QFont::Bold);
    lbMsg->setAlignment(Qt::AlignCenter);
    lbMsg->setFont(fontL);
    lbMsg->setText(showMsg);

    leInput=new QLineEdit();
    leInput->setFont(fontL);
    leInput->setAlignment(Qt::AlignCenter);
    leInput->setMinimumHeight(35);
    leInput->setStyleSheet("border: 3px solid silver;border-radius: 6px;");
    leInput->setMaxLength(length);
    if(regExp!="0")
    {
        const QString  REGEX_AMOUNT = regExp;
        QRegExp regx(REGEX_AMOUNT);
        QValidator *validator = new QRegExpValidator(regx, leInput);
        leInput->setValidator(validator);
    }

    btnSubmit=new QPushButton;
    btnSubmit->setText(tr("Apply"));
    btnSubmit->setFont(fontL);
    btnSubmit->setMinimumHeight(30);
    btnSubmit->setStyleSheet(BTN_GREEN_STYLE);

    btnCancel=new QPushButton;
    btnCancel->setText(tr("Cancel"));
    btnCancel->setFont(fontL);
    btnCancel->setMinimumHeight(30);
    btnCancel->setStyleSheet(BTN_BLUE_STYLE);


    // -----------layout------------//
    QSpacerItem *sp1=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp2=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);

    QHBoxLayout *h1Lay=new QHBoxLayout();
    h1Lay->addSpacing(6);
    h1Lay->addWidget(lbHead);
    h1Lay->addSpacing(6);

    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addItem(sp1);
    v1Lay->addWidget(lbMsg);
    v1Lay->addWidget(leInput);
    v1Lay->addItem(sp2);

    QHBoxLayout *hLay=new QHBoxLayout();
    hLay->addSpacing(10);
    hLay->addLayout(v1Lay);
    hLay->addSpacing(10);

    QHBoxLayout *h2Lay=new QHBoxLayout();
    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnCancel);
    h2Lay->addWidget(btnSubmit);
    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addSpacing(6);
    layout->addLayout(h1Lay);
    layout->addLayout(hLay);
    layout->addLayout(h2Lay);

    layout->setContentsMargins(0,0,0,10);


    // connect
    connect(btnCancel,SIGNAL(clicked()),this,SLOT(slotCancel()));
    connect(btnSubmit,SIGNAL(clicked()),this,SLOT(slotSubmit()));
    connect(leInput,SIGNAL(textChanged(QString)),this,SLOT(restartTimer()));

    this->setAutoClose(g_constantParam.TIMEOUT_UI);
}
void BlacklistFix::on_buttonContinue_clicked()
{
	ui->buttonContinue->setEnabled(false);
	m_details.clear();

	// Check that directory exists
	QDir dir(ui->lineFolder->text());
	if (!dir.exists())
	{
		error(this, tr("Ce dossier n'existe pas."));
		ui->buttonContinue->setEnabled(true);
		return;
	}

	// Make sure the input is valid
	if (!ui->radioForce->isChecked() && !ui->lineFilename->text().contains("%md5%"))
	{
		error(this, tr("Si vous voulez récupérer le MD5 depuis le nom de fichier, vous devez include le token %md5% dans celui-ci."));
		ui->buttonContinue->setEnabled(true);
		return;
	}

	// Get all files from the destination directory
	typedef QPair<QString,QString> QStringPair;
	QVector<QStringPair> files = QVector<QStringPair>();
	QDirIterator it(dir, QDirIterator::Subdirectories);
	while (it.hasNext())
	{
		it.next();
		if (!it.fileInfo().isDir())
		{
			int len = it.filePath().length() - dir.absolutePath().length() - 1;
			files.append(QPair<QString,QString>(it.filePath().right(len), it.filePath()));
		}
	}

	// Parse all files
	for (QStringPair file : files)
	{
		QString md5 = "";
		if (ui->radioForce->isChecked())
		{
			QFile fle(file.second);
			fle.open(QFile::ReadOnly);
			md5 = QCryptographicHash::hash(fle.readAll(), QCryptographicHash::Md5).toHex();
		}
		else
		{
			QRegExp regx("%([^%]*)%");
			QString reg = QRegExp::escape(ui->lineFilename->text());
			int pos = 0, cur = 0, id = -1;
			while ((pos = regx.indexIn(ui->lineFilename->text(), pos)) != -1)
			{
				pos += regx.matchedLength();
				reg.replace(regx.cap(0), "(.+)");
				if (regx.cap(1) == "md5")
				{ id = cur; }
				cur++;
			}
			QRegExp rx(reg);
			rx.setMinimal(true);
			pos = 0;
			while ((pos = rx.indexIn(file.first, pos)) != -1)
			{
				pos += rx.matchedLength();
				md5 = rx.cap(id + 1);
			}
		}

		QMap<QString,QString> det;
		det.insert("md5", md5);
		det.insert("path", file.first);
		det.insert("path_full", file.second);
		m_details.append(det);
	}

	int reponse = QMessageBox::question(this, tr("Réparateur de liste noire"), tr("Vous vous apprêtez à télécharger les informations de %n image(s). Êtes-vous sûr de vouloir continuer ?", "", m_details.size()), QMessageBox::Yes | QMessageBox::No);
	if (reponse == QMessageBox::Yes)
	{
		// Show progresss bar
		ui->progressBar->setValue(0);
		ui->progressBar->setMaximum(files.size());
		ui->progressBar->show();

		getAll();
	}
}
Exemple #22
0
CommServDialog::CommServDialog(QWidget *parent)
:QDialog(parent)
{	
        m_mouse_down = false;
        //setFrameShape(Panel);
        
        // Make this a borderless window which can't
        // be resized or moved via the window system
        setMouseTracking(true);
        this->setAttribute(Qt::WA_QuitOnClose,true);
        m_titleBar = new TitleBar(this);

	QRegExp regx("[0-9]+$");
	label=new QLabel("输入:");
	labelOutput=new QLabel("输出:");
	lineEdit = new QLineEdit;
	lineEdit->setValidator(new QRegExpValidator(regx,this));
	lineOutput = new QLineEdit;
	lineOutput->setValidator(new QRegExpValidator(regx,this));
	lineOutput->setEnabled(false);

    	readButton = new QPushButton(tr("读"));
	//say_helloButton->setFocus();

	writeButton = new QPushButton(tr("写"));
    	writeButton->setEnabled(false);

	read_writeButton = new QPushButton(tr("读/写"));
    	read_writeButton->setEnabled(false);
	
	QObject::connect(lineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(enableWriteButton(const QString &)));
	QObject::connect(lineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(enableRead_writeButton(const QString &)));
    	QObject::connect(readButton,SIGNAL(clicked()),this,SLOT(readClicked()));
    	QObject::connect(writeButton,SIGNAL(clicked()),this,SLOT(writeClicked()));
    	QObject::connect(read_writeButton,SIGNAL(clicked()),this,SLOT(read_writeClicked()));

    	QHBoxLayout *topLayoutUp = new QHBoxLayout;
	topLayoutUp->addWidget(label);
    	topLayoutUp->addWidget(lineEdit);
      	topLayoutUp->setMargin(5);
       	topLayoutUp->setSpacing(3);

    	QHBoxLayout *topLayoutMiddle = new QHBoxLayout;
	topLayoutMiddle->addWidget(labelOutput);
    	topLayoutMiddle->addWidget(lineOutput);
      	topLayoutMiddle->setMargin(5);
       	topLayoutMiddle->setSpacing(3);

    	QHBoxLayout *topLayoutDown = new QHBoxLayout;
    	topLayoutDown->addWidget(readButton);	
	topLayoutDown->addWidget(writeButton);	
	topLayoutDown->addWidget(read_writeButton);
      	topLayoutDown->setMargin(5);
       	topLayoutDown->setSpacing(3);

	QVBoxLayout *mainLayout = new QVBoxLayout;
    	mainLayout->addWidget(m_titleBar);
    	mainLayout->addLayout(topLayoutUp);
    	mainLayout->addLayout(topLayoutMiddle);
    	mainLayout->addLayout(topLayoutDown);
        mainLayout->setMargin(1);
        mainLayout->setSpacing(0);
    	
    	setLayout(mainLayout);
    	setWindowTitle(tr("高密级应用"));
	setFixedSize(300,125);

}