Example #1
0
void TierWindow::openCategoryEdit(TierCategory *c)
{
    helper = new ConfigForm("Delete Category", "Apply", this);
    currentEdit = c->name();
    currentType = CategoryT;
    currentTierCat = c;

    helper->addConfigHelper(new ConfigLine("Name", currentEdit));

    {
        QStringList parents;
        parents << "";
        QList<TierCategory *> cats = dataTree->gatherCategories();
        foreach(TierCategory *c, cats) {
            parents << c->name();
        }
        parent = dataTree->getParentCategory(c)->name();
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Category", parent, parents, parents));
    }

    helper->addConfigHelper(new ConfigSpin("Category display order", c->displayOrder, -100, 100));

    internalWidget = helper->generateConfigWidget();
    updateInternalWidget();

    connect(helper, SIGNAL(button1()), SLOT(deleteCurrent()));
    connect(helper, SIGNAL(button2()), SLOT(updateCategory()));
}
RemoteCommandConfigWidget::RemoteCommandConfigWidget(Transport* t, QWidget *parent) :
		QWidget(parent),
		ui(new Ui::RemoteCommandConfigWidget)
{
	Q_ASSERT(t);
	qDebug() << "RemoteCommandConfigWidget::RemoteCommandConfigWidget for" << t->getDescription();
	current = NULL;
	transport = t;
	ui->setupUi(this);

	connect(ui->commandTable, SIGNAL(clicked(QModelIndex)), this, SLOT(commandTableClicked(QModelIndex)));
	connect(ui->saveCommandButton, SIGNAL(clicked()), this, SLOT(saveCurrent()));
	connect(ui->addCommandButton, SIGNAL(clicked()), this, SLOT(addNewCommand()));
	connect(ui->removeCommandButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
	connect(ui->testCommandButton, SIGNAL(clicked()), this, SLOT(testCurrent()));

	connect(ui->commandEdit, SIGNAL(textEdited(QString)), this, SLOT(madeUpdate()));
	connect(ui->timeoutSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate()));
	connect(ui->reconnectCheck, SIGNAL(toggled(bool)), this, SLOT(madeUpdate()));
	connect(ui->retiesSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate()));

	model.setHorizontalHeaderLabels(QStringList() << "Section" << "Remote Command Description");
	ui->commandTable->setModel(&model);
	ui->commandTable->horizontalHeader()->setStretchLastSection(true);

	populateTable();

	if (model.rowCount()>0)
	{
		ui->commandTable->selectRow(0);
		commandTableClicked(ui->commandTable->currentIndex());
	}
}
Example #3
0
void Q3DataBrowser::del()
{
    QSqlRecord* buf = d->frm.record();
    Q3SqlCursor* cur = d->cur.cursor();
    if (!buf || !cur)
        return;
    QSql::Confirm conf = QSql::Yes;
    switch (d->dat.mode()){
    case QSql::Insert:
        if (confirmCancels())
            conf = confirmCancel(QSql::Insert);
        if (conf == QSql::Yes) {
            cur->editBuffer(true); /* restore from cursor */
            readFields();
            d->dat.setMode(QSql::Update);
        } else
            d->dat.setMode(QSql::Insert);
        break;
    default:
        if (confirmDelete())
            conf = confirmEdit(QSql::Delete);
        switch (conf) {
        case QSql::Yes:
            emit primeDelete(buf);
            deleteCurrent();
            break;
        case QSql::No:
        case QSql::Cancel:
            break;
        }
        d->dat.setMode(QSql::Update);
        break;
    }
}
Example #4
0
/*   BFS   */
void BFS(GraphRef G, int s){
   ListRef Q = newList();
   int v, w, i;
   G->source = s;
   
   insertFront(Q, s);
   G->color[s] = 2;
   G->distance[s] = 0;
   while(getLength(Q) > 0){
      moveTo(Q, 0);
      v = getCurrent(Q);
      G->color[v] = 3;
      deleteCurrent(Q);
      if(!isEmpty(G->adj[v])){
         moveTo(G->adj[v], 0);
         for(i=0;i<getLength(G->adj[v]);i++){
            w = getCurrent(G->adj[v]);
            if(G->color[w] < 2){
               G->color[w] = 2;
               G->parent[w] = v;
               G->distance[w] = G->distance[v]+1;
               insertBack(Q, w);
            }
            if(i<getLength(G->adj[v])-1){
               moveNext(G->adj[v]);
            }
         }
      }
   }
   freeList(&Q);
}
Example #5
0
void XSLExpress::settingsChosen( const QString & text )
{
    if( text.isEmpty() || !mSettings->contains(text) )
        return;

    QStringList settings =  mSettings->value(text,"").toString().split("\n", QString::KeepEmptyParts );
    if( settings.count() < 3 )
        return;

    QString xslFilename = settings.at(2);
    if( !QFile::exists(xslFilename) )
    {
        if( QMessageBox::question(this,tr("XSLExpress"),tr("The XSL file specified in these settings cannot be found. Do you wish to delete these settings?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::Yes )
            deleteCurrent();
        return;
    }

    ui->replaceThis->setText( settings.at(0) );
    ui->replaceWith->setText( settings.at(1) );
    ui->xslFile->setText( xslFilename );

    for(int i=0; i < qMin(aParameterValues.count(),(settings.count()-3)/2); i++)
    {
        aParameterNames.at(i)->setText( settings.at(3 + 2*i) );
        aParameterValues.at(i)->setText( settings.at(3 + 2*i + 1) );
    }

    if( aParameterValues.count() != (settings.count()-3)/2 )
    {
        QMessageBox::information(this,tr("XSLExpress"),tr("The number of parameters in the XSL file and in the saved settings does not match. You should recheck the values to see if they are correct."));
    }
}
Example #6
0
int main(){
	/*make list and output file*/
    ListHndl TheList = newList();
    FILE *out = fopen("out.out", "w");
    
    /*test empty in empty case*/
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    printf("testing insert one number\n");
    insertAtFront(TheList,(unsigned long*)25728);
    printf("%lu\n",(unsigned long)getFirst(TheList));
    printf("%lu\n",(unsigned long)getLast(TheList));
    /*should have same value*/
    
    printf("testing list with three numbers\n");
    insertAtFront(TheList,(unsigned long*)1589458);
    insertAtBack(TheList,(unsigned long*)35762111234);
    printf("%lu\n",(unsigned long)getFirst(TheList));
    
    /*test empty in full case*/
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    
	/*test moving the current pointer around*/
    moveFirst(TheList);
    moveNext(TheList);
    printf("%lu\n",(unsigned long)getCurrent(TheList));
    moveLast(TheList);
    movePrev(TheList);
    printf("%lu\n",(unsigned long)getCurrent(TheList));
    
	/*test printList*/
    printList(out, TheList);
    
	/*test makeEmpty*/
    makeEmpty(TheList);
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    
	/*test inserting functions*/
    insertAtFront(TheList,(unsigned long*)2);
    insertAtFront(TheList,(unsigned long*)1);
    insertAtFront(TheList,(unsigned long*)4);
    insertAtBack(TheList,(unsigned long*)4);
    moveLast(TheList);
    insertBeforeCurrent(TheList,(unsigned long*)3);
    printList(out,TheList);
    deleteFirst(TheList);
    deleteCurrent(TheList);
    deleteLast(TheList);
    printList(out,TheList);
    
    makeEmpty(TheList);
    printList(out,TheList);
    
	/*free list and close output file*/
    freeList(&TheList);
    fclose(out);
    return 0;
}
Example #7
0
bool g_scheduler::applySwitch() {

	g_address_space::switch_to_space(current->value->process->pageDirectory);
	g_gdt_manager::setTssEsp0(current->value->kernelStackEsp0);

	// Eliminate if dead
	if (!current->value->alive) {

		// If the current task is not a process, we can immediately remove it.
		// Otherwise, we have to check if all the processes child threads are dead,
		// once this is done, the process is also kill.
		if (current->value->type != g_thread_type::THREAD_MAIN || g_tasking::killAllThreadsOf(current->value->process)) {
			deleteCurrent();
		}

		return false;
	}

	/*
	 TODO
	 Hier war das Problem, dass wenn ich einen IDLE-Prozess übersprungen hab während alle
	 anderen "waiting" oder nicht "alive" waren, alles komplett gefreggt ist. Allerdings
	 hab ich grad keinen Nerv mir das weiter anzuschauen, deswegen bleibt das hier ^-^
	 */

	// Skip idler if possible
	if (current->value->priority == g_thread_priority::IDLE) {

		// Check if any other process is available (not idling or waiting)
		g_list_entry<g_thread*> *n = taskList;
		while (n) {
			if (n->value->priority != g_thread_priority::IDLE && n->value->alive && !n->value->isWaiting()) {
				// skip the idler
				return false;
			}

			n = n->next;
		}
	}

	// Waiting must be done after the switch because it accesses userspace data
	bool keepWaiting = handleWaiting();
	if (keepWaiting) {
		return false;
	}

	// Set segments for user thread, set segment to user segment
	g_gdt_manager::setUserThreadAddress(current->value->user_thread_addr);
	current->value->cpuState->gs = 0x30; // User pointer segment

	// Switch successful
	return true;
}
Example #8
0
void deleteHashNode(HashTable H, char* name){
    assert (H != NULL);
    ListHndl slot = H->array[hash((unsigned char*)name) % H->tableSize];
    if(isEmpty(slot)) return;
    moveFirst(slot);
    while(!offEnd(slot)){
        HashNode temp = getCurrent(slot);
        if(strcmp(name, temp->name) == 0){
            ListHndl L = temp->L;
            freeList(&L);
            deleteCurrent(slot);
        }else moveNext(slot);
    }
}
Example #9
0
bool g_scheduler::eliminateIfDead(g_thread* thread) {

	// Eliminate if dead
	if (!thread->alive) {
		// Threads can be deleted immediately. For processes, all associated threads must be deleted first.
		// This checks if the task is either no main thread, or all associated threads are already dead.
		if ((thread->type != g_thread_type::THREAD_MAIN) || g_tasking::killAllThreadsOf(thread->process)) {
			deleteCurrent();
		}

		return true;
	}

	return false;
}
Example #10
0
void deleteListNode(HashTable H, char* name, int num){
    assert (H != NULL);
    ListHndl L = lookup(H, name);
    if(L == NULL) return;
    moveFirst(L);
    while(!offEnd(L)){
        ListNode temp = getCurrent(L);
        if(temp->num == num){
            deleteCurrent(L);
            break;
        }
        moveNext(L);
    }
    /* if library list of book ends up being empty, delete the book */
    if(isEmpty(L)) deleteHashNode(H, name);
}
NewStreamView::NewStreamView() :
mStreams(SettingsManager::getSettingsManager()->getStreams())
{
    setupUi(this);
    nameLineEdit->setDisabled(true);
    urlLineEdit->setDisabled(true);
    setWindowTitle("Add new stream");
    for (auto it(mStreams.begin()); it != mStreams.end(); ++it)
    {
        listWidget->addItem (it->first);
    }
    connect(newButton, SIGNAL(clicked()), this, SLOT(addNew()));
    connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
    connect(mStoreButton, SIGNAL(clicked()), this, SLOT(storeStreams()));
    connect(nameLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(storeName(const QString &)));
    connect(urlLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(storeUrl(const QString &)));
    connect(listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateEdits()));
}
DataDisplayEditorForm::DataDisplayEditorForm(QWidget *parent) :
		QWidget(parent),
		ui(new Ui::DataDisplayEditorForm),
		current(NULL)
{
	ui->setupUi(this);


	connect(ui->displayTable, SIGNAL(clicked(QModelIndex)), this, SLOT(displayTableClicked(QModelIndex)));
	connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveCurrent()));
	connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addNewDataDisplay()));
	connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
	connect(ui->testButton, SIGNAL(clicked()), this, SLOT(testCurrent()));
        connect(&GnosticApp::getInstance(), SIGNAL(configUpdated(GnosticApp::ConfigType)), this, SLOT(externalUpdate(GnosticApp::ConfigType)));

	model.setHorizontalHeaderLabels(QStringList() << "Section" << "Display Description");
	ui->displayTable->setModel(&model);
	ui->displayTable->horizontalHeader()->setStretchLastSection(true);
	populateTable();

	ui->saveButton->setEnabled(false);
}
Example #13
0
XSLExpress::XSLExpress(QWidget *parent)
    : QWidget(parent),
      ui(new Ui::XSLExpressClass)
{
    ui->setupUi(this);

    mSettings = new QSettings("AdamBaker","XSLExpress");

    setParameterBoxVisibility();

    populateCombo();

    connect( ui->process, SIGNAL(clicked()), this, SLOT(process()) );
    connect( ui->inputFiles, SIGNAL(drop()), this, SLOT(autoProcess()) );
    connect( ui->saveCurrent, SIGNAL(clicked()), this, SLOT(saveCurrent()) );
    connect( ui->deleteCurrent, SIGNAL(clicked()), this, SLOT(deleteCurrent()) );
    connect( ui->savedSettings, SIGNAL(currentIndexChanged(QString)), this, SLOT(settingsChosen(QString)) );
    connect( ui->getParametersWithDefaults, SIGNAL(clicked()), this, SLOT(loadParametersWithDefaults()));
    connect( ui->clearValues, SIGNAL(clicked()), this, SLOT(clearValues()) );
    connect( ui->xslFile, SIGNAL(textChanged(QString)), this, SLOT(loadParametersWithDefaults()) );
    connect( ui->copyButton, SIGNAL(clicked(bool)), this, SLOT(copyCall()) );
}
Example #14
0
         dialog::RESULT textInput::run()
         {
            if (!init(size_))
               {
                  return dialog::R_NCREAT;
               }

            refresh();

            bool                 cont  = true;
            keyMapping::KEYLABEL label = keyMapping::K_UNDEF;
            t_uint               key   = 0;

            while (cont)
               {
                  key = readAnyKey();
                  if (!handleKeyboard(key, label))
                     {
                        // Got something that is not recognized as one of
                        // the keys that are used.
                        enterKey(key);
                        continue;
                     }

                  switch (label)
                     {
                     case keyMapping::K_QUITSCREEN:
                        {
                           cont = false;
                           break;
                        }
                     case keyMapping::K_HELP:
                        {
                           if (showHelp())
                              {
                                 // Resized.
                                 return dialog::R_RESIZE;
                              }
                           refresh();
                           break;
                        }
                     case keyMapping::K_DELETE:
                        {
                           deleteCurrent();
                           refresh();
                           break;
                        }
                     case keyMapping::K_SELECT:
                        {
                           // Done setting session name.
                           cont         = false;
                           text_entered = true;
                           break;
                        }
                     case keyMapping::K_RESIZE:
                        {
                           return dialog::R_RESIZE;
                           break;
                        }
                     default:
                        {
                           refresh();
                           break;
                        }
                     }
               }

            return dialog::R_QUIT;
         }
Example #15
0
// Queries the use to find out what actions they want to perform.
// Runs continuously until the user selects 'Quit'. Contains basic
// operations for manipulating a doubly linked list, except adding
// a new node.
int query(ring *r) {
	printf("What would you like to do?\n");
	printf("1 - View previous website\n");
	printf("2 - View next website\n");
	printf("3 - View latest website\n");
	printf("4 - View first website\n");
	printf("5 - Open current website\n");
	printf("6 - Remove from history\n");
	printf("7 - Print number of links stored\n");
	printf("8 - Print all links (from last to first)\n");
	printf("9 - Quit\n");
	char option, nl;
	char link[120] = "open ";
	scanf("%c%c", &option, &nl);
	
	switch(option) {
		case '1':
			shiftForward(r);
			printf("Previous:\n%s\n", getCurrent(r));
			return 1;
			break;
		case '2':
			shiftBackward(r);
			printf("Next:\n%s\n", getCurrent(r));
			return 1;
			break;
		case '3':
			setFirst(r);
			printf("Latest:\n%s\n", getCurrent(r));
			return 1;
			break;
		case '4':
			setLast(r);
			printf("First:\n%s\n", getCurrent(r));
			return 1;
			break;
		case '5':
			printf("Opening:\n%s\n", getCurrent(r));
			strcat(link, getCurrent(r));
			system(link);
			return 1;
			break;
		case '6':
			deleteCurrent(r);
			printf("Previous:\n%s\n", getCurrent(r));
			return 1;
			break;
		case '7':
			printf("There are %d links stored.\n", getLength(r));
			printf("Current: \n%s\n", getCurrent(r));
			return 1;
			break;
		case '8':
			printAll(r);
			printf("\nCurrent: \n%s\n", getCurrent(r));
			return 1;
			break;
		case '9':
			return 0;
			break;
		default:
			printf("Please enter a valid option!\n");
			return 1;
	}
}
Example #16
0
void LogViewWindow::rightButtonClicked(QTreeWidgetItem * pItem, const QPoint &)
{
	if(!pItem)
		return;
	m_pListView->setCurrentItem(pItem);

    QMenu * pPopup = new QMenu(this);
	if(((LogListViewItem *)pItem)->childCount())
	{
		//pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::UserList)),__tr2qs_ctx("Export all log files to","log"),m_pExportLogPopup);
		pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)),__tr2qs_ctx("Remove all log files within this folder","log"),this,SLOT(deleteCurrent()));
	} else {
        pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Floppy)),__tr2qs_ctx("Export log file to","log"))->setMenu(m_pExportLogPopup);
		pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)),__tr2qs_ctx("Remove log file","log"),this,SLOT(deleteCurrent()));
	}

	pPopup->exec(QCursor::pos());
}
void RendererWidget::keyPressEvent(QKeyEvent* event)
{
    if(event->key() == Qt::Key_F11)
        emit F11_pressed();

    if(event->key() == Qt::Key_Shift)
        _shiftPressed=true;

    if(_editMode == SCENE_EDITOR && _rightMouse && _stateReady == NO_INTERACTION)
    {
        if(event->key() == Qt::Key_W) _renderer->setMoveDirection(0, true);
        else if(event->key() == Qt::Key_A) _renderer->setMoveDirection(1, true);
        else if(event->key() == Qt::Key_S) _renderer->setMoveDirection(2, true);
        else if(event->key() == Qt::Key_D) _renderer->setMoveDirection(3, true);
        else if(event->key() == Qt::Key_Shift) _renderer->setSpeedBoost(true);

//        else if(event->key() == Qt::Key_G)
//        {
//            _stateReady = TRANSLATE_MODE;
//            emit startEdit();
//            emit stateChanged(_stateReady);
//        }
//        else if(event->key() == Qt::Key_F)
//        {
//            _stateReady = SCALE_MODE;
//            emit startEdit();
//            emit stateChanged(_stateReady);
//        }
//        else if(event->key() == Qt::Key_R)
//        {
//            _stateReady = ROTATE_MODE;
//            emit startEdit();
//            emit stateChanged(_stateReady);
//        }

        event->accept();
    }
    else if(_editMode == SCENE_EDITOR && _stateReady == NO_INTERACTION)
    {
        if(event->key() == Qt::Key_G && _stateReady != TRANSLATE_MODE)
        {
            _stateReady = TRANSLATE_MODE;
            emit startEdit();
            emit stateChanged(_stateReady);
        }
        else if(event->key() == Qt::Key_F && _stateReady != SCALE_MODE)
        {
            _stateReady = SCALE_MODE;
            emit startEdit();
            emit stateChanged(_stateReady);
        }
        else if(event->key() == Qt::Key_R && _stateReady != ROTATE_MODE)
        {
            _stateReady = ROTATE_MODE;
            emit startEdit();
            emit stateChanged(_stateReady);
        }
        else if(event->key() == Qt::Key_Shift) _renderer->setSpeedBoost(true);
        else if(event->key() == Qt::Key_Escape) emit escapePressed();
        else if(event->key() == Qt::Key_Delete) emit deleteCurrent();

        event->accept();
    }
    else if(_editMode == SCENE_EDITOR && _stateReady >= TRANSLATE_MODE && _stateReady <= TRANSLATE_Z_MODE)
    {
        int newState = _stateReady;
        if(event->key() == Qt::Key_X)
            newState = TRANSLATE_X_MODE;
        else if(event->key() == Qt::Key_Y)
            newState = TRANSLATE_Y_MODE;
        else if(event->key() == Qt::Key_Z)
            newState = TRANSLATE_Z_MODE;

        if(newState != _stateReady)
        {
            _stateReady = newState;
            emit stateChanged(_stateReady);
        }

        event->accept();
    }
    else if(_editMode == SCENE_EDITOR && _stateReady >= SCALE_MODE && _stateReady <= SCALE_Z_MODE)
    {
        int newState = _stateReady;
        if(event->key() == Qt::Key_X)
            newState = SCALE_X_MODE;
        else if(event->key() == Qt::Key_Y)
            newState = SCALE_Y_MODE;
        else if(event->key() == Qt::Key_Z)
            newState = SCALE_Z_MODE;

        if(newState != _stateReady)
        {
            _stateReady = newState;
            emit stateChanged(_stateReady);
        }

        event->accept();
    }
    else if(_editMode == SCENE_EDITOR && _stateReady >= ROTATE_MODE && _stateReady <= ROTATE_Z_MODE)
    {
        int newState = _stateReady;
        if(event->key() == Qt::Key_X)
            newState = ROTATE_X_MODE;
        else if(event->key() == Qt::Key_Y)
            newState = ROTATE_Y_MODE;
        else if(event->key() == Qt::Key_Z)
            newState = ROTATE_Z_MODE;

        if(newState != _stateReady)
        {
            _stateReady = newState;
            emit stateChanged(_stateReady);
        }

        event->accept();
    }
}
Example #18
0
int main (){

  /***Exercise List constructor***/
  ListHndl List;
  List = NULL;
  List = newList ();

  if(List){
    printf("List Created\n");
  }else{
    printf("List Not Created\n");
  }
  
  printf("isEmpty %d\n",isEmpty(List)); /*should print 1*/
  
  /***Populate with test data***/
  int i;
  for(i=0; i<=4; i++){
    insertAtFront(List,i);
  }
  
  printList(stdout, List);
  
  printf("isEmpty %d\n",isEmpty(List)); /*should print 0*/

  int j;
  for(j=5; j<=9; j++){
    insertAtBack(List,j);
  } 
  printList(stdout, List);
  
  /***Exercise all access functions***/
  printf("offEnd %d\n",offEnd(List));/*should print 0*/
  
  printf("atFirst %d\n",atFirst(List));/*should print 0*/
  
  printf("atLast %d\n",atLast(List));/*should print 0*/
  
  printf("getFirst %d\n", getFirst(List));/*should print 4*/
  
  printf("getLast %d\n", getLast(List));/*should print 9*/
  
  printf("getCurrent %d\n", getCurrent(List));/*should print 0*/
  
  /***Exercise all removal manipulation functions***/
  deleteLast(List);
  printList(stdout, List);
  printf("getLast %d\n", getLast(List));/*should print 8*/
  
  deleteFirst(List);
  printList(stdout, List);
  printf("getFirst 	\n", getFirst(List));/*should print 3*/
  
  deleteCurrent(List);
  printList(stdout, List);
  
  moveLast(List);
  printList(stdout, List);
  movePrev(List);
  printList(stdout, List);
  moveNext(List);
  printList(stdout, List);

  /***Exercise various edge cases***/  
  makeEmpty(List);
  insertAtFront(List, 40);
  moveFirst(List);
  deleteCurrent(List);
  
  insertAtFront(List, 41);
  insertAtBack(List, 42);
  moveFirst(List);
  insertBeforeCurrent(List, 43);
  printList(stdout, List);
  
  /***Exercise List destructors***/
  
  deleteCurrent(List);
  printList(stdout, List);
  
  makeEmpty(List);
  printf("offEnd %d\n",offEnd(List));/*should print 1*/
  

  freeList(&List);
  return(0);
} 
Example #19
0
void TierWindow::openTierEdit(Tier *t)
{
    helper = new ConfigForm("Delete Tier", "Apply", this);
    currentEdit = t->name();
    currentType = TierT;
    currentTier = t;

    helper->addConfigHelper(new ConfigLine("Name", currentEdit));

    {
        QStringList parents;
        parents << "";
        QList<TierCategory *> cats = dataTree->gatherCategories();
        foreach(TierCategory *c, cats) {
            parents << c->name();
        }
        parent = dataTree->getParentCategory(t)->name();
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Category", parent, parents, parents));
    }
    {
        QStringList parents;
        parents << "";
        QList<Tier *> tiers = dataTree->gatherTiers();
        foreach(Tier *t, tiers) {
            parents << t->name();
        }
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Tier", t->banParentS, parents, parents));
    }

    QStringList genS = QStringList() << "Any";
    QList<Pokemon::gen> gens;
    gens.push_back(0);
    for (int i = GenInfo::GenMin(); i <= GenInfo::GenMax(); i++) {
        for (int j = 0; j < GenInfo::NumberOfSubgens(i); j++) {
            gens << Pokemon::gen(i, j);
            genS << QString("%1 (%2)").arg(GenInfo::Gen(gens.back().num), GenInfo::Version(gens.back()));
        }
    }

    helper->addConfigHelper(new ConfigCombo<Pokemon::gen>("Generation", t->m_gen, genS,  gens ));
    helper->addConfigHelper(new ConfigCheck("Ban pokemon/moves/items (uncheck to restrict the choice to them instead)", t->banPokes));
    helper->addConfigHelper(new ConfigSpin("Max number of pokemon", t->numberOfPokemons, 1, 6));
    helper->addConfigHelper(new ConfigText("Pokemon", pokemons));
    helper->addConfigHelper(new ConfigLine("Moves", moves));
    helper->addConfigHelper(new ConfigLine("Items", items));
    helper->addConfigHelper(new ConfigSpin("Max number of restricted pokemon", t->maxRestrictedPokes, 0, 6));
    helper->addConfigHelper(new ConfigLine("Restricted Pokemon", restrPokemons));
    helper->addConfigHelper(new ConfigSpin("Pokemon's max level", t->maxLevel, 1, 100));

    pokemons = t->getBannedPokes();
    moves = t->getBannedMoves();
    items = t->getBannedItems();
    restrPokemons = t->getRestrictedPokes();

    helper->addConfigHelper(new ConfigCombo<int>("Battle Mode in Find Battle", t->mode, QStringList() << "Singles" << "Doubles" << "Triples"
                                                 << "Rotation Battles",
                                                 QList<int>() << ChallengeInfo::Singles << ChallengeInfo::Doubles << ChallengeInfo::Triples
                                                 << ChallengeInfo::Rotation));

    int clauses = t->clauses;
    for (int i = 0; i < ChallengeInfo::numberOfClauses; i++) {
        this->clauses[i] = (clauses >> i) % 2;

        helper->addConfigHelper(new ConfigCheck(ChallengeInfo::clause(i), this->clauses[i]));
    }

    helper->addConfigHelper(new ConfigSpin("Tier display order", t->displayOrder, -100, 100));

    internalWidget = helper->generateConfigWidget();
    internalWidget->layout()->setMargin(0);
    internalWidget->layout()->setSpacing(0);
    updateInternalWidget();

    connect(helper, SIGNAL(button1()), SLOT(deleteCurrent()));
    connect(helper, SIGNAL(button2()), SLOT(updateTier()));
}
Example #20
0
int main(int argc, char* argv[])
{
    int i;
    ListRef A = newList();
    ListRef B = newList();
	ListRef ACopy = NULL;
	ListRef AB_Cat = NULL;
	insertBack(A, 10);
	insertBack(A, 20);
	insertBack(A, 30);
	insertBack(A, 40);
	insertBack(A, 50);
	insertBack(A, 60);
	printf("equals(A,B)		: %d\n", equals(A, B));
	insertBack(B, 10);
	insertBack(B, 20);
	insertBack(B, 30);
	insertBack(B, 40);
	insertBack(B, 50);
	insertBack(B, 60);
	AB_Cat = catList(A, B);
	printf("printLIST(AB_Cat)	: ");
	printLIST(AB_Cat);
	ACopy = copyList(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("printLIST(ACopy)	: ");
	printLIST(ACopy);
	printf("equals(A,ACopy)		: %d\n", equals(A, ACopy));
	printf("equals(A,B)		: %d\n", equals(A, B));
	printf("printLIST(A)		: ");
	printLIST(A);
	moveTo(A, getLength(A));
	printf("offEnd(A)		: %d\n", offEnd(A));
	moveTo(A, 3);
	insertBeforeCurrent(A, 35);
	insertAfterCurrent(A, 45);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("getCurrent(A)		: %d\n", getCurrent(A));
	movePrev(A);
	printf("getCurrent(A)		: %d\n", getCurrent(A));
	deleteCurrent(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	makeEmpty(B);
	deleteFront(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("getLength(A)		: %d\n", getLength(A));
	printf("isEmpty(A)		: %d\n", isEmpty(A));
	makeEmpty(A);
	printf("isEmpty(A)		: %d\n", isEmpty(A));
	printf("getLength(A)		: %d\n", getLength(A));
	/* printf("printLIST(A)		: ");
	printLIST(A); */
	insertFront(B, 50);
	insertBack(B, 60);
	insertFront(B, 40);
	insertBack(B, 70);
	insertFront(B, 30);
	insertBack(B, 80);
	insertFront(B, 20);
	insertBack(B, 90);
	insertFront(B, 10);
	printf("printLIST(B)		: ");
	printLIST(B);
	printf("offEnd(B)		: %d\n", offEnd(B));
	moveTo(B, 5);
	printf("offEnd(B)		: %d\n", offEnd(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	deleteCurrent(B);
	printf("printLIST(B)		: ");
	printLIST(B);
	/* printf("getCurrent(B) 	: %d\n", getCurrent(B));*/
	moveTo(B, 0);
	printf("getFront(B)		: %d\n", getFront(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	deleteFront(B);
	printf("printLIST(B)		: ");
	printLIST(B);
	printf("getFront(B)		: %d\n", getFront(B));
	/* printf("getCurrent(B)		: %d\n", getCurrent(B)); */
	moveTo(B, (getLength(B)-1));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	printf("getBack(B)		: %d\n", getBack(B));
	deleteBack(B);
	printf("getBack(B)		: %d\n", getBack(B));
	/* printf("getCurrent(B)		: %d\n", getCurrent(B)); */
	moveTo(B, (getLength(B)-1));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	printf("getBack(B)		: %d\n", getBack(B));
	deleteBack(B);
	printf("getBack(B)		: %d\n", getBack(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B)); 
	
	
	
    return(0);
}