void RevsView::setTabLogDiffVisible(bool b) { QStackedWidget* s = tab()->stackedPanes; QTabWidget* t = tab()->tabLogDiff; bool isTabPage = (s->currentIndex() == 0); int idx = (isTabPage ? t->currentIndex() : s->currentIndex()); container->setUpdatesEnabled(false); if (b && !isTabPage) { t->addTab(tab()->textBrowserDesc, "Log"); t->addTab(tab()->textEditDiff, "Diff"); t->setCurrentIndex(idx - 1); s->setCurrentIndex(0); } if (!b && isTabPage) { s->addWidget(tab()->textBrowserDesc); s->addWidget(tab()->textEditDiff); // manually remove the two remaining empty pages t->removeTab(0); t->removeTab(0); s->setCurrentIndex(idx + 1); } container->setUpdatesEnabled(true); }
int QStackedWidgetProto::currentIndex() const { QStackedWidget *item = qscriptvalue_cast<QStackedWidget*>(thisObject()); if (item) return item->currentIndex(); return 0; }
int GoToStackPageAction::nextWidgetIndex() const { QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver); if (!stack) return -1; return stack->currentIndex() + (m_direction == Previous ? -1 : 1); }
void RevsView::toggleDiffView() { QStackedWidget* s = tab()->stackedPanes; QTabWidget* t = tab()->tabLogDiff; bool isTabPage = (s->currentIndex() == 0); int idx = (isTabPage ? t->currentIndex() : s->currentIndex()); bool old = container->updatesEnabled(); container->setUpdatesEnabled(false); if (isTabPage) t->setCurrentIndex(1 - idx); else s->setCurrentIndex(3 - idx); container->setUpdatesEnabled(old); }
void Form3::keyPressEvent(QKeyEvent * ev) { QStackedWidget *sw = ui->stackedWidget; //if(!testEnabled) return; bool ok; ix = sw->currentIndex(); int key = ev->key(); if(key == Qt::Key_F12) { if(testMode == true) { QMessageBox mb; //mb.setText(tr("Ручная правка данных отключена")); //mb.setInformativeText( tr("Чтение из аппаратуры восстановлено") ); mb.exec(); testMode=false; } } else if(key == Qt::Key_F11) { QString text = QInputDialog::getText(this, "",//tr("Ручная правка данных"), "",//tr("Чтение из аппаратуры выключено. Введите через запятую: адрес, значение"), QLineEdit::Normal, 0, &ok); if (ok && !text.isEmpty()) { QStringList slist = text.split(","); int dev=slist[0].toInt(&ok); if(!ok) return; int adr=slist[1].toInt(&ok); if(!ok) return; int val=slist[2].toInt(&ok); if(!ok) return; valData[dev][adr] = val; } testMode = true; } else if(key == Qt::Key_Backspace) { ref->show(); ref->setFocus(); } else if(key == Qt::Key_Slash) { // меню ППН if(ix==12) { // только для ppnRef->show(); ppnRef->setFocus(); } } else if(key == Qt::Key_Right) { // след.страница // если были на слайде алгоритма, переходим сразу на 14й слайд (параметры ИК) if((ix>=1 && ix<=11)) sw->setCurrentIndex(12); else sw->setCurrentIndex( (ix<(sw->count()-1))? ix+1 : 0); } else if(key == Qt::Key_Left) {// предыд.страница // если были на слайде алгоритма, переходим на 1й слайд if(ix>=1 && ix<=11) sw->setCurrentIndex(0); else if(ix==12) // если были на таблице ИК, на первый слайд с алгоритмами sw->setCurrentIndex(1); else sw->setCurrentIndex(ix > 0? ix-1 : sw->count()-1); } else if(key == Qt::Key_Down) { // след.слайд в группе слайдов if(ix==12) { // если мы на таблице ППН ui->sw2->setCurrentIndex(( ui->sw2->currentIndex() <ui->sw2->count()-1 )? ui->sw2->currentIndex() + 1 : 0); } else if(ix>=1 && ix<=11) { // если на алгоритмах защит sw->setCurrentIndex( (ix<11)? ix+1 : 1); } else if(ix==13) { // слайд дискр сигналов discrSlideCurr<3?discrSlideCurr++:discrSlideCurr=0; // switch(discrSlideCurr) { // case 0: // вх 151,152 // paintEvent1(in151); // break; // case 1: // paintEvent1(out155az); // break; // case 2: // paintEvent1(out155pz); // break; // case 3: // paintEvent1(pca); // break; // } update(); } } else if(key == Qt::Key_Up) { // предыд.страница if(ix==12) { // если мы на таблице ППН ui->sw2->setCurrentIndex((ui->sw2->currentIndex() > 0 )? ui->sw2->currentIndex()-1 : ui->sw2->count()-1); } else if(ix>=1 && ix<=11) { // если на алгоритмах защит sw->setCurrentIndex( (ix>1)? ix-1 : 11); } else if(ix==13) { // слайд дискр сигналов discrSlideCurr>0?discrSlideCurr--:discrSlideCurr=3; update(); } } // слайд дискретных сигналов // (ix==14)? discrSlide = true : discrSlide = false; // else if(key >= Qt::Key_0 && key <= Qt::Key_9) { // двузначный номер слайда // sw->setCurrentIndex(ev->key()-Qt::Key_0); // } #if 0 else if(key >= Qt::Key_0 && ev->key() <= Qt::Key_9) { // двузначный номер слайда dig[digCnt] = ev->key(); if (digCnt==0) { QTimer::singleShot(2000,Qt::CoarseTimer , this, SLOT(onHideFrameNumbers())); hideFrameNumbersTimerEnabled = true; hide2DigitTimerEnabled = false; digCnt++; lbFrameNum->setText(QString::number(dig[0]-Qt::Key_0)); lbFrameNum->setVisible(true); } else { hideFrameNumbersTimerEnabled = false; hide2DigitTimerEnabled = true; sw->setCurrentIndex( ((dig[0]-Qt::Key_0) * 10) + (dig[1]-Qt::Key_0) ); lbFrameNum->setText( QString::number((dig[0]-Qt::Key_0) *10) + QString::number( dig[1]-Qt::Key_0) ); QTimer::singleShot(1000,Qt::CoarseTimer , this, SLOT(onHide2Digit())); digCnt=0; } } #endif }
// Update associated CLI widget based on QWidget / QObject data void QtWidgetObject::updateCLI() { // Check treeGuiWidget_ pointer first if (treeGuiWidget_ == NULL) { printf("Internal Error: treeGuiWidget_ pointer is NULL in updateCLI().\n"); return; } // Now, check widget type to see what we do if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget) { QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_); if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, butgroup->checkedId()); } else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget) { QCheckBox *check = static_cast<QCheckBox*>(qWidget_); if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, check->isChecked()); } else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget) { QComboBox* combo = static_cast<QComboBox*>(qWidget_); if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, combo->currentIndex()+1); } else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget) { QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value()); } else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget) { QLineEdit *edit = static_cast<QLineEdit*>(qWidget_); if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, qPrintable(edit->text())); } else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget) { QSpinBox *spin = static_cast<QSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value()); } else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget) { QLabel *label = static_cast<QLabel*>(qWidget_); if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n"); } else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget) { QRadioButton *button = static_cast<QRadioButton*>(qWidget_); if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, button->isChecked()); } else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget) { QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_); if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, tabs->currentIndex()+1); } else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget) { QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_); if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, stack->currentIndex()+1); } else printf("Internal Error: No handler written to update CLI controls of this type (%s).\n", TreeGuiWidget::widgetType(treeGuiWidget_->type())); }