QLCFixtureDef& QLCFixtureDef::operator=(const QLCFixtureDef& fixture) { if (this != &fixture) { QListIterator <QLCChannel*> chit(fixture.m_channels); QListIterator <QLCFixtureMode*> modeit(fixture.m_modes); m_manufacturer = fixture.m_manufacturer; m_model = fixture.m_model; m_type = fixture.m_type; m_author = fixture.m_author; /* Clear all channels */ while (m_channels.isEmpty() == false) delete m_channels.takeFirst(); /* Copy channels from the other fixture */ while (chit.hasNext() == true) m_channels.append(new QLCChannel(chit.next())); /* Clear all modes */ while (m_modes.isEmpty() == false) delete m_modes.takeFirst(); /* Copy modes from the other fixture */ while (modeit.hasNext() == true) m_modes.append(new QLCFixtureMode(this, modeit.next())); } return *this; }
QFile::FileError QLCFixtureDef::saveXML(const QString& fileName) { QFile::FileError error; if (fileName.isEmpty() == true) return QFile::OpenError; QFile file(fileName); if (file.open(QIODevice::WriteOnly) == false) return file.error(); QDomDocument doc(QLCFile::getXMLHeader(KXMLQLCFixtureDefDocument, author())); Q_ASSERT(doc.isNull() == false); /* Create a text stream for the file */ QTextStream stream(&file); stream.setAutoDetectUnicode(true); stream.setCodec("UTF-8"); /* Fixture tag */ QDomElement root = doc.documentElement(); QDomElement tag; QDomText text; /* Manufacturer */ tag = doc.createElement(KXMLQLCFixtureDefManufacturer); root.appendChild(tag); text = doc.createTextNode(m_manufacturer); tag.appendChild(text); /* Model */ tag = doc.createElement(KXMLQLCFixtureDefModel); root.appendChild(tag); text = doc.createTextNode(m_model); tag.appendChild(text); /* Type */ tag = doc.createElement(KXMLQLCFixtureDefType); root.appendChild(tag); text = doc.createTextNode(m_type); tag.appendChild(text); /* Channels */ QListIterator <QLCChannel*> chit(m_channels); while (chit.hasNext() == true) chit.next()->saveXML(&doc, &root); /* Modes */ QListIterator <QLCFixtureMode*> modeit(m_modes); while (modeit.hasNext() == true) modeit.next()->saveXML(&doc, &root); /* Write the document into the stream */ stream << doc.toString(); error = QFile::NoError; file.close(); return error; }
QFile::FileError QLCFixtureDef::saveXML(const QString& fileName) { QFile::FileError error; if (fileName.isEmpty() == true) return QFile::OpenError; QString tempFileName(fileName); tempFileName += ".temp"; QFile file(tempFileName); if (file.open(QIODevice::WriteOnly) == false) return file.error(); QXmlStreamWriter doc(&file); doc.setAutoFormatting(true); doc.setAutoFormattingIndent(1); doc.setCodec("UTF-8"); QLCFile::writeXMLHeader(&doc, KXMLQLCFixtureDefDocument, author()); doc.writeTextElement(KXMLQLCFixtureDefManufacturer, m_manufacturer); doc.writeTextElement(KXMLQLCFixtureDefModel, m_model); doc.writeTextElement(KXMLQLCFixtureDefType, m_type); /* Channels */ QListIterator <QLCChannel*> chit(m_channels); while (chit.hasNext() == true) chit.next()->saveXML(&doc); /* Modes */ QListIterator <QLCFixtureMode*> modeit(m_modes); while (modeit.hasNext() == true) modeit.next()->saveXML(&doc); /* End the document and close all the open elements */ error = QFile::NoError; doc.writeEndDocument(); file.close(); // Save to actual requested file name QFile currFile(fileName); if (currFile.exists() && !currFile.remove()) { qWarning() << "Could not erase" << fileName; return currFile.error(); } if (!file.rename(fileName)) { qWarning() << "Could not rename" << tempFileName << "to" << fileName; return file.error(); } return error; }
bool QLCFixtureDef::removeChannel(QLCChannel* channel) { /* First remove the channel from all modes */ QListIterator <QLCFixtureMode*> modeit(m_modes); while (modeit.hasNext() == true) modeit.next()->removeChannel(channel); /* Then remove the actual channel from this fixture definition */ QMutableListIterator <QLCChannel*> chit(m_channels); while (chit.hasNext() == true) { if (chit.next() == channel) { chit.remove(); delete channel; return true; } } return false; }
// Put a line of chat in all the right places void LLFloaterChat::addChat(const LLChat& chat, BOOL from_instant_message, BOOL local_agent) { LLColor4 text_color = get_text_color(chat, from_instant_message); BOOL invisible_script_debug_chat = chat.mChatType == CHAT_TYPE_DEBUG_MSG && !gSavedSettings.getBOOL("ScriptErrorsAsChat"); // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (rlv_handler_t::isEnabled()) { // TODO-RLVa: we might cast too broad a net by filtering here, needs testing if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!chat.mRlvLocFiltered) && (CHAT_SOURCE_AGENT != chat.mSourceType) ) { LLChat& rlvChat = const_cast<LLChat&>(chat); if (!from_instant_message) RlvUtil::filterLocation(rlvChat.mText); rlvChat.mRlvLocFiltered = TRUE; } if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!chat.mRlvNamesFiltered) ) { LLChat& rlvChat = const_cast<LLChat&>(chat); if ( (!from_instant_message) && (CHAT_SOURCE_AGENT != chat.mSourceType) ) { // Filter object and system chat (names are filtered elsewhere to save ourselves an gObjectList lookup) RlvUtil::filterNames(rlvChat.mText); } rlvChat.mRlvNamesFiltered = TRUE; } } // [/RLVa:KB] if (!invisible_script_debug_chat && !chat.mMuted && gConsole && !local_agent) { // We display anything if it's not an IM. If it's an IM, check pref... if ( !from_instant_message || gSavedSettings.getBOOL("IMInChatConsole") ) { // Replace registered urls in the console so it looks right. std::string chit(chat.mText), // Read through this chat; // Add parts to this LLUrlMatch match; while (!chit.empty() && LLUrlRegistry::instance().findUrl(chit, match)) { const auto start(match.getStart()), length(match.getEnd()+1-start); if (start > 0) chat += chit.substr(0, start); // Add up to the start of the match chat += match.getLabel() + match.getQuery(); // Add the label and the query chit.erase(0, start+length); // remove the url match and all before it } if (!chit.empty()) chat += chit; // Add any leftovers gConsole->addConsoleLine(chat, text_color); } } if(from_instant_message && gSavedPerAccountSettings.getBOOL("LogChatIM")) log_chat_text(chat); if(from_instant_message && gSavedSettings.getBOOL("IMInChatHistory")) addChatHistory(chat,false); triggerAlerts(chat.mText); if(!from_instant_message) addChatHistory(chat); }