int main() {
    Email email;
    email.setFromId("*****@*****.**");
    email.setToId("*****@*****.**");
    email.setSubject("hi there");
    email.setBody("This is a test\nFucked up at that :v ");
    email.setTimeNow();
    email.serialiseEmail();
    std::cout << email.getFromId() << " " << email.getToId() << " ";
    printf("\n");
    std::vector<Email> emailList;
    fillEmail(emailList);

    for(int i = 0; i < emailList.size(); i++) {
        std::cout << emailList[i].getFromId() << "\n";
        std::cout << emailList[i].getToId() << "\n";
        std::cout << emailList[i].getSubject() << "\n";
        std::cout << emailList[i].getBody() << "\n";
    }
}
Esempio n. 2
0
void ContactWidget::silentSetId(const int pId)
{
  disconnect(_first, SIGNAL(editingFinished()), this, SLOT(findDuplicates()));
  disconnect(_last, SIGNAL(editingFinished()), this, SLOT(findDuplicates()));
  if (pId == -1 || pId == 0)
  {
    _id = -1;
    _valid = false;
    connect(_first, SIGNAL(editingFinished()), this, SLOT(findDuplicates()));
    connect(_last, SIGNAL(editingFinished()), this, SLOT(findDuplicates()));
    clear();
  }
  else if (pId == _id)
    return;
  else
  {   
      XSqlQuery idQ;
      _query.replace("cntct()","cntct"); // Switch to non-restrictive table
      idQ.prepare(_query + " WHERE cntct_id = :id;");
      _query.replace("FROM cntct", "FROM cntct()"); // Switch back to restrictive table function
      idQ.bindValue(":id", pId);
      idQ.exec();
      if (idQ.first())
      {
          _ignoreSignals = true;

          _id = pId;

          _valid = true;
          _number->setText(idQ.value("cntct_number").toString());
          _honorific->setEditText(idQ.value("cntct_honorific").toString());
          _first->setText(idQ.value("cntct_first_name").toString());
          _middle->setText(idQ.value("cntct_middle").toString());
          _last->setText(idQ.value("cntct_last_name").toString());
          _suffix->setText(idQ.value("cntct_suffix").toString());
          _initials->setText(idQ.value("cntct_initials").toString());
          _crmAcct->setId(idQ.value("cntct_crmacct_id").toInt());
          _title->setText(idQ.value("cntct_title").toString());
          _phone->setText(idQ.value("cntct_phone").toString());
          _phone2->setText(idQ.value("cntct_phone2").toString());
          _fax->setText(idQ.value("cntct_fax").toString());
          _emailCache=idQ.value("cntct_email").toString();
          _webaddr->setText(idQ.value("cntct_webaddr").toString());
          _address->setId(idQ.value("cntct_addr_id").toInt());
          _active->setChecked(idQ.value("cntct_active").toBool());
          _notes = idQ.value("cntct_notes").toString();
          _owner->setUsername(idQ.value("cntct_owner_username").toString());

          fillEmail();

          if (_mapper->model())
          { 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)),       _number->text()); 	               _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_number)),       _number->text());
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_honorific)),    _honorific->currentText()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_first)),        _first->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_last)),         _last->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_initials)),     _initials->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)),          _number->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_title)),        _title->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_phone)),        _phone->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_phone2)),       _phone2->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_fax)),          _fax->text()); 	 
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_email)),        _email->currentText());
            _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(_webaddr)),      _webaddr->text()); 	 
           }

          _ignoreSignals = false;
      }
      else if (idQ.lastError().type() != QSqlError::NoError)
          QMessageBox::critical(this, tr("A System Error Occurred at %1::%2.")
                                        .arg(__FILE__)
                                        .arg(__LINE__),
                                idQ.lastError().databaseText());
    _valid = true;
  }

  _changed=false;
  // _parsed = TRUE;
}