KXmlCommand* KMSpecialManager::loadCommand(KMPrinter *pr) { KXmlCommand *xmlCmd = loadCommand(pr->option("kde-special-command")); if (xmlCmd && xmlCmd->driver()) xmlCmd->driver()->set("text", pr->printerName()); return xmlCmd; }
DrMain* KMSpecialManager::loadDriver(KMPrinter *pr) { KXmlCommand *xmlCmd; DrMain *driver(0); if ((xmlCmd=loadCommand(pr)) != 0) { driver = xmlCmd->takeDriver(); delete xmlCmd; } return driver; }
void KXmlCommandSelector::slotCommandSelected(int ID) { KXmlCommand *xmlCmd = KXmlCommandManager::self()->loadCommand(m_cmdlist[ID], true); if(xmlCmd) { QString msg; if(xmlCmd->isValid() && KdeprintChecker::check(xmlCmd->requirements())) { msg = QString::fromLocal8Bit("(ID = %1, %2 = ").arg(xmlCmd->name()).arg(i18n("output")); if(KXmlCommandManager::self()->checkCommand(xmlCmd->name(), KXmlCommandManager::None, KXmlCommandManager::Basic)) { if(xmlCmd->mimeType() == "all/all") msg.append(i18n("undefined")); else msg.append(xmlCmd->mimeType()); } else msg.append(i18n("not allowed")); msg.append(")"); emit commandValid(true); } else { msg = "<font color=\"red\">" + i18n("(Unavailable: requirements not satisfied)") + "</font>"; emit commandValid(false); } m_shortinfo->setText(msg); m_help = xmlCmd->comment(); m_helpbtn->setEnabled(!m_help.isEmpty()); } delete xmlCmd; }
QString KMSpecialManager::setupCommand(const QString& cmd, const QMap<QString,QString>& opts) { QString s(cmd); if (!s.isEmpty()) { KXmlCommand *xmlCmd = loadCommand(cmd); if (xmlCmd) { s = xmlCmd->buildCommand(opts, false, false); delete xmlCmd; } } return s; }
void KXmlCommandSelector::slotEditCommand() { QString xmlId = m_cmdlist[m_cmd->currentItem()]; KXmlCommand *xmlCmd = KXmlCommandManager::self()->loadCommand(xmlId); if(xmlCmd) { if(KXmlCommandDlg::editCommand(xmlCmd, this)) { // force to load the driver if not already done xmlCmd->driver(); KXmlCommandManager::self()->saveCommand(xmlCmd); } m_cmd->changeItem(xmlCmd->description(), m_cmd->currentItem()); delete xmlCmd; slotCommandSelected(m_cmd->currentItem()); } else KMessageBox::error(this, i18n("Internal error. The XML driver for the command %1 could not be found.").arg(xmlId)); }