Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
pencilerror.cpp
1 
2 #include "pencilerror.h"
3 #include <map>
4 #include <QObject>
5 #include <QSysInfo>
6 #include "pencildef.h"
7 
8 Status::Status(Status::ErrorCode eCode, QStringList detailsList, QString title, QString description)
9  : mCode( eCode )
10  , mTitle( title )
11  , mDescription( description )
12  , mDetails( detailsList )
13 {
14 }
15 
16 QString Status::msg()
17 {
18  static std::map<ErrorCode, QString> msgMap =
19  {
20  // error messages.
21  { OK, QObject::tr( "Everything ok." ) },
22  { FAIL, QObject::tr( "Ooops, Something went wrong." ) },
23  { FILE_NOT_FOUND, QObject::tr( "File doesn't exist." ) },
24  { ERROR_FILE_CANNOT_OPEN, QObject::tr( "Cannot open file." ) },
25  { ERROR_INVALID_XML_FILE, QObject::tr( "The file is not a valid xml document." ) },
26  { ERROR_INVALID_PENCIL_FILE, QObject::tr( "The file is not valid pencil document." ) },
27  };
28 
29  auto it = msgMap.find( mCode );
30  if ( it == msgMap.end() )
31  {
32  return msgMap[ FAIL ];
33  }
34  return msgMap[ mCode ];
35 }
36 
37 QString Status::details()
38 {
39  QString details = mDetails.join("<br>");
40  details.append("<br><br>");
41  details.append( QString(
42  "Error Display<br>"
43  "Title: %1<br>"
44  "Description: %2"
45  ).arg( mTitle,
46  mDescription )
47  );
48  details.append("<br><br>");
49 #if QT_VERSION >= 0x050400
50  details.append( QString(
51  "System Info<br>"
52  "Pencil version: %1<br>"
53  "Build ABI: %2<br>"
54  "Kernel: %3 %4<br>"
55  "Product name: %5"
56  ).arg( APP_VERSION,
57  QSysInfo::buildAbi(),
58  QSysInfo::kernelType(),
59  QSysInfo::kernelVersion(),
60  QSysInfo::prettyProductName() )
61  );
62 #endif
63  return details;
64 }
65 
66 bool Status::operator==( Status::ErrorCode code )
67 {
68  return ( mCode == code );
69 }