![]() |
OpenAlbum 1.0.b
|
00001 #include <string> 00002 #include "parser.h" 00003 #include <QPainter> 00004 #include <QPaintEvent> 00005 #include <QString> 00006 #include <QGraphicsView> 00007 #include "Portada.h" 00008 #include "Pagina.h" 00009 #include <QColor> 00010 #include <qt4/QtGui/qgraphicsitem.h> 00011 #include <QFont> 00012 #include "error.h" 00013 00014 Pagina::Pagina(int width, int height, QWidget *parent_): w(width), h(height), parent(parent_){ 00015 this->colorpagina=false; 00016 try{ 00017 this->versionFinal=new QGraphicsView(); 00018 this->versionReducida=new QGraphicsView(); 00019 this->fondopagina=new QString(); 00020 00021 this->colorfondopagina=new QColor(); 00022 }catch(std::exception& e){ 00023 Error *err=new Error(2, e.what(), this->parent); 00024 err->LanzarDialogo(); 00025 delete err; 00026 exit(1); 00027 } 00028 this->numTextos=0; 00029 this->PaginaVacia=true; 00030 this->PaginaEditada=false; 00031 this->contieneTextos=false; 00032 this->usaMascara=false; 00033 this->contieneMarcos=false; 00034 } 00035 bool Pagina::activadaMascara(){ 00036 return this->usaMascara; 00037 } 00038 00039 QString Pagina::getMascara(){ 00040 return rutaMascara; 00041 } 00042 00043 void Pagina::activarMascara(QString ruta){ 00044 this->usaMascara=true; 00045 this->rutaMascara=ruta; 00046 } 00047 00048 void Pagina::SetMarcos(QList<marco> marcos_){ 00049 this->marcos=marcos_; 00050 this->contieneMarcos=true; 00051 } 00052 00053 QList<marco> Pagina::getMarcos(){ 00054 return this->marcos; 00055 } 00056 00057 00058 Pagina::~Pagina(){ 00059 delete this->colorfondopagina; 00060 delete this->fondopagina; 00061 delete this->pathPlantillapagina; 00062 for(int i=0; i<this->objetosPagina.size(); i++){ 00063 delete this->objetosPagina[i]; 00064 } 00065 this->objetosPagina.clear(); 00066 for(int j=0; j < this->versionFinal->items().size(); j++){ 00067 delete this->versionFinal->items().at(j); 00068 } 00069 delete this->versionFinal->scene(); 00070 delete this->versionFinal; 00071 for(int j=0; j < this->versionReducida->items().size(); j++){ 00072 delete this->versionReducida->items().at(j); 00073 } 00074 delete this->versionReducida->scene(); 00075 delete this->versionReducida; 00076 } 00077 00078 bool Pagina::ContieneMarcos(){ 00079 return this->contieneMarcos; 00080 } 00081 00082 bool Pagina::GetPaginaVacia(){ 00083 return this->PaginaVacia; 00084 } 00085 00086 void Pagina::setPosicionObjeto(unsigned indice, int posx, int posy){ 00087 00088 try{ 00089 this->objetosPagina.at(indice)->setPos(posx, posy); 00090 this->versionReducida->scene()->items().at(indice)->setPos(posx, posy); 00091 }catch(std::exception& e){ 00092 Error *err=new Error(1, e.what(), this->parent); 00093 err->LanzarDialogo(); 00094 delete err; 00095 exit(1); 00096 } 00097 00098 } 00099 00100 void Pagina::SetPaginaLLena(){ 00101 this->PaginaVacia=false; 00102 } 00103 00104 void Pagina::SetPaginaEditada(){ 00105 this->PaginaEditada=true; 00106 } 00107 00108 bool Pagina::GetPaginaEditada(){ 00109 return this->PaginaEditada; 00110 } 00111 00112 int Pagina::GetNumTextos(){ 00113 00114 return this->numTextos; 00115 } 00116 00117 void Pagina::LoadNumTextos(int num){ 00118 this->numTextos=num; 00119 if(num!=0){ 00120 this->contieneTextos=true; 00121 } 00122 } 00123 00124 bool Pagina::ContieneTextos(){ 00125 return this->contieneTextos; 00126 } 00127 00128 std::vector<AImagen> Pagina::GetVectorImagenes(){ 00129 00130 return Imagenes; 00131 } 00132 00133 std::vector<ATexto> Pagina::GetVectorTextos(){ 00134 00135 return this->Textos; 00136 } 00137 00138 bool Pagina::getImagenPosVertical(unsigned indice){ 00139 bool devolver=false; 00140 try{ 00141 if(this->Imagenes.at(indice).pos=="vertical"){ 00142 devolver=true; 00143 }else{ 00144 devolver=false; 00145 } 00146 }catch(std::exception& e){ 00147 Error *err=new Error(1, e.what(), this->parent); 00148 err->LanzarDialogo(); 00149 delete err; 00150 exit(1); 00151 } 00152 return devolver; 00153 } 00154 00155 void Pagina::LoadFoto(QString filename, int width, int height, int x, int y, std::string pos_){ 00156 AImagen i; 00157 i.ruta=filename; 00158 i.w=width; 00159 i.h=height; 00160 i.pos_x=x; 00161 i.pos_y=y; 00162 i.pos=QString::fromStdString(pos_); 00163 00164 Imagenes.push_back(i); 00165 00166 } 00167 00168 void Pagina::LoadTexto(bool cur, bool neg, bool sub, QString text, QFont f, QColor c){ 00169 ATexto t; 00170 t.cursiva=cur; 00171 t.fuente=f; 00172 t.negrita=neg; 00173 t.subrayado=sub; 00174 t.texto=text; 00175 t.color=c; 00176 this->Textos.push_back(t); 00177 } 00178 00179 void Pagina::LoadTexto(bool cur, bool neg, bool sub, QString text, QFont f){ 00180 ATexto t; 00181 t.cursiva=cur; 00182 t.fuente=f; 00183 t.negrita=neg; 00184 t.subrayado=sub; 00185 t.texto=text; 00186 this->Textos.push_back(t); 00187 00188 00189 } 00190 00191 void Pagina::LoadTextoResto(unsigned i, int weight, int pt, int x, int y, std::string ver, std::string cen){ 00192 try{ 00193 Textos.at(i).w=weight; 00194 00195 Textos.at(i).puntos=pt; 00196 00197 Textos.at(i).pos_x=x; 00198 00199 Textos.at(i).pos_y=y; 00200 if(ver=="vertical"){ 00201 Textos.at(i).vertical=true; 00202 }else{ 00203 Textos.at(i).vertical=false; 00204 } 00205 00206 if(cen=="si"){ 00207 00208 Textos.at(i).centrado=true; 00209 00210 }else{ 00211 Textos.at(i).centrado=false; 00212 } 00213 }catch(std::exception& e){ 00214 Error *err=new Error(1, e.what(), this->parent); 00215 err->LanzarDialogo(); 00216 delete err; 00217 exit(1); 00218 } 00219 00220 } 00221 00222 void Pagina::LoadFondo(QString f){ 00223 *fondopagina=f; 00224 } 00225 00226 void Pagina::LoadFondoColor (QColor c){ 00227 *colorfondopagina=c; 00228 } 00229 00230 QString Pagina::GetFondoImagen (){ 00231 return *fondopagina; 00232 } 00233 00234 QColor Pagina::GetFondoColor (){ 00235 return *colorfondopagina; 00236 } 00237 00238 bool Pagina::ColordeFondo(){ 00239 return colorpagina; 00240 } 00241 00242 void Pagina::DesactivarColordefondo(){ 00243 00244 this->colorpagina=false; 00245 } 00246 00247 void Pagina::ActivarColordefondo(){ 00248 colorpagina=true; 00249 } 00250 00251 void Pagina::LoadDimensiones(int height, int weight){ 00252 w=weight; 00253 h=height; 00254 } 00255 00256 00257 QString Pagina::RutaFoto(AImagen imagen){ 00258 return imagen.ruta; 00259 } 00260 00261 int Pagina::DimensionWImagen(AImagen imagen){ 00262 return imagen.w; 00263 } 00264 00265 int Pagina::DimensionHImagen(AImagen imagen){ 00266 return imagen.h; 00267 } 00268 00269 int Pagina::PosicionXImagen(AImagen imagen){ 00270 return imagen.pos_x; 00271 } 00272 00273 int Pagina::PosicionYImagen(AImagen imagen){ 00274 return imagen.pos_y; 00275 } 00276 00277 QFont Pagina::FuenteTexto(ATexto texto){ 00278 return texto.fuente; 00279 } 00280 00281 QString Pagina::Texto(ATexto textot){ 00282 return textot.texto; 00283 } 00284 00285 int Pagina::WTexto(ATexto texto){ 00286 return texto.w; 00287 } 00288 00289 int Pagina::PosXTexto(ATexto texto){ 00290 return texto.pos_x; 00291 } 00292 00293 int Pagina::PosYTexto(ATexto texto){ 00294 return texto.pos_y; 00295 } 00296 00297 int Pagina::TamTexto(ATexto texto){ 00298 return texto.puntos; 00299 } 00300 00301 bool Pagina::VerticalTexto(ATexto texto){ 00302 return texto.vertical; 00303 } 00304 00305 bool Pagina::CursivaTexto(ATexto texto){ 00306 return texto.cursiva; 00307 } 00308 00309 bool Pagina::NegritaTexto(ATexto texto){ 00310 return texto.negrita; 00311 } 00312 00313 bool Pagina::SubrayadoTexto(ATexto texto){ 00314 return texto.subrayado; 00315 } 00316 00317 bool Pagina::CentradoTexto(ATexto texto){ 00318 return texto.centrado; 00319 } 00320 00321 QColor Pagina::ColorTexto(ATexto texto){ 00322 return texto.color; 00323 } 00324 00325 void Pagina::LoadRutaPlantilla(QString ruta){ 00326 try{ 00327 pathPlantillapagina= new QString(ruta); 00328 }catch(std::exception& e){ 00329 Error *err= new Error(2, e.what(), this->parent); 00330 err->LanzarDialogo(); 00331 delete err; 00332 exit(1); 00333 } 00334 } 00335 00336 QString Pagina::RutaPlantilla(){ 00337 return *pathPlantillapagina; 00338 } 00339 00340 QList <QGraphicsItem*> Pagina::GetObjetosPagina(){ 00341 return this->objetosPagina; 00342 } 00343 00344 void Pagina::setObjetosPagina(QList <QGraphicsItem*> lista){ 00345 00346 this->objetosPagina=lista; 00347 } 00348 00349 00350 void Pagina::LimpiarListaObjetos(){ 00351 for(int eliminador=0; eliminador < this->objetosPagina.size(); eliminador++){ 00352 delete this->objetosPagina.at(eliminador); 00353 } 00354 this->objetosPagina.clear(); 00355 } 00356 00357 int Pagina::GetW(){ 00358 return this->w; 00359 } 00360 00361 int Pagina::GetH(){ 00362 return this->h; 00363 } 00364