Skip to content
Snippets Groups Projects
Commit ae256ae4 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

Add operator<< for pointer types

Refs #66615
parent 8891bdb3
No related branches found
No related tags found
No related merge requests found
...@@ -1472,6 +1472,11 @@ Account* Account::operator<<(Account::EditAction& action) ...@@ -1472,6 +1472,11 @@ Account* Account::operator<<(Account::EditAction& action)
return this; return this;
} }
Account* operator<<(Account* a, Account::EditAction action)
{
return (!a)?nullptr : (*a) << action;
}
///Change the current edition state ///Change the current edition state
bool Account::performAction(const Account::EditAction action) bool Account::performAction(const Account::EditAction action)
{ {
......
...@@ -52,7 +52,17 @@ enum DtmfType { ...@@ -52,7 +52,17 @@ enum DtmfType {
}; };
Q_ENUMS(DtmfType) Q_ENUMS(DtmfType)
///Account: a daemon account (SIP or AIX) /**
* A communication account.
*
* This class represent an account based around a protocol and a bunch of properties.
*
* Using the setters on this object wont cause the changes to take effect immediately.
*
* To save the changes, use the "<<" operator on the account with Account::EditAction::SAVE.
* Similarly, the Account::EditAction::RELOAD action will reset the changes to match the
* current properties used by daemon.
*/
class LIB_EXPORT Account : public QObject { class LIB_EXPORT Account : public QObject {
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
...@@ -394,6 +404,8 @@ Q_DECLARE_METATYPE(Account*) ...@@ -394,6 +404,8 @@ Q_DECLARE_METATYPE(Account*)
Q_DECLARE_METATYPE(Account::RegistrationState) Q_DECLARE_METATYPE(Account::RegistrationState)
Q_DECLARE_METATYPE(Account::EditAction) Q_DECLARE_METATYPE(Account::EditAction)
Account* operator<<(Account* a, Account::EditAction action);
/** /**
* Some accounts can be loaded at later time. This object will be upgraded * Some accounts can be loaded at later time. This object will be upgraded
* to an account when it arrive * to an account when it arrive
......
...@@ -478,6 +478,12 @@ Call* Call::operator<<( Call::Action& c) ...@@ -478,6 +478,12 @@ Call* Call::operator<<( Call::Action& c)
return this; return this;
} }
Call* operator<<(Call* c, Call::Action action)
{
return (!c) ? nullptr : (*c) << action;
}
///Get the history state from the type (see Call.cpp header) ///Get the history state from the type (see Call.cpp header)
Call::LegacyHistoryState CallPrivate::historyStateFromType(const QString& type) Call::LegacyHistoryState CallPrivate::historyStateFromType(const QString& type)
{ {
......
...@@ -361,6 +361,7 @@ Q_DECLARE_METATYPE(Call::State) ...@@ -361,6 +361,7 @@ Q_DECLARE_METATYPE(Call::State)
Q_DECLARE_METATYPE(Call::Direction) Q_DECLARE_METATYPE(Call::Direction)
Q_DECLARE_METATYPE(Call::LegacyHistoryState) Q_DECLARE_METATYPE(Call::LegacyHistoryState)
Call* operator<<(Call* c, Call::Action a);
QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::State& c ); QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::State& c );
QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::DaemonState& c ); QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::DaemonState& c );
QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::Action& c ); QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::Action& c );
......
...@@ -492,6 +492,18 @@ bool UserActionModel::execute(const UserActionModel::Action action) const ...@@ -492,6 +492,18 @@ bool UserActionModel::execute(const UserActionModel::Action action) const
return true; //TODO handle errors return true; //TODO handle errors
} }
UserActionModel* UserActionModel::operator<<(UserActionModel::Action& action)
{
execute(action);
return this;
}
UserActionModel* operator<<(UserActionModel* m,UserActionModel::Action action)
{
return (!m)? nullptr : (*m) << action;
}
/** /**
* Execute an action * Execute an action
* @param idx A model index. It can be from proxies. * @param idx A model index. It can be from proxies.
......
...@@ -97,6 +97,9 @@ public: ...@@ -97,6 +97,9 @@ public:
bool execute( const Action action ) const; bool execute( const Action action ) const;
bool execute( const QModelIndex& idx ) const; bool execute( const QModelIndex& idx ) const;
//Operators
UserActionModel* operator<<(UserActionModel::Action& action);
private: private:
const QScopedPointer<UserActionModelPrivate> d_ptr; const QScopedPointer<UserActionModelPrivate> d_ptr;
Q_DECLARE_PRIVATE(UserActionModel) Q_DECLARE_PRIVATE(UserActionModel)
...@@ -109,6 +112,8 @@ Q_DECLARE_METATYPE(UserActionModel*) ...@@ -109,6 +112,8 @@ Q_DECLARE_METATYPE(UserActionModel*)
Q_DECLARE_METATYPE(UserActionModel::Action) Q_DECLARE_METATYPE(UserActionModel::Action)
UserActionModel* operator<<(UserActionModel* m,UserActionModel::Action action);
/** /**
* "Java bean" used to avoid having a 5+ parameter pixmap delegate * "Java bean" used to avoid having a 5+ parameter pixmap delegate
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment