Ejemplo n.º 1
0
void expandTree(binaryTreePtr tree)
/* This procedure expands a unique tree for the current game state
 * Pre-condition: the tree has been allocated in memory
 * Post-condition: a tree has been created for the given game state
*/
{
	if (tree != NULL)
	{
		//get the current gamestate for the level in tree we are on
		infoPtr gameInfo = retrieveNodeElm(tree);

		//store the adress of the current node in the tree
		treeNodePtr current;
		current = getCurrentNode(tree);

		//get the root level's game state
		nextNode(tree,TOROOT);
		infoPtr rootInfo = retrieveNodeElm(tree);

		//go back to current level
		setCurrentNode(tree,current);
		//we only extend 2 levels, this counts how many we have done
		int cmpSquares = squaresAvailable(rootInfo) - squaresAvailable(gameInfo);

		//is there any sqaures available?
		if ( (cmpSquares  < 3) && (squaresAvailable(gameInfo) != 0) )
		{
			//generate the next level for the tree
			generateSquares(tree);
			//go back to the node we started with
			setCurrentNode(tree, current);
			//go to the first node on the next level
			nextNode(tree, TOLEFT);
			//set this as the current node
			current = getCurrentNode(tree);
			//call this procedure again, to expand the next level
			expandTree(tree);
			//go back to first node of level we are working with
			setCurrentNode(tree, current);

			//does it have a next node on this level?
			while (existNode(tree, TORIGHT) == 1)
			{
				//then go to the next node
				nextNode(tree, TORIGHT);
				//get node on this level we are working with
				current = getCurrentNode(tree);
				//generate a next level for this node
				expandTree(tree);
				//back to working level
				setCurrentNode(tree, current);
			}
		}
	}
}
Ejemplo n.º 2
0
void DuktoProtocol::sendScreen(QString ipDest, qint16 port, QString path)
{
    // Check for default port
    if (port == 0) port = DEFAULT_TCP_PORT;

    // Verifica altre attività in corso
    if (mIsReceiving || mIsSending) return;
    mIsSending = true;

    // File da inviare
    QStringList files;
    files.append(path);
    mFilesToSend = expandTree(files);
    mFileCounter = 0;
    mSendingScreen = true;

    // Connessione al destinatario
    mCurrentSocket = new QTcpSocket(this);

    // Gestione segnali
    connect(mCurrentSocket, SIGNAL(connected()), this, SLOT(sendMetaData()), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sendConnectError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(sendData(qint64)), Qt::DirectConnection);

    // Connessione
    mCurrentSocket->connectToHost(ipDest, port);
}
Ejemplo n.º 3
0
void PrefixTreeToolbar::createActions(){
    treeState.reset(new QAction(this));
    if (this->tree_state == D_TREE_COLLAPSE){
        treeState->setIcon(CoreLib->loadIcon("data/expand.png"));
        treeState->setText(tr("Expand prefix tree"));
        treeState->setStatusTip(tr("Expand prefix tree"));
        emit(collapseTree());
    } else {
        treeState->setIcon(CoreLib->loadIcon("data/collapse.png"));
        treeState->setText(tr("Collapse prefix tree"));
        treeState->setStatusTip(tr("Collapse prefix tree"));
        emit(expandTree());
    }

    connect(treeState.get(), SIGNAL(triggered()), this, SLOT(treeState_Click()));

    prefixImport.reset(new QAction(CoreLib->loadIcon("data/import.png"), tr("Import prefixes"), this));
    prefixImport->setStatusTip(tr("Import prefixes from ~/.local/share/wineprefixes/"));
    connect(prefixImport.get(), SIGNAL(triggered()), this, SLOT(prefixImport_Click()));

    prefixExport.reset(new QAction(CoreLib->loadIcon("data/export.png"), tr("Export prefixes"), this));
    prefixExport->setStatusTip(tr("Export prefixes to ~/.local/share/wineprefixes/"));
    connect(prefixExport.get(), SIGNAL(triggered()), this, SLOT(prefixExport_Click()));

    return;
}
Ejemplo n.º 4
0
Archivo: mancala.c Proyecto: wfei/hw
void expandTree(Node* root, int level, int player) {
    if (level == 0) {
	return;
    }
    int i;
    char possibleChoice[6] = {'A', 'B', 'C', 'D', 'E', 'F'};
    for (i = 0; i < 6; i++) {
	addOneChild(root, possibleChoice[i], player);
    }
    for (i = 0; i < root->curChildIndex; i++) {
	expandTree(root->children[i], level - 1, (player + 1) % 2);
    }
    
}
Ejemplo n.º 5
0
void PrefixTreeToolbar::treeState_Click(){
    if (this->tree_state == D_TREE_EXPAND){
        emit(collapseTree());
        this->tree_state = D_TREE_COLLAPSE;
        treeState->setIcon(CoreLib->loadIcon("data/expand.png"));
        treeState->setText(tr("Expand prefix tree"));
        treeState->setStatusTip(tr("Expand prefix tree"));
    } else {
        emit(expandTree());
        this->tree_state = D_TREE_EXPAND;
        treeState->setIcon(CoreLib->loadIcon("data/collapse.png"));
        treeState->setText(tr("Collapse prefix tree"));
        treeState->setStatusTip(tr("Collapse prefix tree"));
    }
}
Ejemplo n.º 6
0
// ============================================================================
// GLOctree::computeSizeMax()                                                  
//  compute extremum coordinates                                               
void GLOctree::computeSizeMax()
{
  bool visible=false;
  float coo_max[3];
  int i_max[3];
  for (int obj=0; obj< (int ) psv->size(); obj++ ) {
    VirtualParticlesSelect * vps = (*psv)[obj].vps;
    if (vps->is_visible) {
      visible = true;
      coo_max[0]= fabs(p_data->pos[vps->index_tab[0]]);
      i_max[0]  = 0;
      coo_max[1]= fabs(p_data->pos[vps->index_tab[0]]);
      i_max[1]  = 0;
      coo_max[2]= fabs(p_data->pos[vps->index_tab[0]]);
      i_max[2]  = 0;
    }
  }
  for (int obj=0; obj< (int ) psv->size(); obj++ ) { 
    VirtualParticlesSelect * vps = (*psv)[obj].vps;
    if (vps->is_visible) {
      //for (int i=0; i < vps->npart; i+=vps->step_part) {
      //  int index=vps->getIndex(i);
      for (int i=0; i < vps->ni_index; i++) {
        int index=vps->index_tab[i];
	if (fabs(p_data->pos[index*3  ]) > coo_max[0]) {
	  coo_max[0] = fabs(p_data->pos[index*3  ]);
          i_max[0]   = index;
        }
	if (fabs(p_data->pos[index*3+1]) > coo_max[1]) {
	  coo_max[1] = fabs(p_data->pos[index*3+1]);
          i_max[1]   = index;
        }
	if (fabs(p_data->pos[index*3+2]) > coo_max[2]) {
	  coo_max[2] = fabs(p_data->pos[index*3+2]);
          i_max[2]   = index;
        }
      }
    }
  }
  if (visible) {
    PRINT_D std::cerr << "Max coordinates \n";
    PRINT_D std::cerr << coo_max[0] << " " << coo_max[1] << " " << coo_max[2] << "\n";
    PRINT_D std::cerr << i_max[0] << " " << i_max[1] << " " << i_max[2] << "\n";
    float max=MAX(MAX(coo_max[0],coo_max[1]),coo_max[2]);
    expandTree(max);
    PRINT_D std::cerr << "Size max = " << size_max << "\n";
  }
}
Ejemplo n.º 7
0
void DuktoProtocol::sendFile(QString ipDest, QStringList files)
{
    // Verifica altre attività in corso
    if (mIsReceiving || mIsSending) return;
    mIsSending = true;

    // File da inviare
    mFilesToSend = expandTree(files);
    mFileCounter = 0;

    // Connessione al destinatario
    mCurrentSocket = new QTcpSocket(this);
    connect(mCurrentSocket, SIGNAL(connected()), this, SLOT(sendMetaData()), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sendConnectError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(sendData(qint64)), Qt::DirectConnection);
    mCurrentSocket->connectToHost(ipDest, TCP_PORT);
}
Ejemplo n.º 8
0
Archivo: mancala.c Proyecto: wfei/hw
char findBestComputerMove(Hole originalBoard[]) {
    printFlag = 0;
    int i, j, k;
    // make a copy of the originalBoard
    Hole newBoard[BOARDSIZE];
    copyBoard(newBoard, originalBoard);

    
    // construct the searching tree
    Node root;
    initSearchTree(newBoard, &root);
    
    // construct first level. Root is at level 0
    int depth = 3;
    expandTree(&root, depth, 1);
    Node* bestNode;
    bestNode = findBest(&root, depth);
    char computerMove = findBestMove(bestNode, &root);
    deleteTree(&root, &root);
    printFlag = 1;
    return computerMove;
}
Ejemplo n.º 9
0
BitSplit::BitSplit()
{
    fontDb.addApplicationFont(":/fonts/OpenSans-Light.ttf");
    fontDb.addApplicationFont(":/fonts/OpenSans-Regular.ttf");
    exit = true;
    blockToggle = false;
    searchExisting = false;

    /* Timer setup*/
    guiUpdater  = new QTimer( this );
    guiUpdater->setInterval(25);

    syncAnimator  = new QTimer( this );
    syncAnimator->setInterval(75);

    /* Interface setup */
    fileInterface.debug = false;
    fileInterface.copyDirection = BothDirections;
    actionCreator.fileInterface = &fileInterface;
    smartMatch.fileInterface = &fileInterface;
    actionHandler.fileInterface = &fileInterface;
    updater.fileInterface = &fileInterface;

    /* Set up icons */
    remove  = new QIcon(":images/general/remove.png");

    done    = new QIcon(":images/table/tick.png");
    errorIcon   = new QIcon(":images/table/error.png");
    skip    = new QIcon(":images/table/skip.png");

    sync1   = new QIcon(":images/table/sync1.png");
    syncAnimation.append(sync1);
    sync2   = new QIcon(":images/table/sync2.png");
    syncAnimation.append(sync2);
    sync3   = new QIcon(":images/table/sync3.png");
    syncAnimation.append(sync3);
    sync4   = new QIcon(":images/table/sync4.png");
    syncAnimation.append(sync4);
    sync5   = new QIcon(":images/table/sync5.png");
    syncAnimation.append(sync5);
    sync6   = new QIcon(":images/table/sync6.png");
    syncAnimation.append(sync6);
    sync7   = new QIcon(":images/table/sync7.png");
    syncAnimation.append(sync7);
    sync8   = new QIcon(":images/table/sync8.png");
    syncAnimation.append(sync8);


    ui.setupUi( this );
    ui.runButton->setDisabled(true);

    /* Connect buttons to their dialogs */
    connect(ui.editSettingsButton,  SIGNAL(clicked()),  this,   SLOT(editSettings()));
    connect(ui.newProfileButton,    SIGNAL(clicked()),  this,   SLOT(newProfile()));


    /* Log Connections*/
    connect(ui.actionView_Log,  SIGNAL(triggered()),        this,       SLOT(showLog()));
    connect(ui.exitLog,         SIGNAL(clicked()),          this,       SLOT(showMain()));
    connect(&fileInterface,     SIGNAL(updateLog(QString)), ui.log,     SLOT(append(QString)));
    connect(ui.errorViewLog,    SIGNAL(clicked()),          this,       SLOT(showLog()));

    /* Top Bar connections*/
    connect(&fileInterface, SIGNAL(matchComplete()),            this,               SLOT(matchComplete()));
    connect(&fileInterface, SIGNAL(updateSingle(QString)),      ui.topBarSingle,    SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateTopMP(QString)),       ui.mp_top,          SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateBottomMP(QString)),    ui.mp_bottom,       SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateOperationMP(QString)), ui.mp_operation,    SLOT(setText(QString)));
    connect(guiUpdater,     SIGNAL(timeout()),                  &smartMatch,        SLOT(updateGuiLabels()));
    connect(&smartMatch,    SIGNAL(startTime()),                guiUpdater,         SLOT(start()));
    connect(&smartMatch,    SIGNAL(stopTime()),                 guiUpdater,         SLOT(stop()));
    connect(&smartMatch,    SIGNAL(setTopBarLineStack(int)),    this,               SLOT(setTopBarLineStack(int)));

    /* Unmatched files tree Connections */
    connect(ui.unmatchedTree,   SIGNAL(itemChanged(QTreeWidgetItem*,int)),  this,   SLOT(toggleTree(QTreeWidgetItem*,int)));
    connect(&fileInterface,     SIGNAL(updateFileTree(bool, QTreeWidgetItem *)), this, SLOT(insertTreeItem(bool, QTreeWidgetItem *)));
    connect(&fileInterface,     SIGNAL(pop()),                              this,   SLOT(popParent()));
    connect(&fileInterface,     SIGNAL(expandTree()), this, SLOT(expandTree()));

    /* Matched Table Connections */
    connect(&fileInterface, SIGNAL(insertMatchTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertMatchTableRow(QList<QTableWidgetItem*>*)));

    /* Action Table Connections*/
    connect(&fileInterface, SIGNAL(insertActionTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertActionTableRow(QList<QTableWidgetItem*>*)));

    /* Error connections */
    connect(&smartMatch,    SIGNAL(operationFailed()),  this, SLOT(error()));
    connect(&actionCreator,    SIGNAL(operationFailed()),  this, SLOT(error()));
    connect(&actionHandler,     SIGNAL(exception()), this, SLOT(error()));

    /* Developer Test Connections */
    connect(ui.actionDeveloper_Test, SIGNAL(triggered()), this, SLOT(runDeveloperTest()));
    connect(&smartMatch, SIGNAL(stopTestTime()), this, SLOT(endTimer()));

    /* Action Handler Connections */
    connect(&actionHandler, SIGNAL(updateProgress(int)),            ui.progressBar,         SLOT(setValue(int)));
    connect(&actionHandler, SIGNAL(updateActionLabel(QString)),     ui.actionLabel,         SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(updateSpeedLabel(QString)),      ui.speedLabel,          SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(updatePercentageLabel(QString)), ui.mp_busyIndicator,    SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(setComplete(int)),               this,                   SLOT(setDone(int)));
    connect(&actionHandler, SIGNAL(setSkipped(int)),                this,                   SLOT(setSkip(int)));
    connect(&actionHandler, SIGNAL(setError(int)),                  this,                   SLOT(setError(int)));
    connect(&actionHandler, SIGNAL(setInProgress(int)),             this,                   SLOT(setSync(int)));

    /* Updater Connections */
    connect(&updater,       SIGNAL(complete()),     this,   SLOT(updaterComplete()));

    /* General Connections & Button Stack Connections */
    connect(syncAnimator,           SIGNAL(timeout()),  this,   SLOT(showSync()));
    connect(ui.finishEditButton,    SIGNAL(clicked()),  this,   SLOT(createActions()));
    connect(&actionCreator,         SIGNAL(complete()), this,   SLOT(actionsComplete()));
    connect(ui.runButton,           SIGNAL(clicked()),  this,   SLOT(runActionHandler()));
    connect(ui.searchButton,        SIGNAL(clicked()),  this,   SLOT(searchForSync()));
    connect(&actionHandler,         SIGNAL(complete()), this,   SLOT(actionHandlerComplete()));

    /* General Setup*/
    frame = 0;
    currentAction = -1;
    actionHandler.table = ui.actionsTable;
    ui.mp_ProfileLabel->fontMetrics().width(ui.mp_ProfileLabel->text());
    createTrayIcon();
    setupTable();
    fileInterface.loadDatabase();
    recentProfiles = fileInterface.loadRecentProfiles();
    if(recentProfiles.size() > 0)
        showRecentProfiles();

}
Ejemplo n.º 10
0
MainWindow::MainWindow(int startState, QString run_binary, QWidget * parent, Qt::WindowFlags f) : QMainWindow(parent, f){
     // Loading libq4wine-core.so
#ifdef RELEASE
    libq4wine.setFileName(_CORELIB_PATH_);
#else
    libq4wine.setFileName("../q4wine-lib/libq4wine-core");
#endif
    if (!libq4wine.load()){
        libq4wine.load();
    }

    // Getting corelib class pointer
    CoreLibClassPointer = (CoreLibPrototype *) libq4wine.resolve("createCoreLib");
    CoreLib.reset((corelib *)CoreLibClassPointer(true));

    clearTmp();

    db_prefix.fixPrefixPath();

    if (CoreLib->getSetting("DesktopImport", "importAtStartup", false, 0)==1){
        Progress progress(0, "");
        progress.exec();
    }

    //  importIcons(QString("%1/.local/share/applications/wine/").arg(QDir::homePath()));

    //exportProcess.close();
    // Base GUI setup
    setupUi(this);

    if (!this->createSocket()){
        this->close();
        return;
     }

    if (startState == 1)
        this->showMinimized();

    setWindowTitle(tr("%1 :. Qt GUI for Wine v%2").arg(APP_NAME) .arg(APP_VERS));

    std::auto_ptr<QVBoxLayout> vlayout (new QVBoxLayout);

    std::auto_ptr<PrefixConfigWidget> configWidget (new PrefixConfigWidget(tabPrefixSeup));
    connect(configWidget.get(), SIGNAL(updateDatabaseConnections()), this, SLOT(updateDtabaseConnectedItems()));
    connect(configWidget.get(), SIGNAL(setTabIndex (int)), tbwGeneral, SLOT(setCurrentIndex (int)));
    connect(this, SIGNAL(updateDatabaseConnections()), configWidget.get(), SLOT(getPrefixes()));

    std::auto_ptr<LoggingWidget> logWidget (new LoggingWidget(tabLogging));
    connect (this, SIGNAL(reloadLogData()), logWidget.get(), SLOT(getLogRecords()));

    logWidget->getLogRecords();

    logLayout->addWidget(logWidget.release());

    std::auto_ptr<IconListWidget> lstIcons (new IconListWidget(tabPrograms));
    connect(this, SIGNAL(runProgramRequest(QString)), lstIcons.get(), SLOT(runProgramRequest(QString)));
    connect(lstIcons.get(), SIGNAL(iconItemClick(QString, QString, QString, QString, QString)), this, SLOT(updateIconDesc(QString, QString, QString, QString, QString)));
    connect(lstIcons.get(), SIGNAL(changeStatusText(QString)), this, SLOT(changeStatusText(QString)));
    connect(lstIcons.get(), SIGNAL(appRunned(bool)), this, SLOT(setMeVisible(bool)));

    std::auto_ptr<PrefixTreeWidget> twPrograms (new PrefixTreeWidget(tabPrograms));
    connect(twPrograms.get(), SIGNAL(updateDatabaseConnections()), this, SLOT(updateDtabaseConnectedItems()));
    connect(this, SIGNAL(updateDatabaseConnections()), twPrograms.get(), SLOT(getPrefixes()));
    connect(twPrograms.get(), SIGNAL(showFolderContents(QString, QString)), lstIcons.get(), SLOT(showFolderContents(QString, QString)));
    connect(twPrograms.get(), SIGNAL(setSearchFocus()), this, SLOT(setSearchFocus()));
    connect(twPrograms.get(), SIGNAL(changeStatusText(QString)), this, SLOT(changeStatusText(QString)));
    connect(this, SIGNAL(setDefaultFocus(QString, QString)), twPrograms.get(), SLOT(setDefaultFocus(QString, QString)));
    connect(configWidget.get(), SIGNAL(prefixIndexChanged(QString)), twPrograms.get(), SLOT(setDefaultFocus(QString)));
    connect(twPrograms.get(), SIGNAL(prefixIndexChanged(QString)), configWidget.get(), SLOT(setPrefix(QString)));
    connect(twPrograms.get(), SIGNAL(setTabIndex (int)), tbwGeneral, SLOT(setCurrentIndex (int)));

    connect(twPrograms.get(), SIGNAL(pasteAction()), lstIcons.get(), SLOT(iconPaste_Click()));


    std::auto_ptr<WineProcessWidget> procWidget (new WineProcessWidget(tabProcess));
    connect(this, SIGNAL(stopProcTimer()), procWidget.get(), SLOT(stopTimer()));
    connect(this, SIGNAL(startProcTimer()), procWidget.get(), SLOT(startTimer()));
    connect(procWidget.get(), SIGNAL(changeStatusText(QString)), this, SLOT(changeStatusText(QString)));
    tabProcessLayout->addWidget(procWidget.release());

    std::auto_ptr<PrefixControlWidget> prefixWidget (new PrefixControlWidget(tabPrefix));
    connect(prefixWidget.get(), SIGNAL(updateDatabaseConnections()), twPrograms.get(), SLOT(getPrefixes()));
    connect(prefixWidget.get(), SIGNAL(updateDatabaseConnections()), this, SLOT(updateDtabaseConnectedItems()));
    connect(configWidget.get(), SIGNAL(prefixIndexChanged(QString)), prefixWidget.get(), SLOT(setDefaultFocus(QString)));
    connect(prefixWidget.get(), SIGNAL(prefixIndexChanged(QString)), configWidget.get(), SLOT(setPrefix(QString)));
    connect(prefixWidget.get(), SIGNAL(setTabIndex (int)), tbwGeneral, SLOT(setCurrentIndex (int)));
    connect(twPrograms.get(), SIGNAL(updateDatabaseConnections()), prefixWidget.get(), SLOT(updateDtabaseItems()));

    std::auto_ptr<IconListToolbar> iconToolBar (new IconListToolbar(tabPrograms));
    connect(iconToolBar.get(), SIGNAL(searchFilterChange(QString)), lstIcons.get(), SLOT(setFilterString(QString)));
    connect(iconToolBar.get(), SIGNAL(changeView(int)), lstIcons.get(), SLOT(changeView(int)));

    std::auto_ptr<PrefixTreeToolbar> prefixToolBar (new PrefixTreeToolbar(tabPrograms));
    connect(prefixToolBar.get(), SIGNAL(expandTree()), twPrograms.get(), SLOT(expandTree()));
    connect(prefixToolBar.get(), SIGNAL(collapseTree()), twPrograms.get(), SLOT(collapseTree()));
    connect(prefixToolBar.get(), SIGNAL(updatePrefixTree()), this, SLOT(updateDtabaseConnectedItems()));
    connect(prefixToolBar.get(), SIGNAL(updatePrefixTree()), prefixWidget.get(), SLOT(updateDtabaseItems()));

    vlayout.reset(new QVBoxLayout);
    vlayout->addWidget(prefixToolBar.release());
    vlayout->addWidget(twPrograms.release());
    vlayout->setMargin(0);
    vlayout->setSpacing(0);
    std::auto_ptr<QWidget> wid (new QWidget(tabPrograms));
    wid->setLayout(vlayout.release());

    splitter.reset(new QSplitter(tabPrograms));
    splitter->addWidget(wid.release());

    vlayout.reset(new QVBoxLayout);
    vlayout->addWidget(iconToolBar.release());
    vlayout->addWidget(lstIcons.release());
    vlayout->setMargin(0);
    vlayout->setSpacing(0);
    //vlayout->setContentsMargins(0,0,0,0);
    wid.reset(new QWidget(tabPrograms));
    wid->setLayout(vlayout.release());

    splitter->addWidget(wid.release());

    vlayout.reset(new QVBoxLayout);
    vlayout->addWidget(splitter.get());
    vlayout->addWidget(gbInfo);

    vlayout->setContentsMargins(3,0,3,3);
    tabPrograms->setLayout(vlayout.release());
    tabPrefixLayout->addWidget(prefixWidget.release());
    setupLayout->addWidget(configWidget.release());

    // Updating database connected items
    updateDtabaseConnectedItems();

    // Getting settings from config file
    this->createTrayIcon();
    this->getSettings();

    connect(tbwGeneral, SIGNAL(currentChanged(int)), this, SLOT(tbwGeneral_CurrentTabChange(int)));
    //connect(cmdCreateFake, SIGNAL(clicked()), this, SLOT(cmdCreateFake_Click()));
    //connect(cmdUpdateFake, SIGNAL(clicked()), this, SLOT(cmdUpdateFake_Click()));

    //Main menu actions connection to slots
    connect(mainRun, SIGNAL(triggered()), this, SLOT(mainRun_Click()));
    connect(mainPrograms, SIGNAL(triggered()), this, SLOT(mainPrograms_Click()));
    connect(mainLogging, SIGNAL(triggered()), this, SLOT(mainLogging_Click()));
    connect(mainProcess, SIGNAL(triggered()), this, SLOT(mainProcess_Click()));
    connect(mainSetup, SIGNAL(triggered()), this, SLOT(mainSetup_Click()));
    connect(mainPrefix, SIGNAL(triggered()), this, SLOT(mainPrefix_Click()));
    connect(mainImageManage, SIGNAL(triggered()), this, SLOT(mainImageManager_Click()));
    connect(mainAbout, SIGNAL(triggered()), this, SLOT(mainAbout_Click()));
    connect(mainAboutQt, SIGNAL(triggered()), this, SLOT(mainAboutQt_Click()));
    connect(mainExportIcons, SIGNAL(triggered()), this, SLOT(mainExportIcons_Click()));
    connect(mainOptions, SIGNAL(triggered()), this, SLOT(mainOptions_Click()));
    connect(mainInstall, SIGNAL(triggered()), this, SLOT(mainInstall_Click()));
    connect(mainExit, SIGNAL(triggered()), this, SLOT(mainExit_Click()));
    connect(mainImportWineIcons, SIGNAL(triggered()), this, SLOT(mainImportWineIcons_Click()));
    connect(mainVersionManager, SIGNAL(triggered()), this, SLOT(mainVersionManager_Click()));

    CoreLib->runAutostart();

#ifndef WITH_ICOUTILS
    mainExportIcons->setEnabled(false);
#endif

    if (!run_binary.isEmpty())
        messageReceived(run_binary);

    if (!trayIcon->isVisible())
        show();

    return;
}
Ejemplo n.º 11
0
void getComputerMove(infoPtr gameInfo)
/* This procedure creates a move for the player depending on the current game state
 * as given by gameInfo
 * Pre-condition: gameInfo exists
 * Post-Condition: a move has been made, and the game state updated
*/
{
	//does gameinfo exist?
	if (gameInfo == NULL)
	{
		//don't do anything
		return;
	}

	//create a pointer for tree
	binaryTreePtr tree;

	//empty pointers that will reference the unique functions for this tree
	void (*delElem)();
	void (*dspElem)();
	int (*cmpElem)();

	//reference the unique functions
	delElem = deleteElement;
	dspElem = dspElement;
	cmpElem = cmpElement;

	//create a pointer to a new empty tree
	//with the unique functions passed as parameters
	tree = createTree( delElem, dspElem, cmpElem);
	if (tree == NULL)
	{
		//quit procedure there was a fault
		return;
	}

	//make a new node that will serve as the root in our tree
	infoPtr root = NULL;
	root = malloc(sizeof(struct info));
	root->turn = USER;
	root->eval = 0;
	//copy the current game's playing area to root
	copyGameArea(gameInfo,root);


	//insert the new root into the tree
	if (insertNode(tree, root, TOROOT) != 1)
	{
		//it didn't work. don't go further
		return;
	}

	//go to the root level
	nextNode(tree,TOROOT);
	//create the unique tree for the current game state
	expandTree(tree);

	//look if there's a winning move now
 	lookForWinningMove(tree);

	//go to the root level and get the gamestate
	nextNode(tree, TOROOT);
	root = retrieveNodeElm(tree);

	//pick the best move for the current game state from the tree
	//if there hasn't been a winning move already
	if ( (root-> eval != 1000) && (root->eval != -1000) )
	{
		//get the best move
		bestMove(tree);
	}
	//make the best move possible
	makeMove(tree, gameInfo);
	//remove the tree from memory
	deleteTree(tree);
}
Ejemplo n.º 12
0
App::App(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl)
{
    showFullScreen = false;
    setCaption("IQNotes");

    toolbar = new QPEToolBar(this);
    toolbar->setVerticalStretchable(false);
    toolbar->setHorizontalStretchable(false);
    
    setToolBarsMovable(false);
    multiTB = new QToolButton(toolbar);
    
    // File menu
    filePopupMenu = new QPopupMenu(this);
	menu = new QPEMenuBar(this);

    int fileID;
	fileID = menu->insertItem("File", filePopupMenu);
	
#ifndef DEMO
    newID = filePopupMenu->insertItem("New", this, SLOT(newFile()), SHIFT+Key_N);
    openID = filePopupMenu->insertItem("Open", this, SLOT(openFile()), SHIFT+Key_O);
    saveID = filePopupMenu->insertItem("Save", this, SLOT(saveFile()), SHIFT+Key_S);
    // file->insertItem("Save as", this, SLOT(saveAsFile()));
    closeID = filePopupMenu->insertItem("Close", this, SLOT(closeFileMenu()));
    filePopupMenu->insertSeparator();
#endif
	
    filePopupMenu->insertItem("Quit", this, SLOT(goodBye()));

    // Tree menu
    treePopupMenu = new QPopupMenu(this);
    treeID = menu->insertItem("Tree", treePopupMenu);

    searchA = new QAction("Search", ToolBarIcon::prepare("iqnotes/find"), QString::null, Key_F, this, 0 );
    connect(searchA, SIGNAL(activated()), this, SLOT(search()));
    //  searchA->addTo(toolbar);
    searchA->addTo(treePopupMenu);
    multiTB->setIconSet(ToolBarIcon::prepare("iqnotes/find"));
    connect(multiTB, SIGNAL(clicked()), this, SLOT(search()));
	//    toolbar->addSeparator(); // no room for this

    treePopupMenu->insertSeparator();

    quickAddA = new QAction("Quick add", ToolBarIcon::prepare("iqnotes/quick_add"), QString::null, Key_Q, this, 0 );
    connect(quickAddA, SIGNAL(activated()), this, SLOT(quickAdd()));
    quickAddA->addTo(toolbar);
    quickAddA->addTo(treePopupMenu);

    addBeforeA = new QAction("Add before", ToolBarIcon::prepare("iqnotes/add_before"), QString::null, 0, this, 0 );
    connect(addBeforeA, SIGNAL(activated()), this, SLOT(addBefore()));
    addBeforeA->addTo(toolbar);
    addBeforeA->addTo(treePopupMenu);

    addAfterA = new QAction("Add after", ToolBarIcon::prepare("iqnotes/add_after"), QString::null, Key_A, this, 0 );
    connect(addAfterA, SIGNAL(activated()), this, SLOT(addAfter()));
    addAfterA->addTo(toolbar);
    addAfterA->addTo(treePopupMenu);

    addChildA = new QAction("Add child", ToolBarIcon::prepare("iqnotes/add_child"), QString::null, Key_E, this, 0 );
    connect(addChildA, SIGNAL(activated()), this, SLOT(addChild()));
    addChildA->addTo(toolbar);
    addChildA->addTo(treePopupMenu);

    treePopupMenu->insertSeparator();
    sortID = treePopupMenu->insertItem("Sort", this, SLOT(sort()));
    treePopupMenu->insertSeparator();

    expandTreeID = treePopupMenu->insertItem("Expand tree", this, SLOT(expandTree()));
    collapseTreeID = treePopupMenu->insertItem("Collapse tree", this, SLOT(collapseTree()));

    treePopupMenu->insertSeparator();

    taskListPopupMenu = new QPopupMenu(this);
    taskListPopupMenu->insertItem("From whole tree", this, SLOT(taskListWholeTree()));
    taskListPopupMenu->insertItem("From current note down", this, SLOT(taskListCurrent()));

    eventListPopupMenu = new QPopupMenu(this);
    eventListPopupMenu->insertItem("From whole tree", this, SLOT(eventListWholeTree()));
    eventListPopupMenu->insertItem("From current note down", this, SLOT(eventListCurrent()));

    taskListID = treePopupMenu->insertItem("Task list", taskListPopupMenu);
    eventListID = treePopupMenu->insertItem("Event list", eventListPopupMenu);

    treePopupMenu->insertSeparator();
    reminderID = treePopupMenu->insertItem("Reminder", this, SLOT(showReminder()));

    toolbar->addSeparator();

    /*
    closeSearchTreeA = new QAction("Close search tree", Resource::loadPixmap("iqnotes/close_search_tree"), QString::null, 0, this, 0 );
    connect(closeSearchTreeA, SIGNAL(activated()), this, SLOT(closeSearchTree()));
    closeSearchTreeA->addTo(tree);*/

    // Note menu
    notePopupMenu = new QPopupMenu(this);
    noteID = menu->insertItem("Note", notePopupMenu);

    renameNoteID = notePopupMenu->insertItem("Rename", this, SLOT(renameNote()), Key_R);

    editA = new QAction("Edit", ToolBarIcon::prepare("iqnotes/edit"), QString::null, Key_Return, this, 0 );
    editA->setToolTip("Edit note");
    connect(editA, SIGNAL(activated()), this, SLOT(editNote()));
    editA->addTo(toolbar);
    editA->addTo(notePopupMenu);

    cutA = new QAction("Cut", ToolBarIcon::prepare("iqnotes/bin"), QString::null, Key_X, this, 0 );
    cutA->setToolTip("Cut note");
    connect(cutA, SIGNAL(activated()), this, SLOT(cutNote()));
    cutA->addTo(toolbar);
    cutA->addTo(notePopupMenu);

    copyNotePopupMenu = new QPopupMenu(this);
    copyNotePopupMenu->insertItem("Only current note", this, SLOT(copyNoteOnlyCurrent()));
    copyNotePopupMenu->insertItem("Current note and down", this, SLOT(copyNoteCurrentAndDown()));
    copyNoteID = notePopupMenu->insertItem("Copy", copyNotePopupMenu);

    pasteNotePopupMenu = new QPopupMenu(this);
    pasteNotePopupMenu->insertItem("Before", this, SLOT(pasteNoteBefore()));
    pasteNotePopupMenu->insertItem("After", this, SLOT(pasteNoteAfter()), SHIFT+Key_A);
    pasteNotePopupMenu->insertItem("As child", this, SLOT(pasteNoteChild()), SHIFT+Key_E);
    pasteNoteID = notePopupMenu->insertItem("Paste", pasteNotePopupMenu);

    notePopupMenu->insertSeparator();

    setPictureA = new QAction("Set picture", ToolBarIcon::prepare("iqnotes/set_picture"), QString::null, CTRL+Key_P, this, 0);
    setPictureA->setToolTip("Set picture");
    connect(setPictureA, SIGNAL(activated()), this, SLOT(setPicture()));
    //setPictureA->addTo(toolbar);
    setPictureA->addTo(notePopupMenu);

    notePopupMenu->insertSeparator();

    setTaskA = new QAction("Set task", ToolBarIcon::prepare("iqnotes/set_task"), QString::null, CTRL+Key_T, this, 0);
    setTaskA->setToolTip("Set task");
    connect(setTaskA, SIGNAL(activated()), this, SLOT(setTask()));
    //setTaskA->addTo(toolbar);
    setTaskA->addTo(notePopupMenu);
    setEventA = new QAction("Set event", ToolBarIcon::prepare("iqnotes/set_event"), QString::null, CTRL+Key_E, this, 0);
    setEventA->setToolTip("Set event");
    connect(setEventA, SIGNAL(activated()), this, SLOT(setEvent()));
    //setEventA->addTo(toolbar);
    setEventA->addTo(notePopupMenu);
    unsetTaskEventID = notePopupMenu->insertItem("Unset", this, SLOT(unsetTaskEvent()));

    notePopupMenu->insertSeparator();
    setReminderID = notePopupMenu->insertItem("Set reminder", this, SLOT(setReminder()));
    unsetReminderID = notePopupMenu->insertItem("Unset reminder", this, SLOT(unsetReminder()));

    // View menu
    viewPopupMenu = new QPopupMenu(this);
    viewID = menu->insertItem("View", viewPopupMenu);

    toolbar->addSeparator();

    hideNoteA = new QAction("Hide note", ToolBarIcon::prepare("iqnotes/hide_note"), QString::null, Key_1, this, 0 );
    hideNoteA->setToolTip("Hide note");
    connect(hideNoteA, SIGNAL(activated()), this, SLOT(hideNote()));
    hideNoteA->addTo(toolbar);
    hideNoteA->addTo(viewPopupMenu);

    hideTreeA = new QAction("Hide tree", ToolBarIcon::prepare("iqnotes/hide_tree"), QString::null, Key_2, this, 0 );
    hideTreeA->setToolTip("Hide tree");
    connect(hideTreeA, SIGNAL(activated()), this, SLOT(hideTree()));
    hideTreeA->addTo(toolbar);
    hideTreeA->addTo(viewPopupMenu);

    halfViewA = new QAction("Half view", ToolBarIcon::prepare("iqnotes/half_view"), QString::null, Key_3, this, 0 );
    halfViewA->setToolTip("Half view");
    connect(halfViewA, SIGNAL(activated()), this, SLOT(halfView()));
    halfViewA->addTo(toolbar);
    halfViewA->addTo(viewPopupMenu);

	/*
    viewPopupMenu->insertSeparator();
    toggleToolBarID = viewPopupMenu->insertItem("Toggle toolbar", this, SLOT(toggleToolBar()));
    toggleFullScreenID = viewPopupMenu->insertItem("Toggle fullscreen", this, SLOT(toggleFullScreen()));
    */
	
    // Options menu
    optionsPopupMenu = new QPopupMenu(this);
    optionsID = menu->insertItem("Options", optionsPopupMenu);

    optionsPopupMenu->insertItem("Define new entry", this, SLOT(defineNewEntry()));
    optionsPopupMenu->insertItem("Change entry", this, SLOT(changeEntry()));
    optionsPopupMenu->insertItem("Delete entry", this, SLOT(deleteEntry()));

    optionsPopupMenu->insertSeparator();

    optionsPopupMenu->insertItem("Preferences", this, SLOT(preferenc()));

    // Help menu
    helpPopupMenu = new QPopupMenu(this);
    menu->insertItem("Help", helpPopupMenu);

    helpPopupMenu->insertItem("About", this, SLOT(about()));

    addToolBar(toolbar);

    IQApp = this;

    //
    notes = new Notes(this, "bla");
    setCentralWidget(notes);

    connect(notes, SIGNAL(emptyNoteTree()), this, SLOT(isEmptyNoteTree()));
    connect(notes, SIGNAL(noEmptyNoteTree()), this, SLOT(isNotEmptyNoteTree()));
    connect(notes, SIGNAL(searchTreeShown()), this, SLOT(searchTreeShown()));
    connect(notes, SIGNAL(searchTreeClosed()), this, SLOT(searchTreeClosed()));
    connect(notes, SIGNAL(taskListShown()), this, SLOT(taskListShown()));
    connect(notes, SIGNAL(taskListClosed()), this, SLOT(taskListClosed()));
    connect(notes, SIGNAL(eventListShown()), this, SLOT(eventListShown()));
    connect(notes, SIGNAL(eventListClosed()), this, SLOT(eventListClosed()));
    connect(notes, SIGNAL(reminderShown()), this, SLOT(reminderShown()));
    connect(notes, SIGNAL(reminderClosed()), this, SLOT(reminderClosed()));
    connect(notes, SIGNAL(noteModified(bool)), this, SLOT(setModified(bool)));

    readConfig();
    changeFont();
    
    noNoteTree();
}
Ejemplo n.º 13
0
                                          << FilterAction::ActionCopy;

    foreach (FilterAction::Action extra_action, extra_actions) {
        fa = new FilterAction(&ctx_menu_, extra_action);
        ctx_menu_.addAction(fa);
        connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered()));
    }

    //Add collapse/expand all menu options
    QAction *collapse = new QAction(tr("Collapse All"), this);
    ctx_menu_.addAction(collapse);
    connect(collapse, SIGNAL(triggered()), this, SLOT(collapseTree()));

    QAction *expand = new QAction(tr("Expand All"), this);
    ctx_menu_.addAction(expand);
    connect(expand, SIGNAL(triggered()), this, SLOT(expandTree()));

    connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent *)),
            this, SLOT(captureEvent(CaptureEvent *)));
    setDisplayFilter();
    QTimer::singleShot(0, this, SLOT(retapPackets()));
}

ExpertInfoDialog::~ExpertInfoDialog()
{
    delete ui;
    delete proxyModel_;
    delete expert_info_model_;
}

void ExpertInfoDialog::clearAllData()