/**
 * @brief This function add the values to the table
 *
 * @param _list1
 * @param _list2
 */
void ProjectSettingsDialog::addValuesToTable(QStringList _list1, QStringList _list2)
{
    bool _isDifSize = false;
    int _listSize = _list1.size();
    // Check if the lists are not equal
    if ((_list1.size() != _list2.size()))
        _isDifSize = true;
    if ( (_isDifSize) && (_list1.size()>_list2.size()) )
      _listSize = _list2.size();

    for(int i= 0; i < _listSize; i++)
    {
        QString _configFileName = _list1.at(i);
        QString _meshFileName = _list2.at(i);
        int _cRow = i*2;
        addRowToTable(_cRow,_cRow/2, _configFileName);
        _cRow++;
        addRowToTable(_cRow,_cRow/2, _meshFileName);
    }
    // Completing the
    if (_isDifSize)
    {
        bool _addToConfig =false;
        bool _addToMesh = false;
        int _difSizeVal = 0;
        int _startPoint = _listSize;
        if (_list1.size() > _list2.size() )
        {
            _difSizeVal = _list1.size() - _list2.size();
            _addToConfig = true;
        }else
        {
            _difSizeVal = _list2.size() - _list1.size();
            _addToMesh = true;
        }
        for (int j = _startPoint; j < (_difSizeVal+_startPoint);j++)
        {
            QString _configFileName("Not Defined");
            if (_addToConfig)
                _configFileName = _list1.at(j);
            QString _meshFileName("Not Defined");
            if (_addToMesh)
                _meshFileName = _list2.at(j);
            int _cRow = j*2;
            addRowToTable(_cRow,_cRow/2, _configFileName);
            _cRow++;
            addRowToTable(_cRow,_cRow/2, _meshFileName);
        }

    }

}
Esempio n. 2
0
void MainWindow::on_btnLoadFromFile_released()
{
    QString filename = QFileDialog::getOpenFileName(this,
                                                    tr("Load from VDB file"),
                                                    QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation),
                                                    tr("Vanity Datebase (*.vdb)"));

    if(filename == "") {
        QMessageBox::critical(this, tr("Error"), tr("No file name specified!"));
        return;
    }

    if (!filename.endsWith(".vdb"))
        filename += ".vdb";

    bool passwordOk = false;
    QString password = QInputDialog::getText(this, tr("Password"),
                                             tr("Enter password:"******"", &passwordOk);
    if (!passwordOk)
        return;
    else if (password.isEmpty()) {
        QMessageBox::critical(this, tr("Error"), tr("No password entered!"));
        return;
    }

    QFile file(filename);
    if(!file.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(this, tr("Error"), tr("Cannot open file!"));
        return;
    }

    QByteArray fileData = file.readAll();
    file.close();

    VanityDB tempDataBase;
    if (!tempDataBase.setEncryptedData(fileData, password)) {
        QMessageBox::critical(this, tr("Error"), tr("File is corrupted!\nMaybe password was wrong."));
        return;
    }

    for (int i=0; i<tempDataBase.getRecordCount(); i++) {

        QString networkByte = tempDataBase.getRecord(i, VanityDB::networkByte);
        QString prefix = tempDataBase.getRecord(i, VanityDB::prefix);
        QString privateKey = tempDataBase.getRecord(i, VanityDB::privateKey);
        QString publicKey = tempDataBase.getRecord(i, VanityDB::publicKey);

        bool status = false;
        bc.setPrivateKey(privateKey);
        if (bc.getBitcoinAddress().startsWith(prefix))
            status = true;
        addRowToTable(networkByte, prefix, privateKey, publicKey, status);
    }

    QMessageBox::information(this, tr("Success"), tr("Vanity database was successfully loaded."));

}
Esempio n. 3
0
void MainWindow::on_btnNewPrefix_released()
{
    npDialog->exec();
    QStringList sl = npDialog->getPrefPrivPubValues();
    if (!sl.isEmpty()) {
        bool status = false;
        bc.setPublicKey(sl.at(2));
        if (bc.getBitcoinAddress().startsWith(sl.at(0)))
            status = true;
        addRowToTable("00", sl.at(0), sl.at(1), sl.at(2), status);
    }
}
Esempio n. 4
0
void MainWindow::solveActionSlot() {
    QString prefix = ui->tableView->selectionModel()->selectedRows(1).at(0).data(0).toString();
    slvDialog->setPrefPrivPub(prefix,
                           ui->tableView->selectionModel()->selectedRows(2).at(0).data(0).toString(),
                           ui->tableView->selectionModel()->selectedRows(3).at(0).data(0).toString());
    slvDialog->exec();
    QString finalPrivateKey = slvDialog->getPrivateKey();
    QString finalPublicKey = slvDialog->getPublicKey();
    if (!finalPrivateKey.isEmpty() || !finalPublicKey.isEmpty()) {
        prefixTable.removeRow(ui->tableView->selectionModel()->currentIndex().row());
        addRowToTable("00", prefix, finalPrivateKey, finalPublicKey, true);
    }
}
Esempio n. 5
0
list* addTableToColumn(list* table, list* column){
	if(table!=NULL){
		list* newNode= createListNode(table->nodeName);
		copyAttributes(newNode, table->attrList);
		column->down= newNode;
		if(table->down ==NULL || table->down->right==NULL)
			yyerror("ERROR\n");

		list* tableRows= table->down->right;
		while(tableRows!=NULL){
			addRowToTable(tableRows, newNode);
			tableRows= tableRows->right;
		}
	}
}
Esempio n. 6
0
//Le constructeur
Widget::Widget(): QWidget()
{
	//On initialise la fenetre
	this->setWindowTitle("Client B");
	setMinimumSize(640,480);

	//On crèe une table view non éditable
	QTableView *tableView=new QTableView();
	tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);

	//On crèe le model à 2 colonnes de la qtableview
	this->model=new QStandardItemModel(0,2,tableView);

	//On écrit l'entete du model
	QStringList list;
	list<<"Evenement"<<"Heure";
	model->setHorizontalHeaderLabels(list);

	//On affecte le model à sa qtableview, et on configure cette dernière
	tableView->setModel(model);
	tableView->horizontalHeader()->setStretchLastSection(true);
	tableView->setColumnWidth(0,500);

	//On range la qtableview dans la fenetre avec une layout
	QHBoxLayout *layout = new QHBoxLayout;
	layout->addWidget(tableView);
	this->setLayout(layout);
	addRowToTable("Démarage de l'application",model);

	//On créé la configuration réseau
        ConfigurationNetwork *configurationNetwork=ConfigurationNetwork::createConfigurationNetwork("pchky",4321);
	if(configurationNetwork) addRowToTable("La configuration réseau a été crée",model);
	else {addRowToTable("Echec de la création de la configuration réseau",model);return;}

	//On créé la configuration d'identification
	ConfigurationIdentification *configurationIdentification=ConfigurationIdentification::createConfigurationIdentification("hky","hky");
	if(configurationIdentification) addRowToTable("La configuration d'identification' a été crée",model);
	else {addRowToTable("Echec de la création de la configuration d'indentification",model);return;}

	//On créé la configuration de fichier
	QList<Dir*> *depots=new QList<Dir*>();
        Dir *d1=Dir::createDir("/home/julien/test/A","/sd/1");depots->append(d1);
        if(!d1){addRowToTable("Echec de la création du repertoire 1",model);return;}
        //Dir *d2=Dir::createDir("/home/hky/test/B","/sd/1");depots->append(d2);
        //if(!d2){addRowToTable("Echec de la création du repertoire 2",model);return;}
	ConfigurationFile *configurationFile=ConfigurationFile::createConfigurationFile(depots);
	if(configurationFile) addRowToTable("Les configurations des repertoires surveillés ont été créés",model);
	else {addRowToTable("Echec de la création des configurations de repertoires surveillés",model);return;}

	//On créé la configuration totale
        this->configurationData=ConfigurationData::createConfigurationData(configurationNetwork,configurationIdentification,configurationFile,"/home/julien/test/config2.xml");

	//On créé l'interface réseau
	this->networkInterface=NetworkInterface::createNetworkInterface(configurationData);
	if(networkInterface) addRowToTable("L'interface réseau a été crée",model);
	else {addRowToTable("Echec de la création de l'interface réseau",model);return;}

	//On créé l'interface disque dur
	this->hddInterface=HddInterface::createHddInterface(configurationData,networkInterface,model);
	if(hddInterface) addRowToTable("L'interface disque a été crée",model);
	else {addRowToTable("Echec de la création de l'interface disque",model);return;}

	//On tente de se connecter au serveur
	addRowToTable("Tentative de connexion au serveur",model);
	bool a=networkInterface->connect();
	if(a) addRowToTable("Success: Connexion réuissie",model);
	else addRowToTable("Echec: Connexion échouée",model);
}
Esempio n. 7
0
/*
 The query parsing function that does not contain SELECT functions
 This loops through the rows and if they pass, adds it to the new table
*/
void Database::normalQuery(Query_parser* parser, string oldTableName,
		Table* newTable) {
	vector<LogicExpression::ExpressionTree*> expTree = parser->trees;
	string newTableName = parser->new_table_name;
	map<string, string> oldToNewColumns = parser->new_columns;
	Table *oldTable = findTable(oldTableName);
	vector<string> oldTableColumnNames = oldTable->columnNames();
	//Loop through the rows.
	//If each row passes the test, then add it to the new table
	for (int i = 0; i < oldTable->rowCount(); i++) {

		vector<string> thisRow = oldTable->getRow(i);

		//Make sure the row passes each expression
		bool rowPasses = false;
		
		for (int k = 0; k < expTree.size(); k++) {
		
			rowPasses = expTree[k]->isTrue(oldTableColumnNames, thisRow);
			
			if (!rowPasses) {
				break;
			}
		}

		//If there's not comparators, then it auto passes!
		if (expTree.size() == 0) {
			rowPasses = true;
		}

		//Now if they used the AS operator, then we need to
		//assign the values to the new column names
		if (rowPasses) {
			//Loop through the mapping and set the new column names
			//Then find the old column name's value to replace
			map<string, string>::iterator oldToNewColumnsIt;
			vector<string> columnNamesToAdd;
			vector<string> columnDataToAdd;

			for (oldToNewColumnsIt = oldToNewColumns.begin();
					oldToNewColumnsIt != oldToNewColumns.end();
					oldToNewColumnsIt++) {

				string oldName = oldToNewColumnsIt->first;

				string newName = oldToNewColumnsIt->second;
				vector<string> fullName = globalParse::get_separate_statments(
						oldName, ".");
				if (fullName.size() > 1) {
					if (fullName[0] != oldTableName) {
						//this will be different dont care about those
						continue;
					}
					else if (fullName[0] == oldTableName) {
						oldName = fullName[1];
					}
				}
				columnNamesToAdd.push_back(newName);

				//Loop through the column names and at that
				//index add the data from the row
				bool columnFound = false;
				for (int j = 0; j < oldTableColumnNames.size(); j++) {
					if (oldTableColumnNames[j] == oldName) {
						columnDataToAdd.push_back(thisRow[j]);
						columnFound = true;
					}
				}

				//Make sure the old column name was found
				if (!columnFound) {
					throw DatabaseException(20, oldName + " does not exist");
				}
			}

			//Now add the successful row!
			//addRowToTable(newTableName, columnNamesToAdd, columnDataToAdd);
			addRowToTable(newTable->getTableName(), columnNamesToAdd,
					columnDataToAdd);
		}
	}
}
Esempio n. 8
0
/*
 Either passes the data to normalQuery or continues if the SELECT statement has functions like SUM, etc
 Calculates the SELECT functions and adds the resulting value to the new table
*/
Table* Database::queryParsing(Query_parser* parser, string oldTableName,
		Table* newTable) {
	if(debug)
		cout<<"MADE IT THIS FAR IN QUERY PARSING"<<endl;
	vector<LogicExpression::ExpressionTree*> expTree = parser->trees;
	string newTableName = parser->new_table_name;
	map<string, string> oldToNewColumns = parser->new_columns;
	Table *oldTable = findTable(oldTableName);

	//Make sure the tables exist
	if (oldTable == NULL) {
		throw DatabaseException(10, oldTableName + " does not exist.");
	} else if (newTable == NULL) {
		throw DatabaseException(10, newTableName + " does not exist.");
	}
	int selectFuncsExist = parser->selectFunctionsExist();

	if (selectFuncsExist == -1) {
		throw DatabaseException(
				25,
				"SELECT commands must all be select functions (Sum, Count, Min, or Max).");
	}

	vector<string> oldTableColumnNames = oldTable->columnNames();
	
	//If select functions aren't used, then call the normal query parser
	if (selectFuncsExist == 0) {
		if(debug)
		{
			cout<<"NORMAL QUERY"<<endl;
		}
		normalQuery(parser, oldTableName, newTable);
	//Must find the select function and calculate
	} else {
		map<string, string>::iterator oldToNewColumnsIt;
		vector<string> columnNamesToAdd;
		vector<string> columnDataToAdd;

		for (oldToNewColumnsIt = oldToNewColumns.begin();
				oldToNewColumnsIt != oldToNewColumns.end();
				oldToNewColumnsIt++) {
			string oldName = oldToNewColumnsIt->first;
			string newName = oldToNewColumnsIt->second;
			if (newName == "") {
				continue;
			}
			//cout<<"switch "<<oldName<<"="<<newName<<endl;
			columnNamesToAdd.push_back(newName);
			string str = "";
			stringstream strstr;

			if (oldName.find("SUM") != string::npos) {
				strstr
						<< sumStatement(parser,
								parser->selectFunctionRemove(oldName));
			} else if (oldName.find("COUNT") != string::npos) {
				strstr << countStatement(parser);
			} else if (oldName.find("MIN") != string::npos) {
				strstr
						<< minMaxStatement(parser,
								parser->selectFunctionRemove(oldName), true);
			} else if (oldName.find("MAX") != string::npos) {
				strstr
						<< minMaxStatement(parser,
								parser->selectFunctionRemove(oldName), false);
			}

			strstr >> str;

			columnDataToAdd.push_back(str);
		}
		addRowToTable(newTable->getTableName(), columnNamesToAdd,
				columnDataToAdd);
	}
	
	return newTable;
}