Пример #1
0
struct Lnode *add_node_to_payload(uint32_t value, struct Lnode *gadget,
  char *string0, char *string1, char *string2, struct Lnode *existing_node){


  struct Lnode *new_node;
  payload_gadget_t *payload_node_ptr;

  new_node = createLnode(payload);
  payload_node_ptr = GETPOINTER(new_node, payload_gadget_t);

  /*
  if(GETPOINTER(gadget, Gadget_t)->instruction->instr_type == INS_RET){
    TODO
    < rename registers >
  }
  */

  payload_node_ptr->value = value;
  payload_node_ptr->gadget = gadget;
  payload_node_ptr->strings[0] = string0;
  payload_node_ptr->strings[1] = string1;
  payload_node_ptr->strings[2] = string2;

  if(existing_node){
    return addBefore(payload, new_node, existing_node);
  }
  else{
    addHead(payload, new_node);
    return 0;
  }
}
UIMiniRacerMapOptionsWindow::UIMiniRacerMapOptionsWindow (IFrontend *frontend, ServiceProvider& serviceProvider) :
		UIMapOptionsWindow(frontend, serviceProvider)
{
	_solve = new UINodeButtonImage(frontend, "icon-solve");
	_solve->putUnder(_restartMap, 0.02f);
	_solve->setOnActivate(CMD_UI_POP ";solve");
	if (_backButton == nullptr)
		add(_solve);
	else
		addBefore(_backButton, _solve);
}
Пример #3
0
  /*! \brief Replaces current cell with a new cell.
  *
  * \todo create a cellcopy operation.
  * \todo test!
  *
  */
  void CellCursor::replaceCurrentWith(Cell *newCell)
  {
    //       newCell->setParent(currentCell()->parentCell());
    //       newCell->setChild(currentCell()->child());
    //       newCell->setLast(currentCell()->last());
    //       newCell->setPrevious(currentCell()->previous());
    //       newCell->setNext(currentCell()->next());
    qDebug("replaceWithCurrent");

    newCell->setText(currentCell()->text());

    //Replace cell.
    deleteCurrentCell();
    addBefore(newCell);
    qDebug("End replaceWithCurrent");
  }
Пример #4
0
void DLList<T>::add(int i, T x){
	addBefore(getNode(i), x);
}
Пример #5
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();
}
Пример #6
0
 /**
  * Multiplication-assignment operator, equivalent to "this->addBefore( P )".
  */
 self& operator *=(const self& P) {
   return addBefore(P);
 };
Пример #7
0
objlink *objlink::addBefore(object *_obj, HWND hwnd, const char *heading, int level)
{
  objlink *newnode = addBefore(_obj);
  newnode->makeNode(hwnd, heading, level);
  return newnode;
}
Пример #8
0
main()
{
  int i,n,k;
  int quit = 0,choice;
  ElmType key;
  char s[12];
  FILE *f1,*f2;
  Llist *root,*p;

  newLlist(&root);

  while(quit == 0)
    {
      choice = menu();
      switch(choice)
	{

	case 1:  printf("How may people do you want to add? ");
	         scanf("%d",&n);
	         for(i = 0; i < n; i++)
		   { 
		     key = makeData();
		     addLast(&root,key);
		   }
		 rmenu();
		 break;

	case 2:  printList(root);
                 rmenu();
	         break;
	
	case 3:  printf("The position you want to delete: ");
	         scanf("%d",&k);
		 if(k < n && k > 0)
		   delNode(&root,k);
		 else 
		   printf("\nEnter position k(k >0 and k< %d) again.\n",n);
		 rmenu();
		 break;

	case 4:  printf("The position you want to insert: ");
	         scanf("%d",&k);
		 if(k < n && k > 0)
		   {
		     key = makeData();
		     addBefore(&root,k,key);
		   }
		 else 
		   printf("\nEnter position k(k >0 and k<= %d)again.\n",n);
		 rmenu();
		 break;

	case 5:  printf("The number you want to find: ");
	         scanf("%s",s);
		 p = search(root,s);
		 if(p == NULL) printf("This number is n't in the list.\n");
		 else printf(" + Name: %s\n + Email: %s\n",p->key.name,p->key.mail);
		 rmenu();
		 break;
		 
	case 6: f1 = fopen("contact.txt","w");
	        f2 = fopen("contact.dat","wb");
		save_txt(root,f1);
		saveDat(root,f2);
		fclose(f1);
		fclose(f2);
		rmenu();
		break;
	  
	case 7:  LlistFree(root);
	         printf("Have funny times!!\n");
		 quit++;
		 break;
		 
	default: printf("Please choose from 1 to 7.\n");

	}
    }
  return 0;
}
Пример #9
0
int menuList()
{
	setlocale(LC_ALL, "Rus");

	node_list *begin = NULL;
	node_list *end = NULL;

	int m;
	while (1)
	{
		system("CLS");
		cout << "Работа со списком:\t\t\t";
		cout << endl << endl << endl;
		cout << "1. Добавить в начало." << endl << endl;
		cout << "2. Добавить в конец." << endl << endl;
		cout << "3. Добавить после элемента равного n." << endl << endl;
		cout << "4. Добавить перед элементом равным n." << endl << endl;
		cout << "5. Удалить элемент равный n." << endl << endl;
		cout << "6. Сортировка." << endl << endl;
		cout << "7. Вывести список." << endl << endl;
		cout << "0. Выход." << endl << endl;


		cout << "Выберете пункт меню: ";
		while (scanIntVal(m) || (m < 0) || (m > 7))
		{
			cout << "\nОшибка. Попробуйте еще раз.\n\nВыберете пункт меню: ";
		}
		cout << endl;

		switch (m)
		{
		case 1:
		{
			int a;
			while (1)
			{
				cout << "Введите значение: ";
				if (scanIntVal(a))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}
				addBegin(a, begin, end);
				cout << "Добавить еще значение? (Y/N) -->";
				if (!scanYesNo())
				{
					break;
				}
			}
			break;
		}
		case 2:
		{
			int a;
			while (1)
			{
				cout << "Введите значение: ";
				if (scanIntVal(a))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}
				addEnd(a, begin, end);
				cout << "Добавить еще значение? (Y/N) -->";
				if (!scanYesNo())
				{
					break;
				}
			}
			break;
		}
		case 3:
		{
			int n, val;

			while (1)
			{
				cout << "Введите значение, которое нужно добавить: ";
				if (scanIntVal(val))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}

				cout << "Введите значение, после которого добавить: ";
				if (scanIntVal(n))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}

				if (addAfter(val, n, begin, end))
				{
					cout << endl << endl << "Список пуст или такого элемента в нем нет." << endl << endl;
					cout << "1. Добавить в начало." << endl << endl;
					cout << "2. Добавить в конец." << endl << endl;
					cout << "3. Попробовать еще раз." << endl << endl;
					cout << "0. Ничего не делать." << endl << endl;
					cout << "Выберете пункт меню: ";
					int q;
					while (scanIntVal(q) || (q < 0) || (q > 3))
					{
						cout << "\nОшибка. Попробуйте еще раз.\n\nВыберете пункт меню: ";
					}
					cout << endl;
					switch (q)
					{
					case 1:
					{
						addBegin(val, begin, end);
						break;
					}
					case 2:
					{
						addEnd(val, begin, end);
						break;
					}
					case 3:
					{
						continue;
						break;
					}
					default:
					{

					}
					}
					break;
				}
				else
				{
					break;
				}
			}
			break;
		}
		case 4:
		{
			int n, val;

			while (1)
			{
				cout << "Введите значение, которое нужно добавить: ";
				if (scanIntVal(val))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}

				cout << "Введите значение, перед которым добавить: ";
				if (scanIntVal(n))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}

				if (addBefore(val, n, begin, end))
				{
					cout << endl << endl << "Список пуст или такого элемента в нем нет." << endl << endl;
					cout << "1. Добавить в начало." << endl << endl;
					cout << "2. Добавить в конец." << endl << endl;
					cout << "3. Попробовать еще раз." << endl << endl;
					cout << "0. Ничего не делать." << endl << endl;
					cout << "Выберете пункт меню: ";
					int q;
					while (scanIntVal(q) || (q < 0) || (q > 3))
					{
						cout << "\nОшибка. Попробуйте еще раз.\n\nВыберете пункт меню: ";
					}
					cout << endl;
					switch (q)
					{
					case 1:
					{
						addBegin(val, begin, end);
						break;
					}
					case 2:
					{
						addEnd(val, begin, end);
						break;
					}
					case 3:
					{
						continue;
						break;
					}
					default:
					{

					}
					}
					break;
				}
				else
				{
					break;
				}
			}
			break;
		}
		case 5:
		{
			if (!begin)
			{
				print(begin);
				system("PAUSE");
				break;
			}

			int a;
			while (1)
			{
				cout << "Введите значение, которое нужно удалить: ";
				if (scanIntVal(a))
				{
					cout << "\nОшибка. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}
				if (erase(a, begin, end))
				{
					cout << "Такого значение в списке нет. Попробовать еще раз? (Y/N) -->";
					if (scanYesNo())
					{
						continue;
					}
					else
					{
						break;
					}
				}
				cout << "Элемент со значением " << a << " удален." << endl << endl;
				cout << "Удалить еще? (Y/N) -->";
				if (!scanYesNo())
				{
					break;
				}
			}
			break;
		}
		case 6:
		{
			if (!sorting(begin, end))
			{
				cout << "Отсортированный список:" << endl << endl;
				print(begin);
			}
			else
			{
				cout << "Ошибка!! Добавьте больше элементов." << endl << endl;
			}

			system("PAUSE");
			break;
		}
		case 7:
		{
			print(begin);
			system("PAUSE");
			break;
		}
		default:
		{
			while (begin)
			{
				node_list *temp = (*begin).next;
				delete begin;
				begin = temp;
			}
			return 0;
		}
		}
	}
}
Пример #10
0
 /**
  * Multiplication-assignment operator, equivalent to "this->addBefore( F )".
  * \note No operations are performed on forces.
  */
 self& operator *=(const self& F) {
   return addBefore(F);
 };