Krita Source Code Documentation
Loading...
Searching...
No Matches
KisImportExportErrorCode Class Reference

#include <KisImportExportErrorCode.h>

Public Member Functions

QString errorMessage () const
 
bool isCancelled () const
 
bool isInternalError () const
 
bool isOk () const
 
 KisImportExportErrorCode ()
 
 KisImportExportErrorCode (ImportExportCodes::ErrorCodeID code)
 
 KisImportExportErrorCode (KisImportExportErrorCannotRead code)
 
 KisImportExportErrorCode (KisImportExportErrorCannotWrite code)
 
bool operator== (KisImportExportErrorCode errorCode)
 

Private Types

enum  ErrorFieldUsed { None , CodeId , CannotRead , CannotWrite }
 

Private Attributes

KisImportExportErrorCannotRead cannotRead
 
KisImportExportErrorCannotWrite cannotWrite
 
ImportExportCodes::ErrorCodeID codeId {ImportExportCodes::OK}
 
ErrorFieldUsed errorFieldUsed
 

Friends

QDebug & operator<< (QDebug &d, const KisImportExportErrorCode &errorCode)
 

Detailed Description

Definition at line 109 of file KisImportExportErrorCode.h.

Member Enumeration Documentation

◆ ErrorFieldUsed

Constructor & Destructor Documentation

◆ KisImportExportErrorCode() [1/4]

KisImportExportErrorCode::KisImportExportErrorCode ( )

Definition at line 93 of file KisImportExportErrorCode.cpp.

95 , cannotRead()
96 , cannotWrite()
97{ }
KisImportExportErrorCannotRead cannotRead
KisImportExportErrorCannotWrite cannotWrite

◆ KisImportExportErrorCode() [2/4]

KisImportExportErrorCode::KisImportExportErrorCode ( ImportExportCodes::ErrorCodeID code)

Definition at line 99 of file KisImportExportErrorCode.cpp.

101 , codeId(id)
102 , cannotRead()
103 , cannotWrite()
104{ }
ImportExportCodes::ErrorCodeID codeId

◆ KisImportExportErrorCode() [3/4]

KisImportExportErrorCode::KisImportExportErrorCode ( KisImportExportErrorCannotRead code)

◆ KisImportExportErrorCode() [4/4]

KisImportExportErrorCode::KisImportExportErrorCode ( KisImportExportErrorCannotWrite code)

Definition at line 113 of file KisImportExportErrorCode.cpp.

Member Function Documentation

◆ errorMessage()

QString KisImportExportErrorCode::errorMessage ( ) const

Definition at line 137 of file KisImportExportErrorCode.cpp.

138{
139 QString internal = i18n("Unexpected error.");
140 if (errorFieldUsed == CannotRead) {
141 return cannotRead.errorMessage();
142 } else if (errorFieldUsed == CannotWrite) {
143 return cannotWrite.errorMessage();
144 } else if (errorFieldUsed == CodeId) {
145 switch (codeId) {
146 // Reading
148 return i18n("The file doesn't exist.");
150 return i18n("Permission denied: Krita is not allowed to read the file.");
152 return i18n("The file format cannot be parsed.");
154 return i18n("The file format contains unsupported features.");
156 return i18n("The file format contains unsupported color space.");
158 return i18n("Error occurred while reading from the file.");
159
160 // Writing
162 return i18n("The file cannot be created.");
164 return i18n("Permission denied: Krita is not allowed to write to the file.");
166 return i18n("There is not enough disk space left to save the file.");
168 return i18n("Error occurred while writing to the file.");
170 return i18n("Krita does not support this file format.");
171
172 // Both
174 return i18n("The action was cancelled by the user.");
175
176 // Other
178 return i18n("Unknown error.");
180 return internal;
182 return i18n("Image is busy.");
183 // OK
185 return i18n("The action has been completed successfully.");
186 default:
187 return internal;
188
189 }
190 }
191 return internal; // errorFieldUsed = None
192}

References ImportExportCodes::Busy, ImportExportCodes::Cancelled, ImportExportCodes::CannotCreateFile, CannotRead, cannotRead, CannotWrite, cannotWrite, CodeId, codeId, errorFieldUsed, KisImportExportErrorCannotWrite::errorMessage(), KisImportExportErrorCannotRead::errorMessage(), ImportExportCodes::ErrorWhileReading, ImportExportCodes::ErrorWhileWriting, ImportExportCodes::Failure, ImportExportCodes::FileFormatIncorrect, ImportExportCodes::FileFormatNotSupported, ImportExportCodes::FileNotExist, ImportExportCodes::FormatColorSpaceUnsupported, ImportExportCodes::FormatFeaturesUnsupported, ImportExportCodes::InsufficientMemory, ImportExportCodes::InternalError, ImportExportCodes::NoAccessToRead, ImportExportCodes::NoAccessToWrite, and ImportExportCodes::OK.

◆ isCancelled()

bool KisImportExportErrorCode::isCancelled ( ) const

◆ isInternalError()

bool KisImportExportErrorCode::isInternalError ( ) const

◆ isOk()

bool KisImportExportErrorCode::isOk ( ) const

Definition at line 121 of file KisImportExportErrorCode.cpp.

122{
123 // if cannotRead or cannotWrite is "NoError", it means that something is wrong in our code
125}

References CodeId, codeId, errorFieldUsed, and ImportExportCodes::OK.

◆ operator==()

bool KisImportExportErrorCode::operator== ( KisImportExportErrorCode errorCode)

Definition at line 196 of file KisImportExportErrorCode.cpp.

197{
198 if (errorFieldUsed != errorCode.errorFieldUsed) {
199 return false;
200 }
201 if (errorFieldUsed == CodeId) {
202 return codeId == errorCode.codeId;
203 }
204 if (errorFieldUsed == CannotRead) {
205 return cannotRead == errorCode.cannotRead;
206 }
207 return cannotWrite == errorCode.cannotWrite;
208}

References CannotRead, cannotRead, cannotWrite, CodeId, codeId, and errorFieldUsed.

Friends And Related Symbol Documentation

◆ operator<<

QDebug & operator<< ( QDebug & d,
const KisImportExportErrorCode & errorCode )
friend

Definition at line 145 of file KisImportExportErrorCode.h.

146{
147 switch (errorCode.errorFieldUsed) {
149 d << "None of the error fields is in use.";
150 break;
152 d << "Cannot read: " << errorCode.cannotRead.m_error;
153 break;
155 d << "Cannot write: " << errorCode.cannotRead.m_error;
156 break;
158 d << "Error code = " << errorCode.codeId;
159 }
160 d << " " << errorCode.errorMessage();
161 return d;
162}

Member Data Documentation

◆ cannotRead

KisImportExportErrorCannotRead KisImportExportErrorCode::cannotRead
private

Definition at line 141 of file KisImportExportErrorCode.h.

◆ cannotWrite

KisImportExportErrorCannotWrite KisImportExportErrorCode::cannotWrite
private

Definition at line 142 of file KisImportExportErrorCode.h.

◆ codeId

ImportExportCodes::ErrorCodeID KisImportExportErrorCode::codeId {ImportExportCodes::OK}
private

Definition at line 140 of file KisImportExportErrorCode.h.

◆ errorFieldUsed

ErrorFieldUsed KisImportExportErrorCode::errorFieldUsed
private

Definition at line 138 of file KisImportExportErrorCode.h.


The documentation for this class was generated from the following files: