[GUI] Remove broken toQstring function

This commit is contained in:
Nathan Hourt 2015-07-24 13:57:47 -04:00
parent e4ff106cd4
commit 972c9a6407
5 changed files with 34 additions and 38 deletions

View file

@ -31,15 +31,15 @@ public:
{ {
m_account.name = name.toStdString(); m_account.name = name.toStdString();
} }
void setAccountObject( const account_object& obj ) void setAccountObject(const account_object& obj)
{ {
auto old_name = m_account.name; auto old_name = m_account.name;
m_account = obj; m_account = obj;
if( old_name != m_account.name ) if (old_name != m_account.name)
Q_EMIT nameChanged(); Q_EMIT nameChanged();
} }
QString name()const { return toQString(m_account.name); } QString name()const { return QString::fromStdString(m_account.name); }
QQmlListProperty<Balance> balances(); QQmlListProperty<Balance> balances();
void setBalances(QList<Balance*> balances) { void setBalances(QList<Balance*> balances) {

View file

@ -195,7 +195,7 @@ void ChainDataModel::getAccountImpl(QString accountIdentifier, Account* const *
} else { } else {
m_accounts.modify(itr, [this,&accountPackage](Account* a){ m_accounts.modify(itr, [this,&accountPackage](Account* a){
a->setProperty("id", ObjectId(accountPackage->account.id.instance())); a->setProperty("id", ObjectId(accountPackage->account.id.instance()));
a->setAccountObject( accountPackage->account ); a->setAccountObject(accountPackage->account);
// Set balances // Set balances
QList<Balance*> balances; QList<Balance*> balances;

View file

@ -5,8 +5,6 @@
#include <functional> #include <functional>
QString toQString( const std::string& s );
using ObjectId = qint64; using ObjectId = qint64;
Q_DECLARE_METATYPE(ObjectId) Q_DECLARE_METATYPE(ObjectId)

View file

@ -3,10 +3,9 @@
#include <fc/crypto/aes.hpp> #include <fc/crypto/aes.hpp>
#include <fc/io/json.hpp> #include <fc/io/json.hpp>
QString toQString( const std::string& s ) { QString result; result.fromStdString( s ); return result; } QString toQString(public_key_type k) { return QString::fromStdString(fc::variant(k).as_string()); }
QString toQString( public_key_type k ) { return toQString( fc::variant(k).as_string() ); }
Wallet::Wallet( QObject* parent ) Wallet::Wallet(QObject* parent)
:QObject(parent) :QObject(parent)
{ {
} }
@ -16,10 +15,10 @@ Wallet::~Wallet()
close(); close();
} }
bool Wallet::open( QString file_path ) bool Wallet::open(QString file_path)
{ {
fc::path p( file_path.toStdString() ); fc::path p(file_path.toStdString());
if( !fc::exists( p ) ) if( !fc::exists(p) )
{ {
ilog( "Unable to open wallet file '${f}', it does not exist", ("f",p) ); ilog( "Unable to open wallet file '${f}', it does not exist", ("f",p) );
return false; return false;
@ -30,7 +29,7 @@ bool Wallet::open( QString file_path )
for( const auto& key : _data.encrypted_private_keys ) for( const auto& key : _data.encrypted_private_keys )
{ {
if( key.second.label != string() ) if( key.second.label != string() )
_label_to_key[toQString(key.second.label)] = toQString( key.first ); _label_to_key[QString::fromStdString(key.second.label)] = toQString(key.first);
if( key.second.encrypted_private_key.size() ) if( key.second.encrypted_private_key.size() )
_available_private_keys.insert( key.first ); _available_private_keys.insert( key.first );
} }
@ -217,7 +216,7 @@ QString Wallet::getPrivateKey( QString pubkey )
if( itr->second.encrypted_private_key.size() == 0 ) if( itr->second.encrypted_private_key.size() == 0 )
return QString(); return QString();
auto plain = fc::aes_decrypt( _decrypted_master_key, itr->second.encrypted_private_key ); auto plain = fc::aes_decrypt( _decrypted_master_key, itr->second.encrypted_private_key );
return toQString( fc::raw::unpack<std::string>(plain) ); return QString::fromStdString( fc::raw::unpack<std::string>(plain) );
} }
QString Wallet::getPublicKey( QString wif_private_key )const QString Wallet::getPublicKey( QString wif_private_key )const
@ -227,7 +226,7 @@ QString Wallet::getPublicKey( QString wif_private_key )const
auto pub = public_key_type(priv->get_public_key()); auto pub = public_key_type(priv->get_public_key());
return toQString( fc::variant( pub ).as_string() ); return QString::fromStdString( fc::variant( pub ).as_string() );
} }
QString Wallet::getActivePrivateKey( QString owner_pub_key, uint32_t seq ) QString Wallet::getActivePrivateKey( QString owner_pub_key, uint32_t seq )
@ -251,7 +250,7 @@ QString Wallet::getActivePrivateKey( QString owner_pub_key, uint32_t seq )
_data.encrypted_private_keys[active_pub_key].brain_sequence = seq; _data.encrypted_private_keys[active_pub_key].brain_sequence = seq;
_available_private_keys.insert( active_pub_key ); _available_private_keys.insert( active_pub_key );
return toQString(wif); return QString::fromStdString(wif);
} }
QString Wallet::getOwnerPrivateKey( uint32_t seq ) QString Wallet::getOwnerPrivateKey( uint32_t seq )
@ -273,7 +272,7 @@ QString Wallet::getOwnerPrivateKey( uint32_t seq )
_data.encrypted_private_keys[owner_pub_key].brain_sequence = seq; _data.encrypted_private_keys[owner_pub_key].brain_sequence = seq;
_available_private_keys.insert( owner_pub_key ); _available_private_keys.insert( owner_pub_key );
return toQString( wif ); return QString::fromStdString( wif );
} }
QString Wallet::getActivePublicKey( QString active_pub, uint32_t seq ) QString Wallet::getActivePublicKey( QString active_pub, uint32_t seq )
@ -294,7 +293,7 @@ QString Wallet::getKeyLabel( QString pubkey )
auto itr = _data.encrypted_private_keys.find( key ); auto itr = _data.encrypted_private_keys.find( key );
if( itr == _data.encrypted_private_keys.end() ) if( itr == _data.encrypted_private_keys.end() )
return QString(); return QString();
return toQString( itr->second.label ); return QString::fromStdString( itr->second.label );
} }
/** /**
* The same label may not be assigned to more than one key, this method will * The same label may not be assigned to more than one key, this method will
@ -310,7 +309,7 @@ bool Wallet::setKeyLabel( QString pubkey, QString label )
auto old_label = _data.encrypted_private_keys[pub].label; auto old_label = _data.encrypted_private_keys[pub].label;
_data.encrypted_private_keys[pub].label = string(); _data.encrypted_private_keys[pub].label = string();
if( old_label.size() ) if( old_label.size() )
_label_to_key.erase( toQString( old_label ) ); _label_to_key.erase( QString::fromStdString( old_label ) );
return true; return true;
} }
@ -336,7 +335,7 @@ QList<QPair<QString,QString> > Wallet::getAllPublicKeys( bool only_if_private )c
for( const auto& item : _data.encrypted_private_keys ) for( const auto& item : _data.encrypted_private_keys )
{ {
if( only_if_private && !item.second.encrypted_private_key.size() ) continue; if( only_if_private && !item.second.encrypted_private_key.size() ) continue;
result.push_back( qMakePair( toQString( item.first ), toQString( item.second.label ) ) ); result.push_back( qMakePair( toQString( item.first ), QString::fromStdString( item.second.label ) ) );
} }
return result; return result;
@ -390,7 +389,7 @@ bool Wallet::removePublicKey( QString pubkey )
auto itr = _data.encrypted_private_keys.find(pub); auto itr = _data.encrypted_private_keys.find(pub);
if( itr != _data.encrypted_private_keys.end() ) if( itr != _data.encrypted_private_keys.end() )
{ {
_label_to_key.erase( toQString(itr->second.label) ); _label_to_key.erase( QString::fromStdString(itr->second.label) );
_data.encrypted_private_keys.erase(itr); _data.encrypted_private_keys.erase(itr);
return true; return true;
} }

View file

@ -16,7 +16,6 @@ using graphene::chain::digest_type;
using graphene::chain::signature_type; using graphene::chain::signature_type;
using fc::optional; using fc::optional;
QString toQString( const std::string& s );
QString toQString( public_key_type k ); QString toQString( public_key_type k );
struct key_data struct key_data