Exemplo n.º 1
0
QString QTreeWidgetItemProto::toString()    	const
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    return QString("[QTreeWidgetItem with %1 children and %2 columns]")
                   .arg(item->childCount())
                   .arg(item->columnCount());
  return QString();
}
Exemplo n.º 2
0
int LogbookTreeWidget::findColumnWithName(const std::string &name) {
	QTreeWidgetItem *item = headerItem();
	for (int i = 0; i < item->columnCount(); i++) {
		if (item->text(i).toStdString() == name) {
			return i;
		}
	}

	return -1;
}
Exemplo n.º 3
0
QVariantList QcTreeWidget::columns() const
{
  QVariantList varList;
  QTreeWidgetItem *header = headerItem();
  if( header ) {
    for( int i = 0; i < header->columnCount(); ++i ) {
      varList << header->text(i);
    }
  }
  return varList;
}
void TreeWidgetHeaderSetupDialog::setHeader(QTreeWidget* view, int)
{
    m_view = view;

    QTreeWidgetItem* header = view->headerItem();
    for( int i=0;i<header->columnCount();i++ )
    {
        QTreeWidgetItem* item = new QTreeWidgetItem(ui->MasterView);
        item->setText(0, header->text(i));
        item->setTextAlignment(0, header->textAlignment(i));
        item->setCheckState(0, view->isColumnHidden(i) ? Qt::Unchecked : Qt::Checked);
    }
}
Exemplo n.º 5
0
void RDTreeWidget::mouseMoveEvent(QMouseEvent *e)
{
  QTreeWidgetItem *item = itemAt(e->pos());

  clearHovers(invisibleRootItem(), item);

  if(item)
  {
    QVariant normalIcon = item->data(m_hoverColumn, Qt::DecorationRole);
    QVariant hoverIcon = item->data(m_hoverColumn, hoverIconRole);

    if(normalIcon.isValid() && hoverIcon.isValid())
    {
      item->setData(m_hoverColumn, hoverIconRole, QVariant());
      item->setData(m_hoverColumn, Qt::DecorationRole, hoverIcon);
      item->setData(m_hoverColumn, backupNormalIconRole, normalIcon);
    }

    if(!item->data(m_hoverColumn, backupBackColourRole).isValid())
    {
      QVariant backHoverColor = item->data(m_hoverColumn, hoverBackColourRole);

      QColor col = item->data(m_hoverColumn, hoverBackColourRole).value<QColor>();
      if(!col.isValid())
        col = m_defaultHoverColour;

      if(col.isValid())
      {
        item->setData(m_hoverColumn, backupBackColourRole, item->background(m_hoverColumn));
        for(int c = 0; c < item->columnCount(); c++)
          item->setData(c, Qt::BackgroundRole, QBrush(col));
      }
    }

    QModelIndex idx = indexAt(e->pos());

    if(idx.column() == m_hoverColumn && item->data(m_hoverColumn, Qt::DecorationRole).isValid() &&
       m_hoverHandCursor)
    {
      setCursor(QCursor(Qt::PointingHandCursor));
    }
    else
    {
      unsetCursor();
    }
  }

  emit mouseMove(e);

  QTreeWidget::mouseMoveEvent(e);
}
Exemplo n.º 6
0
void KForecastView::adjustHeadersAndResizeToContents(QTreeWidget *widget)
{
  QSize sizeHint(0, widget->sizeHintForRow(0));
  QTreeWidgetItem *header = widget->headerItem();
  for (int i = 0; i < header->columnCount(); ++i) {
    if (i > 0) {
      header->setData(i, Qt::TextAlignmentRole, Qt::AlignRight);
      // make sure that the row height stays the same even when the column that has icons is not visible
      if (m_totalItem) {
        m_totalItem->setSizeHint(i, sizeHint);
      }
    }
    widget->resizeColumnToContents(i);
  }
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_col_count (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         result = v8::Number::New (item->columnCount ());
      }
   }

   return scope.Close (result);
}
int treeWidgetToTextTable(QTreeWidgetItem *item, QTextTable *table, int rowNum) {
	for (int c = 0; c < item->childCount(); ++c) {
		QTreeWidgetItem *child = item->child(c);
		
		//export child
		table->appendRows(1);
		for (int colNum = 0; colNum < child->columnCount(); ++colNum) {
			table->cellAt(rowNum, colNum).firstCursorPosition().insertText(child->text(colNum));
		}
		++rowNum;
		
		//recurse to children
		if (child->isExpanded() && child->childCount() > 0) {
			rowNum = treeWidgetToTextTable(child, table, rowNum);
		}
	}
	
	return rowNum;
}
int toTreeWidget::addColumn(const QString &label, int width)
{
    QTreeWidgetItem *head = QTreeWidget::headerItem();
    if (!head)
        return -1;

    int index = head->columnCount();

    // dirty, dirty hack.

    // QTreeWidget appears to always have at least one column.  you're
    // meant to add columns by using setHeaderLabels() but this is a
    // lot of porting.

    // check if we have just 1 column and it's name is "1" and then
    // change the name.
    if (index == 1 && head->text(0) == "1")
        index = 0;              // don't add

    head->setText(index, label);
    return index;
}
Exemplo n.º 10
0
int ShapeFileOptionsWidget::getColumn(const QString& strField) const
{
   if (strField.isEmpty())
   {
      return -1;
   }

   QTreeWidgetItem* pHeaderItem = mpFeatureTree->headerItem();
   if (pHeaderItem != NULL)
   {
      for (int i = 0; i < pHeaderItem->columnCount(); i++)
      {
         QString strColumn = pHeaderItem->text(i);
         if (strColumn == strField)
         {
            return i;
         }
      }
   }

   return -1;
}
Exemplo n.º 11
0
void OptionsDialog::setSettings() {
    passwordEdit->setText(getSetting("password", "").toString());
    coreEdit->setText(getSetting("coreAddress", "localhost").toString());
    refreshSpin->setValue(getSetting("refresh", 3).toInt());
    savePassword->setChecked(getSetting("savePassword", false).toBool());
    useCompression->setChecked(getSetting("useCompression", false).toBool());
    showSplash->setChecked(getSetting("showSplash", true).toBool());
    trayCheckBox->setChecked(getSetting("useTray", false).toBool());
    altRowsCheckBox->setChecked(getSetting("altRows", false).toBool());
    serverEdit->setText(getSetting("serverURL", "http://www.applejuicenet.de/18.0.html").toString());
    launchCombo->setEditText(getSetting("launcher", launchCombo->itemText(0)).toString());
    int location = getSetting("location", AjSettings::SAME).toInt();
    sameComputerRadio->setChecked(location == AjSettings::SAME);
    specificRadio->setChecked(location == AjSettings::SPECIFIC);
    ftpRadio->setChecked(location == AjSettings::FTP);
    incomingSpecificEdit->setText(getSetting("incomingDirSpecific", "/").toString());
    tempSpecificEdit->setText(getSetting("tempDirSpecific", "/").toString());
    ftpServerEdit->setText(getSetting("ftp", "server", "localhost").toString());
    ftpPortEdit->setText(getSetting("ftp", "port", "21").toString());
    ftpUserEdit->setText(getSetting("ftp", "user", "anonymous").toString());
    ftpPasswordEdit->setText(getSetting("ftp", "password", "").toString());
    ftpInDirEdit->setText(getSetting("ftp", "inDir", "/").toString());
    ftpTmpDirEdit->setText(getSetting("ftp", "tmpDir", "/").toString());
    ftpActiveRadioButton->setChecked(getSetting("ftp", "mode", QFtp::Active) == QFtp::Active);
    ftpPassiveRadioButton->setChecked(getSetting("ftp", "mode", QFtp::Active) == QFtp::Passive);
    ftpMbSpinBox->setValue(getSetting("ftp", "mb", "10").toInt());
    bool ftpFull = getSetting("ftp", "full", false).toBool();
    ftpFullRadioButton->setChecked(ftpFull);
    ftpMbRadioButton->setChecked(!ftpFull);
    fetchServersCheckBox->setChecked(getSetting("fetchServersOnStartup", false).toBool());
    languageComboBox->setCurrentIndex(languageComboBox->findData(getSetting("language", "en").toString().split("_")[0]));

    // -- lists for optionaly showing columns/labales --
    statusbarList->clear();
    QList<QVariant> statusbarShow = getStatusbarShows(juicer->statusBarWidgets.size());
    for(int i=0; i<juicer->statusBarWidgets.size(); i++) {
        statusbarList->addItem(juicer->statusBarWidgets.at(i)->toolTip());
        statusbarList->item(statusbarList->count()-1)->setCheckState(
            statusbarShow.at(i).toBool()?Qt::Checked:Qt::Unchecked);
    }
    downloadTabList->clear();
    QTreeWidgetItem* h = juicer->downloadsTreeWidget->headerItem();
    for(int i=0; i<h->columnCount(); i++) {
        downloadTabList->addItem(h->text(i));
        downloadTabList->item(downloadTabList->count()-1)->setCheckState(
            juicer->downloadsTreeWidget->isColumnHidden(i)?Qt::Unchecked:Qt::Checked);
    }
    uploadTabList->clear();
    h = juicer->uploadsTreeWidget->headerItem();
    for(int i=0; i<h->columnCount(); i++) {
        uploadTabList->addItem(h->text(i));
        uploadTabList->item(uploadTabList->count()-1)->setCheckState(
            juicer->uploadsTreeWidget->isColumnHidden(i)?Qt::Unchecked:Qt::Checked);
    }

    QFont font;
    QVariant v = getSetting("font", QApplication::font());
    if (v.isValid() && ! v.toString().isEmpty()) {
        font = v.value<QFont>();
    }
    else {
      font = QFont("Arial", 9, QFont::Normal);
    }
    QApplication::setFont(font);
    fontComboBox->setCurrentFont(font);
    setFontSizes(font);
#ifdef Q_WS_WIN
    handlerCheckCheckBox->setChecked(!OptionsDialog::hasSetting("handler") || OptionsDialog::getSetting("handler", false).toBool());
    handlerDefaultCheckBox->setChecked(OptionsDialog::hasSetting("handler") && OptionsDialog::getSetting("handler", false).toBool());
    handlerDefaultCheckBox->setEnabled(handlerCheckCheckBox->isChecked());
#endif
    checkUpdatesCheckBox->setChecked(getSetting("checkUpdates", true).toBool());
    observeClipboardCheckBox->setChecked(getSetting("observeClipboard", false).toBool());
    quitGUIAfterCoreExitCheckBox->setChecked(getSetting("quitGUIAfterCoreExit", true).toBool());
    profilesStatusbarCheckBox->setChecked(getSetting("profilesStatusbar", false).toBool());
    videoEdit->setText(video());
    audioEdit->setText(audio());
    imageEdit->setText(image());
    textEdit->setText(text());
    archiveEdit->setText(archive());
    cddvdEdit->setText(cddvd());
}
Exemplo n.º 12
0
/**
\param fechaInicial
\param fechaFinal
\param cuentaInicial
\param cuentaFinal
\param nivel
\param jerarquico
**/
void BalanceView::presentarSyS ( QString fechaInicial, QString fechaFinal, QString cuentaInicial, QString cuentaFinal, int nivel, int, bool jerarquico )
{
    BL_FUNC_DEBUG
    BlFixed tsaldoant ( "0.00" ), tdebe ( "0.00" ), thaber ( "0.00" ), tsaldo ( "0.00" );
    BlDbRecordSet *ramas = NULL;
    BlDbRecordSet *hojas = NULL;

    try {
        /// Primero, averiguaremos la cantidad de ramas iniciales que nacen de la ra&iacute;z
        /// (tantas como n&uacute;mero de cuentas de nivel 2) y las vamos creando.
        mainCompany() ->begin();
        QString query = "SELECT *, nivel(codigo) AS nivel FROM cuenta ORDER BY codigo";

        ramas = mainCompany() ->loadQuery ( query );

        /// Creamos el arbol y lo inicializamos con todas las cuentas.
        BcPlanContableArbol *arbol;
        arbol = new BcPlanContableArbol;
        while ( !ramas->eof() ) {
            if ( ramas->value( "nivel" ).toInt() == 2 ) { /// Cuenta ra&iacute;z.
                /// Se crea una rama en el &aacute;rbol (de las primeritas que salen
                /// de una ra&iacute;z).
                arbol->nuevaRama ( ramas );
            } // end if
            ramas->nextRecord();
        } // end while
        arbol->inicializa ( ramas );
        delete ramas;

        /// Sacamos la subcadena para centros de coste y canales.
        BcCanalSeleccionarView *scanal = mainCompany() ->getselcanales();
        BcCentroCosteSeleccionarView *scoste = mainCompany() ->getselccostes();
        QString ccostes = scoste->cadcoste();
        if ( ccostes != "" ) {
            ccostes = " AND apunte.idc_coste IN (" + ccostes + ") ";
            ;
        } // end if

        QString ccanales = scanal->cadCanal();
        if (scanal->sinCanal()) {
            if ( ccanales != "" ) {
                ccanales = " AND (apunte.idcanal ISNULL OR apunte.idcanal IN (" + ccanales + ")) ";
            } else {
                ccanales = " AND apunte.idcanal ISNULL ";
            } // end if
        } else {
            if ( ccanales != "" ) {
                ccanales = " AND (apunte.idcanal <> NULL OR apunte.idcanal IN (" + ccanales + ")) ";
            } else {
                ccanales = " AND apunte.idcanal <> NULL ";
            } // end if
        } // end if

        QString wherecostesycanales = ccostes + ccanales;

        /// Ahora, usaremos el &aacute;rbol para poner los datos a cada hoja (cuenta)
        /// seg&uacute;n los per&iacute;odos que necesitemos acotar.
        /// Para ello, vamos a recopilar todos los apuntes introducidos agrupados por cuenta
        /// para poder averiguar el estado contable de cada cuenta.
        query = "SELECT cuenta.idcuenta, numapuntes, cuenta.codigo, saldoant, debe, haber, ( COALESCE(saldop,0) + COALESCE(saldoant,0)) AS saldo, debeej, haberej, saldoej FROM ";

        query += "(SELECT idcuenta, codigo FROM cuenta) AS cuenta ";

        query += " LEFT JOIN (SELECT idcuenta, COALESCE(sum(debe),0) AS debeej, COALESCE(sum(haber),0) AS haberej, (COALESCE(sum(debe),0) - COALESCE(sum(haber),0)) AS saldoej FROM apunte WHERE EXTRACT(year FROM fecha) = '" + fechaFinal.right ( 4 ) + "' " + wherecostesycanales + " GROUP BY idcuenta) AS ejercicio ON ejercicio.idcuenta = cuenta.idcuenta";

        query += " LEFT OUTER JOIN (SELECT idcuenta, count(idcuenta) AS numapuntes, COALESCE(sum(debe),0) AS debe, COALESCE(sum(haber),0) AS haber, (COALESCE(sum(debe),0) - COALESCE(sum(haber),0)) AS saldop FROM apunte WHERE fecha >= '" + fechaInicial + "' AND fecha <= '" + fechaFinal + "' " + wherecostesycanales + " GROUP BY idcuenta) AS periodo ON periodo.idcuenta = cuenta.idcuenta ";

        query += " LEFT OUTER JOIN (SELECT idcuenta, (COALESCE(sum(debe),0) - COALESCE(sum(haber),0)) AS saldoant FROM apunte WHERE  fecha < '" + fechaInicial + "' " + wherecostesycanales +  " GROUP BY idcuenta) AS anterior ON cuenta.idcuenta = anterior.idcuenta ORDER BY codigo";

        /// Poblamos el &aacute;rbol de hojas (cuentas).
        hojas = mainCompany() ->loadQuery ( query );
        while ( !hojas->eof() ) {
            /// Para cada cuenta con apuntes introducidos hay que actualizar hojas del &aacute;rbol.
            arbol->actualizaHojas ( hojas );
            hojas->nextRecord();
        } // end while
        delete hojas;
        /// Establecemos la hoja activa
        arbol->inicia();

        /// Por fin, presentamos los valores.
        /// Aunque antes, prepararemos el Widget con la cabecera a mostrar.
        QStringList headers, datos;
        headers << _ ( "Codigo" ) << _ ( "Denominacion" ) << _ ( "Saldo anterior" ) << _ ( "Debe" ) << _ ( "Haber" ) << _ ( "Saldo" ) << _ ( "Debe " ) + fechaFinal.right ( 4 ) << _ ( "Haber " ) + fechaFinal.right ( 4 ) << _ ( "Saldo " ) + fechaFinal.right ( 4 );
        mui_list->setHeaderLabels ( headers );
        mui_list->clear();

        /// Ponemos las columnas

        mui_list->setColumnWidth ( CUENTA, 250 );
        mui_list->setColumnWidth ( DENOMINACION, 150 );
        mui_list->setColumnWidth ( SALDO_ANT, 100 );
        mui_list->setColumnWidth ( DEBE, 100 );
        mui_list->setColumnWidth ( HABER, 100 );
        mui_list->setColumnWidth ( SALDO, 100 );
        mui_list->setColumnWidth ( DEBEEJ, 100 );
        mui_list->setColumnWidth ( HABEREJ, 100 );
        mui_list->setColumnWidth ( SALDOEJ, 100 );


        /// Cada hoja del &aacute;rbol usara uno de estos Widgets para mostrarse.
        QTreeWidgetItem *it;
        int nivelActual;
        /// Mantenemos una tabla con &iacute;ndices de niveles del &aacute;rbol.
        QMap <int, QTreeWidgetItem *> ptrList;
        /// Y el iterador para controlar donde accedemos, as&iacute; como un &iacute;ndice
        /// adicional.
        QMap <int, QTreeWidgetItem *>::const_iterator ptrIt, i;
        ptrList.clear();


        while ( arbol->deshoja ( nivel, jerarquico ) ) {
            QString lcuenta = arbol->hojaActual ( "codigo" );
            QString ldenominacion = arbol->hojaActual ( "descripcion" );
            QString lsaldoant = arbol->hojaActual ( "saldoant" );
            QString ldebe = arbol->hojaActual ( "debe" );
            QString lhaber = arbol->hojaActual ( "haber" );
            QString lsaldo = arbol->hojaActual ( "saldo" );
            QString ldebeej = arbol->hojaActual ( "debeej" );
            QString lhaberej = arbol->hojaActual ( "haberej" );
            QString lsaldoej = arbol->hojaActual ( "saldoej" );

            if ( lcuenta >= cuentaInicial and lcuenta <= cuentaFinal ) {
                /// Acumulamos los totales para al final poder escribirlos.
                /// Solo si son del nivel seleccionado o son hojas finales ya que en un jerarquico no se puede acumular
                /// TODO: No funciona bien en todos los niveles. Principalmente si el arbol no es normalizado
                if (lcuenta.length() == nivel) {
                    tsaldoant = tsaldoant + BlFixed ( lsaldoant );
                    tsaldo = tsaldo + BlFixed ( lsaldo );
                    tdebe = tdebe + BlFixed ( ldebe );
                    thaber = thaber + BlFixed ( lhaber );
                } // end if

                /// Las variables de las filas en formato espa&ntilde;ol.
                lsaldoant = QString::number ( lsaldoant.toDouble(), 'f', 2 );
                ldebe = QString::number ( ldebe.toDouble(), 'f', 2 );
                lhaber = QString::number ( lhaber.toDouble(), 'f', 2 );
                lsaldo = QString::number ( lsaldo.toDouble(), 'f', 2 );
                ldebeej = QString::number ( ldebeej.toDouble(), 'f', 2 );
                lhaberej = QString::number ( lhaberej.toDouble(), 'f', 2 );
                lsaldoej = QString::number ( lsaldoej.toDouble(), 'f', 2 );

                /// Ahora, vamos a pintar en el Widget cada l&iacute;nea.
                /// Formamos la l&iacute;nea.
                datos << lcuenta << ldenominacion << lsaldoant << ldebe << lhaber << lsaldo << ldebeej << lhaberej << lsaldoej;

                /// Si se van mostrar tambi&eacute;n las cuentas superiores, habr&aacute; que
                /// jerarquizar el &aacute;rbol. Sino, se pinta cada l&iacute;nea al mismo nivel.
                if ( jerarquico ) { /// jerarquizando...
                    nivelActual = lcuenta.length();
                    if ( nivelActual == 2 ) {
                        /// La hoja cuelga de la ra&iacute;z principal.
                        it = new QTreeWidgetItem ( mui_list, datos );
                    } else {
                        while ( ptrIt.key() >= nivelActual )
                            /// Ascendemos por el &aacute;rbol para colgar la hoja en el
                            /// lugar correcto.
                            ptrIt--;
                        it = new QTreeWidgetItem ( ptrIt.value(), datos );
                    } // end if
                    /// Insertamos el widget (hoja actual) en la tabla controlada y obtenemos
                    /// su puntero iterador.
                    ptrIt = ptrList.insert ( nivelActual, it );
                    mui_list->setItemExpanded ( it, true );
                    /// Borramos el resto de niveles que cuelgan, para no seguir colgando por
                    /// esa rama.
                    i = ptrIt + 1;
                    while ( i != ptrList.constEnd() ) {
                        /// Borra todas las entradas con la misma clave.
                        ptrList.remove ( i.key() );
                        ++i;
                    } // end while
                } else { /// sin jerarquizar...
                    it = new QTreeWidgetItem ( mui_list, datos );
                } // end if
                datos.clear();

                /// Formateamos un poquito la informaci&oacute;n mostrada.
                int tamanyo = 10;
                if ( ldenominacion.length() > 40 ) {
                    tamanyo -= 1;
                } else if ( ldenominacion.length() > 50 ) {
                    tamanyo -= 2;
                } // end if
                it->setFont ( DENOMINACION, QFont ( "Serif", tamanyo, -1, false ) );
                for ( int col = 0; col < it->columnCount(); col++ ) {

                    if ( col == DEBE || col == HABER || col == SALDO ||  col == DEBEEJ || col == HABEREJ || col == SALDOEJ ) {
                        it->setFont ( col, QFont ( "SansSerif", 9, QFont::DemiBold, false ) );
                    } else {
                        it->setFont ( col, QFont ( "SansSerif", 9, QFont::Normal, false ) );
                    } // end if
                    it->setTextAlignment ( col, Qt::AlignRight );

                    if ( lcuenta.size() == 2 ) {
                        it->setTextColor ( col, Qt::darkGray );
                        it->setFont ( col, QFont ( "SansSerif", 10, QFont::Bold, false ) );
                    } else if ( lcuenta.size() < 5 ) {
                        it->setTextColor ( col, Qt::blue );
                    } else {
                        if ( it->text ( col ).left ( 1 ) == "-" ) {
                            it->setTextColor ( col, Qt::darkRed );
                        } else {
                            it->setTextColor ( col, Qt::black );
                        } // end if
                    } // end if
                } // end for
            } // end if
        } // end while
        mui_list->resizeColumnToContents ( 1 );

        /// Hacemos la actualizaci&oacute;n de los saldos totales en formato
        /// espa&ntilde;ol y los ponemos en su Widget.
        QString totsaldoant = tsaldoant.toQString();
        QString totdebe = tdebe.toQString();
        QString tothaber = thaber.toQString();
        QString totsaldo = tsaldo.toQString();
        mui_totalSaldoAnterior->setText ( totsaldoant );
        mui_totalDebe->setText ( totdebe );
        mui_totalHaber->setText ( tothaber );
        mui_totalSaldo->setText ( totsaldo );

        /// Eliminamos el &aacute;rbol de la mem&oacute;ria y cerramos la conexi&oacute;n
        /// con la BD.
        delete arbol;
        mainCompany() ->commit();
    } catch ( ... ) {
        blMsgInfo ( _("Error en los calculos.") );
        mainCompany() ->rollback();
        /// Libermos posible memoria utilizada
        if ( ramas ) delete ramas;
        if ( hojas ) delete hojas;
    } // end try

}