Ejemplo n.º 1
0
void KMLpdManager::loadPrintcapFile(const QString& filename)
{
	QFile	f(filename);
	if (f.exists() && f.open(IO_ReadOnly))
	{
		QTextStream	t(&f);
		QString		line, comment;
		PrintcapEntry	*entry;
		while (!t.eof())
		{
			line = getPrintcapLine(t,&comment);
			if (line.isEmpty())
				continue;
			entry = new PrintcapEntry;
			if (entry->readLine(line))
			{
				m_entries.insert(entry->m_name,entry);
				entry->m_comment = comment;
			}
			else
			{
				delete entry;
				break;
			}
		}
	}
}
Ejemplo n.º 2
0
QMap<QString,QString> KMLpdManager::loadPrinttoolCfgFile(const QString& filename)
{
	QFile	f(filename);
	QMap<QString,QString>	map;
	if (f.exists() && f.open(IO_ReadOnly))
	{
		QTextStream	t(&f);
		QString		line, name, val;
		int 		p(-1);
		while (!t.eof())
		{
			line = getPrintcapLine(t);
			if (line.isEmpty())
				break;
			if (line.startsWith("export "))
				line.replace(0,7,"");
			if ((p=line.find('=')) != -1)
			{
				name = line.left(p);
				val = line.right(line.length()-p-1);
				val.replace("\"","");
				val.replace("'","");
				if (!name.isEmpty() && !val.isEmpty())
					map[name] = val;
			}
		}
	}
	return map;
}
Ejemplo n.º 3
0
bool PrinttoolEntry::readEntry(QTextStream &t)
{
    QString line;
    QStringList args;

    m_resolutions.setAutoDelete(true);
    m_depths.setAutoDelete(true);
    m_resolutions.clear();
    m_depths.clear();
    while(!t.eof())
    {
        line = getPrintcapLine(t);
        if(line.isEmpty())
            break;
        if(line == "EndEntry")
            return !m_name.isEmpty();
        QStringList l = splitPrinttoolLine(line);
        if(l.count() > 1)
        {
            if(l[0] == "StartEntry")
                m_name = l[1];
            else if(l[0] == "GSDriver")
                m_gsdriver = l[1];
            else if(l[0] == "About")
                m_about = l[1];
            else if(l[0] == "Description")
                m_description = l[1];
            else if(l[0] == "Resolution" && l.count() > 2)
            {
                Resolution *resol = new Resolution;
                bool ok(false);
                resol->xdpi = l[1].toInt(&ok);
                if(ok)
                    resol->ydpi = l[2].toInt(&ok);
                if(l.count() > 3)
                    resol->comment = l[3];
                if(ok)
                    m_resolutions.append(resol);
                else
                    delete resol;
            }
            else if(l[0] == "BitsPerPixel" && l.count() > 1)
            {
                BitsPerPixel *dpth = new BitsPerPixel;
                dpth->bpp = l[1];
                if(l.count() > 2)
                    dpth->comment = l[2];
                m_depths.append(dpth);
            }
        }
    }
    return false;
}