void KListWidgetSearchLineTest::testAddItems() { QListWidget listWidget; listWidget.addItem("Matching test item"); listWidget.addItem("Another test item"); KListWidgetSearchLine searchLine(0, &listWidget); searchLine.setText("match"); // The initial filtering is delayed; we have to wait while(!listWidget.item(1)->isHidden()) { QTest::qWait(50); } QVERIFY(!listWidget.item(0)->isHidden()); QVERIFY(listWidget.item(1)->isHidden()); // Add two items listWidget.addItem("Another item that matches the search pattern"); listWidget.addItem("This item should be hidden"); QVERIFY(!listWidget.item(0)->isHidden()); QVERIFY(listWidget.item(1)->isHidden()); QVERIFY(!listWidget.item(2)->isHidden()); QVERIFY(listWidget.item(3)->isHidden()); // Modify an item listWidget.item(3)->setText("Now this item matches"); QVERIFY(!listWidget.item(0)->isHidden()); QVERIFY(listWidget.item(1)->isHidden()); QVERIFY(!listWidget.item(2)->isHidden()); QVERIFY(!listWidget.item(3)->isHidden()); }
Motion* Move::getMove(){ Motion *motion; int fingerCount = frame->hand[0]->detectFingerCount; int frameCount = frame->getFrameCount(); int lineCount = 0; double sumAtan = 0; for (int i = 0; i < frameCount-1; i++){ for (int j = i; i < frameCount-1; j++){ sumAtan = atan2(this->frame->hand[i + 1]->finger[0]->fingerTip.y, this->frame->hand[i + 1]->finger[0]->fingerTip.x) - atan2(this->frame->hand[i]->finger[0]->fingerTip.y, this->frame->hand[i]->finger[0]->fingerTip.x); if (sumAtan>fabs(M_PI / 8)){ this->line[lineCount++]->setIndex(i,j); i = ++j; } } } for (int i = 0; i < lineCount; i++){ double theta; theta = atan2(this->frame->hand[line[i]->getEnd]->finger[0].y - this->frame->hand[line[i]->getStart]->finger[0].y, this->frame->hand[line[i]->getEnd]->finger[0].x - this->frame->hand[line[i]->getStart].x); motion[i] = searchLine(theta); } }
void goForward(){ for( int a = 0 ; a < 18 ; a ++ ){ searchLine(); setMotorA( FORWARDVEL +1); setMotorB( FORWARDVEL ); delay(390); setMotorA( 0 ); setMotorB( 0 ); } }
void KTreeViewSearchLineWidget::createWidgets() { QLabel *label = new QLabel( i18n("S&earch:"), this ); label->setObjectName( QStringLiteral("kde toolbar widget") ); searchLine()->show(); label->setBuddy( d->searchLine ); label->show(); QHBoxLayout* layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 0 ); layout->addWidget( label ); layout->addWidget( d->searchLine ); }
void KTreeWidgetSearchLineWidget::createWidgets() { if (!k->clearButton) { k->clearButton = new QToolButton(this); k->clearButton->setText(tr("Clear")); } k->clearButton->show(); searchLine()->show(); connect(k->clearButton, SIGNAL(clicked()), k->searchLine, SLOT(clear())); QHBoxLayout* layout = new QHBoxLayout(this); layout->setSpacing(2); layout->setMargin(0); layout->addWidget(k->clearButton); layout->addWidget(k->searchLine); }
void LineFollow_Task(void* param) { while(1) { switch (readCycle){ case 0: SHIFT_Set(0x81); /* 10000001 => 10001000 */ MUX_Set(0,0); break; case 1: SHIFT_Set(0x42); /* 01000010 => 01000100 */ MUX_Set(0,1); break; case 2: SHIFT_Set(0x24); /* 00100100 => 00100010 */ MUX_Set(1,0); break; case 3: SHIFT_Set(0x18); /* 00011000 => 00010001 */ MUX_Set(1,1); break; } /* Let CNY70 do the work : task delay for 250us */ OSTimeDly(OS_TICKS_PER_SEC/4000); /* Read data from ADC */ /* Sensor 6-pack reading cycle (4 cycle = 24 sensors) */ ADCExt_Read(readCycle); SHIFT_Set(0x00); readCycle++; if(readCycle == 4) { readCycle = 0; /* Process the measured data */ frontAverage /= 20; /* the final front average value */ rearAverage /= 4; /* the final rear average value */ if(lineFollowState == INIT_STATE){ if(searchLine()){ edgeValueVerifyingCounter++; if(edgeValueVerifyingCounter > PEAK_VERIF_CNTR_THRES){ /* TODO can we pass to ON_LINE state? */ lineFollowState = ON_LINE; } } } else{ /* TODO process sensor data */ /* FIXME this is the init line searching. Replace with * runtime line searching (same but max. 3 lines) */ if(searchLine()){ /* Line found, Change the state if needed */ LineFollow_StateMachine(); } } maximumSensorValue = 0; frontAverage = 0; } } }