MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); crawler = new Crawler(this); connect(this, SIGNAL(start_crawling()), crawler, SLOT(start_crawl())); }
int main() { State initial_state; Game game; int i, color, value, column; Card deck[52]; printf( "Freecell Solver\n\n" ); memset( &initial_state, 0, sizeof(initial_state) ); // Populate deck for( i=0, color=0, value=1; i<sizeof(deck)/sizeof(deck[0]); ++i ) { deck[i].value = value; deck[i].color = color; ++value; if( value > 13 ) { value = 1; color = (++color)%Color_Max; } } //Shuffle deck for( i=1000+rand()%1000; i>0; --i ) { int from = rand() % 52; int to = rand() % 52; Card temp; temp = deck[to]; deck[to] = deck[from]; deck[from] = temp; } // Populate initial_state for( i=0, column=0; i<sizeof(deck)/sizeof(deck[0]); ++i ) { push_to_column( &initial_state, &deck[i], column ); column = (++column) % COLUMN_NB; } // DUMP display_state( &initial_state ); game_init( &game, &initial_state ); start_crawling( &game ); return 0; }
void MainWindow::on_actionLoad_csv_triggered() { QString fname = QFileDialog::getOpenFileName(this, "Select csv file", "", "*.txt *.csv"); int num_loaded = 0; QString msg; if(!fname.isNull()){ num_loaded = crawler->load_from_file(fname); if(num_loaded > 0) msg = QString("Loaded %1 urls").arg(num_loaded); else msg = QString("0 urls were loaded"); QMessageBox::information(this, "Urls loaded", msg); if(num_loaded > 0) emit start_crawling(); }else{ QMessageBox::warning(this, "Error", "Cannot open file"); } }