int QStackedWidgetProto::count()                  const
{
  QStackedWidget *item = qscriptvalue_cast<QStackedWidget*>(thisObject());
  if (item)
    return item->count();
  return 0;
}
Exemple #2
0
void PagePalette::startMasterPageMode(QString masterPage)
{
	m_view->Deselect(true);

	QStackedWidget* stackedWidget = this->stackedWidget();
	if (stackedWidget->count() < 2)
	{
		PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage);
		mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages"));
		stackedWidget->addWidget(mpWidget);

		connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int )));
		connect(mpWidget, SIGNAL(finished())      , m_scMW, SLOT(manageMasterPagesEnd()));
	}
	else
	{
		ScribusDoc* doc = m_view->Doc;
		PagePalette_MasterPages* mpWidget = this->masterpageWidget();
		if (mpWidget->currentView != m_view)
			mpWidget->setView(m_view, masterPage);
		mpWidget->updateMasterPageList(masterPage);
		if (doc->currentPage()->pageName() != masterPage)
			mpWidget->selectMasterPage(masterPage);
	}

	// Set focus to page palette or focus may be set to wrong document window
	this->setFocus();
	stackedWidget->setCurrentIndex(1);
}
void RemoveStackPageAction::slotTriggered()
{
    if (   !KexiUtils::objectIsA(m_receiver, "QStackedWidget")
        && /* compat */ !KexiUtils::objectIsA(m_receiver, "QWidgetStack"))
    {
        return;
    }
    QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver);
    QWidget *page = stack->currentWidget();

    QWidgetList list;
    list.append(page);
    KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_container->form(), list);

    // raise prev/next widget
    int index = stack->indexOf(page);
    if (index > 0) {
        index--;
    }
    else if (index < (stack->count()-1)) {
        index++;
    }
    else {
        index = -1;
    }
    if (index >= 0) {
        stack->setCurrentIndex(index);
    }
    stack->removeWidget(page);
    m_container->form()->addCommand(com);
}
void InsertPageCommand::undo()
{
    QWidget *page = m_form->objectTree()->lookup(m_name)->widget();
    QWidget *parent = m_form->objectTree()->lookup(m_parentname)->widget();

    QWidgetList list;
    list.append(page);
    KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_form, list);

    QByteArray classname = parent->metaObject()->className();
    if (classname == "KFDTabWidget") {
        TabWidgetBase *tab = dynamic_cast<TabWidgetBase*>(parent);
        tab->removeTab(tab->indexOf(page));
    } else if (classname == "QStackedWidget" || /* compat */ classname == "QWidgetStack") {
        QStackedWidget *stack = dynamic_cast<QStackedWidget*>(parent);
        int index = stack->indexOf(page);
        if (index > 0)
            index--;
        else if (index < (stack->count()-1))
            index++;
        else
            index = -1;

        if (index >= 0)
            stack->setCurrentIndex(index);
        stack->removeWidget(page);
    }

    com->execute();
    delete com;
}
Exemple #5
0
void SplitGrid2::setCell(QWidget * w, int row, int col)
{
    Q_ASSERT( w != 0 );

    QStackedWidget* cell = getCellImp( row, col );
    Q_ASSERT( cell != 0 );
    if( cell->count() > 0 )
        cell->removeWidget( cell->widget(0) );
    cell->addWidget( w );
}
Audio_instrument_widget *get_audio_instrument_widget(struct Patch *patch){
  QStackedWidget* tabs = g_instruments_widget->tabs;

  for(int i=0;i<tabs->count();i++){
    Audio_instrument_widget *instrument = dynamic_cast<Audio_instrument_widget*>(tabs->widget(i));
    if(instrument!=NULL && instrument->_patch.data()==patch)
      return instrument;
  }

  return NULL;
}
Exemple #7
0
SEXP 
qt_qremoveWidgetFromStack(SEXP x, SEXP index) {
    int i = asInteger(index);
    QStackedWidget *s = unwrapQObject(x, QStackedWidget);
    QWidget *w;
    if (i > 0 && i <= s->count()) {
	w = s->widget(i - 1);
	s->removeWidget(w);
	return wrapQWidget(w);
    }    
    return R_NilValue;
}
static void recreate_instruments_widget_from_state(vector_t *state){
  QStackedWidget* tabs = instruments_widget->tabs;

  while(tabs->count()>0)
    tabs->removeWidget(tabs->currentWidget());

  //vector_t *names = (vector_t*)state->elements[0];
  vector_t *pages = (vector_t*)state->elements[0];

  for(int i=pages->num_elements-1; i>=0; i--){
    QWidget *page = (QWidget*)pages->elements[i];
    tabs->insertWidget(0,page);//,(const char*)names->elements[i]);
  }

  tabs->setCurrentWidget((QWidget*)state->elements[1]);
}
void PagePalette::startMasterPageMode(QString masterPage)
{
	ScribusDoc* doc = m_view->Doc;
	
	bool mustDeselect = false;
	mustDeselect |= (!doc->masterPageMode());
	mustDeselect |= (doc->masterPageMode() && doc->currentPage()->pageName() != masterPage);
	if (mustDeselect)
	{
		// We must avoid deselecting directly if doc is in an edit mode,
		// otherwise that would cause an inconsistent state. In such case,
		// fallback to normal mode by precaution
		if (doc->appMode != modeNormal)
			m_view->requestMode(modeNormal);
		m_view->Deselect(true);
	}

	QStackedWidget* stackedWidget = this->stackedWidget();
	if (stackedWidget->count() < 2)
	{
		PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage);
		mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages"));
		stackedWidget->addWidget(mpWidget);

		connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int )));
		connect(mpWidget, SIGNAL(finished())      , m_scMW, SLOT(editMasterPagesEnd()));
	}
	else
	{
		ScribusDoc* doc = m_view->Doc;
		PagePalette_MasterPages* mpWidget = this->masterpageWidget();
		if (mpWidget->m_view != m_view)
			mpWidget->setView(m_view, masterPage);
		mpWidget->updateMasterPageList(masterPage);
		if (doc->currentPage()->pageName() != masterPage)
			mpWidget->selectMasterPage(masterPage);
	}

	// Set focus to page palette or focus may be set to wrong document window
	this->setFocus();
	stackedWidget->setCurrentIndex(1);
}
static vector_t *create_instruments_widget_state(void){
  vector_t *state = (vector_t *)talloc(sizeof(vector_t));

  //vector_t *names = (vector_t *)talloc(sizeof(vector_t));
  vector_t *pages = (vector_t *)talloc(sizeof(vector_t));

  //VECTOR_push_back(state, names);
  VECTOR_push_back(state, pages);

  QStackedWidget* tabs = instruments_widget->tabs;

  for(int i=0;i<tabs->count();i++){
    //VECTOR_push_back(names, talloc_strdup(tabs->tabText(i).toUtf8().constData()));
    VECTOR_push_back(pages, tabs->widget(i));
  }

  VECTOR_push_back(state, tabs->currentWidget());
  
  return state;
}
Exemple #11
0
void GFX_update_all_instrument_widgets(void){
  QStackedWidget* tabs = g_instruments_widget->tabs;

  //printf("*(((((((((( Calling. Update all %d:\n",tabs->count());
  for(int i=0;i<tabs->count();i++){
    MIDI_instrument_widget *midi_instrument = dynamic_cast<MIDI_instrument_widget*>(tabs->widget(i));
    Audio_instrument_widget *audio_instrument = dynamic_cast<Audio_instrument_widget*>(tabs->widget(i));
    //printf("Update all %d: %p/%p\n",i,midi_instrument,audio_instrument);

    if(midi_instrument!=NULL){

      if(midi_instrument->patch->patchdata!=NULL)
        update_midi_instrument_widget(midi_instrument,midi_instrument->patch.data());

    }else if(audio_instrument!=NULL){

      if(audio_instrument->_patch->patchdata!=NULL)
        update_audio_instrument_widget(audio_instrument,audio_instrument->_patch.data());

    }
  }
}
ExportOptionsDlg::ExportOptionsDlg(ExporterResource& pExporter, QWidget* pParent) :
   QDialog(pParent),
   mpExporter(pExporter),
   mpTabWidget(NULL),
   mpSubsetPage(NULL),
   mpExporterPage(NULL)
{
   // Options widget
   QStackedWidget* pStack = new QStackedWidget(this);

   // Subset page
   RasterElement* pRasterElement = dynamic_cast<RasterElement*>(mpExporter->getItem());
   RasterFileDescriptor* pRasterWholeCubeFileDescriptor = NULL;
   RasterDataDescriptor* pRasterOrgDataDescriptor = NULL;
   if (pRasterElement != NULL)
   {
      pRasterOrgDataDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor());
      if (pRasterOrgDataDescriptor != NULL)
      {
         // we are creating a file descriptor for export from the original cube, because the SubsetWidget
         // uses DimensionDescriptor::operator= compare's to determine selection which dictate that on-disk,
         // original and active numbers need to be identical, this guarantees that DimensionDescriptors will
         // compare correctly.
         pRasterWholeCubeFileDescriptor = dynamic_cast<RasterFileDescriptor*>(
            RasterUtilities::generateFileDescriptorForExport(pRasterOrgDataDescriptor, "foobar"));
      }
   }
   RasterFileDescriptor* pRasterFileDescriptor = dynamic_cast<RasterFileDescriptor*>(mpExporter->getFileDescriptor());
   if ((pRasterFileDescriptor != NULL) && (pRasterWholeCubeFileDescriptor != NULL) &&
      (pRasterOrgDataDescriptor != NULL))
   {
      mpSubsetPage = new SubsetWidget();
      mpSubsetPage->setExportMode(true);

      // Rows
      const vector<DimensionDescriptor>& orgRows = pRasterWholeCubeFileDescriptor->getRows();
      const vector<DimensionDescriptor>& selectedRows = pRasterFileDescriptor->getRows();
      mpSubsetPage->setRows(orgRows, selectedRows);

      // Columns
      const vector<DimensionDescriptor>& orgColumns = pRasterWholeCubeFileDescriptor->getColumns();
      const vector<DimensionDescriptor>& selectedColumns = pRasterFileDescriptor->getColumns();
      mpSubsetPage->setColumns(orgColumns, selectedColumns);

      // Bands
      const vector<DimensionDescriptor>& orgBands = pRasterWholeCubeFileDescriptor->getBands();
      const vector<DimensionDescriptor>& selectedBands = pRasterFileDescriptor->getBands();
      vector<string> bandNames = RasterUtilities::getBandNames(pRasterOrgDataDescriptor);
      mpSubsetPage->setBands(orgBands, bandNames, selectedBands);

      // Initial bad band file directory
      QString strDirectory;

      string filename = pRasterFileDescriptor->getFilename();
      if (filename.empty() == false)
      {
         QFileInfo fileInfo(QString::fromStdString(filename));
         strDirectory = fileInfo.absolutePath();
      }

      mpSubsetPage->setBadBandFileDirectory(strDirectory);
   }

   // Exporter page
   if (mpExporter->getPlugIn() != NULL)
   {
      mpExporterPage = mpExporter->getExportOptionsWidget();
   }

   // Horizontal line
   QFrame* pLine = new QFrame(this);
   pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);

   // Buttons
   QDialogButtonBox* pButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
      Qt::Horizontal, this);

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(10);
   pLayout->setSpacing(10);
   pLayout->addWidget(pStack, 10);
   pLayout->addWidget(pLine);
   pLayout->addWidget(pButtonBox);

   // Initialization
   QString strWindowTitle = "Export Options";

   SessionItem* pSessionItem = mpExporter->getItem();
   if (pSessionItem != NULL)
   {
      string name = pSessionItem->getDisplayName();
      if (name.empty() == true)
      {
         name = pSessionItem->getName();
      }

      if (name.empty() == false)
      {
         strWindowTitle += ": " + QString::fromStdString(name);
      }
   }

   setWindowTitle(strWindowTitle);
   setModal(true);

   if ((mpSubsetPage != NULL) || (mpExporterPage != NULL))
   {
      QWidget* pSubsetWidget = NULL;
      if (mpSubsetPage != NULL)
      {
         pSubsetWidget = new QWidget();
         mpSubsetPage->setParent(pSubsetWidget);

         QVBoxLayout* pSubsetLayout = new QVBoxLayout(pSubsetWidget);
         if (mpExporterPage != NULL)
         {
            pSubsetLayout->setMargin(10);
         }
         else
         {
            pSubsetLayout->setMargin(0);
         }

         pSubsetLayout->setSpacing(10);
         pSubsetLayout->addWidget(mpSubsetPage);
      }

      QWidget* pExporterWidget = NULL;
      if (mpExporterPage != NULL)
      {
         pExporterWidget = new QWidget();
         mpExporterPage->setParent(pExporterWidget);

         QVBoxLayout* pExporterLayout = new QVBoxLayout(pExporterWidget);
         if (mpSubsetPage != NULL)
         {
            pExporterLayout->setMargin(10);
         }
         else
         {
            pExporterLayout->setMargin(0);
         }

         pExporterLayout->setSpacing(10);
         pExporterLayout->addWidget(mpExporterPage);
      }

      if ((pSubsetWidget != NULL) && (pExporterWidget != NULL))
      {
         QString strExporterCaption = mpExporterPage->windowTitle();
         if (strExporterCaption.isEmpty() == true)
         {
            PlugIn* pPlugIn = mpExporter->getPlugIn();
            if (pPlugIn != NULL)
            {
               strExporterCaption = QString::fromStdString(pPlugIn->getName());
            }

            if (strExporterCaption.isEmpty() == true)
            {
               strExporterCaption = "Exporter";
            }
         }

         mpTabWidget = new QTabWidget(this);
         mpTabWidget->setTabPosition(QTabWidget::North);
         mpTabWidget->addTab(pSubsetWidget, "Subset");
         mpTabWidget->addTab(pExporterWidget, strExporterCaption);
         pStack->addWidget(mpTabWidget);
      }
      else if (pSubsetWidget != NULL)
      {
         pStack->addWidget(pSubsetWidget);
         pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
      }
      else if (pExporterWidget != NULL)
      {
         pStack->addWidget(pExporterWidget);
      }
   }

   if (pStack->count() == 0)
   {
      QLabel* pNoOptionsLabel = new QLabel("No options are available", this);
      pNoOptionsLabel->setAlignment(Qt::AlignCenter);
      pNoOptionsLabel->setMinimumSize(250, 100);

      pStack->addWidget(pNoOptionsLabel);
   }

   // Connections
   VERIFYNR(connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept())));
   VERIFYNR(connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject())));
}
Exemple #13
0
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
}