Exemplo n.º 1
0
bool FileComparer::overwriteCompared() {
    string line;

    if(!createNew("tmp.txt"))
        return false;

    ifstream tmp("tmp.txt");
    if(!tmp.is_open())
        return false;

    fs_compared.close();
    ofstream new_compared(path_compared);

    while(tmp.good()) {
        getline(tmp, line);
        new_compared << line << endl;
    }

    tmp.close();
    new_compared.close();
    setComparedFile(path_compared);

    remove("tmp.txt");

    return true;
};
Exemplo n.º 2
0
bool FileComparer::overwritePattern() {
    string line;

    if(!createNew("tmp.txt"))
        return false;

    ifstream tmp("tmp.txt");
    if(!tmp.is_open())
        return false;

    fs_pattern.close();
    ofstream new_pattern(path_pattern);

    while(tmp.good()) {
        getline(tmp, line);
        new_pattern << line << endl;
    }

    tmp.close();
    new_pattern.close();
    setPatternFile(path_pattern);

    if(remove("tmp.txt") != 0)
        cout << "NIE USUNIETO PLIKU TYMCZASOWEGO" << endl;

    return true;
};
Exemplo n.º 3
0
PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionCode& ec)
{
    ec = 0;

    // INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than
    // the number of 16-bit units in data.
    if (offset > m_data->length()) {
        ec = INDEX_SIZE_ERR;
        return 0;
    }

    RefPtr<StringImpl> oldStr = m_data;
    RefPtr<Text> newText = createNew(oldStr->substring(offset));
    m_data = oldStr->substring(0, offset);

    dispatchModifiedEvent(oldStr.get());

    if (parentNode())
        parentNode()->insertBefore(newText.get(), nextSibling(), ec);
    if (ec)
        return 0;

    if (parentNode())
        document()->textNodeSplit(this);

    if (renderer())
        static_cast<RenderText*>(renderer())->setText(m_data);

    return newText.release();
}
Exemplo n.º 4
0
int main(int argc, const char * argv[]) {
    struct Node * head = createNew(0);
    struct Node * temp = head;
    
    for (int i = 1; i < 10; i++){
        struct Node * newNode = createNew(i);
        temp->next = newNode;
        temp = temp->next;
    }
    
    printList(head);
    addToList(head, 0);
    printList(head);
    removeDupsFromList(head);
    printList(head);

    return 0;
}
Exemplo n.º 5
0
 LuaClass(const neo::LuaContext& context, const std::string& mtname) : 
   m_context(context), m_mtname(mtname) 
 {
   std::stringstream ss; 
   void* ptr = static_cast<void*>(this);
   ss << "ptr" << ptr << "\n";
   m_objname = ss.str();
   createNew();
 } 
Exemplo n.º 6
0
IngredientsDialog::IngredientsDialog( QWidget* parent, RecipeDB *db ) : QWidget( parent )
{
	// Store pointer to database
	database = db;

	// Design dialog

	QHBoxLayout* page_layout = new QHBoxLayout( this );

	tabWidget = new KTabWidget( this );

	ingredientTab = new QWidget( tabWidget );

	layout = new QHBoxLayout( ingredientTab );

	listLayout = new QVBoxLayout;

	ingredientListWidget = new KreIngredientListWidget( ingredientTab, database );
	ingredientActionsHandler = new KreIngredientActionsHandler( ingredientListWidget, database );
	listLayout->addWidget( ingredientListWidget );

	QVBoxLayout *buttonLayout = new QVBoxLayout();

	addIngredientButton = new KPushButton( ingredientTab );
	addIngredientButton->setText( i18nc( "@action:button", "Create..." ) );
	addIngredientButton->setIcon( KIcon( "list-add") );
	buttonLayout->addWidget( addIngredientButton );

	removeIngredientButton = new KPushButton( ingredientTab );
	removeIngredientButton->setText( i18nc( "@action:button", "Delete" ) );
	removeIngredientButton->setIcon( KIcon( "list-remove" ) );
	buttonLayout->addWidget( removeIngredientButton );

	buttonLayout->addStretch();
	
	QPushButton *propertyButton = new KPushButton( i18nc("@action:button", "Property Information"), ingredientTab );
	propertyButton->setIcon( KIcon( "document-properties") );
	listLayout->addWidget( propertyButton );

	layout->addLayout( listLayout );
	layout->addLayout( buttonLayout );

	tabWidget->insertTab( -1, ingredientTab, i18nc( "@title:tab", "Ingredients" ) );

	groupsDialog = new IngredientGroupsDialog(database,tabWidget,"groupsDialog");
	tabWidget->insertTab( -1, groupsDialog, i18nc( "@title:tab", "Headers" ) );

	page_layout->addWidget( tabWidget );

	// Signals & Slots
	connect( addIngredientButton, SIGNAL( clicked() ), ingredientActionsHandler, SLOT( createNew() ) );
	connect( removeIngredientButton, SIGNAL( clicked() ), ingredientActionsHandler, SLOT( remove() ) );
	connect( propertyButton, SIGNAL( clicked() ), this, SLOT( showPropertyEdit() ) );

}
Exemplo n.º 7
0
/* create menus bar */
void MainWindow::createMenuBar()
{
    // File Menu
    fileMenu = menuBar()->addMenu(tr("&File"));
    newMenuAct = fileMenu->addAction(tr("&New Net"));
    newMenuAct->setIcon(QIcon::fromTheme("window-new"));
    newMenuAct->setShortcut(QKeySequence("Ctrl+N"));
        connect(newMenuAct, SIGNAL(triggered()), tabWidget, SLOT(createNew()));
    openMenuAct = fileMenu->addAction(tr("&Open Net"));
    openMenuAct->setIcon(QIcon::fromTheme("folder-open"));
    openMenuAct->setShortcut(QKeySequence("Ctrl+O"));
        connect(openMenuAct, SIGNAL(triggered()), this, SLOT(open()));
            fileMenu->addSeparator();
    saveMenuAct = fileMenu->addAction(tr("&Save"));
    saveMenuAct->setIcon(QIcon::fromTheme("document-save"));
    saveMenuAct->setShortcut(QKeySequence("Ctrl+S"));
        connect(saveMenuAct, SIGNAL(triggered()), tabWidget, SLOT(save()));
    exportMenuAct = fileMenu->addAction(tr("&Export"));
    //exportMenuAct->setIcon(QIcon(QPixmap("")));
    exportMenuAct->setShortcut(QKeySequence("Ctrl+E"));
        connect(exportMenuAct, SIGNAL(triggered()), tabWidget, SLOT(exportNet()));
            fileMenu->addSeparator();
    quitMenuAct = fileMenu->addAction(tr("&Exit"));
    quitMenuAct->setIcon(QIcon::fromTheme("application-exit"));
    quitMenuAct->setShortcut(QKeySequence("Ctrl+Q"));
        connect(quitMenuAct, SIGNAL(triggered()), this, SLOT(close()));

    // Petri Net Menu
    editMenu = menuBar()->addMenu(tr("&Edit"));
    undoMenuAct = editMenu->addAction(tr("&Undo"));
    undoMenuAct->setIcon(QIcon::fromTheme("edit-undo"));
    undoMenuAct->setShortcut(QKeySequence("Ctrl+Z"));
    undoMenuAct->setEnabled(false);
        connect(undoMenuAct, SIGNAL(triggered()), tabWidget, SLOT(undo()));
        connect(tabWidget, SIGNAL(canUndoChange (bool)), undoMenuAct, SLOT(setEnabled (bool)));
    redoMenuAct = editMenu->addAction(tr("&Redo"));
    redoMenuAct->setIcon(QIcon::fromTheme("edit-redo"));
    redoMenuAct->setShortcut(QKeySequence("Ctrl+Shift+Z"));
    redoMenuAct->setEnabled(false);
        connect(redoMenuAct, SIGNAL(triggered()), tabWidget, SLOT(redo()));
        connect(tabWidget, SIGNAL(canRedoChange (bool)), redoMenuAct, SLOT(setEnabled (bool)));
            editMenu->addSeparator();
    removeMenuAct = editMenu->addAction(tr("&Delete"));
    removeMenuAct->setIcon(QIcon::fromTheme("edit-delete"));
    removeMenuAct->setShortcut(QKeySequence("Del"));
        connect(removeMenuAct, SIGNAL(triggered ()), tabWidget, SLOT(removeItems ()));

    // help menu
    helpMenu = menuBar()->addMenu(tr("&Help"));
    aboutMenuAct = helpMenu->addAction(tr("&About"));
    aboutMenuAct->setIcon(QIcon::fromTheme("help-about"));
    aboutMenuAct->setShortcut(QKeySequence("Ctrl+B"));
        connect(aboutMenuAct, SIGNAL(triggered()), this, SLOT(about()));
}
Exemplo n.º 8
0
BinaryImage BinaryImage::operator*(const BinaryImage& other)
{
	BinaryImage temp = createNew(other);

	for (int x = 0; x < (temp._R * temp._C); x++)
	{
		temp._data[x] = this->_data[x] * other._data[x];
	}

	return temp;
}
Exemplo n.º 9
0
BinaryImage BinaryImage::operator-(const BinaryImage& other)
{
	BinaryImage temp = createNew(other);

	for (int x = 0; x < (temp._R * temp._C); x++)
	{
		if (other._data[x] != this->_data[x])
			temp._data[x] = 1;
		else
			temp._data[x] = 0;
	}

	return temp;
}
Exemplo n.º 10
0
BaseItem* ItemFactory::loadFromDb(int type, QVariant id) {
	// Создаем верхний элемент
	BaseItem* item = createNew(type);

	switch (type)
	{
	case ItemTypes::RegionItemCheckedType:
		dynamic_cast<RegionItemChecked*>(item)->id = -1;
		break;
	default:
		break;
	}

	QList<BaseItem*> children = item->loadItemsFromDb(id);
	
	// Добавляем истинные значения верхнему элементу
	for (int i = 0; i < children.count(); i++)
		
		item->appendChild(children[i]);

	return item;
};
Exemplo n.º 11
0
void addToList(struct Node * head, int val){
    if (head == NULL)
        return;
    
    struct Node * temp = head;
    
    
    while (temp != NULL){
        if (temp->val == val){
            struct Node * newNode = createNew(val);
            if (temp->next == NULL){
                temp->next = newNode;
            }else{
                newNode->next = temp->next;
                temp->next = newNode;
            }
            temp = newNode->next;
        }else{
            temp = temp->next;
        }
    }
}
Exemplo n.º 12
0
Text *Text::splitText(unsigned offset, ExceptionCode& ec)
{
    ec = 0;

    // FIXME: This does not copy markers
    
    // INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than
    // the number of 16-bit units in data.
    if (offset > str->length()) {
        ec = INDEX_SIZE_ERR;
        return 0;
    }

    // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
    if (isReadOnlyNode()) {
        ec = NO_MODIFICATION_ALLOWED_ERR;
        return 0;
    }

    StringImpl *oldStr = str;
    Text *newText = createNew(str->substring(offset, str->length()-offset));
    str = str->copy();
    str->ref();
    str->remove(offset, str->length()-offset);

    dispatchModifiedEvent(oldStr);
    oldStr->deref();

    if (parentNode())
        parentNode()->insertBefore(newText,nextSibling(), ec);
    if (ec)
        return 0;

    if (renderer())
        static_cast<RenderText*>(renderer())->setText(str);

    return newText;
}
Exemplo n.º 13
0
void DiskDir::load()
{
    _files.clear();
    _subdirs.clear();
    // TODO: cache existing files and keep them unless they do no longer exist

    StringList li;
    GetFileList(fullname(), li);
    for(StringList::iterator it = li.begin(); it != li.end(); ++it)
    {
        DiskFile *f = new DiskFile(joinPath(fullname(), it->c_str()).c_str());
        _files[f->name()] = f;
    }

    li.clear();
    GetDirList(fullname(), li, 0);
    for(StringList::iterator it = li.begin(); it != li.end(); ++it)
    {
        // GetDirList() returns relative paths, so need to join
        Dir *d = createNew(joinPath(fullname(), it->c_str()).c_str());
        _subdirs[d->name()] = d;
    }
}
Exemplo n.º 14
0
void MainMenu::callbackActive(Widget &widget) {
	if (widget.getTag() == "ExitButton") {
		EventMan.requestQuit();
		return;
	}

	if (widget.getTag() == "NewButton") {
		createNew();

		NewGameFogs fogs(ConfigMan.getInt("menufogcount", 4));
		fogs.show();

		if (sub(*_new, 0, false) == 2) {
			_returnCode = 2;
			return;
		}

		show();
		return;
	}

	if (widget.getTag() == "MoviesButton") {
		createMovies();

		sub(*_movies);
		return;
	}

	if (widget.getTag() == "OptionsButton") {
		createOptions();

		sub(*_options);
		return;
	}

}
Exemplo n.º 15
0
DirBase *DirBase::_createNewSubdir(const char *subdir) const
{
    assert(*subdir);
    //printf("_createNewSubdir: [%s]\n", subdir);
    // -> newname = fullname() + '/' + subdir
    size_t fullLen = fullnameLen();
    size_t subdirLen = strlen(subdir);
    char * const newname = (char*)VFS_STACK_ALLOC(fullLen + subdirLen + 2);
    char *ptr = newname;
    if(fullLen)
    {
        memcpy(ptr, fullname(), fullLen);
        ptr += fullLen;
        if(ptr[-1] != '/')
            *ptr++ = '/';
    }

    memcpy(ptr, subdir, subdirLen + 1); // copy terminating \0 too
    //printf("_createNewSubdir: newname = [%s]\n", newname);
    DirBase *ret = createNew(newname);
    //printf("_createNewSubdir: fullname = [%s]\n", ret->fullname());
    VFS_STACK_FREE(newname);
    return ret;
}
void ColorView::slotCustomContextMenuRequested(const QPoint& p) {
    QMenu* m = new QMenu(this);

    QAction* reloadA = new QAction(tr("Reload"), this);
    QAction* createA = new QAction(tr("Create..."), this);
    QAction* editA = new QAction(tr("Edit..."), this);
    QAction* deleteA = new QAction(tr("Delete"), this);

    connect(reloadA, SIGNAL(activated()), this, SLOT(slotReload()));
    connect(createA, SIGNAL(activated()), (ColorItemModel*) model(), SLOT(createNew()));
    connect(editA, SIGNAL(activated()), this, SLOT(slotEdit()));
    connect(deleteA, SIGNAL(activated()), this, SLOT(slotDelete()));

    m->addAction(createA);
    if (selectedIndexes().count() == 1) {
        m->addAction(editA);
    }
    if (selectedIndexes().count() > 0) {
        m->addAction(deleteA);
    }
    m->insertSeparator(reloadA);
    m->addAction(reloadA);
    m->exec(mapToGlobal(p));
}
Exemplo n.º 17
0
void TinfoBase::addItems(const TinfoItem *Iitems)
{
    for (; Iitems->type; Iitems++) {
        values.insert(std::make_pair(Iitems->type, createNew(Iitems)));
    }
}
Exemplo n.º 18
0
void gamePlay() {
    // detect the movement of the cursor
    int initHoriz = analogRead(HORIZ);
    int initVerti = analogRead(VERT);
    
   
   
    while(true) {   
        oldCursorX = cursorX;
        oldCursorY = cursorY;
       
        int finalHoriz = analogRead(HORIZ);
        int finalVerti = analogRead(VERT);
       
        int select = digitalRead(SEL);    // HIGH(1) if not pressed, LOW(0) if pressed
                                             
        int deltaHoriz = (finalHoriz - initHoriz)/100;
        int deltaVerti = -(finalVerti - initVerti)/100;
       
        cursorX += deltaHoriz;
        cursorY += deltaVerti;
       
        int whetherFull = full();
       
        //int whetherMove = blockMoved();
       
        // cursur has moved
        if (oldCursorX!=cursorX || oldCursorY!=cursorY) {
            // backup the current grid before updating the tiles, for undo() function
            gridBackup();
            updateTile(deltaVerti, deltaHoriz);
            
            // check if any further movements can be made
            if(whetherFull && noMoreAdd) {continueGame = 0;}
               
            else {
                continueGame = 1;
                createNew();
			}
            
            displayGrid();
            delay(50);
        }
       
        // Undo: button of joystick has been pressed
        if (select == 0) {
            score-=plus;
            undo();
            displayGrid();
           
        }

        // if the game is over, display game over screen and break the while loop
        int gameEnd = gameOverCheck();
        if (gameEnd) {break;}
       
        // test: print out the values of coordinates to serial-mon
        //Serial.print(" whetherMove: ");
        //Serial.print(whetherMove);
        Serial.print(" continueGame: ");
        Serial.print(continueGame);
        Serial.print(" cursorX: ");
        Serial.print(cursorX);
        Serial.print(" cursorY: ");
        Serial.print(cursorY);
        Serial.print(" SEL= ");
        Serial.print(select,DEC);
        Serial.println();
        delay(10);
       
    }
}
Exemplo n.º 19
0
Arquivo: main.cpp Projeto: turu/mikro
 void record(const std::vector<std::vector<cv::Point> > & contours) {
     std::vector<std::vector<cv::Point> > copyOfContours(contours);
     appendToExisting(copyOfContours);
     createNew(copyOfContours);
 }
Exemplo n.º 20
0
bool TcpMq::createNew(unsigned int serverPort, int zmqServerSocketType)
{
	return createNew(boost::lexical_cast<std::string>(serverPort), zmqServerSocketType);
}
// insert the specified key in the Btree
// the tree needs to be opened first by the caller
RC insertKey(BTreeHandle* tree, Value* key, RID rid) {

	Btree_stat *root = tree->mgmtData;

	Btree *node = root->mgmtData;
	int i;

	if (!root->num_nodes) {

		// tree is empty
		root->num_nodes++;

		// create a new nodes
		createNew(node, key, rid);

		// the toptal number of nodes change
		root->num_inserts = root->num_inserts + 1;

		// update the statistic info of the tree
		updateStat(tree, root);

		return RC_OK;
	}


	// find a place where the new node should go
	node = find_node_to_insert(root, key);

	// traverse till the end
	Btree* temp1 = Rootnode;

	while (temp1) {

		for (i = 0; i < temp1->num_keys; i++) {

			// check if theres a match
			if (temp1->keys[i] == key->v.intV) {

				// update the stat info
				updateStat(tree, root);
				return RC_OK;
			}

		}

		temp1 = temp1->next;
	}


	// check which side should we traverse
	if (node->num_keys < root->order) {

		// this is a leaf node
		insertLeaf(node, key, rid);

		
		root->num_inserts = root->num_inserts + 1;

		// update the stat info
		updateStat(tree, root);

		return RC_OK;
	}

	// check if we got aq match
	if (node->num_keys == root->order) {

		// split the current node and insert
		splitInsert(tree, root, node, key, rid);

		
		root->num_inserts = root->num_inserts + 1;

		// update the stat info
		updateStat(tree, root);

		return RC_OK;
	}

	// ok
	return RC_OK;
}
Exemplo n.º 22
0
int inputLoop(){
	char * buffer = malloc(sizeof(char) * BUFFER_SIZE);
	rInput = 1;
	while(rInput){
		clearBuffer(buffer);
		cleanInputLine();
		char * line = readLine(buffer,BUFFER_SIZE);
		if(line){
			//Analyse and do something with this line...
			if(!strcmp(line,"help")){
				outputLine(HELP_MAIN);
				continue;
			}
			if(!strncmp(line,"help",4)){
				//something was called with help
				line += 5;
				if(!strcmp(line,"new")){
					outputLine(HELP_NEW);
				}
				if(!strcmp(line,"quit")){
					outputLine(HELP_QUIT);
				}
				if(!strcmp(line,"rnew")){
					outputLine(HELP_RNEW);
				}
				if(!strcmp(line,"autonew")){
					outputLine(HELP_AUTONEW);
				}
				// ... more help
				continue;
			}
			// NEW PASSENGER
			if(!strncmp(line,"new",3)){
				line += 4;
				int a, b, c = 1;
				sscanf(line,"%d %d %d",&a,&b,&c);
				while(c--){
					createNew(a,b);
				}
				continue;
			}
			//NEW RANDOM PASSENGER:
			if(!strncmp(line,"rnew",4)){
				line += 5;
				int a = 1;
				sscanf(line,"%d",&a);
				createRandom(a);
			}
			if(!strncmp(line,"autonew",7)){
				line += 8;
				if(!strcmp(line,"on") || !strcmp(line,"off")){
					toggleAutonew(*(line+1) == 'n');
				} else {
					outputLine(HELP_AUTONEW);
				}
				continue;
			}
			// QUIT
			if(!strcmp(line,"quit")){
				stopInputLoop();
				continue;
			}
		}
	}
	free(buffer);
	return rInput;
}
Exemplo n.º 23
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
{
  ui->setupUi(this);

  actionNew = actionSave = actionDelete = actionExit = NULL;
  actionScan = actionMirror = actionMake = NULL;
  actionPrint = NULL;
  vcb = NULL;
  grid = NULL;
  printpreview = NULL;
  previewTemplate = NULL;
  previewCell = NULL;

  //qDebug() << db.drivers();
  db = QSqlDatabase::addDatabase("QMYSQL");

  db.setHostName("localhost");
  db.setDatabaseName("crossword");
  db.setUserName("taras");
  db.setPassword("su112per");
  bool ok = db.open();

  if (!ok)
    {
      qDebug() << db.lastError().text();

      QMessageBox msgBox;
      msgBox.setText(tr("Database open error!"));
      msgBox.exec();
    }

  grid = new tableTemplateWidget();

  if (grid)
    {
      // File menu
      actionNew = new QAction(QIcon(":/icons/new16.png"), QString(tr("New")), this);
      connect(actionNew, SIGNAL(triggered()), grid, SLOT(createNew()));

      actionSave = new QAction(QIcon(":/icons/save16.png"), QString(tr("Save")), this);
      connect(actionSave, SIGNAL(triggered()), grid, SLOT(saveToDB()));

      actionDelete = new QAction(QIcon(":/icons/delete16.png"), QString(tr("Delete")), this);
      connect(actionDelete, SIGNAL(triggered()), grid, SLOT(deleteTemplate()));

      actionPrint = new QAction(QIcon(":/icons/preview16.png"), QString(tr("Print")), this);
      connect(actionPrint, SIGNAL(triggered(bool)), this, SLOT(printCrossword()));

      actionExit = new QAction(QIcon(":/icons/x16.png"), QString(tr("Exit")), this);
      connect(actionExit, SIGNAL(triggered()), this, SLOT(exit()));


      QMenu *menuFile = new QMenu(tr("File"), this);
      ui->menuBar->addMenu(menuFile);
      menuFile->addAction(actionNew);
      menuFile->addAction(actionSave);
      menuFile->addAction(actionDelete);
      menuFile->addAction(actionPrint);
      menuFile->addSeparator();
      menuFile->addAction(actionExit);

      ui->mainToolBar->addAction(actionNew);
      ui->mainToolBar->addAction(actionSave);
      ui->mainToolBar->addAction(actionDelete);
      ui->mainToolBar->addAction(actionPrint);

      // Edit menu
      ui->mainToolBar->addSeparator();

      QMenu *menuEdit = new QMenu(tr("Edit"), this);
      ui->menuBar->addMenu(menuEdit);
      //  actionScan = new QAction(QIcon(":/icons/search16.png"), QString(tr("Scan")), this);
      //  connect(actionScan, SIGNAL(triggered()), grid, SLOT(scanTemplate()));
      //  ui->mainToolBar->addAction(actionScan);
      //  menuEdit->addAction(actionScan);

      actionMirror = new QAction(QIcon(":/icons/favorites16.png"), QString(tr("Mirror")), this);
      actionMirror->setCheckable(true);
      actionMirror->setChecked(true);
      connect(actionMirror, SIGNAL(toggled(bool)), grid, SLOT(setSymetricalMode(bool)));
      ui->mainToolBar->addAction(actionMirror);
      menuEdit->addAction(actionMirror);

      actionMake = new QAction(QIcon(":/icons/make.png"), QString(tr("Build crossword")), this);
      actionMake->setCheckable(true);
      connect(actionMake, SIGNAL(toggled(bool)), grid, SLOT(makeCrossword()));
      ui->mainToolBar->addAction(actionMake);
      menuEdit->addAction(actionMake);

      vcb = new QComboBox(this);
      if (vcb)
      {
          QFont font;
          font.setPointSize(10);
          //font.setBold(true);

	  vcb->setFixedSize(350, 32);
	  vcb->setMaxVisibleItems(20);
	  vcb->setFont(font);

	  vcb->addItem("УСЕ (Універсальний словник-енциклопедія)", QVariant(29));
	  vcb->addItem("Орфографічний словник української мови", QVariant(35));
	  vcb->addItem("Фразеологічний словник української мови", QVariant(49));
	  vcb->addItem("Словник синонімів Полюги", QVariant(31));
	  vcb->addItem("Словник синонімів Караванського", QVariant(41));
	  vcb->addItem("Словник іншомовних слів", QVariant(36));
	  vcb->addItem("Словник іншомовних слів Мельничука", QVariant(42));
	  vcb->addItem("Словник англіцизмів", QVariant(46));
	  vcb->addItem("Eкономічна енциклопедія", QVariant(38));
	  vcb->addItem("Словник мови Стуса", QVariant(27));
	  vcb->addItem("Словник іншомовних соціокультурних термінів", QVariant(39));
	  vcb->addItem("Енциклопедія політичної думки", QVariant(40));
	  vcb->addItem("Словник церковно-обрядової термінології", QVariant(43));
	  vcb->addItem("Архітектура і монументальне мистецтво", QVariant(44));
	  vcb->addItem("Словник-антисуржик", QVariant(45));
	  vcb->addItem("Словник термінів, уживаних у чинному Законодавстві України", QVariant(48));
	  vcb->addItem("Словник бюджетної термінології", QVariant(50));
	  vcb->addItem("Термінологічний словник з економіки праці", QVariant(51));
	  vcb->addItem("Глосарій термінів Фондового ринку", QVariant(52));
	  vcb->addItem("Моделювання економіки", QVariant(53));
	  vcb->addItem("Власні імена людей", QVariant(54));
	  vcb->addItem("Словар українського сленгу", QVariant(57));
	  vcb->addItem("Музичні терміни", QVariant(58));
	  vcb->addItem("Тлумачний словник з інформатики та інформаційних систем для економістів", QVariant(59));
	  vcb->addItem("Управління якістю", QVariant(61));

	  ui->mainToolBar->insertWidget(actionMake, vcb);
	  connect(vcb, SIGNAL(currentIndexChanged(int)), this, SLOT(setVocabulary(int)));
	  setVocabulary(vcb->currentIndex());
      }

      //grid->setStyleSheet(readStyleSheet("/home/taras/Projects/qtCrossword/qribbon.qss"));
      grid->setSymetricalMode(true);
      ui->horizontalLayout->addWidget(grid);
      ui->listWidget->setTemplateGrid(grid);

      grid->setStatusBar(ui->statusBar);
      grid->setDB(&db);

      connect(grid, SIGNAL(maked()), this, SLOT(makedCrossword()));
    }

  previewTemplate = new PreviewTemplateDelegate();

  if (previewTemplate)
    ui->listWidget->setItemDelegate(previewTemplate);

  loadListPreview();

  previewCell = new PreviewCellDelegate();
  ui->tableView->setItemDelegate(previewCell);
  ui->tableView->setModel( grid->model() );
  ui->tableView->horizontalHeader()->setDefaultSectionSize(40);
  ui->tableView->verticalHeader()->setDefaultSectionSize(40);
  ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);

  printer = new QPrinter();

  if (printer)
    {
      printer->setPaperSize(QPrinter::A4);
      printer->setOrientation(QPrinter::Portrait);
      printer->setFullPage(true);
      printer->setPageMargins(20.0, 15.0, 15.0, 15.0, QPrinter::Millimeter);
      printer->newPage();

      prnPreview = new QPrintPreviewDialog(printer, this);
      connect(prnPreview, SIGNAL(paintRequested(QPrinter*)), grid, SLOT(printPreview(QPrinter*)));
      ui->horizontalLayout_8->addWidget(prnPreview);

      printpreview = new QPrintPreviewWidget(printer, this);

      if (printpreview)
        {
          printpreview->fitInView();
          printpreview->show();

          ui->horizontalLayout_8->addWidget(printpreview);
          connect(printpreview, SIGNAL(paintRequested(QPrinter*)), grid, SLOT(printPreview(QPrinter*)));
        }
    }
}
Exemplo n.º 24
0
/* create tool bar */
void MainWindow::createToolBar ()
{
    newToolButton = new QToolButton;
    newToolButton->setIconSize(QSize(50, 50));
    newToolButton->setIcon(QIcon::fromTheme("window-new"));
    newToolButton->setToolTip(tr("Create a new Petri Net <span style=\"color:gray;\">Ctrl+N</span>"));
    connect(newToolButton, SIGNAL(clicked()), tabWidget, SLOT(createNew()));
        openToolButton = new QToolButton;
    openToolButton->setIconSize(QSize(50, 50));
    openToolButton->setIcon(QIcon::fromTheme("folder-open"));
    openToolButton->setToolTip(tr("Open a Petri Net document <span style=\"color:gray;\">Ctrl+O</span>"));
    connect(openToolButton, SIGNAL(clicked()), this, SLOT(open()));
        saveToolButton = new QToolButton;
    saveToolButton->setIconSize(QSize(50, 50));
    saveToolButton->setIcon(QIcon::fromTheme("document-save"));
    saveToolButton->setToolTip(tr("Save the current Petri Net <span style=\"color:gray;\">Ctrl+S</span>"));
    connect(saveToolButton, SIGNAL(clicked()), tabWidget, SLOT(save()));
        undoToolButton = new QToolButton;
    undoToolButton->setIconSize(QSize(50, 50));
    undoToolButton->setIcon(QIcon::fromTheme("edit-undo"));
    undoToolButton->setToolTip(tr("Undo the last action <span style=\"color:gray;\">Ctrl+Z</span>"));
    undoToolButton->setEnabled(false);
    connect(undoToolButton, SIGNAL(clicked()), tabWidget, SLOT(undo ()));
    connect(tabWidget, SIGNAL(canUndoChange (bool)), undoToolButton, SLOT(setEnabled (bool)));
        redoToolButton = new QToolButton;
    redoToolButton->setIconSize(QSize(50, 50));
    redoToolButton->setIcon(QIcon::fromTheme("edit-redo"));
    redoToolButton->setToolTip(tr("Redo the last undone action <span style=\"color:gray;\">Ctrl+Shif+Z</span>"));
    redoToolButton->setEnabled(false);
    connect(redoToolButton, SIGNAL(clicked()), tabWidget, SLOT(redo ()));
    connect(tabWidget, SIGNAL(canRedoChange(bool)), redoToolButton, SLOT(setEnabled (bool)));
        removeToolButton = new QToolButton;
    removeToolButton->setIconSize(QSize(50, 50));
    removeToolButton->setIcon(QIcon::fromTheme("edit-delete"));
    removeToolButton->setToolTip(tr("Remove the selected items <span style=\"color:gray;\">Del</span> "));
    connect(removeToolButton, SIGNAL(clicked()), tabWidget, SLOT(removeItems ()));
        cursorToolButton = new QToolButton;
    cursorToolButton->setIconSize(QSize(50, 50));
    cursorToolButton->setCheckable(true);
    cursorToolButton->setIcon(QIcon(QPixmap(":/images/cursor.png")));
    cursorToolButton->setToolTip(tr("Normal cursor"));
        addPlaceToolButton = new QToolButton;
    addPlaceToolButton->setIconSize(QSize(50, 50));
    addPlaceToolButton->setCheckable(true);
    addPlaceToolButton->setIcon(QIcon(QPixmap(":/images/place.png")));
    addPlaceToolButton->setToolTip(tr("Add places"));
        addTransToolButton = new QToolButton;
    addTransToolButton->setIconSize(QSize(50, 50));
    addTransToolButton->setCheckable(true);
    addTransToolButton->setIcon(QIcon(QPixmap(":/images/transition.png")));
    addTransToolButton->setToolTip(tr("Add transitions"));
        drawArcToolButton = new QToolButton;
    drawArcToolButton->setIconSize(QSize(50, 50));
    drawArcToolButton->setCheckable(true);
    drawArcToolButton->setIcon(QIcon(QPixmap(":/images/arc.png")));
    drawArcToolButton->setToolTip(tr("Draw Polylines Arcs"));
        addTokenToolButton = new QToolButton;
    addTokenToolButton->setIconSize(QSize(50, 50));
    addTokenToolButton->setCheckable(true);
    addTokenToolButton->setIcon(QIcon(QPixmap(":/images/token+.png")));
    addTokenToolButton->setToolTip(tr("Add Tokens"));
        subTokenToolButton = new QToolButton;
    subTokenToolButton->setIconSize(QSize(50, 50));
    subTokenToolButton->setCheckable(true);
    subTokenToolButton->setIcon(QIcon(QPixmap(":/images/token-.png")));
    subTokenToolButton->setToolTip(tr("Delete Tokens"));
        animateToolButton = new QToolButton;
    animateToolButton->setIconSize(QSize(50, 50));
    animateToolButton->setCheckable(true);
    animateToolButton->setIcon(QIcon(QPixmap(":/images/animate.png")));
    animateToolButton->setToolTip(tr("Animate the current drawen net"));

    buttonGroup = new QButtonGroup (this);
    buttonGroup->setExclusive(true);
    buttonGroup->addButton(cursorToolButton,      normalMode);
    buttonGroup->addButton(addPlaceToolButton,    addPlaceMode);
    buttonGroup->addButton(addTransToolButton,    addTransMode);
    buttonGroup->addButton(drawArcToolButton,     drawArcMode);
    buttonGroup->addButton(animateToolButton,     animationMode);
    buttonGroup->addButton(addTokenToolButton,    addToken);
    buttonGroup->addButton(subTokenToolButton,    subToken);
        connect(buttonGroup, SIGNAL(buttonClicked (int)),
                this, SLOT(buttonGroupClicked(int)));

    // default mode = normal mode
    cursorToolButton->setChecked (true);

    toolBar = new QToolBar;
    toolBar->addWidget(newToolButton);
    toolBar->addWidget(openToolButton);
    toolBar->addWidget(saveToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(undoToolButton);
    toolBar->addWidget(redoToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(removeToolButton);
    toolBar->addWidget(cursorToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(addPlaceToolButton);
    toolBar->addWidget(addTransToolButton);
    toolBar->addWidget(drawArcToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(addTokenToolButton);
    toolBar->addWidget(subTokenToolButton);
        toolBar->addSeparator ();
    toolBar->addWidget(animateToolButton);

    toolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea | Qt::RightToolBarArea);
    addToolBar(Qt::LeftToolBarArea, toolBar);
}
Exemplo n.º 25
0
Arquivo: handler.c Projeto: UTL/netsec
void setEap(unsigned char * nonce, unsigned char * count, unsigned char * smac, unsigned char * dmac, int socketD){
	struct eap_st * anEap= NULL;
	if((anEap = macsPresent(smac, dmac))!= NULL){
		if(eqCounter(anEap->counter, count)){//secondo run eapol A <-- B
			if(anEap->status == ONE && eqMac(anEap->smac, dmac) && eqMac(anEap->apmac, smac)){
				memcpy(anEap->snonce, nonce, EAP_NONCE_SIZE);
				anEap->status = TWO;
			}
			else
			{
				printf("WARNING\n");
			}

		}
		else if(increasedCounter(anEap->counter, count)){//terzo run eapol A --> B
			if(anEap->status == TWO && eqMac(anEap->apmac, dmac) && eqMac(anEap->smac, smac) && eqNonce(nonce, anEap->anonce)){
				//memcpy(anEap->counter, count, COUNTER_SIZE);
				anEap->status = THR;
			}
			else if(anEap->status == THR && eqMac(anEap->smac, dmac) && eqMac(anEap->apmac, smac)){//quarto run eapol A <-- B
				anEap->status = DONE;
				printf(MSG_EAP_COMPLETE);
						int i;
				printf(" mac1: ");
					for(i=0; i<MAC_SIZE;i++)
				printf("%.2x",anEap->smac[i]);
				printf(" mac2: ");
					for(i=0; i<MAC_SIZE;i++)
				printf("%.2x",anEap->apmac[i]);
				printf(" anonce: ");
					for(i=0; i<EAP_NONCE_SIZE;i++)
				printf("%.2x",anEap->anonce[i]);
				printf(" mac1: ");
					for(i=0; i<EAP_NONCE_SIZE;i++)
				printf("%.2x",anEap->snonce[i]);
				
				printf("\"}\n");

				char eap_compl[strlen(MSG_EAP_COMPLETE)+ 15];
				eap_compl[0] = '\0';
				strcat(eap_compl, MSG_EAP_COMPLETE);
				strcat(eap_compl, "\"}\n");
				send(socketD, eap_compl, strlen(eap_compl), 0);
			}
			else{
				resetHandshake(nonce, count, smac, dmac, anEap); // nuovo handshake resetto
				printf(MSG_RESET_EAP);
				send(socketD, MSG_RESET_EAP, strlen(MSG_RESET_EAP), 0);
			}
		}
		else{
			resetHandshake(nonce, count, smac, dmac, anEap); // nuovo handshake resetto
			printf(MSG_RESET_EAP);
			send(socketD, MSG_RESET_EAP, strlen(MSG_RESET_EAP), 0);
		}
	}
	else{//primo run eapol A --> B
		anEap = createNew(nonce, count, smac, dmac);
		printf(MSG_NEW_EAP);
		send(socketD, MSG_NEW_EAP, strlen(MSG_NEW_EAP), 0);
	}
	if(ready(anEap))
		setSecAss(anEap);
}
Exemplo n.º 26
0
	KTL_INLINE sprig::krkr::tjs::object_type NativeBigInt::min(tTJSVariant const& v1, tTJSVariant const& v2) {
		sprig::krkr::tjs::object_type result = createNew(0, 0);
		BigInt* ptr = reinterpret_cast<BigInt*>(getInstance(sprig::get_pointer(result)));
		sprig::min(ptr->ref(), convertValue(v1), convertValue(v2));
		return result;
	}
Exemplo n.º 27
0
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
    createNew(x, y);
}
Exemplo n.º 28
0
UnitsDialog::UnitsDialog( QWidget *parent, RecipeDB *db ) : QWidget( parent )
{

	// Store pointer to database
	database = db;

	// Design dialog
	QHBoxLayout* page_layout = new QHBoxLayout( this );

	tabWidget = new KTabWidget( this );

	unitTab = new QWidget( tabWidget );
	QHBoxLayout* layout = new QHBoxLayout( unitTab );

	unitListView = new StdUnitListView( unitTab, database, true );
	unitActionsHandler = new UnitActionsHandler( unitListView, database );
	layout->addWidget( unitListView );

	QVBoxLayout* vboxl = new QVBoxLayout();

	newUnitButton = new KPushButton( unitTab );
	newUnitButton->setText( i18nc( "@action:button", "Create..." ) );
	newUnitButton->setIcon( KIcon ( "list-add" ) );
	vboxl->addWidget( newUnitButton );

	removeUnitButton = new KPushButton( unitTab );
	removeUnitButton->setText( i18nc( "@action:button", "Delete" ) );
	removeUnitButton->setIcon( KIcon ( "list-remove" ) );
	vboxl->addWidget( removeUnitButton );
	vboxl->addStretch();
	layout->addLayout( vboxl );

	tabWidget->insertTab( -1, unitTab, i18nc( "@title:tab", "Units" ) );

	massConversionTable = new ConversionTable( tabWidget, 1, 1 );
	tabWidget->insertTab( -1, massConversionTable, i18nc( "@title:tab", "Mass Conversions" ) );

	volumeConversionTable = new ConversionTable( tabWidget, 1, 1 );
	tabWidget->insertTab( -1, volumeConversionTable, i18nc( "@title:tab", "Volume Conversions" ) );

	page_layout->addWidget( tabWidget );

	// Connect signals & slots
	connect( newUnitButton, SIGNAL( clicked() ), unitActionsHandler, SLOT( createNew() ) );
	connect( removeUnitButton, SIGNAL( clicked() ), unitActionsHandler, SLOT( remove() ) );
	connect( massConversionTable, SIGNAL( ratioChanged( int, int, double ) ), this, SLOT( saveRatio( int, int, double ) ) );
	connect( massConversionTable, SIGNAL( ratioRemoved( int, int ) ), this, SLOT( removeRatio( int, int ) ) );
	connect( volumeConversionTable, SIGNAL( ratioChanged( int, int, double ) ), this, SLOT( saveRatio( int, int, double ) ) );
	connect( volumeConversionTable, SIGNAL( ratioRemoved( int, int ) ), this, SLOT( removeRatio( int, int ) ) );

	//TODO: I'm too lazy right now, so do a complete reload to keep in sync with db
	connect( database, SIGNAL( unitCreated( const Unit& ) ), this, SLOT( loadConversionTables() ) );
	connect( database, SIGNAL( unitRemoved( int ) ), this, SLOT( loadConversionTables() ) );

	//this is for the above TODO, but it still has some bugs to be worked out
	//connect(database,SIGNAL(unitCreated(const Element&)),conversionTable,SLOT(unitCreated(const Element&)));
	//connect(database,SIGNAL(unitRemoved(int)),conversionTable,SLOT(unitRemoved(int)));

	//Populate data into the table
	loadConversionTables();

	//FIXME: We've got some sort of build issue... we get undefined references to CreateElementDialog without this dummy code here
	CreateElementDialog d( this, "" );
}