Logo Search packages:      
Sourcecode: qtoctave version File versions  Download package

Operations::MenuResult Operations::menu_window ( QString  title,
QStringList  parameters_labels,
QStringList &  parameters,
QStringList  output_labels,
QStringList &  output,
QString  help = QString(),
bool  accept_blank_parameters = false 
)

Shows dialog with labels and line edits.

Parameters:
title Dialog title.
parameters_labels Dialog labels for input parameters.
parameters Value of line edits for input parameters.
output_labels Dialog labels for output parameters.
output Value of line edits for output parameters.
help Html text with help.
accept_blank_parameters If user lefts parameters in blank, this option lets them. Otherwise function returns CANCEL.
Returns:
Result of dialog.

Definition at line 477 of file operations.cpp.

References copy_clipboard_callback().

Referenced by compex_comand(), exponente_callback(), producto_callback(), and suma_callback().

{
      copy_clipboard_ok=false;
      
      //Se muestra el cuadro de di´┐Żogo.
      QDialog dialog(main_window);
      dialog.setWindowTitle(title);
      QVBoxLayout *layout=new QVBoxLayout;
      dialog.setLayout(layout);
      
      QLabel *parameters_label[parameters_labels.size()];
      QLineEdit *parameters_lineedit[parameters_labels.size()];

      if(parameters_labels.size()>0)
      {
            QGroupBox *input_box=new QGroupBox(&dialog);
            QVBoxLayout *input_layout=new QVBoxLayout;
            
            input_box->setTitle("Input parameters");
            layout->addWidget(input_box);
            input_box->setLayout(input_layout);
            input_box->show();
            
            for (int i = 0; i < parameters_labels.size(); ++i)
            {
                  QHBoxLayout *parameters_layout=new QHBoxLayout;
                  input_layout->addLayout(parameters_layout);
                  
                  parameters_label[i]=new QLabel(input_box);
                  
                  parameters_label[i]->setText(parameters_labels.at(i));
                  parameters_layout->addWidget(parameters_label[i]);
                  parameters_label[i]->show();
                  
                  parameters_lineedit[i]=new QLineEdit(input_box);
                  parameters_lineedit[i]->setText(parameters.at(i));
                  parameters_layout->addWidget(parameters_lineedit[i]);
                  parameters_lineedit[i]->show();
            }
      }
      
      QLabel *output_label[parameters_labels.size()];
      QLineEdit *output_lineedit[parameters_labels.size()];

      if(output_labels.size()>0)
      {
            QGroupBox *output_box=new QGroupBox(&dialog);
            QVBoxLayout *output_box_layout=new QVBoxLayout;
            
            output_box->setTitle("Output parameters");
            layout->addWidget(output_box);
            output_box->setLayout(output_box_layout);
            output_box->show();
      
            for (int i = 0; i < output_labels.size(); ++i)
            {
                  QHBoxLayout *output_layout=new QHBoxLayout;
                  
                  output_box_layout->addLayout(output_layout);
                  
                  output_label[i]= new QLabel(output_box);
                  output_label[i]->setText(output_labels.at(i));
                  output_layout->addWidget(output_label[i]);
                  output_label[i]->show();
                  
                  output_lineedit[i]= new QLineEdit(output_box);
                  output_lineedit[i]->setText(output.at(i));
                  output_layout->addWidget(output_lineedit[i]);
                  output_lineedit[i]->show();
            }
      }
      
      QTextBrowser *help_text=new QTextBrowser(&dialog);
      help_text->hide();
      
      if(!help.isEmpty())
      {
            help_text->setHtml(help);
            layout->addWidget(help_text);
            help_text->show();
      }
      
      QHBoxLayout *buttons_layout=new QHBoxLayout;
      layout->addLayout(buttons_layout);
      QPushButton ok_button("Ok", &dialog);
      buttons_layout->addWidget(&ok_button);
      ok_button.show();
      connect(&ok_button,SIGNAL(clicked()),&dialog,SLOT(accept()));
      
      QPushButton copy_clipboard_button("Copy to clipboard", &dialog);
      buttons_layout->addWidget(&copy_clipboard_button);
      copy_clipboard_button.show();
      connect(&copy_clipboard_button,SIGNAL(clicked()),&dialog,SLOT(accept()));
      connect(&copy_clipboard_button,SIGNAL(clicked()),this,SLOT(copy_clipboard_callback()));
      
      QPushButton cancel_button("Cancel", &dialog);
      buttons_layout->addWidget(&cancel_button);
      cancel_button.show();
      connect(&cancel_button,SIGNAL(clicked()),&dialog,SLOT(reject()));
      
      dialog.exec();
      
      if (dialog.result()==QDialog::Accepted)
      {
            for (int i = 0; i < output_labels.size(); ++i)
            {
                  if(output_lineedit[i]->text().isEmpty() && !accept_blank_parameters)
                  {
                        return CANCEL;
                  }
            }
            
            for (int i = 0; i < parameters_labels.size(); ++i)
            {
                  if(parameters_lineedit[i]->text().isEmpty() && !accept_blank_parameters)
                  {
                        return CANCEL;
                  }
            }
             
            if(output_labels.size()>0)
            {
                  output.clear();
                  for (int i = 0; i < output_labels.size(); ++i)
                  {
                        output << output_lineedit[i]->text();
                  }
            }
            
            if(parameters_labels.size()>0)
            {
                  parameters.clear();
                  for (int i = 0; i < parameters_labels.size(); ++i)
                  {
                        parameters << parameters_lineedit[i]->text();
                  }
            }
            
            if(copy_clipboard_ok)
            {
                  return COPY_CLIPBOARD;
            }
            else
            {
                  return ACCEPTED;
            }
      }
      
      return CANCEL;
}


Generated by  Doxygen 1.6.0   Back to index