Exemple #1
0
int main()
{
    /*llNode * test_node = malloc(sizeof(llNode));
    test_node->value = 1;
    test_node->next = malloc(sizeof(llNode));
    test_node->next->value = 2;
    test_node->next->next = malloc(sizeof(llNode));
    test_node->next->next->value = 3;
    test_node->next->next->next = NULL;
    printList(test_node);
    printf("Hello world!\n");
    push(test_node, 0);
    printList(test_node);
    length(test_node);*/

	//llNode * llist = malloc(sizeof(llNode));
	llNode * llist = createHead(4);
	push(llist, 2);
	push(llist, 1);
	addAfter(llist, 2, 3);
	printList(llist);
	printf("Going to remove one!\n");
	removeByLoc(llist, 4);
	printList(llist);
    return 0;
}
Exemple #2
0
inline void TCGenList::addToHead(TCListNode* node)
/****************************************************************************
*
* Function:		TCGenList::addToHead
* Parameters:	node	- Node to add to list
*
* Description:	Attaches the node to the head of the list, maintaining the
*				head and tail pointers.
*
****************************************************************************/
{
	addAfter(node,head);
}
Exemple #3
0
/*menambahkan di akhir list*/
void addLast(char amal[], list *L){
	if((*L).first == NULL){
		/*jika list adalah list kosong*/
		addFirst(amal, L);
	}else{
		/*jika list tidak kosong*/
		/*mencari elemen terakhir list*/
		elemen *prev= (*L).first;
		while(prev->next != NULL){
			/*iterasi*/
			prev= prev->next;
		}
		addAfter(prev, amal, L);
	}
}
Exemple #4
0
    ui->listWidget_after->clear();
    ui->lineEdit_execUpPost->clear();
    ui->lineEdit_execDownPre->clear();
    ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
    ui->checkBox_debug->setCheckState(Qt::Unchecked);

    ui->pushButton_generalAdvanced->setChecked(false);
    showAdvanced();
}


void GeneralWidget::createActions()
{
    connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
    connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter()));
    connect(ui->comboBox_after->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addAfter()));
    connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
    connect(ui->comboBox_bindto->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addBindTo()));
}


void GeneralWidget::addAfter()
{
    ui->listWidget_after->addItem(ui->comboBox_after->currentText());
}


void GeneralWidget::addBindTo()
{
    ui->listWidget_bindto->addItem(ui->comboBox_bindto->currentText());
}
Exemple #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();
}
Exemple #6
0
//for updating to future instances of the list
void objlink::update(HWND hwnd, const char *heading, int level)   //update the child list's order to game's child list's order
{
  if (!child && getChildren(obj))
  {    
    object *children = getChildren(obj);
    
    if ((unsigned long)children < (unsigned long)objects || (unsigned long)children > (unsigned long)&objects[96])
    {
      return;
    }
    
    if (children)
    {
      addChild(children);
      child->build(hwnd, "Object", level+1);

      objlink *next_child = child;
      while (next_child->obj->process.sibling)
      {
        next_child = next_child->addAfter(next_child->obj->process.sibling);
        next_child->build(hwnd, "Object", level+1);
      }
    }
    
    return;
  }
  else if (child && !getChildren(obj))
  {
    objlink *victim = child;

    while (victim)
    {
      objlink *tmp = victim->next;
      victim->deleteNode(hwnd);
      delete victim;
      victim = tmp;
    }
    
    child = 0;
    
    return;        //1  2
  }                //2          
  
  bool equiv = false;
  objlink *diff_pt = diff(equiv);
     
  if (!equiv && !diff_pt)
  {
    if (child->obj != getChildren(obj))
    {
      child->deleteNode(hwnd);
      delete child;
      child = 0;
      addChild(getChildren(obj));
      child->makeNode(hwnd, heading, level+1);
      diff_pt=child;
    }
    else
    {
      object *children = getChildren(obj);
      object *nextchild = children->process.sibling;
      objlink *nextlink = addAfter(nextchild);
      nextlink->makeNode(hwnd, heading, level+1);
      diff_pt = diff(equiv);
    }
  }
    
  while(!equiv) 
  { 
    object *newlinkobj;
      
    if (diff_pt->next == 0)
    {
      object *newlinkobj = diff_pt->obj->process.sibling;

      while (newlinkobj)
      {
        diff_pt = diff_pt->addAfter(newlinkobj, hwnd, heading, level+1); 
        newlinkobj = diff_pt->obj->process.sibling;
      }

      equiv = true; //ends loop
    }
    else if (diff_pt->obj->process.sibling == 0)
    {
      objlink *victim = diff_pt->next;

      while (victim)
      {
        objlink *tmp = victim->next;
        victim->deleteNode(hwnd);
        delete victim;
        victim = tmp;
      }

      equiv = true;  //ends loop
    }
    else
    {
      object *rec = diff_pt->next->obj;
      object *gam = diff_pt->obj->process.sibling;

      int n=1;
      do
      {
        if (rec)                                              
        {
          object *newlinkobj = diff_pt->obj->process.sibling;
          
          if (!diff_pt->next ||
              !diff_pt->next->obj->process.sibling ||
              rec == diff_pt->next->obj->process.sibling)   
          {  
            objlink *_next = diff_pt->next;   //cant have name next...
       
            //add the n objects starting at link     
            for (int lp = 0; lp < n-1 && newlinkobj; lp++)
            {
              _next = _next->addAfter(newlinkobj, hwnd, heading, level+1);
              newlinkobj = newlinkobj->process.sibling;
            }
                  
            break;
          }
        }
        if (gam)
        {
          if (!diff_pt->next->next ||
              !diff_pt->next->next->obj ||
              gam == diff_pt->next->next->obj)
          {
            //remove the n objects starting after link
            for (int lp = 0; lp < n-1 && diff_pt; lp++)
            {     
              diff_pt->next->deleteNode(hwnd);
              delete diff_pt->next;
              diff_pt = diff_pt->next;
            }
             
            break;
          }
        }
               
        n++;

        diff_pt = diff_pt->next;
 
      } while (diff_pt);
      
      diff_pt = diff(equiv);
    }
  }    

  //update all child nodes as well
  objlink *link = child;
  while (link)
  {
    child->update(hwnd, heading, level+1);
    link = link->next;
  }    
} 
Exemple #7
0
objlink *objlink::addAfter(object *_obj, HWND hwnd, const char *heading, int level)
{
  objlink *newnode = addAfter(_obj);
  newnode->makeNode(hwnd, heading, level);
  return newnode;
}
Exemple #8
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;
		}
		}
	}
}