Ejemplo n.º 1
0
void TextBox::mouseReleased(ofMouseEventArgs& args){
    ofPoint mouse = ofPoint(args.x,args.y);
    if(inside(mouse)) {
        if(!isEditing && mouseDownInRect){
	        beginEditing();
        }
    } else if(isEditing){
		endEditing();
	}
}
void ofxTextInputField::mouseReleased(ofMouseEventArgs& args){

    if(bounds.inside(args.x, args.y)) {
        if(!isEditing && mouseDownInRect){
	        beginEditing();
        }
    }
    else if(isEditing){
		endEditing();
	}
}
Ejemplo n.º 3
0
void List::onMouseButton(Widget& widget,
                         vec2 position,
                         MouseButton button,
                         Action action,
                         uint mods)
{
  if (action != PRESSED)
    return;

  const vec2 local = transformToLocal(position);

  float itemTop = height();

  for (uint i = m_offset;  i < m_items.size();  i++)
  {
    const float itemHeight = m_items[i]->height();
    const float itemBottom = itemTop - itemHeight;

    if (itemBottom <= local.y)
    {
      if (itemBottom < 0.f)
        setOffset(m_offset + 1);

      if (m_selection == i)
      {
        if (m_editable)
          beginEditing();
      }
      else
        setSelection(i, true);

      return;
    }

    itemTop = itemBottom;
    if (itemTop < 0.f)
      break;
  }
}
EditCustumerDialog::EditCustumerDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EditCustumerDialog)
{
    ui->setupUi(this);
    //Removes "What's it?" button
    this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
    //Make Connections
    QObject::connect(this->ui->edit_pushButton,SIGNAL(clicked()),this,SLOT(beginEditing()));
    QObject::connect(this->ui->save_pushButton_3,SIGNAL(clicked()),this,SLOT(endEditing()));
    QObject::connect(this->ui->cancel_pushButton_2,SIGNAL(clicked()),this,SLOT(endEditing()));
    //Sets Items for State Combobox
    this->ui->state_comboBox->addItems(global_config.usa_states);
    //Disables Edit, Cancel and Save Buttons
    this->ui->edit_pushButton->setEnabled(false);
    this->ui->cancel_pushButton_2->setEnabled(false);
    this->ui->save_pushButton_3->setEnabled(false);
    //Disables all LineEdits
    this->ui->personal_info_groupBox->setEnabled(false);
    this->ui->address_info_groupBox_2->setEnabled(false);
    //Defines Model Headers
    this->customer_model = new QSqlTableModel();
    customer_model->setTable("customer");
    //Define Headers
    customer_model->setHeaderData(customer_model->fieldIndex("id"), Qt::Horizontal, tr("#"));
    customer_model->setHeaderData(customer_model->fieldIndex("name"), Qt::Horizontal, tr("Name"));
    customer_model->setHeaderData(customer_model->fieldIndex("email"), Qt::Horizontal, tr("Email"));
    customer_model->setHeaderData(customer_model->fieldIndex("phone1"), Qt::Horizontal, tr("Phone 1"));
    customer_model->setHeaderData(customer_model->fieldIndex("phone2"), Qt::Horizontal, tr("Phone 2"));
    customer_model->setHeaderData(customer_model->fieldIndex("birthday"), Qt::Horizontal, tr("Birthday Date"));
    customer_model->setHeaderData(customer_model->fieldIndex("zip_code"), Qt::Horizontal, tr("Zip-Code"));
    customer_model->setHeaderData(customer_model->fieldIndex("address"), Qt::Horizontal, tr("Address"));
    customer_model->setHeaderData(customer_model->fieldIndex("state"), Qt::Horizontal, tr("State"));
    customer_model->setHeaderData(customer_model->fieldIndex("city"), Qt::Horizontal, tr("City"));
    //customer_model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    customer_model->select();
    //Sets Model on the Table View
    this->ui->customer_tableView->setModel(this->customer_model);
    //Disables Edit on Table
    this->ui->customer_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //Hides some columns on Table View
    this->ui->customer_tableView->hideColumn(customer_model->fieldIndex("points"));
    //Resizes the column according to its content
    this->ui->customer_tableView->resizeColumnsToContents();
    //Defines params for selection
    this->ui->customer_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->ui->customer_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
    //Hides Vertical Header
    this->ui->customer_tableView->verticalHeader()->setVisible(false);
    //Fills the search ComboBox
    QStringList list = QString("#,Name,Email,Phone,Birthday,Address,Zip-Code,State,City").split(",");
    this->ui->comboBox->addItems(list);
    //Connect Selection Changed Signal
    connect(this->ui->customer_tableView->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(selectionChanged(QItemSelection,QItemSelection)));
    connect(this->ui->search_lineEdit_2,SIGNAL(textEdited(QString)),this,SLOT(searchTextChanged(QString)));
    connect(this->ui->comboBox,SIGNAL(currentTextChanged(QString)),this,SLOT(combobox_text_changed(QString)));
    //Creates Data Mapper
    customer_mapper = new QDataWidgetMapper;
    customer_mapper->setModel(this->customer_model);
    customer_mapper->addMapping(this->ui->id_lineEdit, this->customer_model->fieldIndex("id"));
    customer_mapper->addMapping(this->ui->name_lineEdit_2, this->customer_model->fieldIndex("name"));
    customer_mapper->addMapping(this->ui->email_lineEdit_4, this->customer_model->fieldIndex("email"));
    customer_mapper->addMapping(this->ui->phone1_lineEdit_2, this->customer_model->fieldIndex("phone1"));
    customer_mapper->addMapping(this->ui->phone2_lineEdit_3, this->customer_model->fieldIndex("phone2"));
    customer_mapper->addMapping(this->ui->birthday_dateEdit, this->customer_model->fieldIndex("birthday"));
    customer_mapper->addMapping(this->ui->address_lineEdit_5, this->customer_model->fieldIndex("address"));
    customer_mapper->addMapping(this->ui->zip_code_lineEdit_6, this->customer_model->fieldIndex("zip_code"));
    customer_mapper->addMapping(this->ui->state_comboBox, this->customer_model->fieldIndex("state"));
    customer_mapper->addMapping(this->ui->city_lineEdit_7, this->customer_model->fieldIndex("city"));
    customer_mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    //customer_mapper->toFirst();
    //Creates connection for selection of Row on Table
    connect(this->ui->customer_tableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            customer_mapper, SLOT(setCurrentModelIndex(QModelIndex)));
    //Update ComboBox Text
    this->combobox_text_changed(this->ui->comboBox->currentText());
    connect(this->ui->search_dateEdit,SIGNAL(dateChanged(QDate)),this,SLOT(searchDateChanged(QDate)));
}