From f2051fb35b1ad49c4d940e6fbba2acc98b216e13 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 12 Feb 2019 23:59:24 +0100 Subject: clang format --- diceroller.cpp | 114 +++++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 61 deletions(-) (limited to 'diceroller.cpp') diff --git a/diceroller.cpp b/diceroller.cpp index 3abbf4f..d343fcb 100644 --- a/diceroller.cpp +++ b/diceroller.cpp @@ -1,28 +1,25 @@ /*************************************************************************** -* Copyright (C) 2017 by Renaud Guezennec * -* http://www.rolisteam.org/contact * -* * -* Rolisteam is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ + * Copyright (C) 2017 by Renaud Guezennec * + * http://www.rolisteam.org/contact * + * * + * Rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "diceroller.h" -DiceRoller::DiceRoller() -{ - -} +DiceRoller::DiceRoller() {} QString DiceRoller::getDiceList() const { @@ -34,7 +31,6 @@ QString DiceRoller::getResultStr() const return m_resultStr; } - QString DiceRoller::getCommand() const { return m_command; @@ -45,11 +41,11 @@ qreal DiceRoller::getResult() const return m_result; } -void DiceRoller::setCommand(const QString &cmd) +void DiceRoller::setCommand(const QString& cmd) { if(m_command != cmd) { - m_command = cmd; + m_command= cmd; emit commandChanged(); } } @@ -60,20 +56,20 @@ QString DiceRoller::diceToText(QList& diceList) for(auto& dice : diceList) { QStringList resultGlobal; - auto const& keys = dice.keys(); - for(auto& face: keys) + auto const& keys= dice.keys(); + for(auto& face : keys) { QStringList result; - ListDiceResult diceResult = dice.value(face); - for (const HighLightDice& tmp : diceResult) + ListDiceResult diceResult= dice.value(face); + for(const HighLightDice& tmp : diceResult) { QStringList diceListStr; QStringList diceListChildren; - int i = 0; + int i= 0; for(qint64& dievalue : tmp.getResult()) { QString prefix("%1"); - if(i==0) + if(i == 0) { diceListStr << prefix.arg(QString::number(dievalue)); } @@ -90,7 +86,7 @@ QString DiceRoller::diceToText(QList& diceList) result << diceListStr.join(' '); } - if(keys.size()>1) + if(keys.size() > 1) { resultGlobal << QString(" d%2:(%1)").arg(result.join(',')).arg(face); } @@ -112,71 +108,68 @@ void DiceRoller::start() { bool homogeneous; QList list; - m_diceparser.getLastDiceResult(list,homogeneous); - QString diceText = diceToText(list); + m_diceparser.getLastDiceResult(list, homogeneous); + QString diceText= diceToText(list); QString scalarText; QString str; - qreal result = 0; + qreal result= 0; QString resultStr; if(m_diceparser.hasIntegerResultNotInFirst()) { - auto values = m_diceparser.getLastIntegerResults(); + auto values= m_diceparser.getLastIntegerResults(); QStringList strLst; - for(auto& val : values ) + for(auto& val : values) { - result += val; + result+= val; strLst << QString::number(val); } - scalarText = QString("%1").arg(strLst.join(',')); + scalarText= QString("%1").arg(strLst.join(',')); } else if(!list.isEmpty()) { - auto values = m_diceparser.getSumOfDiceResult(); + auto values= m_diceparser.getSumOfDiceResult(); QStringList strLst; - for(auto val : values ) + for(auto val : values) { - result += val; + result+= val; strLst << QString::number(val); } - scalarText = QString("%1").arg(strLst.join(',')); + scalarText= QString("%1").arg(strLst.join(',')); } if(m_diceparser.hasStringResult()) { bool ok; - QStringList allStringlist = m_diceparser.getAllStringResult(ok); - QString stringResult = allStringlist.join(" ; "); - stringResult.replace("%1",scalarText); - stringResult.replace("%2",diceText.trimmed()); - str = stringResult; + QStringList allStringlist= m_diceparser.getAllStringResult(ok); + QString stringResult= allStringlist.join(" ; "); + stringResult.replace("%1", scalarText); + stringResult.replace("%2", diceText.trimmed()); + str= stringResult; } else { - resultStr = scalarText; + resultStr= scalarText; } if(!m_diceparser.getComment().isEmpty()) { - resultStr+=m_diceparser.getComment()+"\n"; + resultStr+= m_diceparser.getComment() + "\n"; } - resultStr += str+"\n"; - m_resultStr = resultStr; - m_result = result; - m_diceList = diceText.trimmed(); + resultStr+= str + "\n"; + m_resultStr= resultStr; + m_result= result; + m_diceList= diceText.trimmed(); emit resultStrChanged(); emit resultChanged(); emit diceListChanged(); } - } if(!m_diceparser.getErrorMap().isEmpty()) { - auto errors = m_diceparser.getErrorMap(); + auto errors= m_diceparser.getErrorMap(); setError(errors.first()); } - - } QString DiceRoller::getError() const @@ -184,12 +177,11 @@ QString DiceRoller::getError() const return m_error; } -void DiceRoller::setError(const QString &error) +void DiceRoller::setError(const QString& error) { if(m_error != error) { - m_error = error; + m_error= error; emit errorOccurs(); } } - -- cgit v1.2.3-70-g09d2