Exemplo n.º 1
0
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	QComboBox *comboDelegate = new QComboBox(parent);
	comboDelegate->setModel(model);
	comboDelegate->setEditable(true);
	comboDelegate->setAutoCompletion(true);
	comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
	comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion);
	comboDelegate->view()->setEditTriggers(QAbstractItemView::AllEditTriggers);
	comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString)));
	connect(comboDelegate->lineEdit(), SIGNAL(editingFinished()), this, SLOT(testActivation()));
	connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation()));
	currCombo.comboEditor = comboDelegate;
	currCombo.currRow = index.row();
	currCombo.model = const_cast<QAbstractItemModel*>(index.model());

	// Current display of things on Gnome3 looks like shit, so
	// let`s fix that.
	if (isGnome3Session()) {
		QPalette p;
		p.setColor(QPalette::Window, QColor(Qt::white));
		p.setColor(QPalette::Base, QColor(Qt::white));
		comboDelegate->lineEdit()->setPalette(p);
		comboDelegate->setPalette(p);
	}
	return comboDelegate;
}
Exemplo n.º 2
0
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	QComboBox *comboDelegate = new QComboBox(parent);
	comboDelegate->setModel(model);
	comboDelegate->setEditable(true);
	comboDelegate->setAutoCompletion(true);
	comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
	comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion);
	comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString)));
	currCombo.comboEditor = comboDelegate;
	currCombo.currRow = index.row();
	currCombo.model = const_cast<QAbstractItemModel*>(index.model());
	return comboDelegate;
}
Exemplo n.º 3
0
void ComboBoxDelegate::testActivation(const QModelIndex &currIndex)
{
	testActivation(currIndex.data().toString());
}
Exemplo n.º 4
0
void Segment::majPerformance(ListePoints *mes_points) {

  int activable, desactivable;
  Point pc;
  Vecteur vect;
  Vecteur delta;

  if (mes_points->longueur() < 2) {
    loggerMsg("Historique insuffisant");
    return;
  }

  pc = *mes_points->getFirstPoint();

  if (!pc.isValid()) {
    loggerMsg("Premier point invalide");
    return;
  }

  activable = testActivation(mes_points);

  delta = _lpts.deltaListe();

  if (_actif == SEG_OFF) {
    if (activable > 0) {
      // activation
      pc = getFirstPoint();
      vect = mes_points->posRelative(pc);

      _monStart = vect._t;
      _monCur = vect._t;

      _monElev0 = vect._z;
      _monPElev = 0.;
      _elevTot = delta._z;
      _monAvance = 0.;
      _actif = SEG_START;

      Serial.print(F("Segment active : "));
      Serial.println(_nomFichier);
    }
  } else if (_actif > SEG_OFF) {
    // deja actif
    if (_actif == SEG_START) {
      _actif = SEG_ON;
    }

    desactivable = testDesactivation(mes_points);

    if (desactivable == 0) {
      // on met a jour la perfo

      vect = posAuSegment(pc);

      if (fabs(vect._y) < MARGE_ACT * DIST_ACT) {

        _monCur = vect._t;
        _monAvance = _monStart + vect._t - pc._rtime;

        _monElev0 = _lpts.getFirstPoint()->_alt;

        if (_elevTot > 5.) {
          _monPElev = vect._z;
          _monPElev -= pc._alt;
          _monPElev /= _elevTot;
        }

      } else {
        loggerMsg("Desactivation pendant segment de ");
        loggerMsg(_nomFichier.c_str());
        Serial.print(F("Desactivation pendant segment de "));
        Serial.print(_nomFichier);
        _actif = SEG_OFF;
      }

    } else {
      // on doit desactiver

      Point lp = *_lpts.getLastPoint();

      if (!lp.isValid()) {
        loggerMsg("Dernier point invalide !!!!!");
        Serial.print(F("Dernier point invalide !!!!!"));
        desallouerPoints();
        _actif = SEG_OFF;
        return;
      }

      // position relative du dernier point segment / mes points
      vect = mes_points->posRelative(lp);

      _monCur = vect._t - _monStart;
      _monAvance = delta._t - _monCur;
      Serial.println(String(_monStart, 2) + " - " + String(vect._t, 2) + " - " + String(delta._t, 2));

      _actif = SEG_FIN;

      Serial.print("Avance: ");
      Serial.println(_monAvance);
    }

  } else if (_actif < SEG_OFF) {
    _actif += 1;
  }



}