kmjob.cpp
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #include "kmjob.h" 00021 00022 #include <klocale.h> 00023 00024 KMJob::KMJob() 00025 : KMObject() 00026 { 00027 init(); 00028 } 00029 00030 KMJob::KMJob(const KMJob& j) 00031 : KMObject() 00032 { 00033 init(); 00034 copy(j); 00035 } 00036 00037 KMJob& KMJob::operator=(const KMJob& j) 00038 { 00039 init(); 00040 copy(j); 00041 return *this; 00042 } 00043 00044 void KMJob::init() 00045 { 00046 m_ID = -1; 00047 m_state = KMJob::Error; 00048 m_size = m_processedsize = 0; 00049 m_type = KMJob::System; 00050 m_pages = m_processedpages = 0; 00051 m_remote = false; 00052 m_attributes.resize(1, 0); 00053 } 00054 00055 void KMJob::copy(const KMJob& j) 00056 { 00057 m_ID = j.m_ID; 00058 m_name = j.m_name; 00059 m_printer = j.m_printer; 00060 m_owner = j.m_owner; 00061 m_state = j.m_state; 00062 m_size = j.m_size; 00063 m_uri = j.m_uri; 00064 m_type = j.m_type; 00065 m_pages = j.m_pages; 00066 m_processedsize = j.m_processedsize; 00067 m_processedpages = j.m_processedpages; 00068 m_remote = j.m_remote; 00069 m_attributes = j.m_attributes; 00070 00071 setDiscarded(false); 00072 } 00073 00074 QString KMJob::pixmap() 00075 { 00076 // special case 00077 if (m_type == KMJob::Threaded) 00078 return QString::fromLatin1("exec"); 00079 00080 // normal case 00081 QString str("kdeprint_job"); 00082 switch (m_state) 00083 { 00084 case KMJob::Printing: 00085 str.append("_process"); 00086 break; 00087 case KMJob::Held: 00088 str.append("_stopped"); 00089 break; 00090 case KMJob::Error: 00091 str.append("_error"); 00092 break; 00093 case KMJob::Completed: 00094 str.append("_completed"); 00095 break; 00096 case KMJob::Cancelled: 00097 str.append("_cancelled"); 00098 break; 00099 default: 00100 break; 00101 } 00102 return str; 00103 } 00104 00105 QString KMJob::stateString() 00106 { 00107 QString str; 00108 switch (m_state) 00109 { 00110 case KMJob::Printing: 00111 str = i18n("Processing..."); 00112 break; 00113 case KMJob::Queued: 00114 str = i18n("Queued"); 00115 break; 00116 case KMJob::Held: 00117 str = i18n("Held"); 00118 break; 00119 case KMJob::Error: 00120 str = i18n("Error"); 00121 break; 00122 case KMJob::Cancelled: 00123 str = i18n("Canceled"); 00124 break; 00125 case KMJob::Aborted: 00126 str = i18n("Aborted"); 00127 break; 00128 case KMJob::Completed: 00129 str = i18n("Completed"); 00130 break; 00131 default: 00132 str = i18n("Unknown State", "Unknown"); 00133 break; 00134 } 00135 return str; 00136 }