void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
    QString strTitle = tr("Bitcoin"); // default title
    // Default to information icon
    int nMBoxIcon = QMessageBox::Information;
    int nNotifyIcon = Notificator::Information;

    QString msgType;

    // Prefer supplied title over style based title
    if (!title.isEmpty()) {
        msgType = title;
    }
    else {
        switch (style) {
        case CClientUIInterface::MSG_ERROR:
            msgType = tr("Error");
            break;
        case CClientUIInterface::MSG_WARNING:
            msgType = tr("Warning");
            break;
        case CClientUIInterface::MSG_INFORMATION:
            msgType = tr("Information");
            break;
        default:
            break;
        }
    }
    // Append title to "Bitcoin - "
    if (!msgType.isEmpty())
        strTitle += " - " + msgType;

    // Check for error/warning icon
    if (style & CClientUIInterface::ICON_ERROR) {
        nMBoxIcon = QMessageBox::Critical;
        nNotifyIcon = Notificator::Critical;
    }
    else if (style & CClientUIInterface::ICON_WARNING) {
        nMBoxIcon = QMessageBox::Warning;
        nNotifyIcon = Notificator::Warning;
    }

    // Display message
    if (style & CClientUIInterface::MODAL) {
        // Check for buttons, use OK as default, if none was supplied
        QMessageBox::StandardButton buttons;
        if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
            buttons = QMessageBox::Ok;

        // Ensure we get users attention, but only if main window is visible
        // as we don't want to pop up the main window for messages that happen before
        // initialization is finished.
        if(!(style & CClientUIInterface::NOSHOWGUI))
            showNormalIfMinimized();
        QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
        int r = mBox.exec();
        if (ret != NULL)
            *ret = r == QMessageBox::Ok;
    }
    else
        notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
}
Exemple #2
0
/**
 * @brief This test cycles through the list of map definitions found in the maps.ufo script
 * and tries to find surfaces to stand on with no sound assigned to them.
 *
 * This test takes too long to be run every time testall is run. So it's set up almost like a game:
 * After 5 maps (the first of them is fully checked) with missing sounds, the test stops.
 * If we manage to 'clean' one of those 5 maps, the next map will show up in the next run.
 */
TEST_F(FootStepTest, DISABLED_MapDefsFootSteps)
{
	const char* filterId = TEST_GetStringProperty("mapdef-id");
	const mapDef_t* md;
	int mapCount = 0;				// the number of maps read
	int badMapCount = 0;
	const int skipCount = 20;		// to skip the first n mapDefs
	const int badMapCountMax = 25;	// # of maps with missing sounds before this test stops
	const int mapCountMax = 150;	// should of cause be higher than skip + bad
	const int texCountMax = 30;
	char texNames[texCountMax][MAX_QPATH];
	bool done = false;

	OBJZERO(texNames);
	ASSERT_TRUE(csi.numMDs > 0);

	MapDef_Foreach(md) {
		if (md->mapTheme[0] == '.')
			continue;
		if (filterId && !Q_streq(filterId, md->id))
			continue;

		mapCount++;
		if (mapCount <= skipCount)
			continue;
		/* use a known seed to reproduce an error */
		unsigned int seed;
		if (TEST_ExistsProperty("mapdef-seed")) {
			seed = TEST_GetLongProperty("mapdef-seed");
		} else {
			seed = (unsigned int) time(nullptr);
		}
		srand(seed);

		int count = 0;
		Com_Printf("testMapDefsFootSteps: Mapdef %s (seed %u)\n", md->id, seed);

		const char* asmName = (const char*)LIST_GetByIdx(md->params, 0);
		SV_Map(true, md->mapTheme, asmName);

		/* now that we have loaded the map, check all cells for walkable places */
		GridBox mBox(sv->mapData.mapBox);	// test ALL the cells
#if !FOOTSTEPS_FULL
		if (mapCount >= skipCount + 4) {	// after the first 4 maps, reduce the testing area
			const pos3_t center = {148, 128, 0};
			mBox.set(center, center);		// the box on the map we're testing
			mBox.expandXY(10);				// just test a few cells around the center of the map
			mBox.maxs[2] = 2;				// and 3 levels high
		}
#endif
		mBox.clipToMaxBoundaries();

		for (int x = mBox.getMinX(); x <= mBox.getMaxX() && !done; x++) {
			for (int y = mBox.getMinY(); y <= mBox.getMaxY() && !done; y++) {
				for (int z = mBox.getMinZ(); z <= mBox.getMaxZ(); z++) {
					const int floor = sv->mapData.routing.getFloor(1, x, y, z);
					if (floor < 0)						// if we have a floor in that cell
						continue;
					const AABB noBox(vec3_origin, vec3_origin);	// we're doing a point-trace
					const pos3_t cellPos = {(pos_t)x, (pos_t)y, (pos_t)z};			// the cell in question
					vec3_t from, to;
					PosToVec(cellPos, from);			// the center of the cell
					VectorCopy(from, to);				// also base for the endpoint of the trace
					from[2] -= UNIT_HEIGHT / 2;			// bottom of the cell
					from[2] += (floor + 2) * QUANT;		// add the height of the floor plus 2 QUANTS
					to[2] -= 2 * UNIT_HEIGHT;			// we should really hit the ground with this
					const trace_t trace = SV_Trace(Line(from, to), noBox, nullptr, MASK_SOLID);
					if (!trace.surface)
						continue;

					const char* snd = SV_GetFootstepSound(trace.surface->name);
					if (snd)
						continue;

					for (int i = 0; i < texCountMax; ++i) {
						if (!texNames[i][0]) {	// found a free slot ?
							Q_strncpyz(texNames[i], trace.surface->name, sizeof(texNames[i]));
							count++;
							break;
						}
						if (Q_streq(trace.surface->name, texNames[i]))	// already there ?
							break;
					}
					if (count > texCountMax) {
						done = true;
						break;	// the z-loop
					}
				}
			}
		}
		if (!texNames[0][0]) {
			Com_Printf("In map %s, asm %s: Nothing detected\n", md->mapTheme, asmName);
		} else {
			++badMapCount;
			for (int i = 0; i < texCountMax; ++i) {
				if (texNames[i][0]) {
					Com_Printf("In map %s, asm %s: No sound for: %s\n", md->mapTheme, asmName, texNames[i]);
				}
			}
		}
		OBJZERO(texNames);
		SV_ShutdownGameProgs();

		if (done || mapCount >= mapCountMax || badMapCount >= badMapCountMax)
			break;
	}
}
Exemple #3
0
void AlterTable::on_actionAgregar_Columna_triggered() {
    QDialog dialog(this);
    dialog.setWindowTitle("Agregar");
    QLabel messageLabel("Nombre de Columna:", &dialog);
    QLineEdit columnNameLineEdit(&dialog);
    QLabel typeLabel("Tipo:");
    QComboBox typeComboBox(&dialog);
    typeComboBox.addItems(QStringList()
                          << "TINYINT"
                         << "SMALLINT"
                         << "MEDIUMINT"
                         << "INT"
                         << "BIGINT"
                         << "BIT"
                         << "FLOAT"
                         << "DOUBLE"
                         << "DECIMAL"
                         << "CHAR"
                         << "VARCHAR"
                         << "TINYTEXT"
                         << "TEXT"
                         << "MEDIUMTEXT"
                         << "LONGTEXT"
                         << "BINARY"
                         << "VARBINARY"
                         << "TINYBLOB"
                         << "BLOB"
                         << "MEDIUMBLOB"
                         << "LONGBLOB"
                         << "DATE"
                         << "TIME"
                         << "YEAR"
                         << "DATETIME"
                         << "TIMESTAMP"
                         << "POINT"
                         << "LINESTRING"
                         << "POLYGON"
                         << "GEOMETRY"
                         << "MULTIPOINT"
                         << "MULTILINESTRING"
                         << "MULTIPOLYGON"
                         << "GEOMETRYCOLLECTION"
                         << "ENUM"
                         << "SET");
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(&messageLabel);
    layout->addWidget(&columnNameLineEdit);
    layout->addWidget(&typeLabel);
    layout->addWidget(&typeComboBox);
    QPushButton addPushButton("Agregar", &dialog);
    QPushButton cancelPushButton("Cancelar", &dialog);
    connect(&addPushButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
    connect(&cancelPushButton, SIGNAL(clicked()), &dialog, SLOT(reject()));
    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(&addPushButton);
    buttonsLayout->addWidget(&cancelPushButton);
    layout->addLayout(buttonsLayout);
    dialog.setLayout(layout);
    if (dialog.exec() == QDialog::Rejected) { return; }
    int lenght = 0;
    if (typeComboBox.currentText() == "VARCHAR" ||
        typeComboBox.currentText() == "VARBINARY") {
        QInputDialog inDialog(&dialog);
        inDialog.setWindowTitle("Longitud");
        inDialog.setLabelText("Longitud:");
        inDialog.setInputMode(QInputDialog::IntInput);
        if (inDialog.exec() == QInputDialog::Rejected) { return; }
        lenght = inDialog.intValue();
    }
    QDialog configurationDialog(&dialog);
    configurationDialog.setWindowTitle("Configuración");
    QRadioButton afterOfRadioButton("Despues de", &configurationDialog);
    QRadioButton lastRadioButton("Al Final", &configurationDialog);
    lastRadioButton.setChecked(true);
    QVBoxLayout *layoutConf = new QVBoxLayout;
    QPushButton acceptPushButton("Aceptar", &configurationDialog);
    QPushButton cancelConfPushButton("Cancelar", &configurationDialog);
    connect(&acceptPushButton, SIGNAL(clicked()), &configurationDialog,
            SLOT(accept()));
    connect(&cancelConfPushButton, SIGNAL(clicked()), &configurationDialog,
            SLOT(reject()));
    layoutConf->addWidget(&afterOfRadioButton);
    layoutConf->addWidget(&lastRadioButton);
    QHBoxLayout *buttonsConfLayout = new QHBoxLayout;
    buttonsConfLayout->addWidget(&acceptPushButton);
    buttonsConfLayout->addWidget(&cancelConfPushButton);
    layoutConf->addLayout(buttonsConfLayout);
    configurationDialog.setLayout(layoutConf);
    if (configurationDialog.exec() == QDialog::Rejected) { return; }
    QString afterOfString = QString();
    if (afterOfRadioButton.isChecked()) {
        QInputDialog inDialog(&configurationDialog);
        inDialog.setWindowTitle("Referencia");
        inDialog.setLabelText("Columna:");
        if (inDialog.exec() == QInputDialog::Rejected) {
            QMessageBox mBox(this);
            mBox.setWindowTitle("ERROR");
            mBox.setIcon(QMessageBox::Critical);
            mBox.setText(
            "No se puede continuar con la operación de agregado");
            mBox.exec();
            return;
        }
        afterOfString = inDialog.textValue();
    }
    QString queryString = "ALTER TABLE " + tableName + " ADD COLUMN " +
    columnNameLineEdit.text() + " " + typeComboBox.currentText();
    if (typeComboBox.currentText() == "VARCHAR" ||
        typeComboBox.currentText() == "VARBINARY") {
            queryString += "(" + QString::number(lenght) + ")";
    }
    if (afterOfRadioButton.isChecked()) {
        queryString += " AFTER " + afterOfString;
    }
    queryString += ";";
    QSqlQuery query(*db);
    query.exec(queryString);
    if (query.lastError().isValid()) {
        QMessageBox mBox(this);
        mBox.setWindowTitle("ERROR");
        mBox.setIcon(QMessageBox::Critical);
        mBox.setText("No se puede realizar la operación de agregado");
        mBox.exec();
        return;
    }
    QString strQuery;
    if (engineName == "sqlite") {
        strQuery = QString("PRAGMA table_info(%1)").arg(tableName);
    } else if (engineName == "mysql") {
        strQuery = QString("SHOW COLUMNS FROM %1").arg(tableName);
    }
    queryModel->setQuery(strQuery);
    counterOfColumns->setText(QString::number(queryModel->rowCount()));
}
Exemple #4
0
/**
	connexion a la base de donnees
  */
char database::connect(){
	db = QSqlDatabase::addDatabase("Q"+m_bdd);
	db.setHostName( m_hostName );
	db.setPort( m_port );
	db.setDatabaseName( m_name);
	db.setUserName( m_login );
	db.setPassword( m_password );

	if (!db.open()) {
		QMessageBox mBox(QMessageBox::Critical, tr("Erreur"), tr("<b>La connexion avec la base de donnees n a pas pu etre etablie!</b>"),QMessageBox::Ok);
		mBox.setDetailedText ( db.lastError().text() );
		mBox.exec();
		m_connected = false;
		return DB_CON_ERR;
	}
	else m_connected = true;

	// Si pas de tables on les crees
	QStringList tList = db.tables();
	if((!tList.contains("TAB_INFORMATIONS"))||(tList.count()< 14)){
		 // Demande si on creer une nouvelle base de donnees
		QString mess;
		if(db.driverName() == "QSQLITE")mess = tr("Voulez-vous créer une nouvelle base de données ?\n\n")+ db.databaseName();
		else mess = tr("Voulez-vous créer de nouvelles tables dans la base de données ?\n\n") + db.databaseName();
		QMessageBox mBox(QMessageBox::Question, tr("Question"), mess ,QMessageBox::Yes | QMessageBox::No);
		mBox.setDefaultButton(QMessageBox::No);
		int ret = mBox.exec();

		if(ret == QMessageBox::Yes){
			if( !create() ){
				m_connected = false;
				return DB_CON_ERR;
			}
		}else{
			m_connected = false;
			return DB_CON_ERR;
		}
	}
	else m_connected = true;

	//DI SQLITE activation des foreign Keys
	if(db.driverName() == "QSQLITE"){
		QSqlQuery query;
		query.prepare("PRAGMA foreign_keys = ON;");

		if(!query.exec()) {
			QMessageBox::critical(m_parent, tr("Erreur"), query.lastError().text());
			return false;
		}
	}

	// AVOIR: SI DEFAUT LES RETURN PRECEDENT QUI ZAPP LA CREATION DES CLASS NE POSE PAS SOUCIS!?
	m_databaseVersion = databaseVersion();
	m_isTax = isTax();
	//Creation des sous class
	m_customer = new customer(db, m_parent);
	//instanciation de la class product
	m_product = new product(db, m_lang, m_parent);
	//class de la gestion des tax
	m_tax = new tax(m_parent);

	//Test de la version de la base de donnees... !!
	if(m_databaseVersion > MCERCLE::Dbase_support){
		QString mess = tr("Version de mcercle: ") + MCERCLE::Version;
		mess += tr("\nVersion de la base de données: ") + QString::number(m_databaseVersion);
		mess += tr("\n\nVersions des bases de données compatibles: <= ") + QString::number(MCERCLE::Dbase_support);
		QMessageBox mBox(QMessageBox::Warning, tr("Attention"), tr("mcercle ne support pas cette version de base de données...\nMerci de faire évoluer mcercle."),QMessageBox::Ok);
		mBox.setDetailedText ( mess );
		mBox.exec();
		this->close();
		return DB_CON_ERR;
	}
	qDebug() << "version base:" <<QString::number(m_databaseVersion);
	
	// Mise a jour de la base de donnees
	if(m_databaseVersion < MCERCLE::Dbase_support){
		int ret = QMessageBox::warning(
								this->m_parent,
								tr("Attention"),
								tr("Cette version de mcercle doit mettre à jour la base de donnée pour fonctionner.\n\nVoulez-vous mettre à jour la base de donnée ?\n(Ceci peut prendre quelques minutes...)"),
								QMessageBox::Yes, QMessageBox::No | QMessageBox::Default
								);
	
		if(ret == QMessageBox::Yes){
			update_db upDatabase(this);

			QString logAll, log, mess;
			bool upgradeOk=true;
			if(m_databaseVersion <= 1) {
				if(!upDatabase.upgradeToV2(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 2 ) {
				if(!upDatabase.upgradeToV3(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 3 ) {
				if(!upDatabase.upgradeToV4(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 4 ) {
				if(!upDatabase.upgradeToV5(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 5 ) {
				if(!upDatabase.upgradeToV6(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 6 ) {
				if(!upDatabase.upgradeToV7(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 7 ) {
				if(!upDatabase.upgradeToV8(&log)) upgradeOk = false;
			}
			logAll += log;
			if(m_databaseVersion <= 8 ) {
				if(!upDatabase.upgradeToV9(&log)) upgradeOk = false;
			}
			logAll += log;

			QMessageBox mBox(QMessageBox::Information, tr("Information"), mess, QMessageBox::Ok);
			if(upgradeOk){
				mess += tr("La mise à jour de la base de données a réussi !\n");
				mBox.setIcon( QMessageBox::Information );
			}
			else{
				mess += tr("La mise à jour contient des erreurs :-(\nAfficher les détails pour voir ce qui ne va pas.");
				mBox.setIcon( QMessageBox::Critical );
			}
			mBox.setText( mess );
			mBox.setDetailedText(logAll);
			mBox.exec();
		}
		else{
			this->close();
			return DB_CON_ERR;
		}
	}
	
	return DB_CON_OK;
}
Exemple #5
0
void AlterTable::on_actionModificar_Columna_triggered() {
    QDialog dialog(this);
    dialog.setWindowTitle("Modificar Columna");
    QRadioButton isNullableRadioButton("Puede ser Nulo", &dialog);
    QRadioButton isNotNullableRadioButton("No puede ser Nulo", &dialog);
    isNullableRadioButton.setChecked(true);
    QLabel messageLabel("Nombre de Columna", &dialog);
    QLineEdit columnNameLineEdit(&dialog);
    QLabel typeLabel("Tipo", &dialog);
    QComboBox typeComboBox(&dialog);
    typeComboBox.addItems(QStringList()
    << "TINYINT"
    << "SMALLINT"
    << "MEDIUMINT"
    << "INT"
    << "BIGINT"
    << "BIT"
    << "FLOAT"
    << "DOUBLE"
    << "DECIMAL"
    << "CHAR"
    << "VARCHAR"
    << "TINYTEXT"
    << "TEXT"
    << "MEDIUMTEXT"
    << "LONGTEXT"
    << "BINARY"
    << "VARBINARY"
    << "TINYBLOB"
    << "BLOB"
    << "MEDIUMBLOB"
    << "LONGBLOB"
    << "DATE"
    << "TIME"
    << "YEAR"
    << "DATETIME"
    << "TIMESTAMP"
    << "POINT"
    << "LINESTRING"
    << "POLYGON"
    << "GEOMETRY"
    << "MULTIPOINT"
    << "MULTILINESTRING"
    << "MULTIPOLYGON"
    << "GEOMETRYCOLLECTION"
    << "ENUM"
    << "SET");
    QPushButton acceptPushButton("Aceptar", &dialog);
    QPushButton cancelPushButton("Cancelar", &dialog);
    connect(&acceptPushButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
    connect(&cancelPushButton, SIGNAL(clicked()), &dialog, SLOT(reject()));
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(&isNullableRadioButton);
    layout->addWidget(&isNotNullableRadioButton);
    layout->addWidget(&messageLabel);
    layout->addWidget(&columnNameLineEdit);
    layout->addWidget(&typeLabel);
    layout->addWidget(&typeComboBox);
    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(&acceptPushButton);
    buttonsLayout->addWidget(&cancelPushButton);
    layout->addLayout(buttonsLayout);
    dialog.setLayout(layout);
    if (dialog.exec() == QDialog::Rejected) { return; }
    if (columnNameLineEdit.text() == QString()) {
        QMessageBox mBox(this);
        mBox.setWindowTitle("ERROR");
        mBox.setIcon(QMessageBox::Critical);
        mBox.setText(
        "No se puede realizar la operación de modificación");
        mBox.exec();
        return;
    }
    QString lenghtString = QString();
    if (typeComboBox.currentText() == "VARCHAR" ||
        typeComboBox.currentText() == "VARBINARY") {
        QDialog lenDialog(&dialog);
        lenDialog.setWindowTitle("Longitud");
        QVBoxLayout *layout = new QVBoxLayout;
        QHBoxLayout *topLayout = new QHBoxLayout;
        topLayout->addWidget(new QLabel("Longitud:", &lenDialog));
        QLineEdit lenValueText(&lenDialog);
        topLayout->addWidget(&lenValueText);
        QHBoxLayout *layoutButtons = new QHBoxLayout;
        QPushButton okButton("Aceptar", &lenDialog);
        QPushButton cancelButton("Cancelar", &lenDialog);
        layoutButtons->addWidget(&okButton);
        layoutButtons->addWidget(&cancelButton);
        layout->addLayout(topLayout);
        layout->addLayout(layoutButtons);
        lenDialog.setLayout(layout);
        connect(&okButton, SIGNAL(clicked()), &lenDialog, SLOT(accept()));
        connect(&cancelButton, SIGNAL(clicked()), &lenDialog, SLOT(reject()));
        if (lenDialog.exec() == QDialog::Rejected) {
            QMessageBox mBox;
            mBox.setWindowTitle("ERROR");
            mBox.setIcon(QMessageBox::Critical);
            mBox.setText(
            "No se puede continuar con la operación de modificación");
            mBox.exec();
            return;
        }
        lenghtString = "(" + lenValueText.text() + ")";
    }
    QString isNullString = QString();
    if (isNotNullableRadioButton.isChecked()) { isNullString = "NOT NULL"; }
    QSqlQuery query(*db);
    query.exec("ALTER TABLE " + tableName + " CHANGE COLUMN " +
        columnNameLineEdit.text() + " " + columnNameLineEdit.text() + " " +
            typeComboBox.currentText() + lenghtString + " " +
                isNullString + ";");
    QString strQuery;
    if (engineName == "sqlite") {
        strQuery = QString("PRAGMA table_info(%1)").arg(tableName);
    } else if (engineName == "mysql") {
        strQuery = QString("SHOW COLUMNS FROM %1").arg(tableName);
    }
    queryModel->setQuery(strQuery);
}