/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include #include "smglobals.h" #include "archivemodel.h" #include "mappingtablemodel.h" #include "mappingtreemodel.h" #include "pictureviewer2.h" #include "picfilesmodel.h" #include "configurationdialog.h" #include "archivecontroller.h" #include "archivebrowsermodel.h" #include #include SmGlobals *SmGlobals::mInstance = 0; SmGlobals::~SmGlobals(){ foreach(QAbstractItemModel *model, mModels.values()){ model->deleteLater(); } } SmGlobals *SmGlobals::instance(){ if(!mInstance){ mInstance = new SmGlobals; if(!QSqlDatabase::contains("treedb")){ QSettings s; QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL", "treedb"); db.setHostName(s.value("database/hostname").toString()); db.setUserName(s.value("database/dbuser").toString()); db.setPassword(s.value("database/dbpass").toString()); db.setDatabaseName(s.value("database/dbname").toString()); if(!db.open()){ QMessageBox::critical(0, tr("Error"), tr("Could not open database.")); ConfigurationDialog configDlg; configDlg.exec(); QMessageBox::information(0, tr("Notice"), tr("I will exit now. Start me again!")); exit(EXIT_SUCCESS); } } } return mInstance; } QAbstractItemModel *SmGlobals::model(const QString &which){ if(which == "actors"){ if(!mModels.contains(which)){ QStringList headers = QStringList() << tr("Actor") << tr("Id"); MappingTableModel *model = new MappingTableModel(headers, "actors"); mModels.insert(which, model); } }else if(which == "genres"){ if(!mModels.contains(which)){ QStringList headers = QStringList() << tr("Genre") << tr("Id"); MappingTableModel *model = new MappingTableModel(headers, "genres"); mModels.insert(which, model); } }else if(which == "MappingTree"){ if(!mModels.contains("MappingTree")){ QStringList headers = QStringList() << tr("Name") << tr("Id") << tr("Date") << tr("Parent") << tr("PPID"); MappingTreeModel *model = new MappingTreeModel(headers); mModels.insert(which, model); } }else if(which == "PicFiles"){ if(!mModels.contains("PicFiles")){ QStringList headers = QStringList() << tr("Filename") << tr("Size") << tr("Format") << tr("Full Path") << tr("Id") << tr("Added") << tr("Md5Sum") << tr("Pic. Size"); PicFilesModel *model = new PicFilesModel(headers); mModels.insert(which, model); } }else if(which == "ArchiveModel"){ if(!mModels.contains("ArchiveModel")){ QStringList headers = QStringList() << tr("Series") << tr("Series ID") << tr("Series part ID") << tr("Part") << tr("Type") << tr("Favorite") << tr("Subtitle") << tr("Count"); ArchiveModel *model = new ArchiveModel(headers); mModels.insert(which, model); } }else if(which == "BrowserModel"){ if(!mModels.contains("BrowserModel")){ QStringList headers = QStringList() << QChar(0x26A7) << tr("Name") << tr("Generic Id") << tr("Node Type") << tr("Size") << tr("Quality") << tr("File Type") << tr("Full Path") << tr("Selected"); ArchiveBrowserModel *model = new ArchiveBrowserModel(headers); mModels.insert(which, model); } } return mModels.contains(which) ? mModels.value(which) : 0; } PictureViewer2 *SmGlobals::pictureViewer() { if(!mPictureViewer){ mPictureViewer = new PictureViewer2; } return mPictureViewer; } QSize SmGlobals::cursorSize() { if(!mCursorSize.isValid()){ Display *dpy = XOpenDisplay(0); XFixesCursorImage *curImage = XFixesGetCursorImage(dpy); mCursorSize = QSize(curImage->width, curImage->height); XFree(curImage); } return mCursorSize; } QIcon SmGlobals::iconFor(const QString &type){ QString settingsS = QString("ui/%1icon").arg(type); QSettings s; QString iconS = s.value(settingsS, "Dildo").toString(); QIcon retval = QIcon(mIcons.value(iconS)); return retval; } SmGlobals::SmGlobals() : mPictureViewer(0), mArchiveController(0){ mIcons.insert("Dildo", ":/dildo.png"); mIcons.insert("Dick to left", ":/back_dick.png"); mIcons.insert("Dick pointing up", ":/up_dick.png"); mIcons.insert("Chastity belt", ":/chastity_belt.png"); mIcons.insert("Clitoris", ":/clitoris.png"); mIcons.insert("Gaping ass", ":/gaping_ass.png"); mIcons.insert("Nipple pointing up", ":/nipple_up.png"); mIcons.insert("Bald pussy", ":/bald_pussy.png"); mIcons.insert("Prince Albert", ":/prince_albert.png"); mIcons.insert("Diaper", ":/diaper.png"); mIcons.insert("High heels", ":/higheels.png"); mIcons.insert("Ball gag", ":/ball_gag.png"); mIcons.insert("French Maid Dress", ":/french_maid_dress.png"); mIcons.insert("Shackles", ":/shackles.png"); mIcons.insert("Steel collar", ":/steel_collar.png"); mIcons.insert("Butt plug", ":/butt_plug.png"); mIcons.insert("Hourglass figure", ":/hourglass_figure.png"); mIcons.insert("Big ass", ":/big_ass.png"); mIcons.insert("Big tit", ":/big_tit.png"); mIcons.insert("Bizarre amputee", ":/bizarre_amputee.png"); mIcons.insert("Spreading pants", ":/spreadingpants.png"); mIcons.insert("Leather dog hood", ":/dog_hood.png"); mIcons.insert("Male chastity belt", ":/male_chastity_belt.png"); mIcons.insert("Anal stretcher", ":/analstretcher.png"); mIcons.insert("Big balls", ":/big_balls.png"); mIcons.insert("Big pierced balls", ":/huge_balls_pierced.png"); mIcons.insert("Huge bra", ":/huge_bra.png"); mIcons.insert("Squirting nipple", ":/squirting_nipple.png"); mIcons.insert("Dick in a cage", ":/dick_in_cage.png"); mIcons.insert("Used tampon", ":/used_tampon.png"); mIcons.insert("Clean tampon", ":/clean_tampon.png"); mFiletypeMap.insert(FT_MOVIE, tr("Movie")); mFiletypeMap.insert(FT_FRONTCOVER, tr("Front Cover")); mFiletypeMap.insert(FT_BACKCOVER, tr("Back Cover")); mFiletypeMap.insert(FT_GENERALCOVER, tr("General Cover")); mFiletypeMap.insert(FT_ORIGIN, tr("Origin")); QSettings s; mReencReasons = s.value("ui/reasons").toStringList(); } void SmGlobals::registerWidget(const QString &name, QWidget *w){ mWidgets.insert(name, w); } void SmGlobals::setReencReasons(const QStringList reasons){ mReencReasons = reasons; qSort(mReencReasons); QSettings s; s.setValue("ui/reasons", mReencReasons); }