void ContactBrowser::init( const QContact& contact, ContactDocument::ContactDocumentType docType) { mLink.clear(); if (!mDocument) mDocument = new ContactDocument(this); mDocument->textDocument()->setTextWidth(width() - 10); mDocument->init(this, contact, docType); setDocument(mDocument->textDocument()); loadLinks(contact.customField(QDL::CLIENT_DATA_KEY)); verifyLinks(); }
bool CLevel::loadGraal(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); bool v0 = (version == "GR-V1.00"); bool v1 = (version == "GR-V1.01"); bool v2 = (version == "GR-V1.02"); bool v3 = (version == "GR-V1.03"); //printf("Loading map %s\n", pFileName.text()); //printf("Loading tiles..\n"); loadTiles(levelData, version); //printf("Loading links..\n"); loadLinks(levelData); //printf("Loading baddies..\n"); loadBaddies(levelData); if (v0 || v1 || v2 || v3) { //printf("Loading npcs..\n"); loadNpcs(levelData); } if (v1 || v2 || v3) { //printf("Loading chests..\n"); loadChests(levelData); } //printf("Loading signs..\n"); loadSigns(levelData); //Find our map id for(int i = 0; i < CMap::mapList.count(); i++) { CMap* m = (CMap*)CMap::mapList[i]; if((levelIndex = m->getLevelpos(pFileName)) >= 0) { map = m; break; } } return true; }
bool CLevel::loadZelda(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); // Some clients will actually save .zelda levels as .graal. // If this is the case, parse it through the .graal loader. if (version.copy(0, 2) == "GR") return loadGraal(pFileName); bool v0 = (version == "unknown"); bool v1 = (version == "unknown"); bool v2 = (version == "unknown"); bool v3 = (version == "Z3-V1.03"); bool v4 = (version == "Z3-V1.04"); // If we encountered an unknown version, ask the user to send it in so we can add support for it. if (!v3 && !v4) { errorOut("errorlog.txt", CString() << "Level " << fileName << " is of version " << version << ". That version is unknown. Please send us the level so we may add support for it.", true); return false; } loadTiles(levelData, version); loadLinks(levelData); loadBaddies(levelData); loadSigns(levelData); //Find our map id for(int i = 0; i < CMap::mapList.count(); i++) { CMap* m = (CMap*)CMap::mapList[i]; if((levelIndex = m->getLevelpos(pFileName)) >= 0) { map = m; break; } } return true; }
LinkView::LinkView(QWidget * parent, const char * name, WFlags f): QScrollView(parent, name, f) { setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Sunken ); setBackgroundMode(Qt::PaletteBase); _blocked = FALSE; splitter = new QSplitter( Qt::Vertical, viewport() ); addChild(splitter); splitter->setMargin(5); splitter->setBackgroundMode(Qt::PaletteBase); splitter->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); splitter->setFrameShape( QFrame::NoFrame ); splitter->setChildrenCollapsible(TRUE); splitter->setHandleWidth( 3 ); splitter->setOpaqueResize(); hardware = new MediaListBox(splitter, "hardware"); splitter->setResizeMode( hardware, QSplitter::KeepSize ); hardware->setFrameShape( QFrame::NoFrame ); hardware->setHScrollBarMode(QScrollView::AlwaysOff); hardware->setVScrollBarMode(QScrollView::AlwaysOff); locations = new DnDListBox(splitter, "locations"); // splitter->setResizeMode( locations, QSplitter::KeepSize ); locations->setFrameShape( QFrame::NoFrame ); locations->setHScrollBarMode(QScrollView::AlwaysOff); locations->setVScrollBarMode(QScrollView::AlwaysOff); // custom area, locations loadLinks(); locations->setCurrentItem(0); locations->setSelected( locations->selectedItem(), false ); hardware->installEventFilter(this); connect (hardware, SIGNAL(highlighted( int )), this, SLOT(unselectLocations())); connect (locations, SIGNAL(highlighted( int )), this, SLOT(unselectHardware())); connect (hardware, SIGNAL(scrolled(int,int)), this, SLOT(scrollBy(int,int))); connect (locations, SIGNAL(scrolled(int,int)), this, SLOT(scrollBy(int,int))); connect (hardware, SIGNAL(itemNumberChanged(bool)), this, SLOT(adjustSplitter2Hardware(bool))); connect (locations, SIGNAL(itemNumberChanged(bool)), this, SLOT(adjustSplitter2Locations())); QTimer::singleShot(50, this, SLOT(adjustSplitter2Locations())); QTimer::singleShot(60, this, SLOT(postInstallEventFilter())); }
bool CLevel::loadGraal(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); bool v0 = (version == "GR-V1.00"); bool v1 = (version == "GR-V1.01"); bool v2 = (version == "GR-V1.02"); bool v3 = (version == "GR-V1.03"); //printf("Loading map %s\n", pFileName.text()); //printf("Loading tiles..\n"); loadTiles(levelData, version); //printf("Loading links..\n"); loadLinks(levelData); //printf("Loading baddies..\n"); loadBaddies(levelData); if (v0 || v1 || v2 || v3) { //printf("Loading npcs..\n"); loadNpcs(levelData); } if (v1 || v2 || v3) { //printf("Loading chests..\n"); loadChests(levelData); } //printf("Loading signs..\n"); loadSigns(levelData); return true; }
void BSClient::replyLinksFinished() { qDebug() << "BSClient::replyLinksFinished()"; QByteArray byteArray = m_reply->readAll(); if(isCaptcha(byteArray)) { loadLinks(m_episodeId); return; } QJsonDocument document = QJsonDocument::fromJson(byteArray); if(!document.isObject()) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x0025")); return; } QJsonObject object = document.object(); if(!object.contains("links")) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x0026")); return; } QJsonValue value = object.value("links"); if(!value.isArray()) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x0027")); return; } QList<QPair<QString, QString> > links; Q_FOREACH(const QJsonValue &value_, value.toArray()) { if(!value_.isObject()) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x0028")); return; } QJsonObject object_ = value_.toObject(); if(!object_.contains("hoster")) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x0029")); return; } QJsonValue hosterValue = object_.value("hoster"); if(!hosterValue.isString()) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x002A")); return; } if(!object_.contains("id")) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x002B")); return; } QJsonValue idValue = object_.value("id"); if(!hosterValue.isString()) { Q_EMIT error(tr("JSON-Parse-Fehler: 0x002C")); return; } links << qMakePair(hosterValue.toString(), idValue.toString()); } Q_EMIT loadLinksFinished(links); }
//int CMapFileFilterXML::loadXMLData(QString filename) int CMapFileFilterXML::loadXMLData(const QByteArray & buffer) { // TODO_jp : Make sure Zone ID and level ID max value is set corretly QDomDocument doc ("map"); if (!doc.setContent( buffer)) { kDebug() << "Unable to open the map file, not a valid xml document"; // file.close(); return -1; } for (CMapPluginBase *plugin = m_mapManager->getPluginList()->first(); plugin!=0; plugin = m_mapManager->getPluginList()->next()) { plugin->loadAboutToStart(); } QDomElement docElem = doc.documentElement(); // Check that this version of the file can be loaded QDomElement e = readChildElement(&docElem,"Version"); if (!e.isNull()) { QString major = e.attribute("Major",""); QString minor = e.attribute("Minor",""); if (major != "1" || minor != "0") { //TODO_jp : Output error message kDebug() << "This version can't be loaded"; return -4; } } else { //TODO_jp : Output error message kDebug() << "Unable to find version"; return -2; } // Find Root Zone QDomElement rootZoneNode = readChildElement(&docElem,"Zone"); if (rootZoneNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find root zone"; return -2; } // Load Root Zone int errorZone =loadZone(&rootZoneNode,NULL); if (errorZone!=0) { return errorZone; } // Find Paths QDomElement pathsNode = readChildElement(&docElem,"Paths"); if (pathsNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find paths"; return -2; } // Load Paths int errorPath = loadPaths(&pathsNode); if (errorPath!=0) { return errorPath; } // Find Links QDomElement linksNode = readChildElement(&docElem,"Links"); if (pathsNode.isNull()) { //TODO_jp : Output error message kDebug() << "Unable to find links"; return -2; } int errorLinks = loadLinks(&linksNode); if (errorLinks!=0) { return errorLinks; } // Return no error return 0; }