void MyMoneyReport::write ( QDomElement& e, QDomDocument *doc, bool anonymous ) const
{
  // No matter what changes, be sure to have a 'type' attribute.  Only change
  // the major type if it becomes impossible to maintain compatability with
  // older versions of the program as new features are added to the reports.
  // Feel free to change the minor type every time a change is made here.

  writeBaseXML ( *doc, e );

  if ( anonymous )
  {
    e.setAttribute ( "name", m_id );
    e.setAttribute ( "comment", QString ( m_comment ).fill ( 'x' ) );
  }
  else
  {
    e.setAttribute ( "name", m_name );
    e.setAttribute ( "comment", m_comment );
  }
  e.setAttribute ( "group", m_group );
  e.setAttribute ( "convertcurrency", m_convertCurrency );
  e.setAttribute ( "favorite", m_favorite );
  e.setAttribute ( "tax", m_tax );
  e.setAttribute ( "investments", m_investments );
  e.setAttribute ( "loans", m_loans );
  e.setAttribute ( "rowtype", kRowTypeText[m_rowType] );
  e.setAttribute ( "datelock", kDateLockText[m_dateLock] );
  e.setAttribute ( "includeschedules", m_includeSchedules );
  e.setAttribute ( "columnsaredays", m_columnsAreDays );
  e.setAttribute ( "includestransfers", m_includeTransfers );
  if ( !m_budgetId.isEmpty() )
    e.setAttribute ( "budget", m_budgetId );
  e.setAttribute ( "includesactuals", m_includeBudgetActuals );
  e.setAttribute ( "includeunused", m_includeUnusedAccounts );
  e.setAttribute ( "includesforecast", m_includeForecast );
  e.setAttribute ( "includesprice", m_includePrice );
  e.setAttribute ( "includesaverageprice", m_includeAveragePrice );
  e.setAttribute ( "includesmovingaverage", m_includeMovingAverage );
  if( m_includeMovingAverage )
    e.setAttribute ( "movingaveragedays", m_movingAverageDays );

  e.setAttribute ( "charttype", kChartTypeText[m_chartType] );
  e.setAttribute ( "chartdatalabels", m_chartDataLabels );
  e.setAttribute ( "chartgridlines", m_chartGridLines );
  e.setAttribute ( "chartbydefault", m_chartByDefault );
  e.setAttribute ( "chartlinewidth", m_chartLineWidth );

  if ( m_reportType == ePivotTable )
  {
    e.setAttribute ( "type", "pivottable 1.15" );
    e.setAttribute ( "detail", kDetailLevelText[m_detailLevel] );
    e.setAttribute ( "columntype", kColumnTypeText[m_columnType] );
    e.setAttribute ( "showrowtotals", m_showRowTotals );
  }
  else if ( m_reportType == eQueryTable )
  {
    e.setAttribute ( "type", "querytable 1.14" );

    QStringList columns;
    unsigned qc = m_queryColumns;
    unsigned it_qc = eQCbegin;
    unsigned index = 1;
    while ( it_qc != eQCend )
    {
      if ( qc & it_qc )
        columns += kQueryColumnsText[index];
      it_qc *= 2;
      index++;
    }
    e.setAttribute ( "querycolumns", columns.join ( "," ) );
  }
  else if ( m_reportType == eInfoTable )
  {
    e.setAttribute ( "type", "infotable 1.0" );
    e.setAttribute ( "detail", kDetailLevelText[m_detailLevel] );
    e.setAttribute ( "showrowtotals", m_showRowTotals );
  }

  //
  // Text Filter
  //

  QRegExp textfilter;
  if ( textFilter ( textfilter ) )
  {
    QDomElement f = doc->createElement ( "TEXT" );
    f.setAttribute ( "pattern", textfilter.pattern() );
    f.setAttribute ( "casesensitive", textfilter.caseSensitive() );
    f.setAttribute ( "regex", !textfilter.wildcard() );
    f.setAttribute ( "inverttext", m_invertText );
    e.appendChild ( f );
  }

  //
  // Type & State Filters
  //
  QValueList<int> typelist;
  if ( types ( typelist ) && ! typelist.empty() )
  {
    // iterate over payees, and add each one
    QValueList<int>::const_iterator it_type = typelist.begin();
    while ( it_type != typelist.end() )
    {
      QDomElement p = doc->createElement ( "TYPE" );
      p.setAttribute ( "type", kTypeText[*it_type] );
      e.appendChild ( p );

      ++it_type;
    }
  }

  QValueList<int> statelist;
  if ( states ( statelist ) && ! statelist.empty() )
  {
    // iterate over payees, and add each one
    QValueList<int>::const_iterator it_state = statelist.begin();
    while ( it_state != statelist.end() )
    {
      QDomElement p = doc->createElement ( "STATE" );
      p.setAttribute ( "state", kStateText[*it_state] );
      e.appendChild ( p );

      ++it_state;
    }
  }
  //
  // Number Filter
  //

  QString nrFrom, nrTo;
  if ( numberFilter ( nrFrom, nrTo ) )
  {
    QDomElement f = doc->createElement ( "NUMBER" );
    f.setAttribute ( "from", nrFrom );
    f.setAttribute ( "to", nrTo );
    e.appendChild ( f );
  }

  //
  // Amount Filter
  //

  MyMoneyMoney from, to;
  if ( amountFilter ( from, to ) ) // bool getAmountFilter(MyMoneyMoney&,MyMoneyMoney&);
  {
    QDomElement f = doc->createElement ( "AMOUNT" );
    f.setAttribute ( "from", from.toString() );
    f.setAttribute ( "to", to.toString() );
    e.appendChild ( f );
  }

  //
  // Payees Filter
  //

  QStringList payeelist;
  if ( payees ( payeelist ) )
  {
    if ( payeelist.empty() )
    {
      QDomElement p = doc->createElement ( "PAYEE" );
      e.appendChild ( p );
    }
    else
    {
      // iterate over payees, and add each one
      QStringList::const_iterator it_payee = payeelist.begin();
      while ( it_payee != payeelist.end() )
      {
        QDomElement p = doc->createElement ( "PAYEE" );
        p.setAttribute ( "id", *it_payee );
        e.appendChild ( p );

        ++it_payee;
      }
    }
  }

  //
  // Account Groups Filter
  //

  QValueList<MyMoneyAccount::accountTypeE> accountgrouplist;
  if ( accountGroups ( accountgrouplist ) )
  {
    // iterate over accounts, and add each one
    QValueList<MyMoneyAccount::accountTypeE>::const_iterator it_group = accountgrouplist.begin();
    while ( it_group != accountgrouplist.end() )
    {
      QDomElement p = doc->createElement ( "ACCOUNTGROUP" );
      p.setAttribute ( "group", kAccountTypeText[*it_group] );
      e.appendChild ( p );

      ++it_group;
    }
  }

  //
  // Accounts Filter
  //

  QStringList accountlist;
  if ( accounts ( accountlist ) )
  {
    // iterate over accounts, and add each one
    QStringList::const_iterator it_account = accountlist.begin();
    while ( it_account != accountlist.end() )
    {
      QDomElement p = doc->createElement ( "ACCOUNT" );
      p.setAttribute ( "id", *it_account );
      e.appendChild ( p );

      ++it_account;
    }
  }

  //
  // Categories Filter
  //

  accountlist.clear();
  if ( categories ( accountlist ) )
  {
    // iterate over accounts, and add each one
    QStringList::const_iterator it_account = accountlist.begin();
    while ( it_account != accountlist.end() )
    {
      QDomElement p = doc->createElement ( "CATEGORY" );
      p.setAttribute ( "id", *it_account );
      e.appendChild ( p );

      ++it_account;
    }
  }

  //
  // Date Filter
  //

  if ( m_dateLock == userDefined )
  {
    QDate dateFrom, dateTo;
    if ( dateFilter ( dateFrom, dateTo ) )
    {
      QDomElement f = doc->createElement ( "DATES" );
      if ( dateFrom.isValid() )
        f.setAttribute ( "from", dateFrom.toString ( Qt::ISODate ) );
      if ( dateTo.isValid() )
        f.setAttribute ( "to", dateTo.toString ( Qt::ISODate ) );
      e.appendChild ( f );
    }
  }
}
Exemple #2
0
void ThumbView::loadPrepare()
{
	float thumbAspect = 1.33;
	if (GData::thumbsLayout == Compact) {
		thumbAspect = 1.77;
	} else if (GData::thumbsLayout == Squares) {
		thumbAspect = 2;
	}

	thumbHeight = (GData::thumbsLayout == Squares)? thumbSize * thumbAspect : thumbSize;
	thumbWidth = (GData::thumbsLayout == Squares)? thumbSize * thumbAspect : thumbHeight * thumbAspect;
	setIconSize(QSize(thumbWidth, thumbHeight));

	fileFilters->clear();
	QString textFilter("*");
	textFilter+= filterStr;
	*fileFilters	<< textFilter + "*.bmp"
					<< textFilter + "*.cur"
					<< textFilter + "*.dds"
					<< textFilter + "*.gif"
					<< textFilter + "*.icns"
					<< textFilter + "*.ico"
					<< textFilter + "*.jpeg"
					<< textFilter + "*.jpg"
					<< textFilter + "*.jp2"
					<< textFilter + "*.jpe"
					<< textFilter + "*.mng"
					<< textFilter + "*.pbm"
					<< textFilter + "*.pgm"
					<< textFilter + "*.png"
					<< textFilter + "*.ppm"
					<< textFilter + "*.svg"
					<< textFilter + "*.svgz"
					<< textFilter + "*.tga"					
					<< textFilter + "*.tif"
					<< textFilter + "*.tiff"
					<< textFilter + "*.wbmp"
					<< textFilter + "*.webp"
					<< textFilter + "*.xbm"
					<< textFilter + "*.xpm";
	thumbsDir->setNameFilters(*fileFilters);
	thumbsDir->setFilter(QDir::Files);
	if (GData::showHiddenFiles) {
		thumbsDir->setFilter(thumbsDir->filter() | QDir::Hidden);
	}
	
	thumbsDir->setPath(GData::currentViewDir);

	QDir::SortFlags tempThumbsSortFlags = thumbsSortFlags;
	if (tempThumbsSortFlags & QDir::Size || tempThumbsSortFlags & QDir::Time) {
		tempThumbsSortFlags ^= QDir::Reversed;
	}
	thumbsDir->setSorting(tempThumbsSortFlags);

	thumbViewModel->clear();
	setSpacing(GData::thumbSpacing);

	if (isNeedScroll) {
		scrollToTop();
	}

	abortOp = false;
	newIndex = 0;

	thumbsRangeFirst = -1;
	thumbsRangeLast = -1;

	imageTags->resetTagsState();
}