Example #1
0
void AppWin::defineBurgersCircuit_end()
{
  PltWin *pw = plotWidget[tabWidget->currentIndex()];
  QString txt;
  DVector B(3);
  double Blen;
  bool ok;

  pw->doAfterMouseClicks = DO_NOTHING;
    
  BVectFromCircuit(pw, pw->napicked, pw->apicked, B, Blen);

  Ui::DCalcBVector ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);
	
  txt.sprintf("%d", pw->napicked-1);
  ui.numNodes->setText(txt); 
  
  txt.sprintf("%0.6lf", B(1));
  ui.Bx->setText(txt); 
  txt.sprintf("%0.6lf", B(2));
  ui.By->setText(txt); 
  txt.sprintf("%0.6lf", B(3));
  ui.Bz->setText(txt); 
  txt.sprintf("%0.6lf", Blen);
  ui.Blen->setText(txt); 
  
  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;
}
Example #2
0
void JBlockerMainWindow::slt_loadingStart()
{
    this->statusBar()->showMessage(tr("LOADING MESSAGES ..."));
    // QMessageBox::information(this, QString(), QString("PROGRAM NEED TO LOAD MESSAGES"), QMessageBox::Ok);
    /* Create dialog */
    QDialog dialog;
    dialog.setWindowTitle(tr("Account Selection"));
    QHBoxLayout* layout = new QHBoxLayout();
    /* Label for dialog */
    QLabel* dialogLabel = new QLabel(tr("Select An Account:"));
    layout->addWidget(dialogLabel, 0, Qt::AlignHCenter);
    /* Combo box for selecting account */
    QComboBox* accountComboBox = new QComboBox();
    accountComboBox->setFixedWidth(280);
    /* Get account name list from message core */
    accountComboBox->addItems(p_messageCore->getAccountNameList());
    layout->addWidget(accountComboBox, 0, Qt::AlignHCenter);
    /* Button for dialog */
    QPushButton* dialogButton = new QPushButton(tr("Confirm"));
    layout->addWidget(dialogButton, 0, Qt::AlignHCenter);
    dialog.setLayout(layout);
    QObject::connect(dialogButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
    dialog.exec();
    if(dialog.result())
    {
        /* Set selected account id */
        p_messageCore->setSelectedAccountId(accountComboBox->currentIndex());
    }

    this->statusBar()->addPermanentWidget(p_progressBar, 0);
    p_progressBar->setValue(0);
    p_progressBar->show();
    /* Core runs */
    p_messageCore->run();
}
Example #3
0
void AppWin::dlgDPosPeierlsNabarro()
{
  PltWin *pw = plotWidget[ tabWidget->currentIndex() ];
  int i;
  bool ok;

  Ui::DFindDPosPeierlsNabarro ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);
  
  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;
  if (ok) {
    for (i=0; i<tabWidget->count(); i++) {
      plotWidget[i]->ndpoly = 0;
      plotWidget[i]->nchain = 0;
      plotWidget[i]->ndpath = 0;
    }
    pw->applyHow = ui.applyHow->currentIndex();
    pw->napicked = 0;
    pw->apicked.Allocate(10);
    pw->apicked.EnlargeStep(5);
    pw->clickAtoms = true;
    pw->doAfterMouseClicks = CALC_DPOS_PEIERLSNABARRO;
    pw->repaint();
  }
}
Example #4
0
void AppWin::probeAtomDispl()
{
  PltWin *pw = plotWidget[ tabWidget->currentIndex() ];
  int i;
  bool ok;
  
  Ui::DSetupProbeAtomDispl ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);

  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;
  if (ok) {
    for (i=0; i<tabWidget->count(); i++) {
      plotWidget[i]->ndpoly = 0;
      plotWidget[i]->nchain = 0;
      plotWidget[i]->ndpath = 0;
    }
    pw->napicked = 0;
    pw->apicked.Allocate(10);
    pw->apicked.EnlargeStep(5);
    pw->clickAtoms = true;
    pw->doAfterMouseClicks = CALC_ATOM_DISPL;
    pw->repaint();
  }
}
Example #5
0
  void DisparityPlugin::SelectTopic()
  {
    QDialog dialog;
    Ui::topicselect ui;
    ui.setupUi(&dialog);

    std::vector<ros::master::TopicInfo> topics;
    ros::master::getTopics(topics);

    for (unsigned int i = 0; i < topics.size(); i++)
    {
      if (topics[i].datatype == "stereo_msgs/DisparityImage")
      {
        ui.displaylist->addItem(topics[i].name.c_str());
      }
    }
    ui.displaylist->setCurrentRow(0);

    dialog.exec();

    if (dialog.result() == QDialog::Accepted && ui.displaylist->selectedItems().count() == 1)
    {
      ui_.topic->setText(ui.displaylist->selectedItems().first()->text());
      TopicEdited();
    }
  }
Example #6
0
void AppWin::defineBurgersCircuit()
{
  PltWin *pw = plotWidget[tabWidget->currentIndex()];
  int i;
  bool ok;

  Ui::DDefineBCircuit ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);
  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;
  if (ok) {
    for (i=0; i<tabWidget->count(); i++) {
      plotWidget[i]->ndpoly = 0;
      plotWidget[i]->nchain = 0;
      plotWidget[i]->ndpath = 0;
    }
    pw->napicked = 0;
    pw->apicked.Allocate(10);
    pw->apicked.EnlargeStep(5);
    pw->clickAtoms = true;
    pw->doAfterMouseClicks = CALC_BURG_VECTOR;
    pw->repaint();
  }
}
Example #7
0
int drv_dialog(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QDialog *self = (QDialog*)head->native;
    switch (drvid) {
    case DIALOG_INIT: {
        drvNewObj(a0,new QDialog);
        break;
    }
    case DIALOG_SETMODAL: {
        self->setModal(drvGetBool(a1));
        break;
    }
    case DIALOG_ISMODAL: {
        drvSetBool(a1,self->isModal());
        break;
    }
    case DIALOG_SETRESULT: {
        self->setResult(drvGetInt(a1));
        break;
    }
    case DIALOG_RESULT: {
        drvSetInt(a1,self->result());
        break;
    }
    case DIALOG_EXEC: {
        drvSetInt(a1,self->exec());
        break;
    }
    case DIALOG_DONE: {
        self->done(drvGetInt(a1));
        break;
    }
    case DIALOG_ACCEPT: {
        self->accept();
        break;
    }
    case DIALOG_REJECT: {
        self->reject();
        break;
    }
    case DIALOG_ONACCEPTED: {
        QObject::connect(self,SIGNAL(acceped()),drvNewSignal(self,a1,a2),SLOT(call()));
        break;
    }
    case DIALOG_ONREJECTED: {
        QObject::connect(self,SIGNAL(rejected()),drvNewSignal(self,a1,a2),SLOT(call()));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
Example #8
0
void BookmarksToolbar::editBookmark()
{
    QAction* act = qobject_cast<QAction*> (sender());
    if (!act) {
        return;
    }

    ToolButton* button = static_cast<ToolButton*>(act->data().value<void*>());
    if (!button) {
        return;
    }

    Bookmark b = button->data().value<Bookmark>();

    QDialog* dialog = new QDialog(this);
    QFormLayout* layout = new QFormLayout(dialog);
    QLabel* label = new QLabel(dialog);
    QLineEdit* editUrl = new QLineEdit(dialog);
    QLineEdit* editTitle = new QLineEdit(dialog);
    QDialogButtonBox* box = new QDialogButtonBox(dialog);
    box->addButton(QDialogButtonBox::Ok);
    box->addButton(QDialogButtonBox::Cancel);
    connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
    connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));

    label->setText(tr("Edit bookmark: "));
    layout->addRow(label);
    layout->addRow(new QLabel(tr("Title: ")), editTitle);
    layout->addRow(new QLabel(tr("Url: ")), editUrl);
    layout->addRow(box);

    editUrl->setText(b.url.toString());
    editTitle->setText(b.title);
    editUrl->setCursorPosition(0);
    editTitle->setCursorPosition(0);

    dialog->setWindowTitle(tr("Edit Bookmark"));
    dialog->setMinimumSize(400, 100);
    dialog->exec();
    if (dialog->result() == QDialog::Rejected) {
        return;
    }

    QUrl url = QUrl::fromEncoded(editUrl->text().toUtf8());
    QString title = editTitle->text();

    if (url.isEmpty() || title.isEmpty()) {
        return;
    }

    m_bookmarksModel->editBookmark(b.id, title, url, b.folder);
}
Example #9
0
void RSSManager::editFeed()
{
    QString url = ui->tabWidget->tabToolTip(ui->tabWidget->currentIndex());
    if (url.isEmpty()) {
        return;
    }

    QDialog* dialog = new QDialog(this);
    QFormLayout* layout = new QFormLayout(dialog);
    QLabel* label = new QLabel(dialog);
    QLineEdit* editUrl = new QLineEdit(dialog);
    QLineEdit* editTitle = new QLineEdit(dialog);
    QDialogButtonBox* box = new QDialogButtonBox(dialog);
    box->addButton(QDialogButtonBox::Ok);
    box->addButton(QDialogButtonBox::Cancel);
    connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
    connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));

    label->setText(tr("Fill title and URL of a feed: "));
    layout->addRow(label);
    layout->addRow(new QLabel(tr("Feed title: ")), editTitle);
    layout->addRow(new QLabel(tr("Feed URL: ")), editUrl);
    layout->addRow(box);

    editUrl->setText(ui->tabWidget->tabToolTip(ui->tabWidget->currentIndex()));
    editTitle->setText(ui->tabWidget->tabText(ui->tabWidget->currentIndex()));

    dialog->setWindowTitle(tr("Edit RSS Feed"));
    dialog->setMinimumSize(400, 100);
    dialog->exec();
    if (dialog->result() == QDialog::Rejected) {
        return;
    }

    QString address = editUrl->text();
    QString title = editTitle->text();

    if (address.isEmpty() || title.isEmpty()) {
        return;
    }

    QSqlQuery query;
    query.prepare("UPDATE rss SET address=?, title=? WHERE address=?");
    query.bindValue(0, address);
    query.bindValue(1, title);
    query.bindValue(2, url);
    query.exec();

    refreshTable();

}
Example #10
0
void GeneralPage::openPPICalculationDialog()
{
	int primary_screen_width = QApplication::primaryScreen()->size().width();
	int primary_screen_height = QApplication::primaryScreen()->size().height();
	float screen_diagonal_pixels = qSqrt(primary_screen_width*primary_screen_width + primary_screen_height*primary_screen_height);
	
	float old_ppi = ppi_edit->value();
	float old_screen_diagonal_inches = screen_diagonal_pixels / old_ppi;
	
	QDialog* dialog = new QDialog(window(), Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
	
	QGridLayout* layout = new QGridLayout();
	
	int row = 0;
	QLabel* resolution_label = new QLabel(tr("Primary screen resolution in pixels:"));
	layout->addWidget(resolution_label, row, 0);
	
	
	QLabel* resolution_display = new QLabel(QStringLiteral("%1 x %2").arg(primary_screen_width).arg(primary_screen_height));
	layout->addWidget(resolution_display, row, 1);
	
	row++;
	QLabel* size_label = new QLabel(tr("Primary screen size in inches (diagonal):"));
	layout->addWidget(size_label, row, 0);
	
	QDoubleSpinBox* size_edit = Util::SpinBox::create(2, 0.01, 9999);
	size_edit->setValue(old_screen_diagonal_inches);
	layout->addWidget(size_edit, row, 1);
	
	row++;
	layout->addItem(Util::SpacerItem::create(this), row, 1);
	
	row++;
	QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
	layout->addWidget(button_box, row, 0, 1, 2);
	
	dialog->setLayout(layout);
	connect(button_box, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
	connect(button_box, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
	dialog->exec();
	
	if (dialog->result() == QDialog::Accepted)
	{
		float screen_diagonal_inches = size_edit->value();
		float new_ppi = screen_diagonal_pixels / screen_diagonal_inches;
		ppi_edit->setValue(new_ppi);
		ppiChanged(new_ppi);
	}
}
Example #11
0
void AppWin::burgVect()
{
  PltWin *pw = plotWidget[ tabWidget->currentIndex() ];
  QString str;
  int i, istart, iend;
  bool ok;

  Ui::DBurgVect ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);

  str.sprintf("%0.4lf", pw->Bvect(1));
  ui.xcoord->setText(str);
  ui.xcoord->selectAll();
  str.sprintf("%0.4lf", pw->Bvect(2));
  ui.ycoord->setText(str);
  str.sprintf("%0.4lf", pw->Bvect(3));
  ui.zcoord->setText(str);

  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;

  if (ok) {
    if (ui.applyHow->currentIndex()==0)
      istart = iend = tabWidget->currentIndex();
    else {
      istart = 0;
      iend = tabWidget->count()-1;
    }
    
    for (i=istart; i<=iend; i++) {
      pw = plotWidget[i];
      if (!pw->isSelected)
	continue;

      pw->Bvect(1) = ui.xcoord->text().toDouble();
      pw->Bvect(2) = ui.ycoord->text().toDouble();
      pw->Bvect(3) = ui.zcoord->text().toDouble();

      // must re-calculate the relative displacements - arrows plotted between different neighbors
      if (pw->DispComponent==EDGE)
	pw->calcEdgeRelDisp();
      else if (pw->DispComponent==SCREW)
	pw->calcScrewRelDisp();

      pw->repaint();
    }
  }
}
void XletSwitchBoard::mouseReleaseEvent(QMouseEvent *)
{
    // qDebug() << Q_FUNC_INFO;
    if (m_trace_box) {
        QRect rect = QRect(m_first_corner, m_second_corner).normalized();

        QRect gridRect = m_layout->getGridRect(rect);
        if ((gridRect.top() != gridRect.bottom()) &&
           (gridRect.right() != gridRect.left())) {
            QString name;
            QDialog dialog;
            dialog.setWindowTitle(tr("New group"));
            QVBoxLayout *layout = new QVBoxLayout(&dialog);
            layout->addWidget(new QLabel(tr("Please enter a name for the new group"), &dialog));
            QLineEdit *lineedit = new QLineEdit(&dialog);
            layout->addWidget(lineedit);
            layout->addWidget(new QLabel(tr("Please choose a color for the new group"), &dialog));
            QtColorPicker *colorpicker = new QtColorPicker(&dialog);
            colorpicker->setStandardColors();
            colorpicker->setCurrentColor(QColor(63, 63, 255));
            layout->addWidget(colorpicker);
            QDialogButtonBox *buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                                                               Qt::Horizontal, &dialog);
            layout->addWidget(buttonbox);
            connect(buttonbox, SIGNAL(accepted()),
                    &dialog, SLOT(accept()) );
            connect(buttonbox, SIGNAL(rejected()),
                    &dialog, SLOT(reject()) );
            dialog.exec();
            if (dialog.result() == QDialog::Accepted)
                name = lineedit->text();
            if (!name.isEmpty()) {
                Group *group = new Group(this);
                group->setRect(gridRect);
                group->setName(name);
                group->setColor(colorpicker->currentColor());
                m_group_list.append(group);
                saveGroups();
            }
        }
        m_trace_box = false;
        update();
    }
    if (m_group_to_resize) {
        unsetCursor();
        m_group_to_resize = NULL;
    }
}
Example #13
0
bool GmailPyInterface::login()
{
    bool goon=true;
    while(m_user == "" || m_pass == "") {
        QDialog d;
        d.setModal(true);
        QLineEdit* user(new QLineEdit);
        QLineEdit* pass(new QLineEdit);
        pass->setEchoMode(QLineEdit::Password);
        QVBoxLayout* layout(new QVBoxLayout);
        d.setLayout(layout);
        layout->addWidget(new QLabel("Enter you gmail account:"));
        QGridLayout* glayout(new QGridLayout());
        glayout->addWidget(new QLabel("Username:"******"Password:"******"Ok"));
        QPushButton* cancelbutton(new QPushButton("Cancel"));
        QObject::connect(okbutton, SIGNAL(clicked()), &d, SLOT(accept()));
        QObject::connect(cancelbutton, SIGNAL(clicked()), &d, SLOT(reject()));
        buttons->addWidget(okbutton);
        buttons->addWidget(cancelbutton);
        layout->addLayout(buttons);
        d.exec();
        if (d.result() == QDialog::Accepted) {
            if (user->text().isEmpty() || pass->text().isEmpty()) continue;
            m_user = user->text();
            m_pass = pass->text();
            break;
        } else return false;
    }
    delete m_sender;
    m_sender = 0;
    m_sender = new MailSender("smtp.gmail.com", m_user + "@gmail.com", QStringList(m_user + "@gmail.com"), "@SAK", "Enjoy!");
    m_sender->setSsl(true);
    m_sender->setPort(587);
    m_sender->setLogin(m_user, m_pass);
    return true;
}
/*
 * Створюємо новий пустий шаблон кросворду
 */
void tableTemplateWidget::createNew(void)
{
  QDialog *dialog = new QDialog();
  sizeOfTemplate = new Ui::SizeOfTemplate();
  sizeOfTemplate->setupUi(dialog);

  dialog->setModal(true);
  dialog->exec();

  if (dialog->result() == QDialog::Accepted)
    {
      numRow = sizeOfTemplate->spinRows->value();
      numCol = sizeOfTemplate->spinColumns->value();

      QSqlQuery query;
      query.prepare("INSERT INTO crossword.templates (_rows, _columns) VALUES (?, ?);");
      query.addBindValue(QVariant(numRow));
      query.addBindValue(QVariant(numCol));
      query.exec();

      QSqlError le = query.lastError();
      if (le.type() == QSqlError::NoError)
        templateId = query.lastInsertId().toInt();
      else
        qDebug() << "createNew: " << le.text();

      wi.clear();
      setRowCount(numRow);
      setColumnCount(numCol);

      for (int i = 0; i < numRow; i++)
        for (int j = 0; j < numCol; j++)
          newCell(i, j, 0);

      isDirty = true;
    }

  delete dialog;
}
// slot
void GeneralSettingsPage::openPPICalculationDialog()
{
	int primary_screen_width = QApplication::primaryScreen()->size().width();
	int primary_screen_height = QApplication::primaryScreen()->size().height();
	float screen_diagonal_pixels = qSqrt(primary_screen_width*primary_screen_width + primary_screen_height*primary_screen_height);
	
	float old_ppi = ppi_edit->value();
	float old_screen_diagonal_inches = screen_diagonal_pixels / old_ppi;
	
	QDialog* dialog = new QDialog(window(), Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
	
	auto layout = new QVBoxLayout(dialog);
	
	auto form_layout = new QFormLayout();
	
	QLabel* resolution_display = new QLabel(tr("%1 x %2").arg(primary_screen_width).arg(primary_screen_height));
	form_layout->addRow(tr("Primary screen resolution in pixels:"), resolution_display);
	
	QDoubleSpinBox* size_edit = Util::SpinBox::create(2, 0.01, 9999);
	size_edit->setValue(old_screen_diagonal_inches);
	form_layout->addRow(tr("Primary screen size in inches (diagonal):"), size_edit);
	
	layout->addLayout(form_layout);
	
	layout->addItem(Util::SpacerItem::create(this));
	
	QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
	layout->addWidget(button_box);
	
	connect(button_box, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
	connect(button_box, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
	dialog->exec();
	
	if (dialog->result() == QDialog::Accepted)
	{
		ppi_edit->setValue(screen_diagonal_pixels / size_edit->value());
	}
}
Example #16
0
void AppWin::compareDisp()
{
  QString item,cstr;
  int i, pos, p1, p2,  n, d, comp, idx;
  bool ok, comparable;

  Ui::DCompareDisp ui;
  QDialog *dialog = new QDialog;
  ui.setupUi(dialog);

  // set up the data
  for (i=0; i<tabWidget->count(); i++) {
    item = plotWidget[i]->FName;
    
    // only the file name is printed
    item = QDir::current().relativeFilePath(item);
    ui.plot1->addItem(item);
    ui.plot2->addItem(item);
  }

  dialog->exec();
  ok = dialog->result()==QDialog::Accepted;

  if (ok) {
    p1 = ui.plot1->currentRow();
    p2 = ui.plot2->currentRow();
    if (p1==p2) {
      msgInfo(info_CompareSamePlots);
      return;
    }

    comp = EDGE * ui.compEdge->isChecked() + SCREW * ui.compScrew->isChecked();
    if (comp==EDGE) 
      cstr = QString(" (edge)");
    else 
      cstr = QString(" (screw)");

    // create a new widget
    PltWin *pw = new PltWin(tabWidget);
    *pw = *plotWidget[p1];
    
    // set the plot-specific parameters
    if (comp==EDGE)
      pw->DispComponent = DIFF_EDGE;  
    else if (comp==SCREW)
      pw->DispComponent = DIFF_SCREW;     
    pw->FName = tabWidget->tabText(p1) + " (-) " + tabWidget->tabText(p2) + cstr.toLatin1().data();

    comparable = pw->CompareDisp(plotWidget[p2], comp);
    if (!comparable) {
      delete(pw);
      msgError(err_CannotComparePlots);
      return;
    }

    plotWidget.append(pw);
    tabWidget->addTab(pw, pw->FName);
    tabWidget->setCurrentIndex(tabWidget->count()-1);
    tabWidget->show();

    idx = tabWidget->currentIndex();
    actFirstPlot->setEnabled(idx > 0);
    actPrevPlot->setEnabled(idx > 0);
    actNextPlot->setEnabled(idx < tabWidget->count()-1);
    actLastPlot->setEnabled(idx < tabWidget->count()-1);

    repaintStatusBar();
  }
}
Example #17
0
void DossierEditeur::afficherProfil()
{
    try
    {
        QDialog* window = new QDialog(this);
        QGridLayout* lay = new QGridLayout;
        QPushButton* ok = new QPushButton("Ok");
        window->setWindowTitle("Profil");
        window->setFixedSize(400, 400);

        QStringList Formation = Dossier::getInstance().ListeCursus();
        int j = 1;
        QTableWidget* valide = new QTableWidget(1,1,this);
        QTableWidget* non_valide = new QTableWidget(1,1,this);
        QLabel* valideLabel = new QLabel("Validé :",this);
        QLabel* NonvalideLabel = new QLabel("A Valider :",this);
        valide->horizontalHeader()->hide();
        non_valide->horizontalHeader()->hide();
        valide->verticalHeader()->hide();
        non_valide->verticalHeader()->hide();
        valide->setMaximumSize(50,25);
        non_valide->setMaximumSize(50,25);

        QTableWidgetItem* ItemValide = new QTableWidgetItem("");
        ItemValide->setBackground(Qt::red);
        valide->setItem(0,0,ItemValide);

        QTableWidgetItem* ItemNonValide = new QTableWidgetItem("");
        ItemNonValide ->setBackground(Qt::gray);
        non_valide->setItem(0,0,ItemNonValide);
        //Tableaus affichant le nombre de crédits obtenu par catégorie
        for(QList<QString>::iterator it1 = Formation.begin(); it1 < Formation.end(); ++it1)
        {
            QMap<QString, unsigned int> ListeProfil = Dossier::getInstance().ListeProfil(*it1);
            QStringList P = ListeProfil.keys();
            QTableWidget* tab = new QTableWidget(1,ListeProfil.size(),this);
            tab->setHorizontalHeaderLabels(P);
            tab->setSelectionBehavior(QAbstractItemView::SelectRows);
            tab->verticalHeader()->hide();


            int i = 0;
            for(QList<QString>::iterator it2 = P.begin(); it2 < P.end(); ++it2)
            {
                QString cr; cr.setNum(ListeProfil[*it2]);
                QString creditFormation; creditFormation.setNum(FormationManager::getInstance().getFormation(*it1).getProfil(*it2));
                QString credit = cr +QString("(")+creditFormation+QString(")");
                QTableWidgetItem* monItem = new QTableWidgetItem(credit);
                if(FormationManager::getInstance().isFinished(*it1,*it2,ListeProfil[*it2]))
                    monItem->setBackground(Qt::red);
                else
                    monItem->setBackground(Qt::gray);
                tab->setItem(0,i,monItem);
                i++;
            }
            QLabel* form = new QLabel(*it1,this);
            lay->addWidget(form,j,0,1,3,Qt::AlignLeft);
            lay->addWidget(tab,j,1,1,3,Qt::AlignJustify);
            j++;
        }

        lay->addWidget(valideLabel,0,0);
        lay->addWidget(valide,0,1);
        lay->addWidget(NonvalideLabel,0,2);
        lay->addWidget(non_valide,0,3);
        lay->addWidget(ok,j,1,Qt::AlignHCenter);
        window->setLayout(lay);

        connect(ok,SIGNAL(clicked()),window,SLOT(accept()));
        window->exec();

        if(window->result())
        {

        }

    }
    catch(UTProfilerException& e)
    {
        QMessageBox::warning(this, "Ajout d'inscription", e.getInfo());
    }
}
Example #18
0
void DossierEditeur::ajouterInscription()
{
    try
    {
        QDialog* window = new QDialog(this);
        QGridLayout* lay = new QGridLayout;
        QPushButton* ok = new QPushButton("Ok");
        QComboBox *ListeUV= new QComboBox(this);
        QComboBox *ListeCursus= new QComboBox(this);
        QComboBox *ListeResultat= new QComboBox(this);
        QComboBox *ListeSaison= new QComboBox(this);
        QLineEdit *Annee= new QLineEdit(this);
        QLabel* UVLabel= new QLabel("UV : ",this);
        QLabel* cursusLabel= new QLabel("Cursus : ",this);
        QLabel* resultatLabel= new QLabel("Note : ",this);
        QLabel* saisonLabel= new QLabel("Saison : ",this);
        QLabel* anneeLabel = new QLabel("Année : ",this);
        window->setFixedSize(300, 400);

        UV** uvs = UVManager::getInstance().getUVs();
        for(unsigned int i=0;i<UVManager::getInstance().getNbUV(); i++)
        {
            ListeUV->addItem(uvs[i]->getCode());
        }


        for(Note n = first; n <= last; n = Note(n+1))
            ListeResultat->addItem(NoteToString(n));

        for(int i = 0; i < FormationManager::getInstance().getTaille(); i++)
            ListeCursus->addItem(FormationManager::getInstance().getElement(i).getCode());
        ListeSaison->addItem("Automne");
        ListeSaison->addItem("Printemps");

        lay->addWidget(UVLabel,0,0);
        lay->addWidget(cursusLabel,1,0);
        lay->addWidget(resultatLabel,2,0);
        lay->addWidget(saisonLabel,3,0);
        lay->addWidget(anneeLabel,4,0);
        lay->addWidget(ListeUV,0,1);
        lay->addWidget(ListeCursus,1,1);
        lay->addWidget(ListeResultat,2,1);
        lay->addWidget(ListeSaison,3,1);
        lay->addWidget(Annee,4,1);
        lay->addWidget(ok,5,1,Qt::AlignHCenter);

        window->setLayout(lay);

        connect(ok,SIGNAL(clicked()),window,SLOT(accept()));
        window->exec();

        if(window->result())
        {
            if(Annee->text().isEmpty())
                throw UTProfilerException("Ne laissez pas l'année vide !");

            UV& uv = UVManager::getInstance().getUV(ListeUV->currentText());
            Semestre s(StringToSaison(ListeSaison->currentText()),Annee->text().toUInt());
            Dossier::getInstance().ajouterInscription(uv,StringToNote(ListeResultat->currentText()),s,ListeCursus->currentText());
            QMessageBox::information(this,"Ajout d'une inscription", QString("Ajout de la catégorie ")+ListeUV->currentText()+" réussie.");
            dossier->setRowCount(Dossier::getInstance().getTaille());

            QTableWidgetItem *monItem = new QTableWidgetItem(ListeUV->currentText());
            dossier->setItem(Dossier::getInstance().getTaille() -1,0,monItem);

            monItem = new QTableWidgetItem(s.FormeContracte());
            dossier->setItem(Dossier::getInstance().getTaille() -1,1,monItem);

            monItem = new QTableWidgetItem(ListeResultat->currentText());
            dossier->setItem(Dossier::getInstance().getTaille() -1,2,monItem);

            monItem = new QTableWidgetItem(ListeCursus->currentText());
            dossier->setItem(Dossier::getInstance().getTaille() -1,3,monItem);
        }
    }
    catch(UTProfilerException& e)
    {
        QMessageBox::warning(this, "Ajout d'inscription", e.getInfo());
    }
}
Example #19
0
void MainWindow::on_btnLinkKey_clicked()
{
    WRITE2LOG("Linking...");
    if(certList.isEmpty() == true)
    {
        WRITE2LOG("Certificate list is empty");
        return;
    }

    if(ui->listCerts->currentIndex().row() == -1)
    {
        QMessageBox::warning(this, "Warning", "Select certificate!");
        return;
    }

    DWORD pcbData = 0;
    if(CertGetCertificateContextProperty(certList[ui->listCerts->currentIndex().row()], CERT_KEY_PROV_INFO_PROP_ID, NULL, &pcbData) != 0)
    {
        int result = QMessageBox::warning(this, "Warning", "This certificate already have private key.\nAre you sure you want to add new key?", QMessageBox::Ok, QMessageBox::Cancel);
        if (result == QMessageBox::Cancel)
        {
            WRITE2LOG("Canceled by user");
            return;
        }
    }

    QDialog* keyInfoDlg = new QDialog(this);
    QLineEdit* lnProvider = new QLineEdit;
    QLineEdit* lnLabel = new QLineEdit;


    QFormLayout* layout = new QFormLayout(keyInfoDlg);
    layout->addRow("CNG Cryptoprovider:", lnProvider);
    layout->addRow("Key name:", lnLabel);


    QDialogButtonBox *btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(btnBox, SIGNAL(accepted()), keyInfoDlg, SLOT(accept()));
    connect(btnBox, SIGNAL(rejected()), keyInfoDlg, SLOT(reject()));
    layout->addRow(btnBox);
    keyInfoDlg->exec();

    if(keyInfoDlg->result() == QDialog::Rejected)
    {
//        delete keyInfoDlg;
//        delete lnProvider;
//        delete lnLabel;
//        delete layout;
//        delete btnBox;
        WRITE2LOG("Canceled by user");
        return;
    }

    if(lnProvider->text().size() == 0 || lnLabel->text().size() == 0 )
    {
        QMessageBox::warning(this, "Warning", "All fields must be filled!", QMessageBox::Ok);
//        delete keyInfoDlg;
//        delete lnProvider;
//        delete lnLabel;
//        delete layout;
//        delete btnBox;
        return;
    }


    QString containerName = lnLabel->text();
    wchar_t* pwszContainerName = new wchar_t[containerName.size()];
    int size = containerName.toWCharArray(pwszContainerName);
    pwszContainerName[size] = 0;

    wchar_t* pwszProvider = new wchar_t[lnProvider->text().size()];
    size = lnProvider->text().toWCharArray(pwszProvider);
    pwszProvider[size] = 0;

    CRYPT_KEY_PROV_INFO kpi;
    ZeroMemory(&kpi, sizeof(kpi));

    kpi.pwszContainerName = pwszContainerName;
    kpi.dwProvType = NULL;
    kpi.pwszProvName = pwszProvider;

    LPCWSTR storage = L"";
    if(ui->rbMYStorage->isChecked() == true)
        storage = L"MY";
    else
        storage = L"ROOT";


    HCERTSTORE hCertStore = CertOpenStore(
           CERT_STORE_PROV_SYSTEM,
           0,
           NULL,
           CERT_SYSTEM_STORE_CURRENT_USER,
           storage);

    int res = CertSetCertificateContextProperty(certList[ui->listCerts->currentIndex().row()], CERT_KEY_PROV_INFO_PROP_ID, 0, &kpi);
    int ret = CertAddCertificateContextToStore(hCertStore, certList[ui->listCerts->currentIndex().row()], CERT_STORE_ADD_ALWAYS, NULL);
    if(res == 1 && ret == 1)
        QMessageBox::information(this, "Information", "Key was associated with certificate successfully. \nCertificate has been added to storage.", QMessageBox::Ok);
    else if (res == 0)
        QMessageBox::warning(this, "Warning", "Failed to associate key with certificate.", QMessageBox::Ok);
    else if (ret == 0)
        QMessageBox::warning(this, "Warning", "Failed to add certificate to store.", QMessageBox::Ok);

    delete keyInfoDlg;
    delete lnProvider;
    delete lnLabel;
    delete layout;
    delete btnBox;
    delete pwszContainerName;
    delete pwszProvider;
}