本文整理汇总了C++中KMPrinter类的典型用法代码示例。如果您正苦于以下问题:C++ KMPrinter类的具体用法?C++ KMPrinter怎么用?C++ KMPrinter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KMPrinter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotTest
void KMInstancePage::slotTest()
{
KMTimer::self()->hold();
QString src = m_view->currentText();
if(!src.isEmpty())
{
if(src == i18n("(Default)"))
src = QString::null;
KMPrinter *mpr = KMFactory::self()->virtualManager()->findInstance(m_printer, src);
if(!mpr)
KMessageBox::error(this, i18n("Internal error: printer not found."));
else if(KMessageBox::warningContinueCancel(this,
i18n("You are about to print a test page on %1. Do you want to continue?").arg(mpr->printerName()),
QString::null, i18n("Print Test Page"), "printTestPage")
== KMessageBox::Continue)
{
if(!KMFactory::self()->virtualManager()->testInstance(mpr))
KMessageBox::error(this, i18n("Unable to send test page to %1.").arg(mpr->printerName()));
else
KMessageBox::information(this, i18n("Test page successfully sent to printer %1.").arg(mpr->printerName()));
}
}
KMTimer::self()->release(false);
}
示例2: slotMove
void KMJobViewer::slotMove(int prID)
{
if (prID >= 0 && prID < (int)(m_printers.count()))
{
KMPrinter *p = m_printers.at(prID);
send(KMJob::Move,i18n("Move to %1").arg(p->printerName()),p->printerName());
}
}
示例3: createPrinter
KMPrinter* LprHandler::createPrinter(PrintcapEntry *entry)
{
KMPrinter *prt = new KMPrinter;
prt->setPrinterName(entry->name);
prt->setName(entry->name);
prt->setType(KMPrinter::Printer);
return prt;
}
示例4: printer
void KPrintAction::slotActivated(int ID)
{
KPrinter printer(false);
KMPrinter *mprt = KMManager::self()->findPrinter(d->printers[ID]);
if (mprt && mprt->autoConfigure(&printer, d->parentWidget))
{
// emit the signal
emit print(&printer);
}
}
示例5: listJobs
bool KMCupsJobManager::listJobs(const QString& prname, KMJobManager::JobType type, int limit)
{
IppRequest req;
QStringList keys;
CupsInfos *infos = CupsInfos::self();
// wanted attributes
keys.append("job-id");
keys.append("job-uri");
keys.append("job-name");
keys.append("job-state");
keys.append("job-printer-uri");
keys.append("job-k-octets");
keys.append("job-originating-user-name");
keys.append("job-k-octets-completed");
keys.append("job-media-sheets");
keys.append("job-media-sheets-completed");
keys.append("job-priority");
keys.append("job-billing");
req.setOperation(IPP_GET_JOBS);
// add printer-uri
KMPrinter *mp = KMManager::self()->findPrinter(prname);
if (!mp)
return false;
if (!mp->uri().isEmpty())
{
req.addURI(IPP_TAG_OPERATION, "printer-uri", mp->uri().prettyURL());
/*
req.setHost(mp->uri().host());
req.setPort(mp->uri().port());
*/
}
else
req.addURI(IPP_TAG_OPERATION, "printer-uri", QString("ipp://%1/%2/%3").arg(infos->hostaddr(),
(mp&&mp->isClass())?"classes":"printers", prname));
// other attributes
req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys);
if (type == KMJobManager::CompletedJobs)
req.addKeyword(IPP_TAG_OPERATION,"which-jobs",QString::fromLatin1("completed"));
if (limit > 0)
req.addInteger(IPP_TAG_OPERATION,"limit",limit);
// send request
if (req.doRequest("/"))
parseListAnswer(req, mp);
else
return false;
return true;
}
示例6: loadPrinters
void KMJobViewer::addToManager()
{
if (m_prname == i18n("All Printers"))
{
loadPrinters();
QPtrListIterator<KMPrinter> it(m_printers);
for (; it.current(); ++it)
m_manager->addPrinter(it.current()->printerName(), (KMJobManager::JobType)m_type, it.current()->isSpecial());
}
else if (!m_prname.isEmpty())
{
KMPrinter *prt = KMManager::self()->findPrinter( m_prname );
bool isSpecial = ( prt ? prt->isSpecial() : false );
m_manager->addPrinter(m_prname, (KMJobManager::JobType)m_type, isSpecial);
}
}
示例7: f
// "/etc/printcap" file parsing (Linux/LPR)
void KMLpdUnixManager::parseEtcPrintcap()
{
QFile f(getPrintcapFileName());
if (f.exists() && f.open(IO_ReadOnly))
{
KTextBuffer t(&f);
QMap<QString,QString> entry;
while (!t.eof())
{
entry = readEntry(t);
if (entry.isEmpty() || !entry.contains("printer-name") || entry.contains("server"))
continue;
if (entry["printer-name"] == "all")
{
if (entry.contains("all"))
{
// find separator
int p = entry["all"].find(QRegExp("[^a-zA-Z0-9_\\s-]"));
if (p != -1)
{
QChar c = entry["all"][p];
QStringList prs = QStringList::split(c,entry["all"],false);
for (QStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it)
{
KMPrinter *printer = ::createPrinter(*it);
printer->setDescription(i18n("Description unavailable"));
addPrinter(printer);
}
}
}
}
else
{
KMPrinter *printer = ::createPrinter(entry);
if (entry.contains("rm"))
printer->setDescription(i18n("Remote printer queue on %1").arg(entry["rm"]));
else
printer->setDescription(i18n("Local printer"));
addPrinter(printer);
}
}
}
}
示例8: setInitialized
void PrintMenu::initialize()
{
if (initialized()) clear();
setInitialized(true);
int ID = PRINTER_LIST_ID;
// just to be sure the plugin is loaded -> icons are available
KMManager::self();
if ((KMManager::self()->printerOperationMask() & KMManager::PrinterCreation) && KMManager::self()->hasManagement())
insertItem(KIcon("wizard"), i18n("Add Printer..."), ADD_PRINTER_ID);
insertItem(KIcon("kdeprint-configmgr"), i18n("KDE Print Settings"), KDEPRINT_SETTINGS_ID);
if (KMManager::self()->serverOperationMask() & KMManager::ServerConfigure)
insertItem(KIcon("kdeprint-configsrv"), i18n("Configure Server"), CONFIG_SERVER_ID);
addSeparator();
insertItem(KIcon("kcontrol"), i18n("Print Manager"), PRINT_MANAGER_ID);
insertItem(KIcon("konqueror"), i18n("Print Browser (Konqueror)"), PRINT_BROWSER_ID);
addSeparator();
insertItem(KIcon("document-print"), i18n("Print File..."), KPRINTER_ID);
// printer list
QList<KMPrinter*> l = KMManager::self()->printerList();
if (!l.isEmpty())
{
bool separatorInserted = false;
QListIterator<KMPrinter*> it(l);
while (it.hasNext())
{
KMPrinter *itprt = it.next();
// no special, implicit or pure instances
if (itprt->isSpecial() || itprt->isVirtual())
continue;
if (!separatorInserted)
{
// we insert a separator only when we find the first
// printer
addSeparator();
separatorInserted = true;
}
insertItem(KIcon(itprt->pixmap()),
itprt->printerName(), ID++);
}
}
}
示例9: pixname
void KMJobViewer::updateCaption()
{
if (!m_standalone)
return;
QString pixname("fileprint");
if (!m_prname.isEmpty())
{
setCaption(i18n("Print Jobs for %1").arg(m_prname));
KMPrinter *prt = KMManager::self()->findPrinter(m_prname);
if (prt)
pixname = prt->pixmap();
}
else
{
setCaption(i18n("No Printer"));
}
KWin::setIcons(winId(), DesktopIcon(pixname), SmallIcon(pixname));
}
示例10: needRefresh
void KMMainView::slotConfigure()
{
if(m_current)
{
KMTimer::self()->hold();
bool needRefresh(false);
if(m_current->isSpecial())
{
KMSpecialPrinterDlg dlg(this);
dlg.setPrinter(m_current);
if(dlg.exec())
{
KMPrinter *prt = dlg.printer();
if(prt->name() != m_current->name())
m_manager->removeSpecialPrinter(m_current);
m_manager->createSpecialPrinter(prt);
needRefresh = true;
}
}
else
{
DrMain *driver = m_manager->loadPrinterDriver(m_current, true);
if(driver)
{
KMDriverDialog dlg(this);
dlg.setCaption(i18n("Configure %1").arg(m_current->printerName()));
dlg.setDriver(driver);
// disable OK button for remote printer (read-only dialog)
if(m_current->isRemote())
dlg.enableButtonOK(false);
if(dlg.exec())
if(!m_manager->savePrinterDriver(m_current, driver))
showErrorMsg(i18n("Unable to modify settings of printer %1.").arg(m_current->printerName()));
delete driver;
}
else
showErrorMsg(i18n("Unable to load a valid driver for printer %1.").arg(m_current->printerName()));
}
KMTimer::self()->release(needRefresh);
}
}
示例11: setupCommand
bool KRlprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer)
{
// retrieve the KMPrinter object, to get host and queue name
KMPrinter *rpr = KMFactory::self()->manager()->findPrinter(printer->printerName());
if (!rpr)
return false;
QString host(rpr->option("host")), queue(rpr->option("queue"));
if (!host.isEmpty() && !queue.isEmpty())
{
QString exestr = TDEStandardDirs::findExe("rlpr");
if (exestr.isEmpty())
{
printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr"));
return false;
}
cmd = TQString::fromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies());
// proxy settings
TDEConfig *conf = KMFactory::self()->printConfig();
conf->setGroup("RLPR");
QString host = conf->readEntry("ProxyHost",TQString::null), port = conf->readEntry("ProxyPort",TQString::null);
if (!host.isEmpty())
{
cmd.append(" -X ").append(quote(host));
if (!port.isEmpty()) cmd.append(" --port=").append(port);
}
return true;
}
else
{
printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it."));
return false;
}
}
示例12: slotPrinterSelected
void KMMainView::slotPrinterSelected(const TQString& prname)
{
KMPrinter *p = KMManager::self()->findPrinter(prname);
m_current = p;
if (p && !p->isSpecial())
KMFactory::self()->manager()->completePrinter(p);
m_printerpages->setPrinter(p);
// update actions state (only if toolbar enabled, workaround for toolbar
// problem).
//if (m_toolbar->isEnabled())
//{
int mask = (m_manager->hasManagement() ? m_manager->printerOperationMask() : 0);
bool sp = !(p && p->isSpecial());
// m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && p->isLocal() && !p->isImplicit()));
m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && !p->isImplicit()));
m_actions->action("printer_configure")->setEnabled(!sp || ((mask & KMManager::PrinterConfigure) && p && !p->isClass(true) /*&& p->isLocal()*/));
m_actions->action("printer_hard_default")->setEnabled((sp && (mask & KMManager::PrinterDefault) && p && !p->isClass(true) && !p->isHardDefault() && p->isLocal()));
m_actions->action("printer_soft_default")->setEnabled((p && !p->isSoftDefault()));
m_actions->action("printer_test")->setEnabled((sp && (mask & KMManager::PrinterTesting) && p && !p->isClass(true)));
bool stmask = (sp && (mask & KMManager::PrinterEnabling) && p);
m_actions->action("printer_state_change")->setEnabled(stmask && p->isLocal());
m_actions->action("printer_spool_change")->setEnabled(stmask);
m_actions->action("printer_start")->setEnabled((stmask && p->state() == KMPrinter::Stopped));
m_actions->action("printer_stop")->setEnabled((stmask && p->state() != KMPrinter::Stopped));
m_actions->action("printer_enable")->setEnabled((stmask && !p->acceptJobs()));
m_actions->action("printer_disable")->setEnabled((stmask && p->acceptJobs()));
m_actions->action("printer_add")->setEnabled((mask & KMManager::PrinterCreation));
mask = m_manager->serverOperationMask();
m_actions->action("server_restart")->setEnabled((mask & KMManager::ServerRestarting));
m_actions->action("server_configure")->setEnabled((mask & KMManager::ServerConfigure));
KMFactory::self()->manager()->validatePluginActions(m_actions, p);
//}
m_actions->action("printer_tool")->setEnabled(p && !p->isClass(true) && !p->isRemote() && !p->isSpecial());
}
示例13: KMPrinter
KMPrinter *PrintcapEntry::createPrinter()
{
KMPrinter *printer = new KMPrinter();
printer->setName(m_name);
printer->setPrinterName(m_name);
printer->setInstanceName(QString::null);
printer->setState(KMPrinter::Idle);
printer->setType(KMPrinter::Printer);
return printer;
}
示例14: d
// "/etc/lp/printers/" directory parsing (Solaris non-2.6)
void KMLpdUnixManager::parseEtcLpPrinters()
{
QDir d("/etc/lp/printers");
const QFileInfoList *prlist = d.entryInfoList(QDir::Dirs);
if (!prlist)
return;
QFileInfoListIterator it(*prlist);
for (;it.current();++it)
{
if (it.current()->fileName() == "." || it.current()->fileName() == "..")
continue;
QFile f(it.current()->absFilePath() + "/configuration");
if (f.exists() && f.open(IO_ReadOnly))
{
KTextBuffer t(&f);
QString line, remote;
while (!t.eof())
{
line = readLine(t);
if (line.isEmpty()) continue;
if (line.startsWith("Remote:"))
{
QStringList l = QStringList::split(':',line,false);
if (l.count() > 1) remote = l[1];
}
}
KMPrinter *printer = new KMPrinter;
printer->setName(it.current()->fileName());
printer->setPrinterName(it.current()->fileName());
printer->setType(KMPrinter::Printer);
printer->setState(KMPrinter::Idle);
if (!remote.isEmpty())
printer->setDescription(i18n("Remote printer queue on %1").arg(remote));
else
printer->setDescription(i18n("Local printer"));
addPrinter(printer);
}
}
}
示例15: slotSettings
void KMInstancePage::slotSettings()
{
KMTimer::self()->hold();
QString src = m_view->currentText();
if(!src.isEmpty())
{
if(src == i18n("(Default)"))
src = QString::null;
KMPrinter *pr = KMFactory::self()->virtualManager()->findInstance(m_printer, src);
if(!pr)
KMessageBox::error(this, i18n("Unable to find instance %1.").arg(m_view->currentText()));
else if(!pr->isSpecial() && !KMFactory::self()->manager()->completePrinterShort(pr))
KMessageBox::error(
this,
i18n("Unable to retrieve printer information. Message from printing system: %1.").arg(KMFactory::self()->manager()->errorMsg()));
else
{
int oldAppType = KMFactory::self()->settings()->application;
KMFactory::self()->settings()->application = -1;
KPrinterPropertyDialog::setupPrinter(pr, this);
KMFactory::self()->settings()->application = oldAppType;
if(pr->isEdited())
{ // printer edited, need to save changes
pr->setDefaultOptions(pr->editedOptions());
pr->setEditedOptions(QMap< QString, QString >());
pr->setEdited(false);
KMFactory::self()->virtualManager()->triggerSave();
}
}
}
else
KMessageBox::error(this, i18n("The instance name is empty. Please select an instance."));
KMTimer::self()->release();
}