void testUnionFilter()
    {
        QLandmarkCategoryId catId;
        catId.setLocalId("1");
        catId.setManagerUri("qtlandmarks:mock:");

        QLandmarkCategoryId catId2;
        catId2.setLocalId("2");
        catId2.setManagerUri("qtlandmarks:mock:");

        //test a match with the union filter
        QLandmarkUnionFilter unionFilter;
        QLandmarkNameFilter nameFilter("beach");
        QLandmarkProximityFilter proximityFilter(QGeoCoordinate(30,30));
        proximityFilter.setRadius(QGeoCoordinate(30,30).distanceTo(QGeoCoordinate(30,32)));
        QLandmarkCategoryFilter categoryFilter;
        categoryFilter.setCategoryId(catId);

        QLandmark lm;
        lm.setName("statue");
        lm.setCoordinate(QGeoCoordinate(-30,-29));
        lm.addCategoryId(catId);

        unionFilter << nameFilter << categoryFilter << proximityFilter;
        QVERIFY(MockEngine::testFilter(unionFilter,lm));

        //test no match with union filter
        lm.removeCategoryId(catId);
        lm.addCategoryId(catId2);
        QVERIFY(!MockEngine::testFilter(unionFilter,lm));

        //test empty union filter
        unionFilter.clear();
        QVERIFY(!MockEngine::testFilter(unionFilter,lm));
    }
Example #2
0
void kpoBaseApp::loadModelFiles()
{
    std::cout << "kpoBaseApp::loadModelFiles() with " << models_folder_.toStdString() << std::endl;

    QStringList nameFilter("*.pcd");
    QDir directory(models_folder_);
    QStringList model_files = directory.entryList(nameFilter);

    int count = model_files.length();
    std::cout << "will load " << count << " model files." << std::endl;
    if (count < thread_load) {
        thread_load = count;
    }

    #pragma omp parallel
    {
        #pragma omp for

        for (int i=0; i<count; i++) {

            QString qs_filename = model_files[i];
            string filename = qs_filename.toStdString();

            std::cout << "reading " << filename << std::endl;

            int object_id = qs_filename.replace(QRegExp("[a-z]*.pcd"), "").toInt();

            std::cout << "object_id " << object_id << std::endl;

            load_model_cloud(models_folder_.toStdString() + "/" + filename, object_id);
        }

    }

}
Example #3
0
QString PythonMapFormat::shortName() const
{
    QString ret;

    // find fun
    PyObject *pfun = PyObject_GetAttrString(mClass, "shortName");
    if (!pfun || !PyCallable_Check(pfun)) {
        PySys_WriteStderr("Plugin extension doesn't define \"shortName\". Falling back to \"nameFilter\"\n");
        return nameFilter();
    }

    // have fun
    PyObject *pinst = PyEval_CallFunction(pfun, "()");
    if (!pinst) {
        PySys_WriteStderr("** Uncaught exception in script **\n");
    } else {
        ret = PyString_AsString(pinst);
        Py_DECREF(pinst);
    }
    handleError();

    Py_DECREF(pfun);

    return ret;
}
FormSettingsContainer::FormSettingsContainer(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormSettingsContainer)
{
    ui->setupUi(this);
    connect(ui->pushButtonConfirm,SIGNAL(released()),this,SLOT(addNewSettingsField()));
    connect(ui->pushButtonConfirm,SIGNAL(released()),this,SLOT(toggleAdding()));
    connect(ui->pushButtonCancel ,SIGNAL(released()),this,SLOT(toggleAdding()));
    connect(ui->lineEditFilterPreset,SIGNAL(textEdited(QString)),this,SLOT(filterPresets(QString)));
    ui->groupBoxAddingOptions->hide();
    ui->verticalLayoutSettingsList->setAlignment(Qt::AlignTop);


    QSettings list_settings("Configs/config_list",QSettings::IniFormat);
    FormSettingsField::settingsGlobalID =  list_settings.value("last_id",0).toInt();


    QStringList nameFilter("*.ini");
    QDir directory("Configs/");
    QStringList iniFiles = directory.entryList(nameFilter);
    qDebug() << "Reading the list of available configs settings:";
    // reading configs
    for (int i = 0; i < iniFiles.size(); ++i){
        FormSettingsField* sfield = new FormSettingsField("Configs/"+iniFiles[i],this);
        connect(sfield,SIGNAL(emitDeleteSettings(FormSettingsField*)),this,SLOT(removeSetting(FormSettingsField*)));
        connect(sfield,SIGNAL(emitLoadSettings(FormSettingsField*))  ,this,SLOT(reloadSettings(FormSettingsField*)));
        connect(sfield,SIGNAL(emitSaveSettings())  ,this,SLOT(saveSettings()));
        connect(sfield,SIGNAL(emitLoadAndConvert()),this,SLOT(loadAndConvert()));
        ui->verticalLayoutSettingsList->addWidget(sfield);


        settingsList.push_back(sfield);
    }

}
Example #5
0
void OfflineAstrometryParser::verifyIndexFiles(double fov_x, double fov_y)
{
    static double last_fov_x=0, last_fov_y=0;

    if (last_fov_x == fov_x && last_fov_y == fov_y)
        return;

    last_fov_x = fov_x;
    last_fov_y = fov_y;
    double fov_lower = 0.10 * fov_x;
    double fov_upper = fov_x;
    QStringList indexFiles;
    QString astrometryDataDir;
    bool indexesOK = true;

    if (getAstrometryDataDir(astrometryDataDir) == false)
        return;

    QStringList nameFilter("*.fits");
    QDir directory(astrometryDataDir);
    QStringList indexList = directory.entryList(nameFilter);
    QString indexSearch = indexList.join(" ");
    QString startIndex, lastIndex;
    unsigned int missingIndexes=0;

    foreach(float skymarksize, astrometryIndex.keys())
    {
        if (skymarksize >= fov_lower && skymarksize <= fov_upper)
        {
            indexFiles << astrometryIndex.value(skymarksize);

            if (indexSearch.contains(astrometryIndex.value(skymarksize)) == false)
            {
                if (startIndex.isEmpty())
                    startIndex = astrometryIndex.value(skymarksize);

                lastIndex = astrometryIndex.value(skymarksize);

                indexesOK = false;

                missingIndexes++;
            }

        }
    }

    if (indexesOK == false)
    {
        if (missingIndexes == 1)
            align->appendLogText(i18n("Index file %1 is missing. Astrometry.net would not be able to adequately solve plates until you install the missing index files. Download the index files from http://www.astrometry.net",
                                             startIndex));
        else
            align->appendLogText(i18n("Index files %1 to %2 are missing. Astrometry.net would not be able to adequately solve plates until you install the missing index files. Download the index files from http://www.astrometry.net",
                                             startIndex, lastIndex));

    }
}
Example #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QStringList nameFilter("*.txt"); // Фильтр по которому отделяют файлы
    QDir directory("C:/Users/Mikio/Desktop/slovar/slbase"); // Директория с файлами
    QStringList txtFilesAndDirectories = directory.entryList(nameFilter);
    foreach (QString str, txtFilesAndDirectories) {
        //cout << str.toLocal8Bit().constData() << endl;
        ui->listWidget->addItem(str);
    }
Example #7
0
void SaveManager::load(QString loadpath)
{
	//// Création d'un dossier temporaire ////
	tempdir.reset(new QTemporaryDir);

	//// Extraction de l'archive dans le dossier temp ////
	KZip archive(loadpath);

	if (!archive.open(QIODevice::ReadOnly)) {
		qWarning("Cannot open the archive");
		qWarning("Is it a valid zip file?");
		return;
	}

	const KArchiveDirectory *root = archive.directory();

	root->copyTo(tempdir->path(), true);

	archive.close();

	qDebug() << tempdir->path();

	//// Lecture des données
	// On cherche le .ini :
	QStringList nameFilter("*.ini");
	QDir directory(tempdir->path());
	QString iniFile = tempdir->path() + "/" + directory.entryList(nameFilter).first();
	qDebug() << iniFile;

	MainWidget* mw = qobject_cast<MainWidget*>(parent());
	mw->clearChannels();


	QSettings settings(iniFile, QSettings::IniFormat);

	mw->ui->songName->setText(settings.value("General/songName").toString());
	mw->ui->tempo->setValue(settings.value("General/tempo").toInt());
	mw->ui->trackCount->setValue(settings.value("General/trackCount").toInt());
	mw->ui->numerateur->setValue(settings.value("General/sigNumerator").toInt());
	mw->ui->denominateur->setValue(settings.value("General/sigDenominator").toInt());

	int n = mw->ui->trackCount->value();
	for(int i = 0; i < n; ++i)
	{
		mw->channels[i]->setName(settings.value(QString("Track%1/name").arg(i)).toString());
		mw->channels[i]->setFilename(settings.value(QString("Track%1/filename").arg(i)).toString());
		mw->channels[i]->setBox(settings.value(QString("Track%1/boxnumber").arg(i)).toInt());
	}

}
void OwncloudSyncd::getSyncFolders()
{
    //Path should be: //home/phablet/.local/share
    QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);

    path += "/owncloud-sync/Databases";
    qDebug() << "Writeable Path: " << path;

    //Find the Database Name
    QStringList nameFilter("*.sqlite");
    QDir directory(path);
    QStringList dbName = directory.entryList(nameFilter);

    qDebug() << "DB Name: " << dbName.at(0);

    path += "/" + dbName.at(0);

    qDebug() << "Attempting to access DB: " << path;

    //QSqlDatabase db = QSqlDatabase::database();
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(path);

    //db.open();

    if (!db.open())
    {
        qDebug() << "Error: connection with database fail";
    }
    else
    {
        qDebug() << "Database: connection ok";
        qDebug() << "Database Tables:" << db.tables(QSql::AllTables).at(0);

        QSqlQuery query(db);

        query.exec("SELECT local, remote FROM SyncFolders");

        while (query.next()) {
            //qDebug() << query.value(0).toString();
            //qDebug() << query.value(1).toString();
            m_folderMap.insert(query.value(0).toString(), query.value(1).toString());

        }
    }

    db.close();
}
Example #9
0
void UsersDialog::populateList(const QString &filter) {
  QRegExp nameFilter("*" + filter + "*");
  nameFilter.setPatternSyntax(QRegExp::Wildcard);
  nameFilter.setCaseSensitivity(Qt::CaseInsensitive);
  ui->listWidget->clear();
  if (userList) {
    for (QList<UserInfo>::iterator it = userList->begin();
         it != userList->end(); ++it) {
      UserInfo &user(*it);
      if (filter.isEmpty() || nameFilter.exactMatch(user.name)) {
        if (user.validity == '-' && !ui->checkBox->isChecked())
          continue;
        if (user.expiry.toTime_t() > 0 &&
            user.expiry.daysTo(QDateTime::currentDateTime()) > 0 &&
            !ui->checkBox->isChecked())
          continue;
        QString userText = user.name + "\n" + user.key_id;
        if (user.created.toTime_t() > 0) {
          userText += " " + tr("created") + " " +
                      user.created.toString(Qt::SystemLocaleShortDate);
        }
        if (user.expiry.toTime_t() > 0)
          userText += " " + tr("expires") + " " +
                      user.expiry.toString(Qt::SystemLocaleShortDate);
        QListWidgetItem *item = new QListWidgetItem(userText, ui->listWidget);
        item->setCheckState(user.enabled ? Qt::Checked : Qt::Unchecked);
        item->setData(Qt::UserRole, QVariant::fromValue(&user));
        if (user.have_secret) {
          // item->setForeground(QColor(32, 74, 135));
          item->setForeground(Qt::blue);
          QFont font;
          font.setFamily(font.defaultFamily());
          font.setBold(true);
          item->setFont(font);
        } else if (user.validity == '-') {
          item->setBackground(QColor(164, 0, 0));
          item->setForeground(Qt::white);
        } else if (user.expiry.toTime_t() > 0 &&
                   user.expiry.daysTo(QDateTime::currentDateTime()) > 0) {
          item->setForeground(QColor(164, 0, 0));
        }

        ui->listWidget->addItem(item);
      }
    }
  }
}
Example #10
0
void kpoBaseApp::loadContourFiles()
{
    std::cout << "kpoBaseApp::loadContourFiles() with " << contours_folder_.toStdString() << std::endl;

    QStringList nameFilter("*.path");
    QDir directory(contours_folder_);
    QStringList contour_files = directory.entryList(nameFilter);

    int count = contour_files.length();
    std::cout << "will load " << count << " contour files." << std::endl;

    for (int i=0; i<count; i++) {

        QString qs_filename = contour_files[i];
        string filename = qs_filename.toStdString();

        std::cout << "reading " << filename << std::endl;

        kpoObjectContour obj = load_contour_file(contours_folder_.toStdString() + "/" + filename);
        contour_objects_.push_back(obj);
    }
}
Example #11
0
void UsersDialog::populateList(const QString &filter)
{
    QRegExp nameFilter("*"+filter+"*");
    nameFilter.setPatternSyntax(QRegExp::Wildcard);
    nameFilter.setCaseSensitivity(Qt::CaseInsensitive);
    ui->listWidget->clear();
    if (userList) {
        for (UserInfo &user : *userList) {
            if (filter.isEmpty() || nameFilter.exactMatch(user.name)) {
                QListWidgetItem *item = new QListWidgetItem(user.name + "\n" + user.key_id, ui->listWidget);
                item->setCheckState(user.enabled ? Qt::Checked : Qt::Unchecked);
                item->setData(Qt::UserRole, QVariant::fromValue(&user));
                if (user.have_secret) {
                    item->setForeground(Qt::blue);
                } else if (user.validity == '-') {
                    item->setBackground(Qt::red);
                }
                ui->listWidget->addItem(item);
            }
        }
    }
}
Example #12
0
QVector<InvoiceData> XmlDataLayer::invoiceSelectAllData(QDate start, QDate end) {
	qDebug() << __FILE__ << __LINE__ << __FUNCTION__;

	QVector<InvoiceData> o_invDataVec;

	QDir allFiles;
	QString text;

	QDomDocument doc(sett().getInoiveDocName());
	QDomElement root;
	QDomElement nadawca;
	QDomElement odbiorca;

	allFiles.setPath(sett().getInvoicesDir());
	allFiles.setFilter(QDir::Files);
	QStringList filters;
	filters << "h*.xml" << "k*.xml";
	allFiles.setNameFilters(filters);
	QStringList files = allFiles.entryList();
	int i, max = files.count();
	for (i = 0; i < max; ++i) {
		if (nameFilter(files[i], start, end)) {

			InvoiceData invDt;
			// qDebug() << files[i];
			QFile file(sett().getInvoicesDir() + files[i]);

			if (!file.open(QIODevice::ReadOnly)) {
				qDebug() << "File" << file.fileName() << "doesn't exists";
				continue;
			} else {
				QTextStream stream(&file);
				if (!doc.setContent(stream.readAll())) {
					// qDebug ("can not set content ");
					file.close();
					// return o_invDataVec;
					continue;
				}
			}

			invDt.id = files[i];
			root = doc.documentElement();
			invDt.frNr = root.attribute("no");
			invDt.sellingDate = QDate::fromString(root.attribute("sellingDate"), sett().getDateFormat());
			invDt.productDate = QDate::fromString(root.attribute("issueDate"), sett().getDateFormat());
			invDt.type = root.attribute("type");

			QDomNode nab;
			nab = root.firstChild();
			nab = nab.toElement().nextSibling();

			invDt.custStreet = nab.toElement().attribute("street", "NULL");
			invDt.custTic  = nab.toElement().attribute("tic", "NULL");
			invDt.custCity  = nab.toElement().attribute("city", "NULL");
			invDt.custName = nab.toElement().attribute("name", "NULL");

			o_invDataVec.push_back(invDt);
		}
	}
	return o_invDataVec;
}