Ejemplo n.º 1
0
CSV::CSV ()
{
  pluginName = "CSV";
  delim = ',';
  helpFile = "csv.html";
  cancelFlag = FALSE;

  reloadTimer = new QTimer(this);
  connect(reloadTimer, SIGNAL(timeout()), SLOT(parse()));

  config.getData(Config::QuotePluginStorage, ruleDir);
  ruleDir.append("/CSV");
  QDir dir;
  if (! dir.exists(ruleDir))
  {
    if (! dir.mkdir(ruleDir, TRUE))
      qDebug("CSVDialog::could not create storage directory %s", ruleDir.latin1());
  }

  createMainPage();
  setOkButton();
  setCancelButton();
  setHelpButton();
  QObject::connect(this, SIGNAL(helpButtonPressed()), this, SLOT(help()));
  loadSettings();
  updateRules();
  resize(640, 480);
}
Ejemplo n.º 2
0
void CDeleteAclTask::sendCMD(int groupId)
{
	QSqlTableModel model;
	QString filter1;
	SACL* psacl;
	char* pSendBuff;
	int len,len1;
	int ruleCount;

	model.setTable("aclrules");
	filter1 = QString("groupid=%1").arg(groupId);
	model.setFilter(filter1);
	model.select();

	ruleCount=model.rowCount();

	if (ruleCount==0)
	{
		//QMessageBox::information(this,"information", G2U(""));
		return;
	}

	psacl=new SACL[ruleCount];

	for (int i=0;i<model.rowCount();++i)
	{
		QSqlRecord record=model.record(i);
		psacl[i].cmdType=ACL_DELETE;             
		psacl[i].id=record.value("id").toInt();
	}

	len1=sizeof(SACL);
	len=ruleCount*len1;
	pSendBuff=new char[len];

	for (int i=0;i!=ruleCount;++i)
	{
		memcpy_s(pSendBuff+len1*i, len, (char*)&(psacl[i]), len1 );
	}

	boost::asio::io_service ios;
	CSocketClientSyn socketClientSyn(ios); 
	socketClientSyn.startConnection();
	socketClientSyn.sendData(pSendBuff,len);

	char* pRecvBuff=new char[len];
	socketClientSyn.recvData(pRecvBuff,len);
	socketClientSyn.closeConnection();

	for (int i=0;i!=ruleCount;++i)
	{
		memcpy_s(&psacl[i],len1,pRecvBuff+len1*i,len1);
		updateRules(psacl[i].id,psacl[i].cmdType);
	}
	delete [] psacl;
	delete [] pRecvBuff;
	delete [] pSendBuff;
}
Ejemplo n.º 3
0
MoveGen::MoveGen(GameLaw *gl, Board *board, MoveList *moveList, QObject *parent) :
    QObject(parent)
{
    m_gameLaw = gl;
    m_board = board;
    m_moveList = moveList;

    connect(gl, SIGNAL(onChangeLaw()), this, SLOT(changeLaw()));
    connect(board, SIGNAL(onChangeSize(int,int)), this, SLOT(changeSize(int,int)));

    updateRules();
    updateSizes();
}
Ejemplo n.º 4
0
/*!
    \internal
    Installs logging rules as specified in \a content.
 */
void QLoggingRegistry::setApiRules(const QString &content)
{
    QLoggingSettingsParser parser;
    parser.setSection(QStringLiteral("Rules"));
    parser.setContent(content);

    QMutexLocker locker(&registryMutex);

    if (qtLoggingDebug())
        debugMsg("Loading logging rules set by Qt API ...");

    apiRules = parser.rules();

    updateRules();
}
Ejemplo n.º 5
0
/*!
    \internal
    Installs a custom filter rule.
*/
QLoggingCategory::CategoryFilter
QLoggingRegistry::installFilter(QLoggingCategory::CategoryFilter filter)
{
    QMutexLocker locker(&registryMutex);

    if (filter == 0)
        filter = defaultCategoryFilter;

    QLoggingCategory::CategoryFilter old = categoryFilter;
    categoryFilter = filter;

    updateRules();

    return old;
}
Ejemplo n.º 6
0
/*!
    \internal
    Installs logging rules as specified in \a content.
 */
void QLoggingRegistry::setApiRules(const QString &content)
{
    QLoggingSettingsParser parser;
    parser.setImplicitRulesSection(true);
    parser.setContent(content);

    if (qtLoggingDebug())
        debugMsg("Loading logging rules set by QLoggingCategory::setFilterRules ...");

    const QMutexLocker locker(&registryMutex);

    ruleSets[ApiRules] = parser.rules();

    updateRules();
}
Ejemplo n.º 7
0
/*!
    \internal
    Initializes the rules database by loading
    $QT_LOGGING_CONF, $QT_LOGGING_RULES, and .config/QtProject/qtlogging.ini.
 */
void QLoggingRegistry::init()
{
    // get rules from environment
    const QByteArray rulesFilePath = qgetenv("QT_LOGGING_CONF");
    if (!rulesFilePath.isEmpty()) {
        QFile file(QFile::decodeName(rulesFilePath));
        if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            QTextStream stream(&file);
            QLoggingSettingsParser parser;
            parser.setContent(stream);
            if (qtLoggingDebug())
                debugMsg("Loading \"%s\" ...",
                         QDir::toNativeSeparators(file.fileName()).toUtf8().constData());
            envRules = parser.rules();
        }
    }
    const QByteArray rulesSrc = qgetenv("QT_LOGGING_RULES");
    if (!rulesSrc.isEmpty()) {
         QTextStream stream(rulesSrc);
         QLoggingSettingsParser parser;
         parser.setSection(QStringLiteral("Rules"));
         parser.setContent(stream);
         envRules += parser.rules();
    }

    // get rules from qt configuration
    QString envPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation,
                                             QStringLiteral("QtProject/qtlogging.ini"));
    if (!envPath.isEmpty()) {
        QFile file(envPath);
        if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            QTextStream stream(&file);
            QLoggingSettingsParser parser;
            parser.setContent(stream);
            if (qtLoggingDebug())
                debugMsg("Loading \"%s\" ...",
                         QDir::toNativeSeparators(envPath).toUtf8().constData());
            configRules = parser.rules();
        }
    }

    if (!envRules.isEmpty() || !configRules.isEmpty()) {
        QMutexLocker locker(&registryMutex);
        updateRules();
    }
}
Ejemplo n.º 8
0
void CSV::deleteRule ()
{
  QString s("*");
  SymbolDialog *dialog = new SymbolDialog(this,
  				          ruleDir,
                                          ruleDir,
					  s,
					  Q3FileDialog::ExistingFiles);
  dialog->setCaption(tr("Select Rules To Delete"));

  int rc = dialog->exec();

  if (rc == QDialog::Accepted)
  {
    rc = QMessageBox::warning(this,
  			      tr("Qtstalker: Warning"),
			      tr("Are you sure to delete selected rules?"),
			      QMessageBox::Yes,
			      QMessageBox::No,
			      QMessageBox::NoButton);

    if (rc == QMessageBox::No)
    {
      delete dialog;
      return;
    }

    QStringList l = dialog->selectedFiles();
    delete dialog;
    if (! l.count())
      return;

    int loop;
    QDir dir;
    for (loop = 0; loop < (int) l.count(); loop++)
      dir.remove(l[loop]);

    updateRules();
  }
  else
    delete dialog;
}
Ejemplo n.º 9
0
void CSV::newRule ()
{
  bool ok = FALSE;
  QString s = QInputDialog::getText(tr("New Rule"),
  				    tr("Enter new rule name."),
				    QLineEdit::Normal,
				    tr("NewRule"),
				    &ok,
				    this);
  if ((! ok) || (s.isNull()))
    return;

  // remove any bad chars
  int loop;
  QString name;
  for (loop = 0; loop < (int) s.length(); loop++)
  {
    QChar c = s.at(loop);
    if (c.isLetterOrNumber())
      name.append(c);
  }

  QDir dir;
  s = ruleDir + "/" + name;
  if (dir.exists(s))
  {
    QMessageBox::information(this, tr("Warning"), tr("This rule already exists."));
    return;
  }

  CSVRuleDialog *dialog = new CSVRuleDialog(this, s);

  int rc = dialog->exec();

  if (rc == QDialog::Accepted)
  {
    updateRules();
  }

  delete dialog;
}
Ejemplo n.º 10
0
/*!
    \internal
    Initializes the rules database by loading
    $QT_LOGGING_CONF, $QT_LOGGING_RULES, and .config/QtProject/qtlogging.ini.
 */
void QLoggingRegistry::initializeRules()
{
    QVector<QLoggingRule> er, qr, cr;
    // get rules from environment
    const QByteArray rulesFilePath = qgetenv("QT_LOGGING_CONF");
    if (!rulesFilePath.isEmpty())
        er = loadRulesFromFile(QFile::decodeName(rulesFilePath));

    const QByteArray rulesSrc = qgetenv("QT_LOGGING_RULES").replace(';', '\n');
    if (!rulesSrc.isEmpty()) {
         QTextStream stream(rulesSrc);
         QLoggingSettingsParser parser;
         parser.setImplicitRulesSection(true);
         parser.setContent(stream);
         er += parser.rules();
    }

    const QString configFileName = QStringLiteral("qtlogging.ini");

#if !defined(QT_BOOTSTRAPPED)
    // get rules from Qt data configuration path
    const QString qtConfigPath
            = QDir(QLibraryInfo::location(QLibraryInfo::DataPath)).absoluteFilePath(configFileName);
    qr = loadRulesFromFile(qtConfigPath);
#endif

    // get rules from user's/system configuration
    const QString envPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation,
                                                   QString::fromLatin1("QtProject/") + configFileName);
    if (!envPath.isEmpty())
        cr = loadRulesFromFile(envPath);

    const QMutexLocker locker(&registryMutex);

    ruleSets[EnvironmentRules] = std::move(er);
    ruleSets[QtConfigRules] = std::move(qr);
    ruleSets[ConfigRules] = std::move(cr);

    if (!ruleSets[EnvironmentRules].isEmpty() || !ruleSets[QtConfigRules].isEmpty() || !ruleSets[ConfigRules].isEmpty())
        updateRules();
}
Ejemplo n.º 11
0
void CSV::createMainPage ()
{
  setCaption(tr("CSV Quotes"));

  QString s = "new";
  QString s2 = tr("New Rule");
  toolbar->addButton(s, newchart, s2);
  QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(newRule()));

  s = "edit";
  s2 = tr("Edit Rule");
  toolbar->addButton(s, edit, s2);
  QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(editRule()));

  s = "delete";
  s2 = tr("Delete Rule");
  toolbar->addButton(s, deleteitem, s2);
  QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(deleteRule()));

  QLabel *label = new QLabel(tr("Rule"), baseWidget);
  grid->addWidget(label, 0, 0);

  ruleCombo = new QComboBox(baseWidget);
  updateRules();
  grid->addWidget(ruleCombo, 0, 1);

  label = new QLabel(tr("Input"), baseWidget);
  grid->addWidget(label, 1, 0);

  QStringList l;
  file = new FileButton(baseWidget, l, lastPath);
  grid->addWidget(file, 1, 1);

  label = new QLabel(tr("Symbol"), baseWidget);
  grid->addWidget(label, 2, 0);

  symbol = new QLineEdit(baseWidget);
  grid->addWidget(symbol, 2, 1);

  label = new QLabel(tr("Auto Reload"), baseWidget);
  grid->addWidget(label, 3, 0);

  minutes = new QSpinBox(baseWidget);
  minutes->setMinValue(0);
  minutes->setMaxValue(99);
  minutes->setLineStep(1);
  QObject::connect(minutes, SIGNAL(valueChanged(int)), this, SLOT(reloadTimerChanged(int)));
  grid->addWidget(minutes, 3, 1);

  dateRange = new QCheckBox(tr("Select Date Range"), baseWidget);
  QObject::connect(dateRange, SIGNAL(toggled(bool)), this, SLOT(dateRangeChanged(bool)));
  grid->addWidget(dateRange, 5, 0);

  label = new QLabel(tr("Date Start"), baseWidget);
  grid->addWidget(label, 6, 0);

  sdate = new Q3DateEdit(QDate::currentDate(), baseWidget);
  sdate->setAutoAdvance(TRUE);
  sdate->setOrder(Q3DateEdit::YMD);
  grid->addWidget(sdate, 6, 1);

  label = new QLabel(tr("Date End"), baseWidget);
  grid->addWidget(label, 7, 0);

  edate = new Q3DateEdit(QDate::currentDate(), baseWidget);
  edate->setAutoAdvance(TRUE);
  edate->setOrder(Q3DateEdit::YMD);
  grid->addWidget(edate, 7, 1);

  // set the default end date
  QDate dt = QDate::currentDate();
  if (dt.dayOfWeek() == 6)
    dt = dt.addDays(-1);
  else
  {
    if (dt.dayOfWeek() == 7)
      dt = dt.addDays(-2);
  }
  edate->setDate(dt);
  sdate->setDate(dt);
}
Ejemplo n.º 12
0
void MoveGen::changeLaw()
{
    updateRules();
}