void ListWidget::keyPressEvent(QKeyEvent *event) //On key press. Handles enter key, up arrow, down arrow. { switch (event->key()) { case Qt::Key_Enter: //Enter/return key case Qt::Key_Return: emit attemptedSelect(); break; case Qt::Key_Up: //Up arrow if (currentRow() != 0) setCurrentRow(currentRow()); else { selectionModel()->clearSelection(); m_CompletionBox->activateWindow(); m_CompletionBox->setFocus(); } break; case Qt::Key_Down: //Down arrow if (currentRow() != count() - 1) setCurrentRow(currentRow()); else { selectionModel()->clearSelection(); m_CompletionBox->activateWindow(); m_CompletionBox->setFocus(); } break; case Qt::Key_Escape: hide(); break; } QListWidget::keyPressEvent(event); }
void Formamendweight::DataEntered(int nWeight, int nAxls) { //TODO:计算超重率/ //表格显示数据 if(flag1==true) { if(table->rowCount()<=0 || table->currentRow()<=0) { ui->tableWidget->insertRow(0); ui->tableWidget->setItem(0, 6, new QTableWidgetItem("输入")); ui->tableWidget->setItem(0, 5, new QTableWidgetItem(QString::number(0))); ui->tableWidget->setItem(0, 4, new QTableWidgetItem(QString::number(OverWeightRate(nWeight,nAxls)/10.0))); ui->tableWidget->setItem(0, 3, new QTableWidgetItem(QString::number(nWeight))); ui->tableWidget->setItem(0, 2, new QTableWidgetItem(QString::number(getWeightLimit(nAxls)/1000))); ui->tableWidget->setItem(0, 1, new QTableWidgetItem(QString::number(nAxls))); } else { int tmp = table->currentRow(); ui->tableWidget->insertRow(tmp); ui->tableWidget->setItem(tmp, 6, new QTableWidgetItem("输入")); ui->tableWidget->setItem(tmp, 5, new QTableWidgetItem(QString::number(0))); ui->tableWidget->setItem(tmp, 4, new QTableWidgetItem(QString::number(OverWeightRate(nWeight,nAxls)/10.0))); ui->tableWidget->setItem(tmp, 3, new QTableWidgetItem(QString::number(nWeight))); ui->tableWidget->setItem(tmp, 2, new QTableWidgetItem(QString::number(getWeightLimit(nAxls)/1000))); ui->tableWidget->setItem(tmp, 1, new QTableWidgetItem(QString::number(nAxls))); } setCurrentRow(table->currentRow()); FormWtInfo *Pwt=NULL; getWidgetByType(emFormWtInfo, (QWidget**)&Pwt); //轴数 限载 总重 超限率 Pwt->inexitFormWtInfohead(nAxls,getWeightLimit(nAxls)/1000,nWeight,OverWeightRate(nWeight,nAxls)); Pwt->inexitFormWtInfo(nAxls,getWeightLimit(nAxls)/1000,nWeight,OverWeightRate(nWeight,nAxls),0,tr("输入")); showHHeadNum(); flag1=false; } else if(flag2 == false && flag1 == false) { TWtVehicle veh; TWtDataMgr vehMgr; int nRlt = table->currentRow(); ui->tableWidget->insertRow(nRlt); ui->tableWidget->setItem(nRlt, 6, new QTableWidgetItem("称重")); ui->tableWidget->setItem(nRlt, 5, new QTableWidgetItem(QString::number(veh.getSpeed()))); ui->tableWidget->setItem(nRlt, 4, new QTableWidgetItem(QString::number(veh.GetOverloadRate()/10.0))); ui->tableWidget->setItem(nRlt, 3, new QTableWidgetItem(QString::number(veh.GetWeight()))); ui->tableWidget->setItem(nRlt, 2, new QTableWidgetItem(QString::number(veh.GetLimitWeight()/1000))); ui->tableWidget->setItem(nRlt, 1, new QTableWidgetItem(QString::number(vehMgr.GetVehicleCount()))); setCurrentRow(table->currentRow()); FormWtInfo *Pwt=NULL; getWidgetByType(emFormWtInfo, (QWidget**)&Pwt); //轴数 限载 总重 超限率 // Pwt->inexitFormWtInfohead(nAxls,getWeightLimit(nAxls)/1000,nWeight,OverWeightRate(nWeight,nAxls)); // Pwt->inexitFormWtInfo(nAxls,getWeightLimit(nAxls)/1000,nWeight,OverWeightRate(nWeight,nAxls),0,tr("输入")); showHHeadNum(); } // TWtVehicle veh; }
/** * Make sure the current tab visible. If it is not visible the tabbar scrolls * so that it is visible. */ void KTinyTabBar::makeCurrentTabVisible() { if( !m_activeButton || m_activeButton->isVisible() ) return; //BEGIN copy of resizeEvent int tabbar_width = width() - ( 4 - ( numRows()>3?3:numRows() ) ) * m_navigateSize; int tabs_per_row = tabbar_width / minimumTabWidth(); if( tabs_per_row == 0 ) tabs_per_row = 1; int tab_width = minimumTabWidth(); int needed_rows = m_tabButtons.count() / tabs_per_row; if( needed_rows * tabs_per_row < (int)m_tabButtons.count() ) ++needed_rows; // if we do not need more rows than available we can increase the tab // buttons' width up to maximumTabWidth. if( needed_rows <= numRows() ) { // use available size optimal, but honor maximumTabWidth() tab_width = tabbar_width * numRows() / m_tabButtons.count(); if( tab_width > maximumTabWidth() ) tab_width = maximumTabWidth(); tabs_per_row = tabbar_width / tab_width; // due to rounding fuzzys we have to increase the tabs_per_row if // the number of tabs does not fit. if( tabs_per_row * numRows() < (int)m_tabButtons.count() ) ++tabs_per_row; } //END copy of resizeEvent int index = m_tabButtons.indexOf( m_activeButton ); int firstVisible = currentRow() * tabs_per_row; int lastVisible = ( currentRow() + numRows() ) * tabs_per_row - 1; if( firstVisible >= m_tabButtons.count() ) firstVisible = m_tabButtons.count() - 1; if( lastVisible >= m_tabButtons.count() ) lastVisible = m_tabButtons.count() - 1; if( index < firstVisible ) { setCurrentRow( index / tabs_per_row ); } else if( index > lastVisible ) { const int diff = index / tabs_per_row - ( numRows() - 1 ); setCurrentRow( diff ); } }
void KCompletionBox::up() { const int row = currentRow(); if (row > 0) { setCurrentRow(row - 1); return; } const int lastRow = count() - 1; if (lastRow > 0) { setCurrentRow(lastRow); } }
void KCompletionBox::down() { const int row = currentRow(); const int lastRow = count() - 1; if (row < lastRow) { setCurrentRow(row + 1); return; } if (lastRow > -1) { setCurrentRow(0); } }
void CtrlRegisterList::keydownEvent(wxKeyEvent& evt) { switch (evt.GetKeyCode()) { case WXK_UP: setCurrentRow(std::max<int>(currentRows[category]-1,0)); break; case WXK_DOWN: setCurrentRow(std::min<int>(currentRows[category]+1,cpu->getRegisterCount(category)-1)); break; case WXK_TAB: category = (category+1) % cpu->getRegisterCategoryCount(); Refresh(); break; } }
void QcListWidget::setCurrentRowWithoutAction( int row ) { bool b = _emitAction; _emitAction = false; setCurrentRow( row ); _emitAction = b; }
void PlaylistWindow::selectNext() { auto qdp = currentPlaylistWidget(); int index = qdp->currentRow(); if (index < qdp->count()) qdp->setCurrentRow(index + 1); }
void PlaylistWindow::selectPrevious() { auto qdp = currentPlaylistWidget(); int index = qdp->currentRow(); if (index > 0) qdp->setCurrentRow(index - 1); }
void SyntaxHighlightingList::reload(QString i){ if(!m_issaved){ QMessageBox save_dialog(QMessageBox::Warning,"Jeu de couleur modifié","Le jeu de couleur "+m_current_file+"a été modifé. Voulez-vous l'enregistrer?",QMessageBox::Save|QMessageBox::Abort,this); if(save_dialog.exec()==QMessageBox::Save) save(); } // _lex = HighlightingThemeRegistry::get()->filterByLanguage(_lex.language()).value(i); //on remplit le QListWidget clear(); /* foreach (HighlightingFormat format, _lex) { QListWidgetItem* item =new QListWidgetItem(format.formatName(), this); QFont f = item->font(); f.setBold(format.currentFormat().font().bold()); f.setItalic(format.currentFormat().font().bold()); f.setUnderline(format.currentFormat().font().bold()); item->setFont(f); item->setForeground(format.currentFormat().foreground()); item->setBackground(format.currentFormat().background()); addItem(item); } */ setCurrentRow(0); m_issaved=true; }
void ListTable::createNewRow() { QListWidgetItem * item = 0; switch (type_) { case ListEditor::INT: item = new QListWidgetItem("0"); break; case ListEditor::FLOAT: item = new QListWidgetItem("0.0"); break; default: item = new QListWidgetItem(""); } item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); addItem(item); setItemSelected(item, true); setCurrentRow(row(item)); itemActivated(item); edit(currentIndex()); }
void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const QString& parentName, Database* database) { m_entry = entry; m_database = database; m_create = create; m_history = history; if (history) { setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history"))); } else { if (create) { setHeadline(QString("%1 > %2").arg(parentName, tr("Add entry"))); } else { setHeadline(QString("%1 > %2 > %3").arg(parentName, entry->title(), tr("Edit entry"))); } } setForms(entry); setCurrentRow(0); setRowHidden(m_historyWidget, m_history); }
void KVocTrainTable::setDoc(kvoctrainDoc * rows) { if (defaultItem) endEdit(defaultItem->row(), defaultItem->col(), true, false); KVocTrainTableItem *d = defaultItem; defaultItem = 0; if (rows) { m_doc = rows; setNumRows(rows->numEntries()); setNumCols(QMAX(1+KV_EXTRA_COLS, m_doc->numLangs()+KV_EXTRA_COLS)); setCurrentRow(0, 0); } else { setNumRows(0); setNumCols(1+KV_EXTRA_COLS); m_doc = 0; } if (d == 0) { defaultItem = new KVocTrainTableItem(this, QTableItem::OnTyping, rows); } else { defaultItem = d; defaultItem->setDoc(rows); } //gradecols = gc; }
void EditGroupWidget::loadGroup(Group* group, bool create, Database* database) { m_group = group; m_database = database; if (create) { setHeadline(tr("Add group")); } else { setHeadline(tr("Edit group")); } m_mainUi->editName->setText(m_group->name()); m_mainUi->editNotes->setPlainText(m_group->notes()); m_mainUi->expireCheck->setChecked(group->timeInfo().expires()); m_mainUi->expireDatePicker->setDateTime(group->timeInfo().expiryTime().toLocalTime()); m_mainUi->searchComboBox->setCurrentIndex(indexFromTriState(group->searchingEnabled())); m_mainUi->autotypeComboBox->setCurrentIndex(indexFromTriState(group->autoTypeEnabled())); IconStruct iconStruct; iconStruct.uuid = group->iconUuid(); iconStruct.number = group->iconNumber(); m_editGroupWidgetIcons->load(group->uuid(), database, iconStruct); m_editWidgetProperties->setFields(group->timeInfo(), group->uuid()); setCurrentRow(0); m_mainUi->editName->setFocus(); }
void KCompletionBox::insertItems( const QStringList& items, int index ) { bool block = signalsBlocked(); blockSignals( true ); KListWidget::insertItems( index, items ); blockSignals( block ); setCurrentRow(-1); }
void SettingsList::selectFirst(){ QListWidgetItem* list_item; list_item = item(0); if (list_item){ setCurrentRow(0); } emit(itemActivated(list_item)); }
void TToolbarEditor::onLeftButtonClicked() { int row = active_actions_table->currentRow(); if (row >= 0) { active_actions_table->removeRow(row); setCurrentRow(row); } }
void PartsBinListView::setSelected(int position, bool doEmit) { Q_UNUSED(doEmit); if(position > -1 && position < count()) { item(position)->setSelected(true); } else { setCurrentRow(position); } }
void TToolbarEditor::onUpButtonClicked() { int row = active_actions_table->currentRow(); if (row > 0) { swapRows(row - 1, row); setCurrentRow(row - 1); } }
void TToolbarEditor::onDownButtonClicked() { int row = active_actions_table->currentRow(); if (row >= 0 && row < active_actions_table->rowCount() - 1) { swapRows(row, row + 1); setCurrentRow(row + 1); } }
bool MorkParser::parseTable() { bool Result = true; QString TextId; int Id = 0, Scope = 0; char cur = nextChar(); // Get id while (cur != '{' && cur != '[' && cur != '}' && cur) { if (!isWhiteSpace(cur)) { TextId += cur; } cur = nextChar(); } parseScopeId(TextId, Id, Scope); // Parse the table while (Result && cur != '}' && cur) { if (!isWhiteSpace(cur)) { switch (cur) { case '{': Result = parseMeta('}'); break; case '[': Result = parseRow(Id, Scope); break; case '-': case '+': break; default: { QString JustId; while (!isWhiteSpace(cur) && cur) { JustId += cur; cur = nextChar(); if (cur == '}') { return Result; } } int JustIdNum = 0, JustScopeNum = 0; parseScopeId(JustId, JustIdNum, JustScopeNum); setCurrentRow(Scope, Id, JustScopeNum, JustIdNum); } break; } } cur = nextChar(); } return Result; }
ListBox::ListBox(imli_context_t ctx, std::vector<SylString>& wordlist, QTextCharFormat& f, QWidget* parent) : QListWidget(parent), ctx_(ctx), data_(wordlist), format_(f) { CreateItems(); setCurrentRow(0); }
void QcListWidget::setItems( const QVariantList & items ) { _emitAction = false; clear(); Q_FOREACH( const QVariant & item, items ) addItem( item.toString() ); setCurrentRow( 0 ); _emitAction = true; }
void VerticesList::resetMesh() { clear(); for (int i=0; i<mesh->getVSize(); i++) addItem(new VertexItem(mesh->getV(i))); if (count() > 0) { setCurrentRow(0); sendInfo(currentItem()); } }
void MyListWidget::setCurrentItem(CatItem catItem){ for(int i=0; i< count();i++){ QListWidgetItem* listWidgetItem = item(i); if((listWidgetItem->data((ROLE_ITEM_PATH)).toString() == catItem.getPath())){ setCurrentRow(i); break; } } }
void My_List_Widget::wheelEvent(QWheelEvent* e) { if ( e->angleDelta().y() > 0 ) { if ( currentRow() == 0 ) setCurrentRow(count()-1); else setCurrentRow(currentRow()-1); e->accept(); } else if ( e->angleDelta().y() < 0 ) { if ( currentRow() == count() -1 ) setCurrentRow(0); else setCurrentRow(currentRow()+1); e->accept(); } }
void DocInfo::setCurrentFrame(unsigned int frame) { doc()->lock(); if (frame >= doc()->GetFrameCount()) frame = doc()->GetFrameCount()-1; doc()->unlock(); m_currentFrame = frame; setCurrentRow(m_currentRow); }
void CtrlRegisterList::mouseEvent(wxMouseEvent& evt) { if (evt.GetEventType() == wxEVT_RIGHT_UP) { int y = evt.GetPosition().y; if (y >= rowHeight) { int row = (y-rowHeight)/rowHeight; if (row != currentRows[category] && row < cpu->getRegisterCount(category)) setCurrentRow(row); } PopupMenu(&menu,evt.GetPosition()); return; } if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT)) { int x = evt.GetPosition().x; int y = evt.GetPosition().y; if (y < rowHeight) { int piece = GetSize().x/cpu->getRegisterCategoryCount(); int cat = x/piece; if (cat != category) { category = cat; Refresh(); } } else { int row = (y-rowHeight)/rowHeight; if (row != currentRows[category] && row < cpu->getRegisterCount(category)) setCurrentRow(row); } SetFocus(); SetFocusFromKbd(); } }
void EventView::mousePressEvent(QMouseEvent *event) { QListWidgetItem *selectedItem = itemAt(event->pos()); if (selectedItem != NULL) setCurrentRow(row(selectedItem)); else { for (int i = 0; i < count(); ++i) item(i)->setSelected(false); setCurrentItem(NULL); } }
QtContactList::QtContactList(AddressBookModel &model, QWidget *parent) : QListWidget(parent), dataSource(model) { setSelectionMode(QAbstractItemView::SingleSelection); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(dispatchListItemContactId())); populateList(); setCurrentRow(0, QItemSelectionModel::SelectCurrent); }