Sesion::Sesion(QWidget *parent) : QMainWindow(parent), ui(new Ui::Sesion) { ui->setupUi(this); ui->tableWidget->setEnabled(false); ui->tableWidget->setColumnCount(1); QHeaderView* header = ui->tableWidget->horizontalHeader(); header->setSectionResizeMode(0,QHeaderView::Stretch); header->setVisible(true); QStringList nameLabels; nameLabels<<"Aplicaciones"; ui->tableWidget->setHorizontalHeaderLabels(nameLabels); this->windowsAnhadir = new dNewApp(); ui->btnEditar->setEnabled(false); ui->btnEliminar->setEnabled(false); //ui->btnUp->setEnabled(false); //ui->btnDown->setEnabled(false); connect(this->windowsAnhadir,SIGNAL(getData(QString,QString,int,bool)),this,SLOT(newItem(QString,QString,int,bool))); connect(ui->btnAnhadir,SIGNAL(clicked()),this,SLOT(anhadirItem())); connect(ui->btnEditar,SIGNAL(clicked()),this,SLOT(editarItem())); connect(ui->btnEliminar,SIGNAL(clicked()),this,SLOT(eliminarItem())); connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(activarEditarBtn(int,int))); connect(ui->tableWidget,SIGNAL(cellPressed(int,int)),this,SLOT(activarEditarBtn(int,int))); connect(ui->tableWidget,SIGNAL(cellActivated(int,int)),this,SLOT(activarEditarBtn(int,int))); }
void Graficadora::llenarTabla(QMap<int, double> tablita) { this->table->clear(); int De = this->ui->le_De->text().toInt(); int A = this->ui->le_A->text().toInt(); int fila = 0; int columna = 0; QHeaderView *view = new QHeaderView(Qt::Horizontal); this->table->setRowCount((A-De)+1); this->table->setColumnCount(2); view->setDefaultSectionSize(60); view->setVisible(false); this->table->setHorizontalHeader(view); QHeaderView *vview = new QHeaderView(Qt::Vertical); vview->setVisible(false); this->table->setVerticalHeader(vview); for(int i = De; i<=A; i++) { columna = 0; QTableWidgetItem * y = new QTableWidgetItem(QString().setNum(tablita.value(i))); QTableWidgetItem * x = new QTableWidgetItem(QString().setNum(i)); this->table->setItem(fila,columna++,x); this->table->setItem(fila++,columna,y); } }
void MainWindow::loadSoup() { if(this->soupLoaded){ delete this->soup; } this->soup = new QTableWidget(this->logical->size,this->logical->size,this); for(int i = 0; i<this->logical->size; i++) { for(int z = 0; z<this->logical->size; z++) { QTableWidgetItem *t = new QTableWidgetItem(this->logical->logicalSoup[i][z]); this->soup->setItem(i,z,t); } } QHeaderView *viewH; QHeaderView *viewV; viewH = new QHeaderView(Qt::Horizontal); viewV = new QHeaderView(Qt::Vertical); viewH->setDefaultSectionSize(15); viewV->setDefaultSectionSize(15); viewH->setVisible(false); viewV->setVisible(false); this->soup->setHorizontalHeader(viewH); this->soup->setVerticalHeader(viewV); this->ui->gridLayout->addWidget(this->soup); this->soupLoaded = true; }
void TreeComboBox::updateView() { QTreeView *v = new QTreeView(); setView( v ); v->setSelectionMode( m_selectionmode ); // don't want to have mouseover select an item v->disconnect(SIGNAL(entered(QModelIndex))); QHeaderView *h = v->header(); for ( int i = 0; i < h->count(); ++i ) { h->setSectionHidden( i, ! m_showcolumns.contains( i ) ); } h->setVisible( m_showheader ); v->setRootIsDecorated( false ); }
void FrmAlbaran::lineasVentas() { // lineas de ventas QString cSQL; QString cId; cId = cId.number(oAlbaran->Getid()); cSQL ="select id,cCodigo,nCantidad,cDescripcion,rPvp,rSubtotal,nDto,rDto,rTotal, nPorcIva from lin_alb " " where Id_Cab = "+cId; ModelLin_alb = new QSqlQueryModel(); ModelLin_alb->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->Lineas->setModel(ModelLin_alb); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *Cabecera = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->Lineas->setHorizontalHeader(Cabecera); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". (en nuestro caso está oculta ya que muestra el id de la tabla y esto no nos interesa que lo vea el usuario */ // Cabecera->setResizeMode(0,QHeaderView::Fixed); Cabecera->resizeSection(0,0); // Cabecera->setResizeMode(1,QHeaderView::Fixed); Cabecera->resizeSection(1,85); // Cabecera->setResizeMode(2,QHeaderView::Fixed); Cabecera->resizeSection(2,65); // Cabecera->setResizeMode(3,QHeaderView::Fixed); Cabecera->resizeSection(3,413); // Cabecera->setResizeMode(4,QHeaderView::Fixed); Cabecera->resizeSection(4,120); // Cabecera->setResizeMode(9,QHeaderView::Fixed); Cabecera->resizeSection(9,35); ModelLin_alb->setHeaderData(1, Qt::Horizontal, QObject::tr("CÓDIGO")); ModelLin_alb->setHeaderData(2, Qt::Horizontal, QObject::tr("CANTIDAD")); ModelLin_alb->setHeaderData(3, Qt::Horizontal, QObject::tr("DESCRIPCIÓN")); ModelLin_alb->setHeaderData(4, Qt::Horizontal, QObject::tr("PVP")); ModelLin_alb->setHeaderData(5, Qt::Horizontal, QObject::tr("SUBTOTAL")); ModelLin_alb->setHeaderData(6, Qt::Horizontal, QObject::tr("%DTO")); ModelLin_alb->setHeaderData(7, Qt::Horizontal, QObject::tr("DTO")); ModelLin_alb->setHeaderData(8, Qt::Horizontal, QObject::tr("BASE")); ModelLin_alb->setHeaderData(9, Qt::Horizontal, QObject::tr("%IVA")); // Hacemos visible la cabecera Cabecera->setVisible(true); // Delegamos el control contenido en las columnas al nuevo objeto ColumnaGrid //ui->Lineas->setItemDelegateForColumn(4, Columna1); //ui->Lineas->setItemDelegateForColumn(5, Columna1); //ui->Lineas->setItemDelegateForColumn(6, Columna1); //ui->Lineas->setItemDelegateForColumn(7, Columna1); //ui->Lineas->setItemDelegateForColumn(8, Columna1); }
void TableView::setConfig() { scroolWidth = 16; this->setFrameStyle(0); QHeaderView *headerV = new QHeaderView(Qt::Vertical); headerV->setDefaultSectionSize(22); headerV->setVisible(false); this->setVerticalHeader(headerV); this->setSelectionMode(SingleSelection); this->setSelectionBehavior(SelectRows); this->setAlternatingRowColors(true); this->setEditTriggers(NoEditTriggers); this->setSortingEnabled(false); this->setFrameStyle(0); }
DownloadAbstractTableWidget::DownloadAbstractTableWidget(QWidget *parent) : QTableWidget(parent) { setAttribute(Qt::WA_TranslucentBackground); setFont(QFont("Helvetica")); setColumnCount(3); setRowCount(0); setShowGrid(false);//Does not display the grid QHeaderView *headerview = horizontalHeader(); headerview->setVisible(false); headerview->resizeSection(0, 20); headerview->resizeSection(1, 247); headerview->resizeSection(2, 45); verticalHeader()->setVisible(false); setMouseTracking(true); //Open the capture mouse function setStyleSheet(DownloadUIObject::MTableWidgetStyle01 + \ DownloadUIObject::MScrollBarStyle03 + \ DownloadUIObject::MLineEditStyle01 ); QFont f = font(); f.setBold(false); setFont(f); //Set the color of selected row setFrameShape(QFrame::NoFrame);//Set No Border setEditTriggers(QTableWidget::NoEditTriggers);//No edit setSelectionBehavior(QTableWidget::SelectRows); //Multi-line election setSelectionMode(QAbstractItemView::SingleSelection); setFocusPolicy(Qt::NoFocus); DownloadUtils::Widget::setTransparent(this, 0); m_previousColorRow = -1; m_previousClickRow = -1; m_defaultBkColor = QColor(255, 255, 255, 0); connect(this, SIGNAL(cellEntered(int,int)), SLOT(listCellEntered(int,int))); connect(this, SIGNAL(cellClicked(int,int)), SLOT(listCellClicked(int,int))); }
EditItems::EditItems(QWidget * parent, ItemsModel * it) : QDialog(parent) { setupUi(this); setModal(true); items = it; itemsView->setModel(items); itemsView->setItemDelegate(new ViewDelegate); itemsView->sortByColumn(1, Qt::AscendingOrder); itemsView->setColumnHidden(0, true); itemsView->setColumnWidth(1, 200); itemsView->setSelectionMode(QAbstractItemView::SingleSelection); itemsView->setSelectionBehavior(QAbstractItemView::SelectRows); QHeaderView *v = itemsView->verticalHeader(); v->setVisible(false); connect(closeButton, SIGNAL(clicked()), this, SLOT(accept())); }
SalesOrderManager::SalesOrderManager(QWidget* parent) : QSplitter(parent) { model = new SalesOrderModel(this); proxyModel = new SalesOrderProxyModel(this); proxyModel->setSourceModel(model); QWidget* container = new QWidget(this); QBoxLayout* containerLayout = new QVBoxLayout(container); containerLayout->setMargin(0); QString actionTooltip("%1<br><b>%2</b>"); QToolBar* toolBar = new QToolBar(container); toolBar->setIconSize(QSize(16, 16)); QAction* refreshAction = toolBar->addAction(QIcon(":/resources/icons/refresh.png"), "&Muat Ulang", this, SLOT(refresh())); refreshAction->setShortcut(QKeySequence("F5")); refreshAction->setToolTip(actionTooltip.arg("Muat ulang daftar pesanan").arg(refreshAction->shortcut().toString())); QAction* newAction = toolBar->addAction(QIcon(":/resources/icons/plus.png"), "&Baru", this, SLOT(openEditor())); newAction->setShortcut(QKeySequence("Ctrl+N")); newAction->setToolTip(actionTooltip.arg("Pesanan baru").arg(newAction->shortcut().toString())); QAction* closeTabAction = new QAction(this); closeTabAction->setShortcuts(QList<QKeySequence>({QKeySequence("Esc"), QKeySequence("Ctrl+W")})); addAction(closeTabAction); QAction* closeAllTabsAction = new QAction(this); closeAllTabsAction->setShortcut(QKeySequence("Ctrl+Shift+W")); addAction(closeAllTabsAction); containerLayout->addWidget(toolBar); QLabel* spacer = new QLabel(toolBar); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); toolBar->addWidget(spacer); stateComboBox = new QComboBox(toolBar); stateComboBox->setToolTip("Saring daftar pesanan berdasarkan status"); stateComboBox->addItem("Semua"); stateComboBox->addItem("Aktif"); stateComboBox->addItem("Selesai"); stateComboBox->addItem("Dibatalkan"); stateComboBox->setCurrentIndex(1); toolBar->addWidget(stateComboBox); searchEdit = new QLineEdit(toolBar); searchEdit->setToolTip("Cari di daftar pesanan"); searchEdit->setPlaceholderText("Cari"); searchEdit->setClearButtonEnabled(true); searchEdit->setMaxLength(100); searchEdit->setMaximumWidth(150); toolBar->addWidget(searchEdit); view = new QTableView(container); view->setToolTip("Klik ganda atau ketuk Enter untuk membuka pesanan"); view->setModel(proxyModel); view->setAlternatingRowColors(true); view->setSortingEnabled(true); view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setTabKeyNavigation(false); QHeaderView* header = view->verticalHeader(); header->setVisible(false); header->setMinimumSectionSize(20); header->setMaximumSectionSize(20); header->setDefaultSectionSize(20); header = view->horizontalHeader(); header->setToolTip("Klik pada header kolom untuk mengurutkan"); header->setHighlightSections(false); containerLayout->addWidget(view); infoLabel = new QLabel(container); infoLabel->setStyleSheet("font-style:italic;padding-bottom:1px;"); infoLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); containerLayout->addWidget(infoLabel); tabWidget = new QTabWidget(this); tabWidget->setDocumentMode(true); tabWidget->setTabsClosable(true); tabWidget->setMovable(true); tabWidget->hide(); setCollapsible(0, false); setCollapsible(1, false); connect(closeTabAction, SIGNAL(triggered(bool)), SLOT(closeCurrentTab())); connect(closeAllTabsAction, SIGNAL(triggered(bool)), SLOT(closeAllTabs())); connect(tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int))); connect(stateComboBox, SIGNAL(currentIndexChanged(int)), SLOT(refresh())); connect(searchEdit, SIGNAL(textChanged(QString)), SLOT(applyFilter())); connect(view, SIGNAL(activated(QModelIndex)), SLOT(edit())); QTimer::singleShot(0, this, SLOT(init())); }
bool Login::init(Datapipe *datapipe, const QString ¶ms) { this->datapipe = datapipe; this->params = params; QHBoxLayout *mainLayout = new QHBoxLayout(); setLayout(mainLayout); QSqlQuery query; loglevel = datapipe->getVariables()->value(_S("loglevel")).toInt(); query.prepare(datapipe->getSettings()->value(_S("login/queries/userslist")).toString()); query.bindValue(":current_base_id", datapipe->getVariables()->value(_S("current_base_id"))); if (!query.exec()) { qCritical() << _T("%1 Ошибка: %2\nЗапрос: %3\nПеременные: %4") .arg(posForLog, query.lastError().text(), query.lastQuery(), Service::join(query.boundValues())); QMessageBox message; message.setText(_T("Ошибка получения списка пользователей\nТекст: %1\n").arg(query.lastError().text())); message.exec(); return false; } model.setQuery(query); model.setHeaderData(0, Qt::Horizontal, _T("Пользователи")); view.setModel(&model); view.setSelectionMode(QAbstractItemView::SingleSelection); view.hideColumn(1); view.hideColumn(2); QHeaderView *header = view.verticalHeader(); header->setDefaultSectionSize(datapipe->getVariables()->value(_S("standart_text_height")).toInt()); header->setVisible(false); header = view.horizontalHeader(); header->setStretchLastSection(true); view.setFocusPolicy(Qt::NoFocus); mainLayout->addWidget(&view); QVBoxLayout *numpadLayout = new QVBoxLayout(); mainLayout->addLayout(numpadLayout); Numpad *npad = new Numpad(datapipe, this); npad->setEchoMode(QLineEdit::Password); numpadLayout->addWidget(npad); numpadLayout->addStretch(); connect(npad, SIGNAL(inputCommited(QString)), this, SLOT(passwordCommited(QString))); setFocusProxy(npad); this->installEventFilter(this); datapipe->getVariables()->remove(_S("user")); datapipe->getVariables()->remove(_S("user_id")); return true; }
void PlotSettingsDialog::setupSourceTable(const QStringList &dataSeriesNames, const PlotSettings &preset, bool offsetsEditable) { ui->sourceTable->setColumnCount(COLCOUNT); QTableWidgetItem *sourceNameColHeader = new QTableWidgetItem(tr("Data Series Name")); sourceNameColHeader->setToolTip(tr("The name of the data series.")); ui->sourceTable->setHorizontalHeaderItem(SOURCENAMECOL, sourceNameColHeader); QTableWidgetItem *offsetColHeader = new QTableWidgetItem(tr("Offset")); offsetColHeader->setToolTip(tr("The offset in milliseconds.\n\n" "This value is added to each timestamp\n" "of the respective data series.\n" "You can use this for example to adjust for\n" "time lags in the transmission of signals.")); ui->sourceTable->setHorizontalHeaderItem(OFFSETCOL, offsetColHeader); QTableWidgetItem *scaleColHeader = new QTableWidgetItem(tr("Scale Type")); if (offsetsEditable) { scaleColHeader->setToolTip(tr("The <i>default</i> type of scale to be used for the data series.")); } else { scaleColHeader->setToolTip(tr("The type of scale to be used for the data series.")); } ui->sourceTable->setHorizontalHeaderItem(SCALECOL, scaleColHeader); QHeaderView *hHeader = ui->sourceTable->horizontalHeader(); hHeader->setDefaultAlignment(Qt::AlignLeft); hHeader->setResizeMode(SOURCENAMECOL, QHeaderView::Stretch); hHeader->setResizeMode(OFFSETCOL, QHeaderView::ResizeToContents); hHeader->setResizeMode(SCALECOL, QHeaderView::ResizeToContents); hHeader->setMinimumSectionSize(120); QHeaderView *vHeader = ui->sourceTable->verticalHeader(); vHeader->setVisible(false); foreach (QString sourceName, dataSeriesNames) { int row = ui->sourceTable->rowCount(); ui->sourceTable->setRowCount(row + 1); QTableWidgetItem *sourceItem = new QTableWidgetItem(sourceName); // the item showing the data series name should not be editable sourceItem->setFlags(sourceItem->flags() & ~Qt::ItemIsEditable); ui->sourceTable->setItem(row, SOURCENAMECOL, sourceItem); QDoubleSpinBox *offsetSpinner = new QDoubleSpinBox(ui->sourceTable); offsetSpinner->setAlignment(Qt::AlignRight); // helps to set the min/max before you set the value ;) offsetSpinner->setMinimum(0.0); offsetSpinner->setMaximum(std::numeric_limits<double>::max()); offsetSpinner->setDecimals(qRound(qLn(OFFSETDIVISOR)/qLn(10))); offsetSpinner->setValue(preset.offset(sourceName)/OFFSETDIVISOR); offsetSpinner->setEnabled(offsetsEditable); ui->sourceTable->setCellWidget(row, OFFSETCOL, offsetSpinner); if (preset.scaleType(sourceName) == PlotSettings::NOT_SCALABLE) { QTableWidgetItem *scaleItem = new QTableWidgetItem(tr("n/a")); scaleItem->setFlags(scaleItem->flags() & ~Qt::ItemIsEditable); ui->sourceTable->setItem(row, SCALECOL, scaleItem); } else { QComboBox *scaleCombo = new QComboBox(); scaleCombo->addItems(PlotSettings::scaleTypeNames); scaleCombo->setCurrentIndex(preset.scaleType(sourceName)); ui->sourceTable->setCellWidget(row, SCALECOL, scaleCombo); } }
bool Cashbox::init(Datapipe *data, const QString ¶ms) { this->data = data; this->params = params; QMap<QString, QVariant>* vars = data->getVariables(); int button_width = vars->value(_S("standart_button_width")).toInt(); int button_height = vars->value(_S("standart_button_height")).toInt(); // int button_margin = vars->value(_S("standart_margins")).toInt(); loglevel = vars->value(_S("loglevel")).toInt(); QGridLayout *mainLayout = new QGridLayout(); this->setLayout(mainLayout); QSettings *settings = data->getSettings(); // model = new QSqlQueryModel(this); model.setQuery(settings->value("cashbox/queries/operations").toString()); model.setHeaderData(0, Qt::Horizontal, "Операции"); view.setModel(&model); view.hideColumn(1); QHeaderView *header = view.verticalHeader(); header->setDefaultSectionSize(button_height); header->setVisible(false); header = view.horizontalHeader(); header->setStretchLastSection(true); view.setFocusPolicy(Qt::NoFocus); mainLayout->addWidget(&view,0,1); view.setMaximumWidth(button_width * 2); QVBoxLayout *numpadLayout = new QVBoxLayout(); Numpad *npad = new Numpad(data, this); numpadLayout->addWidget(npad); numpadLayout->addStretch(1); mainLayout->addLayout(numpadLayout,0,2); connect(npad, SIGNAL(inputCommited(QString)), this, SLOT(summCommited(QString))); QVBoxLayout *totalsLayout = new QVBoxLayout(); totalsLayout->addWidget(&totals); totalsLayout->addStretch(); // totals.setMaximumWidth(button_width * 3); //totals.setMinimumWidth(Height(button_width * 3); mainLayout->addLayout(totalsLayout,0,0); updateTotals(); setFocusProxy(npad); return true; }
void frmClientes::LLenarCampos() { Configuracion *o_Configuracion = new Configuracion(); ui->txtcCodigoCliente->setText(oCliente->getcCodigoCliente()); ui->txtPrimerApellido->setText(oCliente->getcApellido1()); ui->txtSegundoApellido->setText(oCliente->getcApellido2()); ui->txtcNombre->setText(oCliente->getcNombre()); ui->txtcNombreFiscal->setText(oCliente->getcNombreFiscal()); ui->txtNombreFiscal->setText(oCliente->getcNombreFiscal()); ui->txtcNombreComercial->setText(oCliente->getcNombreComercial()); ui->txtcPersonaContacto->setText(oCliente->getcPersonaContacto()); ui->txtcCifNif->setText(oCliente->getcCifNif()); ui->txtcDireccion1->setText(oCliente->getcDireccion1()); ui->txtcDireccion2->setText(oCliente->getcDireccion2()); ui->txtcCp->setText(oCliente->getcCP()); ui->txtcPoblacion->setText(oCliente->getcPoblacion()); ui->txtcProvincia->setText(oCliente->getcProvincia()); ui->txtcPais->setText(oCliente->getcPais()); ui->txtcTelefono1->setText(oCliente->getcTelefono1()); ui->txtcTelefono2->setText(oCliente->getcTelefono2()); ui->txtcFax->setText(oCliente->getcFax()); ui->txtcMovil->setText(oCliente->getcMovil()); ui->txtcEMail->setText(oCliente->getcEmail()); ui->txtcWeb->setText(oCliente->getcWeb()); ui->txtcDireccionFactura1->setText(oCliente->getcDireccionFactura1()); ui->txtcDireccionFactura2->setText(oCliente->getcDireccionFactura2()); ui->txtcCPFactura->setText(oCliente->getcCPFactura()); ui->txtcPoblacionFactura->setText(oCliente->getcPoblacionFactura()); ui->txtcProvinciaFactura->setText(oCliente->getcProvinciaFactura()); ui->txtcPaisFactura->setText(oCliente->getcPaisFactura()); ui->txtcDireccionAlmacen1->setText(oCliente->getcDireccionAlmacen()); ui->txtcDireccionAlmacen2->setText(oCliente->getcDireccionAlmacen2()); ui->txtcCpPoblacionAlmacen->setText(oCliente->getcCPAlmacen()); ui->txtcPoblacionAlmacen->setText(oCliente->getcPoblacionAlmacen()); ui->txtcProvinciaAlmacen->setText(oCliente->getcProvinciaAlmacen()); ui->txtcPaisAlmacen->setText(oCliente->getcPaisAlmacen()); ui->txtdFechaAlta->setDate(oCliente->getdFechaAlta()); ui->txtdFechaUltimaCompra->setDate(oCliente->getdFechaUltimaCompra()); ui->txtrImporteAcumulado->setText(o_Configuracion->FormatoNumerico(QString::number( oCliente->getrAcumuladoVentas(),'f',2))); ui->txtrVentasEjercicio->setText(o_Configuracion->FormatoNumerico(QString::number(oCliente->getrVentasEjercicio(),'f',2))); ui->txtrRiesgoPermitido->setText(o_Configuracion->FormatoNumerico(QString::number(oCliente->getrRiesgoMaximo(),'f',2))); ui->txtrDeudaActual->setText(o_Configuracion->FormatoNumerico(QString::number(oCliente->getrDeudaActual(),'f',2))); ui->txttComentarios->setText(oCliente->gettComentarios()); if(oCliente->islBloqueado()) { ui->chklBloqueoCliente->setChecked(true); } else { ui->chklBloqueoCliente->setChecked(false); } ui->txttComentarioBloqueo->setText(oCliente->gettComentarioBloqueo()); ui->txtnPorcDtoCliente->setText(QString::number(oCliente->getnPorcDtoCliente())); if(oCliente->islRecargoEquivalencia()) { ui->chklRecargoEquivalencia->setChecked(true); } else { ui->chklRecargoEquivalencia->setChecked(false); } ui->txtcCuentaContable->setText(oCliente->getcCuentaContable()); ui->txtcCuentaIvaRepercutido->setText(oCliente->getcCuentaIvaRepercutido()); ui->txtcCuentaDeudas->setText(oCliente->getcCuentaDeudas()); ui->txtcCuentaCobros->setText(oCliente->getcCuentaCobros()); int indice=ui->cbocFormaPago->findText(oCliente->getcFormaPago()); if(indice!=-1) ui->cbocFormaPago->setCurrentIndex(indice); //ui->cbocFormaPago->setItemText(); ui->txtnDiaPago1->setValue(oCliente->getnDiaPago1()); ui->txtnDiaPago2->setValue(oCliente->getnDiaPago2()); // ui->cbonTarifaCliente->lineEdit()->setText(oCliente->getnTarifaCliente()); ui->txtrImporteACuenta->setText( o_Configuracion->FormatoNumerico(QString::number(oCliente->getrImporteACuenta(),'f',2))); ui->txtrVales->setText(o_Configuracion->FormatoNumerico(QString::number(oCliente->getrVales(),'f',2))); ui->txtcEntidadBancaria->setText(oCliente->getcEntidadBancaria()); ui->txtcOficinaBancaria->setText(oCliente->getcOficinaBancaria()); ui->txtcDc->setText(oCliente->getcDC()); ui->txtcCuentaCorriente->setText(oCliente->getcCuentaCorriente()); ui->txtdFechaNacimiento->setDate(oCliente->getdFechaNacimiento()); ui->txtcAccesoWeb->setText(oCliente->getcAccesoWeb()); ui->txtcPasswordWeb->setText(oCliente->getcPasswordweb()); if (oCliente->getlIRPF()) ui->chkClienteEmpresa->setChecked(true); else ui->chkClienteEmpresa->setChecked(false); // Tablas /******************************************************************** * DEUDAS *******************************************************************/ QSqlQueryModel *deudas = new QSqlQueryModel(); QString cSQL; cSQL= "Select id,cDocumento,rPendienteCobro,dFecha,dVencimiento from clientes_deuda where Id_cliente =" + QString::number(oCliente->getId()); deudas->setQuery(cSQL,QSqlDatabase::database("empresa")); ColumnaMoneda *columnaMoneda = new ColumnaMoneda(); ColumnaFecha *columnaFecha = new ColumnaFecha(); ui->TablaDeudas->setModel(deudas); ui->TablaDeudas->setItemDelegateForColumn(2,columnaMoneda); ui->TablaDeudas->setItemDelegateForColumn(3,columnaFecha); ui->TablaDeudas->setItemDelegateForColumn(4,columnaFecha); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraDeu = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->TablaDeudas->setHorizontalHeader(CabeceraDeu); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraDeu->setResizeMode(0,QHeaderView::Fixed); CabeceraDeu->resizeSection(0,0); CabeceraDeu->setResizeMode(1,QHeaderView::Fixed); CabeceraDeu->resizeSection(1,85); CabeceraDeu->setResizeMode(2,QHeaderView::Fixed); CabeceraDeu->resizeSection(2,85); CabeceraDeu->setResizeMode(3,QHeaderView::Fixed); CabeceraDeu->resizeSection(3,85); CabeceraDeu->setResizeMode(4,QHeaderView::Fixed); CabeceraDeu->resizeSection(4,85); deudas->setHeaderData(1, Qt::Horizontal, QObject::tr("DOCUMENTO")); deudas->setHeaderData(2, Qt::Horizontal, QObject::tr("I.PENDIENTE")); deudas->setHeaderData(3, Qt::Horizontal, QObject::tr("FECHA")); deudas->setHeaderData(4, Qt::Horizontal, QObject::tr("VTO")); CabeceraDeu->setVisible(true); /******************************************************************** * ALBARANES *******************************************************************/ QSqlQueryModel *Albaranes = new QSqlQueryModel(); cSQL= "Select id,nAlbaran,dFecha,nFactura,rTotalAlbaran from cab_alb where id_Cliente =" + QString::number(oCliente->getId()); Albaranes->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->TablaAlbaranes->setModel(Albaranes); ui->TablaAlbaranes->setItemDelegateForColumn(2,columnaFecha); ui->TablaAlbaranes->setItemDelegateForColumn(4,columnaMoneda); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraAlb = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->TablaAlbaranes->setHorizontalHeader(CabeceraAlb); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraAlb->setResizeMode(0,QHeaderView::Fixed); CabeceraAlb->resizeSection(0,0); CabeceraAlb->setResizeMode(1,QHeaderView::Fixed); CabeceraAlb->resizeSection(1,85); CabeceraAlb->setResizeMode(2,QHeaderView::Fixed); CabeceraAlb->resizeSection(2,85); CabeceraAlb->setResizeMode(3,QHeaderView::Fixed); CabeceraAlb->resizeSection(3,85); CabeceraAlb->setResizeMode(4,QHeaderView::Fixed); CabeceraAlb->resizeSection(4,85); Albaranes->setHeaderData(1, Qt::Horizontal, QObject::tr("ALBARAN")); Albaranes->setHeaderData(2, Qt::Horizontal, QObject::tr("FECHA")); Albaranes->setHeaderData(3, Qt::Horizontal, QObject::tr("FACTURA")); Albaranes->setHeaderData(4, Qt::Horizontal, QObject::tr("TOTAL")); CabeceraAlb->setVisible(true); /******************************************************************** * FACTURAS *******************************************************************/ QSqlQueryModel *Facturas = new QSqlQueryModel(this); cSQL= "Select id,cFactura,dFecha,dFechaCobro,rTotal from cab_fac where iId_Cliente =" + QString::number(oCliente->getId()); Facturas->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->tablaFacturas->setModel(Facturas); ui->tablaFacturas->setItemDelegateForColumn(2,columnaFecha); ui->tablaFacturas->setItemDelegateForColumn(3,columnaFecha); ui->tablaFacturas->setItemDelegateForColumn(4,columnaMoneda); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraFac = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->tablaFacturas->setHorizontalHeader(CabeceraFac); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraFac->setResizeMode(0,QHeaderView::Fixed); CabeceraFac->resizeSection(0,0); CabeceraFac->setResizeMode(1,QHeaderView::Fixed); CabeceraFac->resizeSection(1,85); CabeceraFac->setResizeMode(2,QHeaderView::Fixed); CabeceraFac->resizeSection(2,85); CabeceraFac->setResizeMode(3,QHeaderView::Fixed); CabeceraFac->resizeSection(3,85); CabeceraFac->setResizeMode(4,QHeaderView::Fixed); CabeceraFac->resizeSection(4,85); Facturas->setHeaderData(1, Qt::Horizontal, QObject::tr("FACTURA")); Facturas->setHeaderData(2, Qt::Horizontal, QObject::tr("FECHA")); Facturas->setHeaderData(3, Qt::Horizontal, QObject::tr("FECHA COBRO")); Facturas->setHeaderData(4, Qt::Horizontal, QObject::tr("TOTAL")); CabeceraFac->setVisible(true); /******************************************************************** * PRESUPUESTOS *******************************************************************/ QSqlQueryModel *Presupuestos = new QSqlQueryModel(this); cSQL= "Select id,nPresupuesto,dFecha,dValidoHasta,rTotal from cab_pre where id_Cliente =" + QString::number(oCliente->getId()); Presupuestos->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->tablaPresupuestos->setModel(Presupuestos); ui->tablaPresupuestos->setItemDelegateForColumn(2,columnaFecha); ui->tablaPresupuestos->setItemDelegateForColumn(3,columnaFecha); ui->tablaPresupuestos->setItemDelegateForColumn(4,columnaMoneda); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraPre = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->tablaPresupuestos->setHorizontalHeader(CabeceraPre); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraPre->setResizeMode(0,QHeaderView::Fixed); CabeceraPre->resizeSection(0,0); CabeceraPre->setResizeMode(1,QHeaderView::Fixed); CabeceraPre->resizeSection(1,85); CabeceraPre->setResizeMode(2,QHeaderView::Fixed); CabeceraPre->resizeSection(2,85); CabeceraPre->setResizeMode(3,QHeaderView::Fixed); CabeceraPre->resizeSection(3,85); CabeceraPre->setResizeMode(4,QHeaderView::Fixed); CabeceraPre->resizeSection(4,85); Presupuestos->setHeaderData(1, Qt::Horizontal, QObject::tr("PRES")); Presupuestos->setHeaderData(2, Qt::Horizontal, QObject::tr("FECHA")); Presupuestos->setHeaderData(3, Qt::Horizontal, QObject::tr("FECHA APRO.")); Presupuestos->setHeaderData(4, Qt::Horizontal, QObject::tr("TOTAL")); CabeceraPre->setVisible(true); /******************************************************************** * VALES *******************************************************************/ QSqlQueryModel *Vales = new QSqlQueryModel(this); cSQL= "Select id,nNumero,dFecha,dVto,rImporte from vales where id_Cliente =" + QString::number(oCliente->getId()); Vales->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->tablaVales->setModel(Vales); ui->tablaVales->setItemDelegateForColumn(2,columnaFecha); ui->tablaVales->setItemDelegateForColumn(3,columnaFecha); ui->tablaVales->setItemDelegateForColumn(4,columnaMoneda); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraVal = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->tablaVales->setHorizontalHeader(CabeceraVal); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraVal->setResizeMode(0,QHeaderView::Fixed); CabeceraVal->resizeSection(0,0); CabeceraVal->setResizeMode(1,QHeaderView::Fixed); CabeceraVal->resizeSection(1,85); CabeceraVal->setResizeMode(2,QHeaderView::Fixed); CabeceraVal->resizeSection(2,85); CabeceraVal->setResizeMode(3,QHeaderView::Fixed); CabeceraVal->resizeSection(3,85); CabeceraVal->setResizeMode(4,QHeaderView::Fixed); CabeceraVal->resizeSection(4,85); Vales->setHeaderData(1, Qt::Horizontal, QObject::tr("VALE")); Vales->setHeaderData(2, Qt::Horizontal, QObject::tr("FECHA")); Vales->setHeaderData(3, Qt::Horizontal, QObject::tr("VTO.")); Vales->setHeaderData(4, Qt::Horizontal, QObject::tr("TOTAL")); CabeceraVal->setVisible(true); /******************************************************************** * TICKETS *******************************************************************/ QSqlQueryModel *Tickets = new QSqlQueryModel(this); cSQL= "Select id,nTicket,dFecha,cHora,rImporte from cab_tpv where id_Cliente =" + QString::number(oCliente->getId()); Tickets->setQuery(cSQL,QSqlDatabase::database("empresa")); ui->tablaTickets->setModel(Tickets); ui->tablaTickets->setItemDelegateForColumn(2,columnaFecha); ui->tablaTickets->setItemDelegateForColumn(3,columnaFecha); ui->tablaTickets->setItemDelegateForColumn(4,columnaMoneda); //Creamos Objeto de la clase Cabecera para las cabeceras horizontales QHeaderView *CabeceraTic = new QHeaderView(Qt::Horizontal,this); // Le decimos a nuestro objeto QTableView que use la instancia de QHeaderView que acabamos de crear. ui->tablaTickets->setHorizontalHeader(CabeceraTic); /*Ponemos el tamaño deseado para cada columna, teniendo en cuenta que la primera columna es la "0". */ CabeceraTic->setResizeMode(0,QHeaderView::Fixed); CabeceraTic->resizeSection(0,0); CabeceraTic->setResizeMode(1,QHeaderView::Fixed); CabeceraTic->resizeSection(1,85); CabeceraTic->setResizeMode(2,QHeaderView::Fixed); CabeceraTic->resizeSection(2,85); CabeceraTic->setResizeMode(3,QHeaderView::Fixed); CabeceraTic->resizeSection(3,85); CabeceraTic->setResizeMode(4,QHeaderView::Fixed); CabeceraTic->resizeSection(4,85); Tickets->setHeaderData(1, Qt::Horizontal, QObject::tr("TICKET")); Tickets->setHeaderData(2, Qt::Horizontal, QObject::tr("FECHA")); Tickets->setHeaderData(3, Qt::Horizontal, QObject::tr("HORA")); Tickets->setHeaderData(4, Qt::Horizontal, QObject::tr("TOTAL")); CabeceraTic->setVisible(true); }
/* we create a table that has a fixed height, but can stretch to fit certain width */ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW) { // setup a new table QTableView *table = new QTableView(); QHeaderView *vHeader = table->verticalHeader(); QHeaderView *hHeader = table->horizontalHeader(); table->setAttribute(Qt::WA_DontShowOnScreen); table->setSelectionMode(QAbstractItemView::NoSelection); table->setFocusPolicy(Qt::NoFocus); table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); hHeader->setVisible(false); vHeader->setVisible(false); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) hHeader->setResizeMode(QHeaderView::Fixed); vHeader->setResizeMode(QHeaderView::Fixed); #else hHeader->setSectionResizeMode(QHeaderView::Fixed); vHeader->setSectionResizeMode(QHeaderView::Fixed); #endif // set the model table->setModel(model); /* setup cell span for the table using QTableView::setSpan(). * changes made here reflect on ProfilePrintModel::data(). */ const int cols = model->columnCount(); const int rows = model->rowCount(); // info on top table->setSpan(0, 0, 1, 4); table->setSpan(1, 0, 1, 4); // gas used table->setSpan(2, 0, 1, 2); table->setSpan(3, 0, 1, 2); // notes table->setSpan(6, 0, 1, 5); table->setSpan(7, 0, 5, 5); /* resize row heights to the 'profilePrintRowHeights' indexes. * profilePrintTableMaxH will then hold the table height. */ int i; profilePrintTableMaxH = 0; for (i = 0; i < rows; i++) { int h = profilePrintRowHeights.at(i); profilePrintTableMaxH += h; vHeader->resizeSection(i, h); } // resize columns. columns widths are percentages from the table width. int accW = 0; for (i = 0; i < cols; i++) { int pw = qCeil((qreal)(profilePrintColumnWidths.at(i) * tableW) / 100.0); accW += pw; if (i == cols - 1 && accW > tableW) /* adjust last column */ pw -= accW - tableW; hHeader->resizeSection(i, pw); } // resize table->resize(tableW, profilePrintTableMaxH); // hide the grid and set a stylesheet table->setItemDelegate(new ProfilePrintDelegate(this)); table->setShowGrid(false); table->setStyleSheet( "QTableView { border: none }" "QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }"); // return return table; }