Exemplo n.º 1
0
ConnectDialog::ConnectDialog(QWidget *p) : QDialog(p) {

	qhList = new QHttp(QLatin1String("mumble.hive.no"), 80, this);
	qhList->setObjectName(QLatin1String("Request"));

	setupUi(this);
#ifdef Q_OS_MAC
	setWindowFlags(Qt::Sheet);
#endif

	bPublicInit = false;
	bDirty = false;

	if (tPublicServers.elapsed() >= 60 * 24 * 1000000ULL) {
		qlPublicServers.clear();
	}

	qtwServers->sortItems(0, Qt::AscendingOrder);

	qstmServers = new QSqlTableModel(this);
	qstmServers->setTable(QLatin1String("servers"));
	qstmServers->setSort(1, Qt::AscendingOrder);
	if (! qstmServers->select()) {
		qWarning("ConnectDialog: Failed to reselect table");
	}
	qstmServers->setEditStrategy(QSqlTableModel::OnManualSubmit);

	qlwServers->setModel(qstmServers);
	qlwServers->setModelColumn(1);

	QItemSelectionModel *selectionModel = qlwServers->selectionModel();

	connect(selectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(onSelection_Changed(const QModelIndex &, const QModelIndex &)));
	connect(qleName, SIGNAL(textEdited(const QString &)), this, SLOT(onDirty(const QString &)));
	connect(qleServer, SIGNAL(textEdited(const QString &)), this, SLOT(onDirty(const QString &)));
	connect(qleUsername, SIGNAL(textEdited(const QString &)), this, SLOT(onDirty(const QString &)));
	connect(qlePassword, SIGNAL(textEdited(const QString &)), this, SLOT(onDirty(const QString &)));
	connect(qlePort, SIGNAL(textEdited(const QString &)), this, SLOT(onDirty(const QString &)));

	qlePort->setValidator(new QIntValidator(1, 65535, qlePort));

	if (g.sh && g.sh->isRunning()) {
		fillEmpty();
	} else {
		QModelIndex idx = qstmServers->index(g.s.iServerRow, 0);
		if (idx.isValid()) {
			qlwServers->setCurrentIndex(idx);
		} else if (qstmServers->rowCount() > 0) {
			qlwServers->setCurrentIndex(qstmServers->index(0,0));
		}
	}

	fillList();
	qtwTab->setCurrentIndex(0);

	if (qstmServers->rowCount() < 1) {
		on_qpbAdd_clicked();
		qtwTab->setCurrentIndex(1);
	}
}
Exemplo n.º 2
0
/**
 *  returns true if is complete filled
 *  return false in other cases
*/
bool Preprocessor::doIt(Sudokufield &field){
    // Create a array for the possible Numbers
    possibleNumber.clear();
    possiblitiesCol.clear();
    possiblitiesRow.clear();
    possiblitiesSquare.clear();
    varToNumber.clear();
    numberToVar.clear();

    for(int i=0; i<field.getSize(); ++i){
        std::vector< std::set < Pos> > buffer;
        for(int j=0; j<field.getSize(); ++j){
            std::set<Pos> t;
            buffer.push_back(t);
        }
        possibleNumber.push_back(buffer);
    }
// Test if it is Empty, fill it whit a given pattern
    if(isEmpty(field)){
        fillEmpty(field);
    } else {
// in other cases calc all Possible Numbers and set all Numbers to one, where only one possiblity is given
        fillInAllNumbersWithOnePossiblity(field);
        calcVarTransform(field);
    }
    std::cout << "number Vars: " << getVarCount() << std::endl;
    return field.isCompleteFilledIn();
}
Exemplo n.º 3
0
void resizeMap(map m, size_t scale){
	void** old = m->values;
	size_t size = scale * m->size;
	size_t oldSize = m->size;

	m->size = size;
	m->values = malloc(sizeof(void*) * size);

	fillEmpty(m);

	size_t index;

	for(index = 0; index < oldSize; index++){
		linkedList list = old[index];

		if(list){
			while(!linkedListIsEmpty(list)){
				linkedNode node = removeLinkedListHead(list);
				var v = node->content;

				m->count--; //Don't double count items.
				insertMapValue(v->name, v->content, m);
				free(v);
				free(node);
			}

			free(list);
		}
	}

	free(old);
}
Exemplo n.º 4
0
map newMap(size_t size, double load){
	map m = malloc(sizeof(*m));
	m->size = size;
	m->count = 0;
	m->load = load;
	m->values = malloc(sizeof(void*) * size);

	fillEmpty(m);

	return m;
}
int main(int argc, const char * argv[]) {
    // Two arguments passed:
    int  height;
    int fractals;
    // Creation of the 2D array to hold our Sierpinski Triangle
    char triangleArray[1000][1000];
    
    // We need 3 arguments passed. If less or more -> error
    if (argc != 3) {
        printf("ERROR: Please enter both a height and a fractal level. \n");
    }
    // Check if the fractal is a digit/number
    else if (!isNumber(argv[2])) {
        printf("ERROR: Fractal level must be an integer. \n");
    }
    // Check if the height is a digit/number
    else if (!isNumber(argv[1])) {
        printf("ERROR: Height must be an integer. \n");
    }
    // Check if the height is divisble by 2^fractal levels as required
    else if (isDivisible(height, fractals) == 0) {
        printf("ERROR: Height not divisible by 2^fractal levels. \n");
    }
    // Check if height is at least of 1
    else if (height < 1) {
        printf("ERROR: Height is too small. \n");
    }
    // Max height is 128
    else if (height > 128) {
        printf("ERROR: Height is too large. \n");
    }
    
    // Proceed to the recursive fractal figure "Sierpinski Triangles"
    else {
        // Start by calling the method once, which will, in return, recursively call itself
        sierpinskiTriangle(height, triangleArray, height-1, height-1, fractals);
        // We fill the rest of the empty chars with a space " ".
        fillEmpty(triangleArray);
        
        // Final step, priting the 2D array with for loops
        int j;
        int i;
        for (j = height - 1; j >= 0; j--) {
            for (i = 0; i < (2*height - 1); i++)
                printf("%c", triangleArray[i][j]);
            // New line after every y coordinate is done printing
            printf("\n");
        }
    }
    return 0;
}
Exemplo n.º 6
0
bool trySwitch(int source,int target)
{
	elim_area src_area = {0,0,0,0,{0},{0}};
	elim_area tgt_area = {0,0,0,0,{0},{0}};
	fprintf(flog,"trySwitch start,source:%d,target:%d \n",source,target);
	
	if(checkBombSwitch(source,target))
	{
		fillEmpty();
		return true;
	}
	
	if(checkLocalElimination(source,&src_area))
	{
		fprintf(flog,"checkLocalElimination source\n");
		if(src_area.num_horiz > 2 || src_area.num_verti > 2)
		{
			fprintf(flog,"makeElimination start\n");
			int num_areas = 1;
			makeElimination(&src_area,num_areas);
		}
	}
	if(checkLocalElimination(target,&tgt_area))
	{
		fprintf(flog,"checkLocalElimination target\n");
		if(tgt_area.num_horiz > 2 || tgt_area.num_verti > 2)
		{
			fprintf(flog,"makeElimination start\n");
			int num_areas = 1;
			makeElimination(&tgt_area,num_areas);
		}
	}
	fillEmpty();
	fprintf(flog,"trySwitch end--------------------\n");
	return src_area.num_horiz > 2 || src_area.num_verti > 2 || tgt_area.num_horiz > 2 || tgt_area.num_verti > 2;
}
Exemplo n.º 7
0
void update(int eclipse)
{
	bool ready = true;
	bool hasElimination = false;
	for(int i=0;i<num_jewels;i++)
	{
		if(offsetYs[i] == 0) continue;
		else
		{
			//fprintf(flog,"offsetYs[i]:%f\n",offsetYs[i]);
			//fprintf(flog,"eclipse * 0.5:%f\n",eclipse * 0.5);
			// offsetYs[i] -= eclipse * 0.2;
			offsetYs[i] -= speeds[i];
			times[i]++;
			speeds[i] +=0.5*offsetYs[i] / 100.0;
			//fprintf(flog,"offsetYs[i]:%f\n",offsetYs[i]);
			if(offsetYs[i] < 0) 
			{
				// fprintf(flog,"offsetYs[i] < 0\n");
				offsetYs[i] = 0;
				speeds[i] = 0.1;
				elim_area area;
				int num_area = 1;
				// fprintf(flog,"checkLocalElimination,i:%d\n",i);
				if(checkLocalElimination(i,&area))
				{
					makeElimination(&area,num_area);
					hasElimination = true;
				}
			}
			ready = false;
		}
	}
	if(hasElimination)
	{
		fillEmpty();
	}
	
	if(ready)
	{
		// check match
		// rematch(swap_times+=5);
	}
}