Skip to content

Commit

Permalink
code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Nov 1, 2022
1 parent caffa35 commit fcedc12
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
24 changes: 12 additions & 12 deletions src/addaccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,34 @@ addaccount::addaccount( QDialog * parent,
class accs : public gmailauthorization::actions
{
public:
accs( addaccount * acc ) : m_parent( acc )
accs( addaccount& acc ) : m_parent( acc )
{
}
void cancel() override
{
m_parent->cancel() ;
m_parent.cancel() ;
}
void getToken( const QString& e,const QByteArray& s ) override
{
if( e.isEmpty() ){

m_parent->HideUI() ;
m_parent.HideUI() ;

auto m = "Failed To Generate Token\n" + s ;

m_parent->m_logWindow.update( logWindow::TYPE::INFO,m,true ) ;
m_parent.m_logWindow.update( logWindow::TYPE::INFO,m,true ) ;
}else{
m_parent->getLabels( e ) ;
m_parent.getLabels( e ) ;
}
}
private:
addaccount * m_parent ;
addaccount& m_parent ;
};

gmailauthorization::instance( this,
m_setting,
m_getAuthorization,
{ util::type_identity< accs >(),this } ) ;
{ util::type_identity< accs >(),*this } ) ;
}

addaccount::addaccount( QDialog * parent,
Expand Down Expand Up @@ -152,22 +152,22 @@ void addaccount::getLabels( const QString& e )
class meaw : public addaccount::gmailAccountInfo
{
public:
meaw( addaccount * acc ) : m_parent( acc )
meaw( addaccount& acc ) : m_parent( acc )
{
}
void operator()( addaccount::labels s ) override
{
m_parent->showLabels( std::move( s ) ) ;
m_parent.showLabels( std::move( s ) ) ;
}
void operator()( const QString& e ) override
{
m_parent->showError( e ) ;
m_parent.showError( e ) ;
}
private:
addaccount * m_parent ;
addaccount& m_parent ;
};

m_gmailAccountInfo( e,{ util::type_identity< meaw >(),this } ) ;
m_gmailAccountInfo.withoutToken( e,{ util::type_identity< meaw >(),*this } ) ;
}

void addaccount::showLabels( addaccount::labels&& s )
Expand Down
14 changes: 6 additions & 8 deletions src/addaccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ class addaccount : public QDialog

struct gMailInfo
{
virtual void operator()( const QString& authoCode,addaccount::GmailAccountInfo )
virtual void withoutToken( const QString&,addaccount::GmailAccountInfo )
{
Q_UNUSED( authoCode )
}
virtual void operator()( const QByteArray& accountName,addaccount::GmailAccountInfo )
virtual void withToken( const QString&,addaccount::GmailAccountInfo )
{
Q_UNUSED( accountName )
}
virtual ~gMailInfo() ;
} ;
Expand All @@ -109,13 +107,13 @@ class addaccount : public QDialog
m_handle( std::make_unique< typename Type::type >( std::forward< Args >( args ) ... ) )
{
}
void operator()( const QString& authocode,addaccount::GmailAccountInfo result )
void withoutToken( const QString& authocode,addaccount::GmailAccountInfo result )
{
( *m_handle )( authocode,std::move( result ) ) ;
m_handle->withoutToken( authocode,std::move( result ) ) ;
}
virtual void operator()( const QByteArray& accountName,addaccount::GmailAccountInfo result )
virtual void withToken( const QString& accountName,addaccount::GmailAccountInfo result )
{
( *m_handle )( accountName,std::move( result ) ) ;
m_handle->withToken( accountName,std::move( result ) ) ;
}
private:
std::unique_ptr< addaccount::gMailInfo > m_handle ;
Expand Down
20 changes: 10 additions & 10 deletions src/qcheckgmail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ statusicon::clickActions qCheckGMail::clickActions()
class meaw : public statusicon::clickActionsInterface
{
public:
meaw( qCheckGMail& q ) : m_parent( q )
meaw( qCheckGMail& e ) : m_parent( e )
{
}
void onLeftClick() const override
Expand Down Expand Up @@ -582,7 +582,7 @@ void qCheckGMail::configurationoptionWindow()
class meaw : public configurationoptionsdialog::actions
{
public:
meaw( qCheckGMail& g ) : m_parent( g )
meaw( qCheckGMail& e ) : m_parent( e )
{
}
void configurationWindowClosed( int s ) override
Expand Down Expand Up @@ -1014,8 +1014,8 @@ void qCheckGMail::networkAccess( int counter,const QNetworkRequest& request )
} ) ;
}

void qCheckGMail::getGMailAccountInfo( const QString& authocode,
addaccount::GmailAccountInfo ginfo )
void qCheckGMail::getGMailAccountInfoWithoutToken( const QString& authocode,
addaccount::GmailAccountInfo ginfo )
{
m_manager.post( m_networkRequest,[ & ](){

Expand Down Expand Up @@ -1071,8 +1071,8 @@ void qCheckGMail::getGMailAccountInfo( const QString& authocode,
} ) ;
}

void qCheckGMail::getGMailAccountInfo( const QByteArray& accName,
addaccount::GmailAccountInfo ginfo )
void qCheckGMail::getGMailAccountInfoWithToken( const QString& accName,
addaccount::GmailAccountInfo ginfo )
{
for( const auto& it : m_accounts ){

Expand Down Expand Up @@ -1235,15 +1235,15 @@ void qCheckGMail::configureAccounts()
meaw( qCheckGMail& m ) : m_parent( m )
{
}
void operator()( const QString& authocode,
void withoutToken( const QString& authocode,
addaccount::GmailAccountInfo returnEmail ) override
{
m_parent.getGMailAccountInfo( authocode,std::move( returnEmail ) ) ;
m_parent.getGMailAccountInfoWithoutToken( authocode,std::move( returnEmail ) ) ;
}
void operator()( const QByteArray& accountName,
void withToken( const QString& accountName,
addaccount::GmailAccountInfo returnEmail ) override
{
m_parent.getGMailAccountInfo( accountName,std::move( returnEmail ) ) ;
m_parent.getGMailAccountInfoWithToken( accountName,std::move( returnEmail ) ) ;
}
private:
qCheckGMail& m_parent ;
Expand Down
4 changes: 2 additions & 2 deletions src/qcheckgmail.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class qCheckGMail : public QObject

void networkAccess( int,const QNetworkRequest& ) ;

void getGMailAccountInfo( const QString&,addaccount::GmailAccountInfo ) ;
void getGMailAccountInfo( const QByteArray&,addaccount::GmailAccountInfo ) ;
void getGMailAccountInfoWithoutToken( const QString&,addaccount::GmailAccountInfo ) ;
void getGMailAccountInfoWithToken( const QString&,addaccount::GmailAccountInfo ) ;

void getLabels( const QString& accessToken,addaccount::GmailAccountInfo ) ;

Expand Down
4 changes: 2 additions & 2 deletions src/walletmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void walletmanager::editEntryLabels()
this->disableAll() ;
auto item = m_table->currentItem() ;
auto row = item->row() ;
auto accName = m_table->item( row,0 )->text().toUtf8() ;
auto accName = m_table->item( row,0 )->text() ;

class meaw : public addaccount::gmailAccountInfo
{
Expand Down Expand Up @@ -477,7 +477,7 @@ void walletmanager::editEntryLabels()

auto txt = tr( "Getting Account's Label List" ) ;

m_getAccountInfo( accName,{ util::type_identity< meaw >(),this,row,std::move( txt ) } ) ;
m_getAccountInfo.withToken( accName,{ util::type_identity< meaw >(),this,row,std::move( txt ) } ) ;
}

void walletmanager::pushButtonToAdd()
Expand Down

0 comments on commit fcedc12

Please sign in to comment.