CI: apply coding style across the entire codebase again

main
Adriaan de Groot 5 years ago
parent 1cd9b93a22
commit a2180936ef

@ -26,29 +26,31 @@
#include <QDomDocument> #include <QDomDocument>
static const char usage[] = "Usage: txload <origin> [<alternate> ...]\n" static const char usage[] = "Usage: txload <origin> [<alternate> ...]\n"
"\n" "\n"
"Reads a .ts source file <origin> and zero or more .ts <alternate>\n" "Reads a .ts source file <origin> and zero or more .ts <alternate>\n"
"files, and does a comparison between the translations. Source (English)\n" "files, and does a comparison between the translations. Source (English)\n"
"strings that are untranslated are flagged in each of the translation\n" "strings that are untranslated are flagged in each of the translation\n"
"files, while differences in the translations are themselves also shown.\n" "files, while differences in the translations are themselves also shown.\n"
"\n" "\n"
"Outputs to stdout a human-readable list of differences between the\n" "Outputs to stdout a human-readable list of differences between the\n"
"translations.\n"; "translations.\n";
bool load_file(const char* filename, QDomDocument& doc) bool
load_file( const char* filename, QDomDocument& doc )
{ {
QFile file(filename); QFile file( filename );
QString err; QString err;
int err_line, err_column; int err_line, err_column;
if (!file.open(QIODevice::ReadOnly)) if ( !file.open( QIODevice::ReadOnly ) )
{ {
qDebug() << "Could not open" << filename; qDebug() << "Could not open" << filename;
return false; return false;
} }
QByteArray ba( file.read(1024 * 1024) ); QByteArray ba( file.read( 1024 * 1024 ) );
qDebug() << "Read" << ba.length() << "bytes from" << filename; qDebug() << "Read" << ba.length() << "bytes from" << filename;
if (!doc.setContent(ba, &err, &err_line, &err_column)) { if ( !doc.setContent( ba, &err, &err_line, &err_column ) )
{
qDebug() << "Could not read" << filename << ':' << err_line << ':' << err_column << ' ' << err; qDebug() << "Could not read" << filename << ':' << err_line << ':' << err_column << ' ' << err;
file.close(); file.close();
return false; return false;
@ -58,15 +60,20 @@ bool load_file(const char* filename, QDomDocument& doc)
return true; return true;
} }
QDomElement find_context(QDomDocument& doc, const QString& name) QDomElement
find_context( QDomDocument& doc, const QString& name )
{ {
QDomElement top = doc.documentElement(); QDomElement top = doc.documentElement();
QDomNode n = top.firstChild(); QDomNode n = top.firstChild();
while (!n.isNull()) { while ( !n.isNull() )
if (n.isElement()) { {
if ( n.isElement() )
{
QDomElement e = n.toElement(); QDomElement e = n.toElement();
if ( ( e.tagName() == "context" ) && ( e.firstChildElement( "name" ).text() == name ) ) if ( ( e.tagName() == "context" ) && ( e.firstChildElement( "name" ).text() == name ) )
{
return e; return e;
}
} }
n = n.nextSibling(); n = n.nextSibling();
} }
@ -74,17 +81,22 @@ QDomElement find_context(QDomDocument& doc, const QString& name)
return QDomElement(); return QDomElement();
} }
QDomElement find_message(QDomElement& context, const QString& source) QDomElement
find_message( QDomElement& context, const QString& source )
{ {
QDomNode n = context.firstChild(); QDomNode n = context.firstChild();
while (!n.isNull()) { while ( !n.isNull() )
if (n.isElement()) { {
if ( n.isElement() )
{
QDomElement e = n.toElement(); QDomElement e = n.toElement();
if ( e.tagName() == "message" ) if ( e.tagName() == "message" )
{ {
QString msource = e.firstChildElement( "source" ).text(); QString msource = e.firstChildElement( "source" ).text();
if ( msource == source ) if ( msource == source )
{
return e; return e;
}
} }
} }
n = n.nextSibling(); n = n.nextSibling();
@ -92,11 +104,14 @@ QDomElement find_message(QDomElement& context, const QString& source)
return QDomElement(); return QDomElement();
} }
bool merge_into(QDomElement& origin, QDomElement& alternate) bool
merge_into( QDomElement& origin, QDomElement& alternate )
{ {
QDomNode n = alternate.firstChild(); QDomNode n = alternate.firstChild();
while (!n.isNull()) { while ( !n.isNull() )
if (n.isElement()) { {
if ( n.isElement() )
{
QDomElement alternateMessage = n.toElement(); QDomElement alternateMessage = n.toElement();
if ( alternateMessage.tagName() == "message" ) if ( alternateMessage.tagName() == "message" )
{ {
@ -119,7 +134,8 @@ bool merge_into(QDomElement& origin, QDomElement& alternate)
} }
if ( !alternateTranslationText.isEmpty() && ( alternateTranslationText != originTranslationText ) ) if ( !alternateTranslationText.isEmpty() && ( alternateTranslationText != originTranslationText ) )
{ {
qDebug() << "\n\n\nSource:" << alternateSourceText << "\nTL1:" << originTranslationText << "\nTL2:" << alternateTranslationText; qDebug() << "\n\n\nSource:" << alternateSourceText << "\nTL1:" << originTranslationText
<< "\nTL2:" << alternateTranslationText;
} }
} }
} }
@ -130,12 +146,14 @@ bool merge_into(QDomElement& origin, QDomElement& alternate)
} }
bool
bool merge_into(QDomDocument& originDocument, QDomElement& context) merge_into( QDomDocument& originDocument, QDomElement& context )
{ {
QDomElement name = context.firstChildElement( "name" ); QDomElement name = context.firstChildElement( "name" );
if ( name.isNull() ) if ( name.isNull() )
{
return false; return false;
}
QString contextname = name.text(); QString contextname = name.text();
QDomElement originContext = find_context( originDocument, contextname ); QDomElement originContext = find_context( originDocument, contextname );
@ -148,16 +166,21 @@ bool merge_into(QDomDocument& originDocument, QDomElement& context)
return merge_into( originContext, context ); return merge_into( originContext, context );
} }
bool merge_into(QDomDocument& originDocument, QDomDocument& alternateDocument) bool
merge_into( QDomDocument& originDocument, QDomDocument& alternateDocument )
{ {
QDomElement top = alternateDocument.documentElement(); QDomElement top = alternateDocument.documentElement();
QDomNode n = top.firstChild(); QDomNode n = top.firstChild();
while (!n.isNull()) { while ( !n.isNull() )
if (n.isElement()) { {
if ( n.isElement() )
{
QDomElement e = n.toElement(); QDomElement e = n.toElement();
if ( e.tagName() == "context" ) if ( e.tagName() == "context" )
if ( !merge_into( originDocument, e ) ) if ( !merge_into( originDocument, e ) )
{
return false; return false;
}
} }
n = n.nextSibling(); n = n.nextSibling();
} }
@ -165,39 +188,46 @@ bool merge_into(QDomDocument& originDocument, QDomDocument& alternateDocument)
return true; return true;
} }
int main(int argc, char** argv) int
main( int argc, char** argv )
{ {
QCoreApplication a(argc, argv); QCoreApplication a( argc, argv );
if (argc < 2) if ( argc < 2 )
{ {
qWarning() << usage; qWarning() << usage;
return 1; return 1;
} }
QDomDocument originDocument("origin"); QDomDocument originDocument( "origin" );
if ( !load_file(argv[1], originDocument) ) if ( !load_file( argv[ 1 ], originDocument ) )
{
return 1; return 1;
}
for (int i = 2; i < argc; ++i) for ( int i = 2; i < argc; ++i )
{ {
QDomDocument alternateDocument("alternate"); QDomDocument alternateDocument( "alternate" );
if ( !load_file(argv[i], alternateDocument) ) if ( !load_file( argv[ i ], alternateDocument ) )
{
return 1; return 1;
}
if ( !merge_into( originDocument, alternateDocument ) ) if ( !merge_into( originDocument, alternateDocument ) )
{
return 1; return 1;
}
} }
QString outfilename( argv[1] ); QString outfilename( argv[ 1 ] );
outfilename.append( ".new" ); outfilename.append( ".new" );
QFile outfile(outfilename); QFile outfile( outfilename );
if (!outfile.open(QIODevice::WriteOnly)) if ( !outfile.open( QIODevice::WriteOnly ) )
{ {
qDebug() << "Could not open" << outfilename; qDebug() << "Could not open" << outfilename;
return 1; return 1;
} }
outfile.write( originDocument.toString(4).toUtf8() ); outfile.write( originDocument.toString( 4 ).toUtf8() );
outfile.close(); outfile.close();
return 0; return 0;

@ -67,7 +67,8 @@ CalamaresApplication::init()
{ {
Logger::setupLogfile(); Logger::setupLogfile();
cDebug() << "Calamares version:" << CALAMARES_VERSION; cDebug() << "Calamares version:" << CALAMARES_VERSION;
cDebug() << Logger::SubEntry << " languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " ); cDebug() << Logger::SubEntry
<< " languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " );
if ( !Calamares::Settings::instance() ) if ( !Calamares::Settings::instance() )
{ {

@ -28,7 +28,7 @@ class CalamaresWindow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
CalamaresWindow( QWidget* parent = nullptr ); CalamaresWindow( QWidget* parent = nullptr );
virtual ~CalamaresWindow() override { } virtual ~CalamaresWindow() override {}
public slots: public slots:
/** /**

@ -184,7 +184,8 @@ DebugWindow::DebugWindow()
#endif #endif
] { ] {
QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
Module* module = ModuleManager::instance()->moduleInstance( ModuleSystem::InstanceKey::fromString( moduleName ) ); Module* module
= ModuleManager::instance()->moduleInstance( ModuleSystem::InstanceKey::fromString( moduleName ) );
if ( module ) if ( module )
{ {
m_module = module->configurationMap(); m_module = module->configurationMap();

@ -14,26 +14,29 @@
#include "utils/Yaml.h" #include "utils/Yaml.h"
#include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <iostream> #include <iostream>
#include <QFile>
#include <QByteArray> #include <QByteArray>
#include <QFile>
using std::cerr; using std::cerr;
static const char usage[] = "Usage: test_conf [-v] [-b] <file> ...\n"; static const char usage[] = "Usage: test_conf [-v] [-b] <file> ...\n";
int main(int argc, char** argv) int
main( int argc, char** argv )
{ {
bool verbose = false; bool verbose = false;
bool bytes = false; bool bytes = false;
int opt; int opt;
while ((opt = getopt(argc, argv, "vb")) != -1) { while ( ( opt = getopt( argc, argv, "vb" ) ) != -1 )
switch (opt) { {
switch ( opt )
{
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
@ -52,7 +55,7 @@ int main(int argc, char** argv)
return 1; return 1;
} }
const char* filename = argv[optind]; const char* filename = argv[ optind ];
try try
{ {
YAML::Node doc; YAML::Node doc;
@ -60,10 +63,14 @@ int main(int argc, char** argv)
{ {
QFile f( filename ); QFile f( filename );
if ( f.open( QFile::ReadOnly | QFile::Text ) ) if ( f.open( QFile::ReadOnly | QFile::Text ) )
{
doc = YAML::Load( f.readAll().constData() ); doc = YAML::Load( f.readAll().constData() );
}
} }
else else
{
doc = YAML::LoadFile( filename ); doc = YAML::LoadFile( filename );
}
if ( doc.IsNull() ) if ( doc.IsNull() )
{ {
@ -86,12 +93,14 @@ int main(int argc, char** argv)
{ {
cerr << "Keys:\n"; cerr << "Keys:\n";
for ( auto i = doc.begin(); i != doc.end(); ++i ) for ( auto i = doc.begin(); i != doc.end(); ++i )
cerr << i->first.as<std::string>() << '\n'; {
cerr << i->first.as< std::string >() << '\n';
}
} }
} }
catch ( YAML::Exception& e ) catch ( YAML::Exception& e )
{ {
cerr << "WARNING:" << filename << '\n'; cerr << "WARNING:" << filename << '\n';
cerr << "WARNING: YAML parser error " << e.what() << '\n'; cerr << "WARNING: YAML parser error " << e.what() << '\n';
return 1; return 1;
} }

@ -192,7 +192,7 @@ ExecViewModule::ExecViewModule()
// We don't have one, so build one -- this gives us "x@x". // We don't have one, so build one -- this gives us "x@x".
QVariantMap m; QVariantMap m;
m.insert( "name", "x" ); m.insert( "name", "x" );
Calamares::Module::initFrom( Calamares::ModuleSystem::Descriptor::fromDescriptorData(m), "x" ); Calamares::Module::initFrom( Calamares::ModuleSystem::Descriptor::fromDescriptorData( m ), "x" );
} }
ExecViewModule::~ExecViewModule() {} ExecViewModule::~ExecViewModule() {}
@ -323,7 +323,8 @@ load_module( const ModuleConfig& moduleConfig )
cDebug() << "Module" << moduleName << "job-configuration:" << configFile; cDebug() << "Module" << moduleName << "job-configuration:" << configFile;
Calamares::Module* module = Calamares::moduleFromDescriptor( Calamares::ModuleSystem::Descriptor::fromDescriptorData( descriptor ), name, configFile, moduleDirectory ); Calamares::Module* module = Calamares::moduleFromDescriptor(
Calamares::ModuleSystem::Descriptor::fromDescriptorData( descriptor ), name, configFile, moduleDirectory );
return module; return module;
} }

@ -67,7 +67,8 @@ Handler::Handler( const QString& implementation, const QString& url, const QStri
{ {
cWarning() << "GeoIP style *none* does not do anything."; cWarning() << "GeoIP style *none* does not do anything.";
} }
else if ( m_type == Type::Fixed && Calamares::Settings::instance() && !Calamares::Settings::instance()->debugMode() ) else if ( m_type == Type::Fixed && Calamares::Settings::instance()
&& !Calamares::Settings::instance()->debugMode() )
{ {
cWarning() << "GeoIP style *fixed* is not recommended for production."; cWarning() << "GeoIP style *fixed* is not recommended for production.";
} }

@ -34,10 +34,10 @@ class DLLEXPORT Handler
public: public:
enum class Type enum class Type
{ {
None, // No lookup, returns empty string None, // No lookup, returns empty string
JSON, // JSON-formatted data, returns extracted field JSON, // JSON-formatted data, returns extracted field
XML, // XML-formatted data, returns extracted field XML, // XML-formatted data, returns extracted field
Fixed // Returns selector string verbatim Fixed // Returns selector string verbatim
}; };
/** @brief An unconfigured handler; this always returns errors. */ /** @brief An unconfigured handler; this always returns errors. */

@ -358,7 +358,9 @@ ZonesModel::find( const QString& region, const QString& zone ) const
} }
STATICTEST const TimeZoneData* STATICTEST const TimeZoneData*
find( double startingDistance, const ZoneVector& zones, const std::function< double( const TimeZoneData* ) >& distanceFunc ) find( double startingDistance,
const ZoneVector& zones,
const std::function< double( const TimeZoneData* ) >& distanceFunc )
{ {
double smallestDistance = startingDistance; double smallestDistance = startingDistance;
const TimeZoneData* closest = nullptr; const TimeZoneData* closest = nullptr;
@ -379,7 +381,8 @@ const TimeZoneData*
ZonesModel::find( const std::function< double( const TimeZoneData* ) >& distanceFunc ) const ZonesModel::find( const std::function< double( const TimeZoneData* ) >& distanceFunc ) const
{ {
const auto* officialZone = CalamaresUtils::Locale::find( 1000000.0, m_private->m_zones, distanceFunc ); const auto* officialZone = CalamaresUtils::Locale::find( 1000000.0, m_private->m_zones, distanceFunc );
const auto* altZone = CalamaresUtils::Locale::find( distanceFunc( officialZone ), m_private->m_altZones, distanceFunc ); const auto* altZone
= CalamaresUtils::Locale::find( distanceFunc( officialZone ), m_private->m_altZones, distanceFunc );
// If nothing was closer than the official zone already was, altZone is // If nothing was closer than the official zone already was, altZone is
// nullptr; but if there is a spot-patch, then we need to re-find // nullptr; but if there is a spot-patch, then we need to re-find

@ -86,8 +86,7 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c
return paths; return paths;
} }
void void Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
{ {
QStringList configCandidates QStringList configCandidates
= moduleConfigurationCandidates( Settings::instance()->debugMode(), name(), configFileName ); = moduleConfigurationCandidates( Settings::instance()->debugMode(), name(), configFileName );

@ -89,9 +89,8 @@ RequirementsModel::describe() const
int count = 0; int count = 0;
for ( const auto& r : m_requirements ) for ( const auto& r : m_requirements )
{ {
cDebug() << Logger::SubEntry << "requirement" << count << r.name cDebug() << Logger::SubEntry << "requirement" << count << r.name << "satisfied?" << r.satisfied << "mandatory?"
<< "satisfied?" << r.satisfied << r.mandatory;
<< "mandatory?" << r.mandatory;
if ( r.mandatory && !r.satisfied ) if ( r.mandatory && !r.satisfied )
{ {
acceptable = false; acceptable = false;

@ -62,7 +62,8 @@ InternalManager::InternalManager()
else else
{ {
auto* backend_p = CoreBackendManager::self()->backend(); auto* backend_p = CoreBackendManager::self()->backend();
cDebug() << Logger::SubEntry << "Backend" << Logger::Pointer(backend_p) << backend_p->id() << backend_p->version(); cDebug() << Logger::SubEntry << "Backend" << Logger::Pointer( backend_p ) << backend_p->id()
<< backend_p->version();
s_kpm_loaded = true; s_kpm_loaded = true;
} }
} }

@ -187,7 +187,8 @@ System::runCommand( System::RunLocation location,
? ( static_cast< int >( std::chrono::milliseconds( timeoutSec ).count() ) ) ? ( static_cast< int >( std::chrono::milliseconds( timeoutSec ).count() ) )
: -1 ) ) : -1 ) )
{ {
cWarning() << "Process" << args.first() << "timed out after" << timeoutSec.count() << "s. Output so far:\n" << Logger::NoQuote{} << process.readAllStandardOutput(); cWarning() << "Process" << args.first() << "timed out after" << timeoutSec.count() << "s. Output so far:\n"
<< Logger::NoQuote {} << process.readAllStandardOutput();
return ProcessResult::Code::TimedOut; return ProcessResult::Code::TimedOut;
} }
@ -195,7 +196,7 @@ System::runCommand( System::RunLocation location,
if ( process.exitStatus() == QProcess::CrashExit ) if ( process.exitStatus() == QProcess::CrashExit )
{ {
cWarning() << "Process" << args.first() << "crashed. Output so far:\n" << Logger::NoQuote{} << output; cWarning() << "Process" << args.first() << "crashed. Output so far:\n" << Logger::NoQuote {} << output;
return ProcessResult::Code::Crashed; return ProcessResult::Code::Crashed;
} }
@ -204,7 +205,8 @@ System::runCommand( System::RunLocation location,
bool showDebug = ( !Calamares::Settings::instance() ) || ( Calamares::Settings::instance()->debugMode() ); bool showDebug = ( !Calamares::Settings::instance() ) || ( Calamares::Settings::instance()->debugMode() );
if ( ( r != 0 ) || showDebug ) if ( ( r != 0 ) || showDebug )
{ {
cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "output:\n" << Logger::NoQuote{} << output; cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "output:\n"
<< Logger::NoQuote {} << output;
} }
return ProcessResult( r, output ); return ProcessResult( r, output );
} }

@ -412,7 +412,8 @@ LibCalamaresTests::testVariantStringListCode()
m.insert( key, 17 ); m.insert( key, 17 );
QCOMPARE( getStringList( m, key ), QStringList {} ); QCOMPARE( getStringList( m, key ), QStringList {} );
m.insert( key, QString( "more strings" ) ); m.insert( key, QString( "more strings" ) );
QCOMPARE( getStringList( m, key ), QStringList { "more strings" } ); // A single string **can** be considered a stringlist! QCOMPARE( getStringList( m, key ),
QStringList { "more strings" } ); // A single string **can** be considered a stringlist!
m.insert( key, QVariant {} ); m.insert( key, QVariant {} );
QCOMPARE( getStringList( m, key ), QStringList {} ); QCOMPARE( getStringList( m, key ), QStringList {} );
} }

@ -49,17 +49,30 @@ namespace CalamaresUtils
*/ */
namespace Traits namespace Traits
{ {
template< class > struct sfinae_true : std::true_type{}; template < class >
} struct sfinae_true : std::true_type
} {
};
} // namespace Traits
} // namespace CalamaresUtils
#define DECLARE_HAS_METHOD(m) \ #define DECLARE_HAS_METHOD( m ) \
namespace CalamaresUtils { namespace Traits { \ namespace CalamaresUtils \
struct has_ ## m { \ { \
template< class T > static auto f(int) -> sfinae_true<decltype(&T:: m)>; \ namespace Traits \
template< class T > static auto f(long) -> std::false_type; \ { \
template< class T > using t = decltype( f <T>(0) ); \ struct has_##m \
}; } } \ { \
template< class T > using has_ ## m = CalamaresUtils::Traits:: has_ ## m ::t<T>; template < class T > \
static auto f( int ) -> sfinae_true< decltype( &T::m ) >; \
template < class T > \
static auto f( long ) -> std::false_type; \
template < class T > \
using t = decltype( f< T >( 0 ) ); \
}; \
} \
} \
template < class T > \
using has_##m = CalamaresUtils::Traits::has_##m ::t< T >;
#endif #endif

@ -38,7 +38,7 @@ DLLEXPORT QStringList getStringList( const QVariantMap& map, const QString& key,
/** /**
* Get an integer value from a mapping with a given key; returns @p d if no value. * Get an integer value from a mapping with a given key; returns @p d if no value.
*/ */
DLLEXPORT qint64 getInteger( const QVariantMap& map, const QString& key, qint64 d = 0); DLLEXPORT qint64 getInteger( const QVariantMap& map, const QString& key, qint64 d = 0 );
/** /**
* Get an unsigned integer value from a mapping with a given key; returns @p d if no value. * Get an unsigned integer value from a mapping with a given key; returns @p d if no value.
@ -58,7 +58,10 @@ DLLEXPORT double getDouble( const QVariantMap& map, const QString& key, double d
* Returns @p d if there is no such key or it is not a map-value. * Returns @p d if there is no such key or it is not a map-value.
* (e.g. if @p success is false). * (e.g. if @p success is false).
*/ */
DLLEXPORT QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success, const QVariantMap& d = QVariantMap() ); DLLEXPORT QVariantMap getSubMap( const QVariantMap& map,
const QString& key,
bool& success,
const QVariantMap& d = QVariantMap() );
} // namespace CalamaresUtils } // namespace CalamaresUtils
#endif #endif

@ -180,7 +180,7 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
msgBox->show(); msgBox->show();
cDebug() << "Calamares will quit when the dialog closes."; cDebug() << "Calamares will quit when the dialog closes.";
connect( msgBox, &QMessageBox::buttonClicked, [ msgBox ]( QAbstractButton* button ) { connect( msgBox, &QMessageBox::buttonClicked, [msgBox]( QAbstractButton* button ) {
if ( msgBox->buttonRole( button ) == QMessageBox::ButtonRole::YesRole ) if ( msgBox->buttonRole( button ) == QMessageBox::ButtonRole::YesRole )
{ {
// TODO: host and port should be configurable // TODO: host and port should be configurable

@ -48,7 +48,8 @@ moduleFromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescripto
std::unique_ptr< Module > m; std::unique_ptr< Module > m;
if ( !moduleDescriptor.isValid() ) { if ( !moduleDescriptor.isValid() )
{
cError() << "Bad module descriptor format" << instanceId; cError() << "Bad module descriptor format" << instanceId;
return nullptr; return nullptr;
} }
@ -68,7 +69,9 @@ moduleFromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescripto
} }
else else
{ {
cError() << "Bad interface" << Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() ) << "for module type" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() ); cError() << "Bad interface"
<< Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() )
<< "for module type" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() );
} }
} }
else if ( moduleDescriptor.type() == Type::Job ) else if ( moduleDescriptor.type() == Type::Job )
@ -91,7 +94,9 @@ moduleFromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescripto
} }
else else
{ {
cError() << "Bad interface" << Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() ) << "for module type" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() ); cError() << "Bad interface"
<< Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() )
<< "for module type" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() );
} }
} }
else else
@ -101,7 +106,9 @@ moduleFromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescripto
if ( !m ) if ( !m )
{ {
cError() << "Bad module type (" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() ) << ") or interface string (" << Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() ) << ") for module " cError() << "Bad module type (" << Calamares::ModuleSystem::typeNames().find( moduleDescriptor.type() )
<< ") or interface string ("
<< Calamares::ModuleSystem::interfaceNames().find( moduleDescriptor.interface() ) << ") for module "
<< instanceId; << instanceId;
return nullptr; return nullptr;
} }

@ -104,8 +104,9 @@ ModuleManager::doInit()
if ( ok && !moduleName.isEmpty() && ( moduleName == currentDir.dirName() ) if ( ok && !moduleName.isEmpty() && ( moduleName == currentDir.dirName() )
&& !m_availableDescriptorsByModuleName.contains( moduleName ) ) && !m_availableDescriptorsByModuleName.contains( moduleName ) )
{ {
auto descriptor = Calamares::ModuleSystem::Descriptor::fromDescriptorData( moduleDescriptorMap ); auto descriptor
descriptor.setDirectory(descriptorFileInfo.absoluteDir().absolutePath() ); = Calamares::ModuleSystem::Descriptor::fromDescriptorData( moduleDescriptorMap );
descriptor.setDirectory( descriptorFileInfo.absoluteDir().absolutePath() );
m_availableDescriptorsByModuleName.insert( moduleName, descriptor ); m_availableDescriptorsByModuleName.insert( moduleName, descriptor );
} }
} }
@ -243,11 +244,8 @@ ModuleManager::loadModules()
} }
else else
{ {
thisModule thisModule = Calamares::moduleFromDescriptor(
= Calamares::moduleFromDescriptor( descriptor, descriptor, instanceKey.id(), configFileName, descriptor.directory() );
instanceKey.id(),
configFileName,
descriptor.directory() );
if ( !thisModule ) if ( !thisModule )
{ {
cError() << "Module" << instanceKey.toString() << "cannot be created from descriptor" cError() << "Module" << instanceKey.toString() << "cannot be created from descriptor"
@ -375,8 +373,7 @@ ModuleManager::checkDependencies()
for ( auto it = m_availableDescriptorsByModuleName.begin(); it != m_availableDescriptorsByModuleName.end(); for ( auto it = m_availableDescriptorsByModuleName.begin(); it != m_availableDescriptorsByModuleName.end();
++it ) ++it )
{ {
QStringList unmet = missingRequiredModules( it->requiredModules(), QStringList unmet = missingRequiredModules( it->requiredModules(), m_availableDescriptorsByModuleName );
m_availableDescriptorsByModuleName );
if ( unmet.count() > 0 ) if ( unmet.count() > 0 )
{ {
@ -403,8 +400,7 @@ ModuleManager::checkModuleDependencies( const Module& m )
} }
bool allRequirementsFound = true; bool allRequirementsFound = true;
QStringList requiredModules QStringList requiredModules = m_availableDescriptorsByModuleName[ m.name() ].requiredModules();
= m_availableDescriptorsByModuleName[ m.name() ].requiredModules();
for ( const QString& required : requiredModules ) for ( const QString& required : requiredModules )
{ {

@ -71,7 +71,7 @@ ProcessJobModule::ProcessJobModule()
} }
ProcessJobModule::~ProcessJobModule() { } ProcessJobModule::~ProcessJobModule() {}
} // namespace Calamares } // namespace Calamares

@ -67,7 +67,7 @@ PythonJobModule::PythonJobModule()
} }
PythonJobModule::~PythonJobModule() { } PythonJobModule::~PythonJobModule() {}
} // namespace Calamares } // namespace Calamares

@ -179,6 +179,6 @@ PythonQtViewModule::PythonQtViewModule()
{ {
} }
PythonQtViewModule::~PythonQtViewModule() { } PythonQtViewModule::~PythonQtViewModule() {}
} // namespace Calamares } // namespace Calamares

@ -23,7 +23,7 @@ ImageRegistry::instance()
} }
ImageRegistry::ImageRegistry() { } ImageRegistry::ImageRegistry() {}
QIcon QIcon

@ -53,7 +53,7 @@ BlankViewStep::BlankViewStep( const QString& title,
m_widget->setLayout( layout ); m_widget->setLayout( layout );
} }
BlankViewStep::~BlankViewStep() { } BlankViewStep::~BlankViewStep() {}
QString QString
BlankViewStep::prettyName() const BlankViewStep::prettyName() const

@ -31,7 +31,7 @@ class GlobalStorage : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit GlobalStorage( Calamares::GlobalStorage* gs ); explicit GlobalStorage( Calamares::GlobalStorage* gs );
virtual ~GlobalStorage() { } virtual ~GlobalStorage() {}
public slots: public slots:
bool contains( const QString& key ) const; bool contains( const QString& key ) const;

@ -35,7 +35,7 @@ class PythonQtJob : public Calamares::Job
{ {
Q_OBJECT Q_OBJECT
public: public:
virtual ~PythonQtJob() { } virtual ~PythonQtJob() {}
QString prettyName() const override; QString prettyName() const override;
QString prettyDescription() const override; QString prettyDescription() const override;

@ -24,7 +24,7 @@ class Utils : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit Utils( QObject* parent = nullptr ); explicit Utils( QObject* parent = nullptr );
virtual ~Utils() { } virtual ~Utils() {}
public slots: public slots:
void debug( const QString& s ) const; void debug( const QString& s ) const;

@ -79,7 +79,7 @@ QmlViewStep::QmlViewStep( QObject* parent )
// QML Loading starts when the configuration for the module is set. // QML Loading starts when the configuration for the module is set.
} }
QmlViewStep::~QmlViewStep() { } QmlViewStep::~QmlViewStep() {}
QString QString
QmlViewStep::prettyName() const QmlViewStep::prettyName() const

@ -22,7 +22,7 @@ ViewStep::ViewStep( QObject* parent )
} }
ViewStep::~ViewStep() { } ViewStep::~ViewStep() {}
QString QString

@ -27,7 +27,7 @@ ClickableLabel::ClickableLabel( const QString& text, QWidget* parent )
} }
ClickableLabel::~ClickableLabel() { } ClickableLabel::~ClickableLabel() {}
void void

@ -17,7 +17,7 @@ FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent )
} }
FixedAspectRatioLabel::~FixedAspectRatioLabel() { } FixedAspectRatioLabel::~FixedAspectRatioLabel() {}
void void

@ -38,7 +38,7 @@ class UIDLLEXPORT PrettyRadioButton : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit PrettyRadioButton( QWidget* parent = nullptr ); explicit PrettyRadioButton( QWidget* parent = nullptr );
virtual ~PrettyRadioButton() { } virtual ~PrettyRadioButton() {}
/// @brief Passes @p text on to the ClickableLabel /// @brief Passes @p text on to the ClickableLabel
void setText( const QString& text ); void setText( const QString& text );

@ -202,7 +202,8 @@ PreserveFiles::setConfigurationMap( const QVariantMap& configurationMap )
{ {
QString filename = li.toString(); QString filename = li.toString();
if ( !filename.isEmpty() ) if ( !filename.isEmpty() )
m_items.append( Item { filename, filename, CalamaresUtils::Permissions( defaultPermissions ), ItemType::Path } ); m_items.append(
Item { filename, filename, CalamaresUtils::Permissions( defaultPermissions ), ItemType::Path } );
else else
{ {
cDebug() << "Empty filename for preservefiles, item" << c; cDebug() << "Empty filename for preservefiles, item" << c;

@ -8,8 +8,8 @@
#include "utils/Logger.h" #include "utils/Logger.h"
#include <QtTest/QtTest>
#include <QObject> #include <QObject>
#include <QtTest/QtTest>
class TrackingTests : public QObject class TrackingTests : public QObject
{ {
@ -28,17 +28,17 @@ TrackingTests::TrackingTests()
{ {
} }
TrackingTests::~TrackingTests() TrackingTests::~TrackingTests() {}
{
}
void TrackingTests::initTestCase() void
TrackingTests::initTestCase()
{ {
Logger::setupLogLevel( Logger::LOGDEBUG ); Logger::setupLogLevel( Logger::LOGDEBUG );
cDebug() << "Tracking test started."; cDebug() << "Tracking test started.";
} }
void TrackingTests::testEmptyConfig() void
TrackingTests::testEmptyConfig()
{ {
Logger::setupLogLevel( Logger::LOGDEBUG ); Logger::setupLogLevel( Logger::LOGDEBUG );

@ -16,11 +16,11 @@
#include "utils/CalamaresUtilsSystem.h" #include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include <QDir>
#include <QFile>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QDir>
#include <QFile>
using WriteMode = CalamaresUtils::System::WriteMode; using WriteMode = CalamaresUtils::System::WriteMode;

@ -106,15 +106,16 @@ UserTests::testDefaultGroups()
} }
} }
void UserTests::testDefaultGroupsYAML_data() void
UserTests::testDefaultGroupsYAML_data()
{ {
QTest::addColumn< QString >( "filename" ); QTest::addColumn< QString >( "filename" );
QTest::addColumn< int >("count"); QTest::addColumn< int >( "count" );
QTest::addColumn<QString>("group"); QTest::addColumn< QString >( "group" );
QTest::newRow("users.conf") << "users.conf" << 7 << "video"; QTest::newRow( "users.conf" ) << "users.conf" << 7 << "video";
QTest::newRow("dashed list") << "tests/4-audio.conf" << 4 << "audio"; QTest::newRow( "dashed list" ) << "tests/4-audio.conf" << 4 << "audio";
QTest::newRow("blocked list") << "tests/3-wing.conf" << 3 << "wing"; QTest::newRow( "blocked list" ) << "tests/3-wing.conf" << 3 << "wing";
} }
void void
@ -125,23 +126,23 @@ UserTests::testDefaultGroupsYAML()
(void)new Calamares::JobQueue(); (void)new Calamares::JobQueue();
} }
QFETCH(QString, filename); QFETCH( QString, filename );
QFETCH(int, count); QFETCH( int, count );
QFETCH(QString, group); QFETCH( QString, group );
QFile fi( QString("%1/%2").arg(BUILD_AS_TEST, filename) ); QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
QVERIFY(fi.exists()); QVERIFY( fi.exists() );
bool ok = false; bool ok = false;
const auto map = CalamaresUtils::loadYaml(fi, &ok); const auto map = CalamaresUtils::loadYaml( fi, &ok );
QVERIFY(ok); QVERIFY( ok );
QVERIFY(map.count() > 0); QVERIFY( map.count() > 0 );
Config c; Config c;
c.setConfigurationMap(map); c.setConfigurationMap( map );
QCOMPARE( c.defaultGroups().count(), count); QCOMPARE( c.defaultGroups().count(), count );
QVERIFY( c.defaultGroups().contains( group ) ); QVERIFY( c.defaultGroups().contains( group ) );
} }

@ -45,7 +45,8 @@ static inline void
labelOk( QLabel* pix, QLabel* label ) labelOk( QLabel* pix, QLabel* label )
{ {
label->clear(); label->clear();
pix->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::StatusOk, CalamaresUtils::Original, label->size() ) ); pix->setPixmap(
CalamaresUtils::defaultPixmap( CalamaresUtils::StatusOk, CalamaresUtils::Original, label->size() ) );
} }
/** @brief Sets error or ok on a label depending on @p status and @p value /** @brief Sets error or ok on a label depending on @p status and @p value

@ -25,8 +25,8 @@
CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersQmlViewStepFactory, registerPlugin< UsersQmlViewStep >(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersQmlViewStepFactory, registerPlugin< UsersQmlViewStep >(); )
UsersQmlViewStep::UsersQmlViewStep( QObject* parent ) UsersQmlViewStep::UsersQmlViewStep( QObject* parent )
: Calamares::QmlViewStep( parent ) : Calamares::QmlViewStep( parent )
, m_config( new Config(this) ) , m_config( new Config( this ) )
{ {
connect( m_config, &Config::readyChanged, this, &UsersQmlViewStep::nextStatusChanged ); connect( m_config, &Config::readyChanged, this, &UsersQmlViewStep::nextStatusChanged );
@ -96,6 +96,6 @@ UsersQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
m_config->setConfigurationMap( configurationMap ); m_config->setConfigurationMap( configurationMap );
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
setContextProperty( "Users", m_config ); setContextProperty( "Users", m_config );
} }

@ -19,8 +19,8 @@
#include <DllMacro.h> #include <DllMacro.h>
#include <QVariant>
#include "Config.h" #include "Config.h"
#include <QVariant>
class PLUGINDLLEXPORT UsersQmlViewStep : public Calamares::QmlViewStep class PLUGINDLLEXPORT UsersQmlViewStep : public Calamares::QmlViewStep
{ {
@ -44,13 +44,10 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override; void setConfigurationMap( const QVariantMap& configurationMap ) override;
QObject * getConfig() override QObject* getConfig() override { return m_config; }
{
return m_config;
}
private: private:
Config *m_config; Config* m_config;
Calamares::JobList m_jobs; Calamares::JobList m_jobs;
}; };

@ -8,8 +8,8 @@
* *
*/ */
#include "WebViewConfig.h"
#include "WebViewStep.h" #include "WebViewStep.h"
#include "WebViewConfig.h"
#include <QVariant> #include <QVariant>

@ -39,7 +39,7 @@
WelcomePage::WelcomePage( Config* conf, QWidget* parent ) WelcomePage::WelcomePage( Config* conf, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::WelcomePage ) , ui( new Ui::WelcomePage )
, m_checkingWidget( new CheckerContainer( *(conf->requirementsModel()), this ) ) , m_checkingWidget( new CheckerContainer( *( conf->requirementsModel() ), this ) )
, m_languages( nullptr ) , m_languages( nullptr )
, m_conf( conf ) , m_conf( conf )
{ {

@ -146,10 +146,8 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( checkEntries.append(
{ entry, { entry,
[ req = m_requiredStorageGiB ] { [req = m_requiredStorageGiB] { return tr( "has at least %1 GiB available drive space" ).arg( req ); },
return tr( "has at least %1 GiB available drive space" ).arg( req ); [req = m_requiredStorageGiB] {
},
[ req = m_requiredStorageGiB ] {
return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req );
}, },
enoughStorage, enoughStorage,
@ -159,8 +157,8 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( checkEntries.append(
{ entry, { entry,
[ req = m_requiredRamGiB ] { return tr( "has at least %1 GiB working memory" ).arg( req ); }, [req = m_requiredRamGiB] { return tr( "has at least %1 GiB working memory" ).arg( req ); },
[ req = m_requiredRamGiB ] { [req = m_requiredRamGiB] {
return tr( "The system does not have enough working memory. At least %1 GiB is required." ) return tr( "The system does not have enough working memory. At least %1 GiB is required." )
.arg( req ); .arg( req );
}, },
@ -349,7 +347,7 @@ GeneralRequirements::checkEnoughRam( qint64 requiredRam )
// Ignore the guesstimate-factor; we get an under-estimate // Ignore the guesstimate-factor; we get an under-estimate
// which is probably the usable RAM for programs. // which is probably the usable RAM for programs.
quint64 availableRam = CalamaresUtils::System::instance()->getTotalMemoryB().first; quint64 availableRam = CalamaresUtils::System::instance()->getTotalMemoryB().first;
return double(availableRam) >= double(requiredRam) * 0.95; // cast to silence 64-bit-int conversion to double return double( availableRam ) >= double( requiredRam ) * 0.95; // cast to silence 64-bit-int conversion to double
} }

@ -11,13 +11,14 @@
#define PARTMAN_DEVICES_H #define PARTMAN_DEVICES_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
int check_big_enough(long long required_space); int check_big_enough( long long required_space );
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // PARTMAN_DEVICES_H #endif // PARTMAN_DEVICES_H

@ -29,9 +29,9 @@ WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
, m_requirementsChecker( new GeneralRequirements( this ) ) , m_requirementsChecker( new GeneralRequirements( this ) )
{ {
connect( Calamares::ModuleManager::instance(), connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsComplete, &Calamares::ModuleManager::requirementsComplete,
this, this,
&WelcomeQmlViewStep::nextStatusChanged ); &WelcomeQmlViewStep::nextStatusChanged );
} }

Loading…
Cancel
Save