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 (const QString &message)
 
 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
 
QString failureMessage
 

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/5]

KisImportExportErrorCode::KisImportExportErrorCode ( )

Definition at line 93 of file KisImportExportErrorCode.cpp.

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

◆ KisImportExportErrorCode() [2/5]

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/5]

KisImportExportErrorCode::KisImportExportErrorCode ( KisImportExportErrorCannotRead code)

◆ KisImportExportErrorCode() [4/5]

KisImportExportErrorCode::KisImportExportErrorCode ( KisImportExportErrorCannotWrite code)

Definition at line 113 of file KisImportExportErrorCode.cpp.

◆ KisImportExportErrorCode() [5/5]

KisImportExportErrorCode::KisImportExportErrorCode ( const QString & message)
explicit

Member Function Documentation

◆ errorMessage()

QString KisImportExportErrorCode::errorMessage ( ) const

Definition at line 144 of file KisImportExportErrorCode.cpp.

145{
146 QString internal = i18n("Unexpected error.");
147 if (errorFieldUsed == CannotRead) {
148 return cannotRead.errorMessage();
149 } else if (errorFieldUsed == CannotWrite) {
150 return cannotWrite.errorMessage();
151 } else if (errorFieldUsed == CodeId) {
152 switch (codeId) {
153 // Reading
155 return i18n("The file doesn't exist.");
157 return i18n("Permission denied: Krita is not allowed to read the file.");
159 return i18n("The file format cannot be parsed.");
161 return i18n("The file format contains unsupported features.");
163 return i18n("The file format contains unsupported color space.");
165 return i18n("Error occurred while reading from the file.");
166
167 // Writing
169 return i18n("The file cannot be created.");
171 return i18n("Permission denied: Krita is not allowed to write to the file.");
173 return i18n("There is not enough disk space left to save the file.");
175 return i18n("Error occurred while writing to the file.");
177 return i18n("Krita does not support this file format.");
178
179 // Both
181 return i18n("The action was cancelled by the user.");
182
183 // Other
185 return failureMessage.isEmpty() ? i18n("Unknown error.") : failureMessage;
187 return internal;
189 return i18n("Image is busy.");
190 // OK
192 return i18n("The action has been completed successfully.");
193 default:
194 return internal;
195
196 }
197 }
198 return internal; // errorFieldUsed = None
199}

References ImportExportCodes::Busy, ImportExportCodes::Cancelled, ImportExportCodes::CannotCreateFile, CannotRead, cannotRead, CannotWrite, cannotWrite, CodeId, codeId, errorFieldUsed, KisImportExportErrorCannotWrite::errorMessage(), KisImportExportErrorCannotRead::errorMessage(), ImportExportCodes::ErrorWhileReading, ImportExportCodes::ErrorWhileWriting, ImportExportCodes::Failure, failureMessage, 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 128 of file KisImportExportErrorCode.cpp.

129{
130 // if cannotRead or cannotWrite is "NoError", it means that something is wrong in our code
132}

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

◆ operator==()

bool KisImportExportErrorCode::operator== ( KisImportExportErrorCode errorCode)

Definition at line 203 of file KisImportExportErrorCode.cpp.

204{
205 if (errorFieldUsed != errorCode.errorFieldUsed) {
206 return false;
207 }
208 if (errorFieldUsed == CodeId) {
209 return codeId == errorCode.codeId;
210 }
211 if (errorFieldUsed == CannotRead) {
212 return cannotRead == errorCode.cannotRead;
213 }
214 return cannotWrite == errorCode.cannotWrite;
215}

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 147 of file KisImportExportErrorCode.h.

148{
149 switch (errorCode.errorFieldUsed) {
151 d << "None of the error fields is in use.";
152 break;
154 d << "Cannot read: " << errorCode.cannotRead.m_error;
155 break;
157 d << "Cannot write: " << errorCode.cannotRead.m_error;
158 break;
160 d << "Error code = " << errorCode.codeId;
161 }
162 d << " " << errorCode.errorMessage();
163 return d;
164}

Member Data Documentation

◆ cannotRead

KisImportExportErrorCannotRead KisImportExportErrorCode::cannotRead
private

Definition at line 142 of file KisImportExportErrorCode.h.

◆ cannotWrite

KisImportExportErrorCannotWrite KisImportExportErrorCode::cannotWrite
private

Definition at line 143 of file KisImportExportErrorCode.h.

◆ codeId

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

Definition at line 141 of file KisImportExportErrorCode.h.

◆ errorFieldUsed

ErrorFieldUsed KisImportExportErrorCode::errorFieldUsed
private

Definition at line 139 of file KisImportExportErrorCode.h.

◆ failureMessage

QString KisImportExportErrorCode::failureMessage
private

Definition at line 144 of file KisImportExportErrorCode.h.


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