refs #643, moved aircraft model icon loading to model class

* removed iconForModel from interface and aircraft config parser
* CPixmap support for loading pixmap from file
* Access to model of model set loader by model string
* icon path as member of CAircraftModel
This commit is contained in:
Klaus Basan
2016-04-15 18:49:55 +02:00
parent a3a3380008
commit ddc7347927
20 changed files with 143 additions and 67 deletions

View File

@@ -9,6 +9,7 @@
#include "pixmap.h"
#include <QBuffer>
#include <QFile>
#include <tuple>
namespace BlackMisc
@@ -69,6 +70,31 @@ namespace BlackMisc
return "Pixmap";
}
CPixmap CPixmap::loadFromFile(const QString &filePath, CStatusMessage &msg)
{
if (filePath.isEmpty())
{
msg = CStatusMessage(CStatusMessage::SeverityError, "no file path");
return CPixmap();
}
if (!QFile(filePath).exists())
{
msg = CStatusMessage().error("file %1 does not exist") << filePath;
return CPixmap();
}
QPixmap pm;
if (pm.load(filePath))
{
msg = CStatusMessage().info("file %1 loaded") << filePath;
return CPixmap(pm);
}
else
{
msg = CStatusMessage().error("file %1 not loaded") << filePath;
return CPixmap();
}
}
QPixmap CPixmap::toPixmap() const
{
return this->pixmap();