Beispiel #1
0
void AccountsComboBox::changeAccount()
{
	account_ = 0;
	if (currentIndex() >= 0 && currentIndex() < accounts().count())
		account_ = accounts().at(currentIndex());
	emit activated(account_);
}
Beispiel #2
0
void AccountsComboBox::updateAccounts()
{
	clear();

	foreach(PsiAccount* account, accounts())
		addItem(account->nameWithJid());

	if (accounts().indexOf(account_) == -1) {
		account_ = accounts().isEmpty() ? 0 : accounts().first();
		emit activated(account_);
	}
	setCurrentIndex(accounts().indexOf(account_));
}
void WebContentManager::update()
{
    SettingsManager settingsManager;
    QString disc;
    QString currentAccountName(settingsManager.currentAccount(panelNum));

    settingsManager.setCurrentPanel(panelNum);

    disc = settingsManager.accountDrive(currentAccountName);
    disc += QString(":");
    disc += QDir::toNativeSeparators("/");

    pathLabel->setText(disc + settingsManager.currentFolderPath(panelNum));
    drivesComboBox->setToolTip(tr("Email: ") + currentAccountName + tr("\nName: ") + settingsManager.name(currentAccountName));

    get(settingsManager.currentFolderUrl(panelNum));

    ComboBoxItem drivesMap;
    QIcon icon(QApplication::style()->standardIcon(QStyle::SP_DriveFDIcon));
    QStringList accounts(settingsManager.accounts());

    foreach(QString account, accounts)
    {
        QString driveLetter (settingsManager.accountDrive(account));
        QMap<QString, QIcon> drivesAdditionalInfo;

        drivesAdditionalInfo[account] = icon;
        drivesMap[driveLetter] = drivesAdditionalInfo;
    }
Beispiel #4
0
bool MyMoneyReport::hasReferenceTo ( const QString& id ) const
{
  QStringList list;

  // collect all ids
  accounts ( list );
  categories ( list );
  payees ( list );

  return ( list.contains ( id ) > 0 );
}
Beispiel #5
0
int		main( void ) {

	typedef std::vector<Account::t>							  accounts_t;
	typedef std::vector<int>								  ints_t;
	typedef std::pair<accounts_t::iterator, ints_t::iterator> acc_int_t;

	int	const				amounts[]	= { 42, 54, 957, 432, 1234, 0, 754, 16576 };
	size_t const			amounts_size( sizeof(amounts) / sizeof(int) );
	accounts_t				accounts( amounts, amounts + amounts_size );
	accounts_t::iterator 	acc_begin	= accounts.begin();
	accounts_t::iterator 	acc_end		= accounts.end();

	int	const				d[]			= { 5, 765, 564, 2, 87, 23, 9, 20 };
	size_t const			d_size( sizeof(d) / sizeof(int) );
	ints_t					deposits( d, d + d_size );
	ints_t::iterator 		dep_begin	= deposits.begin();
	ints_t::iterator 		dep_end		= deposits.end();

	int	const				w[]			= { 321, 34, 657, 4, 76, 275, 657, 7654 };
	size_t const			w_size( sizeof(w) / sizeof(int) );
	ints_t					withdrawals( w, w + w_size );
	ints_t::iterator 		wit_begin	= withdrawals.begin();
	ints_t::iterator 		wit_end		= withdrawals.end();

	Account::displayAccountsInfos();
	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );

	for ( acc_int_t it( acc_begin, dep_begin );
			it.first != acc_end && it.second != dep_end;
			++(it.first), ++(it.second) ) {

		(*(it.first)).makeDeposit( *(it.second) );
	}

	Account::displayAccountsInfos();
	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );

	for ( acc_int_t it( acc_begin, wit_begin );
			it.first != acc_end && it.second != wit_end;
			++(it.first), ++(it.second) ) {

		(*(it.first)).makeWithdrawal( *(it.second) );
	}

	Account::displayAccountsInfos();
	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );

	return 0;
}
MeeGo::ActiveSync::ConfigModel::ConfigModel(QObject* parent)
  : QAbstractListModel(parent)
  , m_configs()
  , m_email_accounts(0)
{
  QHash<int, QByteArray> roles;
  roles[EmailAddressRole] = "email";
  roles[UsernameRole]     = "username";
  roles[PasswordRole]     = "password";
  roles[ServerUrlRole]    = "serverUrl";
  setRoleNames(roles);

  // Initialize the Glib type system
  g_type_init ();

  // Retrieve e-mail accounts.
  GConfClient * const client = gconf_client_get_default();
  m_email_accounts = e_account_list_new(client);
  g_object_unref(client);

  // Retrieve the activesyncd configurations from GConf.
  MGConfItem accounts(MeeGo::ActiveSync::KEY_BASE);
  QList<QString> const keys = accounts.listDirs();

  typedef QList<QString>::const_iterator const_iterator;
  const_iterator const end = keys.end();
  for (const_iterator i = keys.begin(); i != end; ++i) {
    QString const & key = *i;
    if (!key.isEmpty()) {
      // Retrieve the e-mail from the key.
      // @todo There has to be a better way to do this!
      QString const email = key.right(key.count() - key.lastIndexOf("/") - 1);
      m_configs.append(new Config(email, m_email_accounts));
    }
  }

  // --------------------------------------------------
  // Retrieve ActiveSync calendar and contacts accounts
  // --------------------------------------------------
  // @todo ...
}
QByteArray KMoneyThingFile::dump()
{
  QByteArray output;
  QDataStream stream(output, IO_WriteOnly);
  
  stream << (QString) "KMoneyThing Document" << (QString) "pre1_draft";
  stream << (QString) "<name>" << mName << (QString) "</name>";
  stream << (QString) "<locale>" << mLocale << (QString) "</locale>";
  for (Q_UINT32 aI = 0; aI < accounts(); aI++)
  {
    KMoneyThingAccount* account = getAccount(aI);
    stream << (QString) "<account>";
    stream << (QString) "<type>" << account->type() << (QString) "</type>";
    stream << (QString) "<name>" << account->name() << (QString) "</name>";
    stream << (QString) "<description>" << account->description() << (QString) "</description>";
    stream << (QString) "<accountNumber>" << account->accountNumber() << (QString) "</accountNumber>";
    stream << (QString) "<institution>" << account->institution() << (QString) "</institution>";
    stream << (QString) "<locale>" << account->locale() << (QString) "</locale>";
    stream << (QString) "<balance>" << account->balance() << (QString) "</balance>";
    stream << (QString) "<startingBalance>" << account->startingBalance() << (QString) "</startingBalance>";
    for (Q_UINT32 tI = 0; tI < account->transactions(); tI++)
    {
      KMoneyThingTransaction* transaction = account->getTransaction(tI);
      stream << (QString) "<transaction>";
      stream << (QString) "<name>" << transaction->name() << (QString) "</name>";
      stream << (QString) "<type>" << transaction->type() << (QString) "</type>";
      stream << (QString) "<category>" << transaction->category() << (QString) "</category>";
      stream << (QString) "<payee>" << transaction->payee() << (QString) "</payee>";
      stream << (QString) "<state>" << transaction->state() << (QString) "</state>";
      stream << (QString) "<statement>" << transaction->statementId() << (QString) "</statement>";
      stream << (QString) "<split>" << transaction->split() << (QString) "</split>";
      stream << (QString) "<foreign>" << transaction->foreign() << (QString) "</foreign>";
      stream << (QString) "<exRate>" << transaction->exchangeRate() << (QString) "</exRate>";
      stream << (QString) "<accCurIn>" << transaction->accountCurrencyIn() << (QString) "</accCurIn>";
      stream << (QString) "<accCurOut>" << transaction->accountCurrencyOut() << (QString) "</accCurOut>";
      stream << (QString) "<trCurIn>" << transaction->transactionCurrencyIn() << (QString) "</trCurIn>";
      stream << (QString) "<trCurOut>" << transaction->transactionCurrencyOut() << (QString) "</trCurOut>";
      stream << (QString) "<trCurName>" << transaction->transactionCurrencyName() << (QString) "</trCurName>";
      for (Q_UINT32 stI = 0; stI < transaction->subTransactions(); stI++)
      {
        KMoneyThingSubTransaction* subTransaction = transaction->getSubTransaction(stI);
        stream << (QString) "<subTransaction>";
        stream << (QString) "<name>" << subTransaction->name() << (QString) "</name>";
        stream << (QString) "<category>" << subTransaction->category() << (QString) "</category>";
        stream << (QString) "<trCurIn>" << subTransaction->transactionCurrencyIn() << (QString) "</trCurIn>";
        stream << (QString) "<trCurOut>" << subTransaction->transactionCurrencyOut() << (QString) "</trCurOut>";
        stream << (QString) "</subTransaction>";
      }
      for (Q_UINT32 rI = 0; rI < transaction->references(); rI++)
      {
        KMoneyThingTransaction::Reference* reference = transaction->getReference(rI);
        stream << (QString) "<reference>";
        stream << (QString) "<refAccount>" << reference->accountName << (QString) "</refAccount>";
        stream << (QString) "<refTransaction>" << reference->transactionID << (QString) "</refTransaction>";
        stream << (QString) "</reference>";
      }
      stream << (QString) "</transaction>";
    }
    stream << (QString) "</account>";
  }
  for (Q_UINT32 cI = 0; cI < categories(); cI++)
    stream << (QString) "<category>" << getCategory(cI) << (QString) "</category>";
  for (Q_UINT32 rI = 0; rI < recurrences(); rI++)
  {
    KMoneyThingRecurringTransaction* transaction = getRecurrence(rI);
    stream << (QString) "<recurrence>";
    // If KMoneyThingTransaction is changed, copy its new code from above,
    // overwriting from ***HERE*** ...
    stream << (QString) "<name>" << transaction->name() << (QString) "</name>";
    stream << (QString) "<type>" << transaction->type() << (QString) "</type>";
    stream << (QString) "<category>" << transaction->category() << (QString) "</category>";
    stream << (QString) "<state>" << transaction->state() << (QString) "</state>";
    stream << (QString) "<statement>" << transaction->statementId() << (QString) "</statement>";
    stream << (QString) "<split>" << transaction->split() << (QString) "</split>";
    stream << (QString) "<foreign>" << transaction->foreign() << (QString) "</foreign>";
    stream << (QString) "<exRate>" << transaction->exchangeRate() << (QString) "</exRate>";
    stream << (QString) "<accCurIn>" << transaction->accountCurrencyIn() << (QString) "</accCurIn>";
    stream << (QString) "<accCurOut>" << transaction->accountCurrencyOut() << (QString) "</accCurOut>";
    stream << (QString) "<trCurIn>" << transaction->transactionCurrencyIn() << (QString) "</trCurIn>";
    stream << (QString) "<trCurOut>" << transaction->transactionCurrencyOut() << (QString) "</trCurOut>";
    stream << (QString) "<trCurName>" << transaction->transactionCurrencyName() << (QString) "</trCurName>";
    for (Q_UINT32 stI = 0; stI < transaction->subTransactions(); stI++)
    {
      KMoneyThingSubTransaction* subTransaction = transaction->getSubTransaction(stI);
      stream << (QString) "<subTransaction>";
      stream << (QString) "<name>" << subTransaction->name() << (QString) "</name>";
      stream << (QString) "<category>" << subTransaction->category() << (QString) "</category>";
      stream << (QString) "<trCurIn>" << subTransaction->transactionCurrencyIn() << (QString) "</trCurIn>";
      stream << (QString) "<trCurOut>" << subTransaction->transactionCurrencyOut() << (QString) "</trCurOut>";
      stream << (QString) "</subTransaction>";
    }
    for (Q_UINT32 rI = 0; rI < transaction->references(); rI++)
    {
      KMoneyThingTransaction::Reference* reference = transaction->getReference(rI);
      stream << (QString) "<reference>";
      stream << (QString) "<refAccount>" << reference->accountName << (QString) "</refAccount>";
      stream << (QString) "<refTransaction>" << reference->transactionID << (QString) "</refTransaction>";
      stream << (QString) "</reference>";
    }
    // ... to ***HERE***
    stream << (QString) "<recurrency>" << transaction->recurrence() << (QString) "</recurrency>";
    stream << (QString) "<xDays>" << transaction->xDays() << (QString) "</xDays>";
    stream << (QString) "<firstDate>" << transaction->firstDate() << (QString) "</firstDate>";
    stream << (QString) "<daysOn>";
    for (char i = 0; i < 7; i++)
      stream << transaction->isDayOn(i);
    stream << (QString) "</daysOn>";
    stream << (QString) "</recurrence>";
  }
  
  stream.device()->close();
  return qCompress(output);
}
Beispiel #8
0
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 );
    }
  }
}
Beispiel #9
0
void gTox::on_activate() {
    utils::debug::scope_log log(DBG_LVL_1("gtox"), {});
    Glib::Dir dir(m_config_path);
    std::vector<std::string> accounts(dir.begin(), dir.end());
    accounts.resize(std::distance(
        accounts.begin(),
        std::remove_if(
            accounts.begin(), accounts.end(), [](const std::string& name) {
                utils::debug::scope_log log(DBG_LVL_3("gtox"), { name });
                std::string state_ext = ".tox";
                bool f_tox = !(name.size() > state_ext.size()
                               && name.substr(name.size() - state_ext.size(),
                                        state_ext.size()) == state_ext);
                bool f_old_tox = (name != "tox_save");
                return f_tox && f_old_tox;
            })));

    //filter files with same name .tox
    //1. remove extension
    std::transform(accounts.begin(), accounts.end(), accounts.begin(), [](std::string a) {
        utils::debug::scope_log log(DBG_LVL_3("gtox"), { a });
        auto a_p = a.find_last_of(".");
        if (a_p != std::string::npos) {
            a.resize(a_p);
        }
        return a;
    });
    //2. sort
    std::sort(accounts.begin(), accounts.end());
    //3. remove duplicates
    accounts.erase(std::unique(accounts.begin(), accounts.end()), accounts.end());
    //4. make the full paths
    std::transform(accounts.begin(), accounts.end(), accounts.begin(), [this](const std::string& name) {
        utils::debug::scope_log log(DBG_LVL_3("gtox"), { name });
        return Glib::build_filename(m_config_path, name + ".tox");
    });

    // start profile select
    mark_busy();
    auto profile = dialog::profile_selection::create(accounts);
    unmark_busy();

    add_window(*profile);
    profile->present();

    auto profile_ptr = profile.raw();
    if (profile->get_path().empty()) {
        profile->signal_hide().connect_notify([this, profile_ptr]() {
            utils::debug::scope_log log(DBG_LVL_2("gtox"), {});
            if (!profile_ptr->get_path().empty()) {
                open(Gio::File::create_for_path(profile_ptr->get_path()));
            } else if (!profile_ptr->is_aborted()) {
                mark_busy();
                auto assistant = dialog::profile_create::create(m_config_path);
                unmark_busy();

                add_window(*assistant);

                assistant->present();

                auto assistant_ptr = assistant.raw();
                assistant->signal_hide().connect_notify([this, assistant_ptr]() {
                    utils::debug::scope_log log(DBG_LVL_2("gtox"), {});
                    Glib::ustring path = assistant_ptr->get_path();
                    remove_window(*assistant_ptr);
                    delete assistant_ptr;
                    if (!path.empty()) {
                        open(Gio::File::create_for_path(path));
                    } else {
                        activate();
                    }
                }, true);
            }
            remove_window(*profile_ptr);
            delete profile_ptr;
        }, true);
        profile->show();
    } else {
        if (!profile->is_aborted()) {
            activate();
        }
    }

    Gtk::Application::on_activate();
}