Пример #1
0
bool CMakeCondition::evaluateCondition(QStringList::const_iterator itBegin, QStringList::const_iterator itEnd) const
{
    if(itBegin==itEnd)
    {
        return isTrue(*itBegin);
    }
    
    bool last = false, done=false;
    last = isTrue(*(prevOperator(itEnd, itBegin)+1));
    while(!done && itBegin!=itEnd)
    {
        QStringList::const_iterator it2;
        it2 = prevOperator(itEnd, itBegin);
        
        done=(itBegin==it2);
        conditionToken c = typeName(*it2);

//         qDebug() << "operator" << *it2 << done;
        QString cmd;
        
        switch(c)
        {
            case NOT:
                last = !last;
                itEnd=it2;
                break;
            case COMMAND:
#ifdef Q_OS_WIN
                cmd = CMakeProjectVisitor::findFile(*(it2+1),
                        CMakeProjectVisitor::envVarDirectories("Path"), QStringList(), CMakeProjectVisitor::Executable);
#else
                cmd = CMakeProjectVisitor::findFile(*(it2+1),
                        CMakeProjectVisitor::envVarDirectories("PATH"), QStringList(), CMakeProjectVisitor::Executable);
#endif
                last = !cmd.isEmpty();
                itEnd=it2-1;
                break;
            case EXISTS:
            {
                QString v=*(it2+1);
//                 kDebug(9042) << "EXISTS" << v << *it2;
                if(v.isEmpty())
                    kDebug(9042) << "error: no";
                else
                {
                    last=false;
                    QFileInfo f(v);
                    if(f.exists())
                    {
                        last=true;
                    }
                }
                itEnd=it2;
            }   break;
            case IS_DIRECTORY: {
                QFileInfo f(*(it2+1));
                last = f.isDir();
                itEnd=it2;
            }   break;
            case DEFINED:
                last=m_vars->contains(*(it2+1));
                itEnd=it2;
                break;
            case AND:
                return evaluateCondition(itBegin, it2-1) && last;
            case OR:
                return evaluateCondition(itBegin, it2-1) || last;
            case MATCHES: {
                QRegExp rx(*(it2+1));
                if(m_vars->contains(*(it2-1)))
                    rx.indexIn(m_vars->value(*(it2-1)).join(""));
                else
                    rx.indexIn(*(it2-1));
                last=rx.matchedLength()>0;
                itEnd=it2-1;
            }   break;
            case LESS: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a<b);
                itEnd=it2-1;
            }   break;
            case GREATER: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a>b);
                itEnd=it2-1;
            }   break;
            case EQUAL: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a==b);
                itEnd=it2-1;
            }   break;
            case STRLESS: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA<strB);
                itEnd=it2-1;
            }   break;
            case STRGREATER: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA>strB);
                itEnd=it2-1;
            }   break;
            case STREQUAL: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA==strB);
                itEnd=it2-1;
            }   break;
            case IS_NEWER_THAN: {
                QFileInfo pathA(*(it2-1));
                QFileInfo pathB(*(it2+1));
//                 kDebug(9042) << "newer" << strA << strB;
                last= (pathA.lastModified()>pathB.lastModified());
                itEnd=it2-1;
            }
            /*default:
                kDebug(9042) << "no operator:" << *it2;
                break;*/
        }
    }
    return last;
}
Пример #2
0
	void walletReceived( KWallet::Wallet *wallet )
	{
		kDebug( 14010 ) ;
		mWallet = wallet;
		processRequest();
	}
Пример #3
0
KonqOperations *KonqOperations::doDrop( const KFileItem & destItem, const KUrl & dest, QDropEvent * ev, QWidget * parent,
                                        const QList<QAction*> & userActions  )
{
    kDebug(1203) << "dest:" << dest;
    QMap<QString, QString> metaData;
    // Prefer local urls if possible, to avoid problems with desktop:/ urls from other users (#184403)
    const KUrl::List lst = KUrl::List::fromMimeData(ev->mimeData(), &metaData, KUrl::List::PreferLocalUrls);
    if (!lst.isEmpty()) { // Are they urls ?
        //kDebug(1203) << "metaData:" << metaData.count() << "entries.";
        //QMap<QString,QString>::ConstIterator mit;
        //for( mit = metaData.begin(); mit != metaData.end(); ++mit ) {
        //    kDebug(1203) << "metaData: key=" << mit.key() << "value=" << mit.value();
        //}
        // Check if we dropped something on itself
        KUrl::List::ConstIterator it = lst.begin();
        for (; it != lst.end() ; it++) {
            kDebug(1203) << "URL:" << (*it);
            if (dest.equals(*it, KUrl::CompareWithoutTrailingSlash)) {
                // The event source may be the view or an item (icon)
                // Note: ev->source() can be 0L! (in case of kdesktop) (Simon)
                if ( !ev->source() || ( ev->source() != parent && ev->source()->parent() != parent ) )
                    KMessageBox::sorry( parent, i18n("You cannot drop a folder on to itself") );
                kDebug(1203) << "Dropped on itself";
                ev->setAccepted( false );
                return 0; // do nothing instead of displaying kfm's annoying error box
            }
        }

        // Check the state of the modifiers key at the time of the drop
        Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();

        Qt::DropAction action = ev->dropAction();
        // Check for the drop of a bookmark -> we want a Link action
        if ( ev->mimeData()->hasFormat( QLatin1String("application/x-xbel")) )
        {
            modifiers |= Qt::ControlModifier | Qt::ShiftModifier;
            action = Qt::LinkAction;
            kDebug(1203) << "Bookmark -> emulating Link";
        }

        KonqOperations * op = new KonqOperations(parent);
        op->setDropInfo( new DropInfo( modifiers, lst, metaData, QCursor::pos(), action, userActions ) );

        // Ok, now we need destItem.
        if ( !destItem.isNull() )
        {
            // We have it already, we could just call asyncDrop.
            // But popping up a menu in the middle of a DND operation confuses and crashes Qt (#157630)
            // So let's delay it.
            qRegisterMetaType<KFileItem>("KFileItem");
            QMetaObject::invokeMethod(op, "asyncDrop", Qt::QueuedConnection, Q_ARG(KFileItem, destItem));
        }
        else
        {
            // we need to stat to get it.
            op->_statUrl( dest, op, SLOT(asyncDrop(KFileItem)) );
        }
        // In both cases asyncDrop will delete op when done

        ev->acceptProposedAction();
        return op;
    }
    else
    {
        //kDebug(1203) << "Pasting to " << dest.url();
        KonqOperations * op = new KonqOperations(parent);
        KIO::Job* job = KIO::pasteMimeData(ev->mimeData(), dest,
                                           i18n( "File name for dropped contents:" ),
                                           parent);
        if (KIO::SimpleJob* simpleJob = qobject_cast<KIO::SimpleJob *>(job)) {
            op->setOperation(job, PUT, simpleJob->url());
            KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Put, KUrl::List(), simpleJob->url(), simpleJob);
        }
        ev->acceptProposedAction();
        return op;
    }
}
Пример #4
0
void SkypeConnection::connectSkype(const QString &start, const QString &appName, int protocolVer, int bus, int launchTimeout, int waitBeforeConnect, const QString &name, const QString &pass) {
	kDebug(SKYPE_DEBUG_GLOBAL);

	if (d->fase != cfNotConnected)
		return;

	d->appName = appName;
	d->protocolVer = protocolVer;
	d->bus = bus;

        new ClientAdaptor(this);
	QDBusConnection busConn = BUS;
	bool registred = busConn.registerObject("/com/Skype/Client", this); //Register skype client to dbus for receiving messages to slot Notify

	if ( ! registred ) {
		kDebug(SKYPE_DEBUG_GLOBAL) << "Cant register Skype communication for Kopete on D-Bus";
		emit error(i18n("Cannot register Skype communication for Kopete on D-Bus"));
		return;
	}

	{
		QDBusInterface interface("com.Skype.API", "/com/Skype", "com.Skype.API", BUS);
		QDBusReply <QString> reply = interface.call("Invoke", "PING");

		bool started = interface.isValid();
		bool loggedin = reply.value() == "PONG";

		if ( ! started || ! loggedin ){
			if ( ! started && ! start.isEmpty() ) {//try starting Skype by the given command
				QStringList args = start.split(' ');
				QString skypeBin = args.takeFirst();
				if ( !name.isEmpty() && !pass.isEmpty() ){
					args << "--pipelogin";
				}
				kDebug(SKYPE_DEBUG_GLOBAL) << "Starting skype process" << skypeBin << "with parms" << args;
				d->skypeProcess.start(skypeBin, args);
				if ( !name.isEmpty() && !pass.isEmpty() ){
					kDebug(SKYPE_DEBUG_GLOBAL) << "Sending login name:" << name;
					d->skypeProcess.write(name.trimmed().toLocal8Bit());
					d->skypeProcess.write(" ");
					kDebug(SKYPE_DEBUG_GLOBAL) << "Sending password";
					d->skypeProcess.write(pass.trimmed().toLocal8Bit());
					d->skypeProcess.closeWriteChannel();
				}
				d->skypeProcess.waitForStarted();
				kDebug(SKYPE_DEBUG_GLOBAL) << "Skype process state:" << d->skypeProcess.state() << "Skype process error:" << d->skypeProcess.error();
				if ( d->skypeProcess.state() != QProcess::Running || d->skypeProcess.error() == QProcess::FailedToStart ) {
					emit error(i18n("Could not launch Skype.\nYou need to install the original dynamic linked Skype version 2.0 binary from http://www.skype.com"));
					disconnectSkype(crLost);
					emit connectionDone(seNoSkype, 0);
					return;
				}
			} else {
				if ( start.isEmpty() ){
					emit error(i18n("Could not find Skype.\nYou need to install the original dynamic linked Skype version 2.0 binary from http://www.skype.com"));
					disconnectSkype(crLost);
					emit connectionDone(seNoSkype, 0);
					return;
				}
			}
			d->fase = cfWaitingStart;
			d->startTimer = new QTimer();
			connect(d->startTimer, SIGNAL(timeout()), this, SLOT(tryConnect()));
			d->startTimer->start(1000);
			d->timeRemaining = launchTimeout;
			d->waitBeforeConnect = waitBeforeConnect;
			return;
		}
	}

	startLogOn();
}
Пример #5
0
int SkypeConnection::protocolVer() const {
	kDebug(SKYPE_DEBUG_GLOBAL);

	return d->protocolVer;//just give him the protocol version
}
Пример #6
0
void DebugScriptAdaptor::debug(const QString &message)
{

    kDebug() << message;

}
Пример #7
0
void KCValidity::loadOdfValidation(KCCell* const cell, const QString& validationName,
                                 KCOdfLoadingContext& tableContext)
{
    KXmlElement element = tableContext.validities.value(validationName);
    KCValidity validity;
    if (element.hasAttributeNS(KOdfXmlNS::table, "condition")) {
        QString valExpression = element.attributeNS(KOdfXmlNS::table, "condition", QString());
        kDebug(36003) << " element.attribute( table:condition )" << valExpression;
        //Condition ::= ExtendedTrueCondition | TrueFunction 'and' TrueCondition
        //TrueFunction ::= cell-content-is-whole-number() | cell-content-is-decimal-number() | cell-content-is-date() | cell-content-is-time()
        //ExtendedTrueCondition ::= ExtendedGetFunction | cell-content-text-length() Operator KCValue
        //TrueCondition ::= GetFunction | cell-content() Operator KCValue
        //GetFunction ::= cell-content-is-between(KCValue, KCValue) | cell-content-is-not-between(KCValue, KCValue)
        //ExtendedGetFunction ::= cell-content-text-length-is-between(KCValue, KCValue) | cell-content-text-length-is-not-between(KCValue, KCValue)
        //Operator ::= '<' | '>' | '<=' | '>=' | '=' | '!='
        //KCValue ::= NumberValue | String | KCFormula
        //A KCFormula is a formula without an equals (=) sign at the beginning. See section 8.1.3 for more information.
        //A String comprises one or more characters surrounded by quotation marks.
        //A NumberValue is a whole or decimal number. It must not contain comma separators for numbers of 1000 or greater.

        //ExtendedTrueCondition
        if (valExpression.contains("cell-content-text-length()")) {
            //"cell-content-text-length()>45"
            valExpression = valExpression.remove("oooc:cell-content-text-length()");
            kDebug(36003) << " valExpression = :" << valExpression;
            setRestriction(KCValidity::TextLength);

            loadOdfValidationCondition(valExpression, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-is-text()")) {
            setRestriction(KCValidity::Text);
        }
        //cell-content-text-length-is-between(KCValue, KCValue) | cell-content-text-length-is-not-between(KCValue, KCValue) | cell-content-is-in-list( StringList )
        else if (valExpression.contains("cell-content-text-length-is-between")) {
            setRestriction(KCValidity::TextLength);
            setCondition(KCConditional::Between);
            valExpression = valExpression.remove("oooc:cell-content-text-length-is-between(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
            loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-text-length-is-not-between")) {
            setRestriction(KCValidity::TextLength);
            setCondition(KCConditional::Different);
            valExpression = valExpression.remove("oooc:cell-content-text-length-is-not-between(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            kDebug(36003) << " valExpression :" << valExpression;
            QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
            loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-is-in-list(")) {
            setRestriction(KCValidity::List);
            valExpression = valExpression.remove("oooc:cell-content-is-in-list(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            setValidityList(valExpression.split(';',  QString::SkipEmptyParts));

        }
        //TrueFunction ::= cell-content-is-whole-number() | cell-content-is-decimal-number() | cell-content-is-date() | cell-content-is-time()
        else {
            if (valExpression.contains("cell-content-is-whole-number()")) {
                setRestriction(KCValidity::KCNumber);
                valExpression = valExpression.remove("oooc:cell-content-is-whole-number() and ");
            } else if (valExpression.contains("cell-content-is-decimal-number()")) {
                setRestriction(KCValidity::Integer);
                valExpression = valExpression.remove("oooc:cell-content-is-decimal-number() and ");
            } else if (valExpression.contains("cell-content-is-date()")) {
                setRestriction(KCValidity::Date);
                valExpression = valExpression.remove("oooc:cell-content-is-date() and ");
            } else if (valExpression.contains("cell-content-is-time()")) {
                setRestriction(KCValidity::Time);
                valExpression = valExpression.remove("oooc:cell-content-is-time() and ");
            }
            kDebug(36003) << "valExpression :" << valExpression;

            if (valExpression.contains("cell-content()")) {
                valExpression = valExpression.remove("cell-content()");
                loadOdfValidationCondition(valExpression, cell->sheet()->map()->parser());
            }
            //GetFunction ::= cell-content-is-between(KCValue, KCValue) | cell-content-is-not-between(KCValue, KCValue)
            //for the moment we support just int/double value, not text/date/time :(
            if (valExpression.contains("cell-content-is-between(")) {
                valExpression = valExpression.remove("cell-content-is-between(");
                valExpression = valExpression.remove(')');
                QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
                loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
                setCondition(KCConditional::Between);
            }
            if (valExpression.contains("cell-content-is-not-between(")) {
                valExpression = valExpression.remove("cell-content-is-not-between(");
                valExpression = valExpression.remove(')');
                QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
                loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
                setCondition(KCConditional::Different);
            }
        }
    }
    if (element.hasAttributeNS(KOdfXmlNS::table, "allow-empty-cell")) {
        kDebug(36003) << " element.hasAttribute( table:allow-empty-cell ) :" << element.hasAttributeNS(KOdfXmlNS::table, "allow-empty-cell");
        setAllowEmptyCell(((element.attributeNS(KOdfXmlNS::table, "allow-empty-cell", QString()) == "true") ? true : false));
    }
    if (element.hasAttributeNS(KOdfXmlNS::table, "base-cell-address")) {
        //todo what is it ?
    }

    KXmlElement help = KoXml::namedItemNS(element, KOdfXmlNS::table, "help-message");
    if (!help.isNull()) {
        if (help.hasAttributeNS(KOdfXmlNS::table, "title")) {
            kDebug(36003) << "help.attribute( table:title ) :" << help.attributeNS(KOdfXmlNS::table, "title", QString());
            setTitleInfo(help.attributeNS(KOdfXmlNS::table, "title", QString()));
        }
        if (help.hasAttributeNS(KOdfXmlNS::table, "display")) {
            kDebug(36003) << "help.attribute( table:display ) :" << help.attributeNS(KOdfXmlNS::table, "display", QString());
            setDisplayValidationInformation(((help.attributeNS(KOdfXmlNS::table, "display", QString()) == "true") ? true : false));
        }
        KXmlElement attrText = KoXml::namedItemNS(help, KOdfXmlNS::text, "p");
        if (!attrText.isNull()) {
            kDebug(36003) << "help text :" << attrText.text();
            setMessageInfo(attrText.text());
        }
    }

    KXmlElement error = KoXml::namedItemNS(element, KOdfXmlNS::table, "error-message");
    if (!error.isNull()) {
        if (error.hasAttributeNS(KOdfXmlNS::table, "title"))
            setTitle(error.attributeNS(KOdfXmlNS::table, "title", QString()));
        if (error.hasAttributeNS(KOdfXmlNS::table, "message-type")) {
            QString str = error.attributeNS(KOdfXmlNS::table, "message-type", QString());
            if (str == "warning")
                setAction(KCValidity::Warning);
            else if (str == "information")
                setAction(KCValidity::Information);
            else if (str == "stop")
                setAction(KCValidity::Stop);
            else
                kDebug(36003) << "validation : message type unknown  :" << str;
        }

        if (error.hasAttributeNS(KOdfXmlNS::table, "display")) {
            kDebug(36003) << " display message :" << error.attributeNS(KOdfXmlNS::table, "display", QString());
            setDisplayMessage((error.attributeNS(KOdfXmlNS::table, "display", QString()) == "true"));
        }
        KXmlElement attrText = KoXml::namedItemNS(error, KOdfXmlNS::text, "p");
        if (!attrText.isNull())
            setMessage(attrText.text());
    }
    cell->setValidity(validity);
}
Пример #8
0
BitBltRecord::BitBltRecord( QDataStream &stream, quint32 recordSize )
    : m_bitmap(0)
{
    //kDebug(31000) << "stream position at the start: " << stream.device()->pos();
    //kDebug(31000) << "record size: " << recordSize;

    stream >> m_bounds;

    stream >> m_xDest;          // x, y of upper left corner of the destination.
    stream >> m_yDest;
    stream >> m_cxDest;         // width, height of the rectangle in logical coords.
    stream >> m_cyDest;
    //kDebug(31000) << "Destination" << m_xDest << m_yDest << m_cxDest << m_cyDest;

    stream >> m_BitBltRasterOperation;
    //kDebug(31000) << "bitblt raster operation:" << hex << m_BitBltRasterOperation << dec;

    stream >> m_xSrc;           // x, y of the source
    stream >> m_ySrc;
    //kDebug(31000) << "Source" << m_xSrc << m_ySrc;

    //kDebug(31000) << "position before the matrix: " << stream.device()->pos();
    stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
    float M11, M12, M21, M22, Dx, Dy;
    stream >> M11;              // Transformation matrix
    stream >> M12;
    stream >> M21;
    stream >> M22;
    stream >> Dx;
    stream >> Dy;
    m_XFormSrc = QTransform( M11, M12, M21, M22, Dx, Dy );
    //kDebug(31000) << "Matrix" << m_XFormSrc;
    //kDebug(31000) << "position after the matrix: " << stream.device()->pos();

    stream >> m_red >> m_green >> m_blue >> m_reserved;
    //kDebug(31000) << "Background color" << m_red << m_green << m_blue << m_reserved;
    //kDebug(31000) << "position after background color: " << stream.device()->pos();

    stream >> m_UsageSrc;
    //kDebug(31000) << "Color table interpretation" << m_UsageSrc;

    stream >> m_offBmiSrc;      // Offset to start of bitmap header from start of record
    stream >> m_cbBmiSrc;       // Size of source bitmap header
    stream >> m_offBitsSrc;     // Offset to source bitmap from start of record
    stream >> m_cbBitsSrc;      // Size of source bitmap
#if 0
    kDebug(31000) << "header offset:" << m_offBmiSrc;
    kDebug(31000) << "header size:  " << m_cbBmiSrc;
    kDebug(31000) << "bitmap offset:" << m_offBitsSrc;
    kDebug(31000) << "bitmap size:  " << m_cbBitsSrc;
#endif

    //kDebug(31000) << "stream position before the image: " << stream.device()->pos();
    if (m_cbBmiSrc > 0) {
        m_bitmap = new Bitmap( stream, recordSize, 8 + 23 * 4, // header + 23 ints
                               m_offBmiSrc, m_cbBmiSrc,
                               m_offBitsSrc, m_cbBitsSrc );
    }

    //kDebug(31000) << "stream position at the end: " << stream.device()->pos();
}
Пример #9
0
void TweetJob::recv(KIO::Job* , const QByteArray& data)
{
    kDebug() << "data " << m_url;
    m_data.append(data);
}
Пример #10
0
StretchDiBitsRecord::StretchDiBitsRecord( QDataStream &stream, quint32 recordSize )
    : m_bitmap(0)
{
    //kDebug(31000) << "stream position at the start: " << stream.device()->pos();
    //kDebug(31000) << "recordSize =" << recordSize;

    stream >> m_Bounds;
    stream >> m_xDest;
    stream >> m_yDest;
    stream >> m_xSrc;
    stream >> m_ySrc;
    stream >> m_cxSrc;
    stream >> m_cySrc;

    stream >> m_offBmiSrc;
    stream >> m_cbBmiSrc;
    stream >> m_offBitsSrc;
    stream >> m_cbBitsSrc;

    stream >> m_UsageSrc;       // How to interpret color table values.
    stream >> m_BitBltRasterOperation;
    stream >> m_cxDest;
    stream >> m_cyDest;
#if 0
    kDebug(31000) << "bounds:" << m_Bounds;
    kDebug(31000) << "destination:" << QPoint(m_xDest, m_yDest) << QSize(m_cxDest, m_cyDest);
    kDebug(31000) << "source:" << QPoint(m_xSrc, m_ySrc) << QSize(m_cxSrc, m_cySrc);
    kDebug(31000) << "header offset:" << m_offBmiSrc;
    kDebug(31000) << "header size:  " << m_cbBmiSrc;
    kDebug(31000) << "bitmap offset:" << m_offBitsSrc;
    kDebug(31000) << "bitmap size:  " << m_cbBitsSrc;

    kDebug(31000) << "m_BitBltRasterOperation =" << hex << m_BitBltRasterOperation << dec;
#endif

    //kDebug(31000) << "stream position before the image: " << stream.device()->pos();
    if (m_cbBmiSrc > 0) {
        m_bitmap = new Bitmap( stream, recordSize, 8 + 18 * 4, // header + 18 ints
                               m_offBmiSrc, m_cbBmiSrc,
                               m_offBitsSrc, m_cbBitsSrc );
    }

    //kDebug(31000) << "stream position at the end: " << stream.device()->pos();
#if 0
    // Read away those bytes that preceed the header.  These are undefined
    // according to the spec.  80 is the size of the record above.
    qint32 dummy;
    int    padding = 0;
    while (m_offBmiSrc - padding > 80) {
        stream >> dummy;
        padding += 4;
    }
    m_BmiSrc = new BitmapHeader( stream, m_cbBmiSrc );

    // 40 is the size of the header record.
    while (m_offBitsSrc - padding > 80 + 40) {
        stream >> dummy;
        padding += 4;
    }
    m_imageData.resize( m_cbBitsSrc );
    stream.readRawData( m_imageData.data(), m_cbBitsSrc );
#endif
}
Пример #11
0
QImage StretchDiBitsRecord::image() 
{
    return m_bitmap->image();
#if 0
    if ( m_image != 0 ) {
        return m_image;
    }

    QImage::Format format = QImage::Format_Invalid;

    // Start by determining which QImage format we are going to use.
    if (m_BmiSrc->bitCount() == BI_BITCOUNT_1) {
        format = QImage::Format_Mono;
    } else if ( m_BmiSrc->bitCount() == BI_BITCOUNT_4 ) {
        if ( m_BmiSrc->compression() == BI_RGB ) {
            format = QImage::Format_RGB555;
        } else {
            kDebug(33100) << "Unexpected compression format for BI_BITCOUNT_4:"
                          << m_BmiSrc->compression();
            Q_ASSERT( 0 );
        }
    } else if ( m_BmiSrc->bitCount() == BI_BITCOUNT_5 ) {
        format = QImage::Format_RGB888;
    } else {
        kDebug(31000) << "Unexpected format:" << m_BmiSrc->bitCount();
        //Q_ASSERT(0);
    }

    // According to MS-WMF 2.2.2.3, the sign of the height decides if
    // this is a compressed bitmap or not.
    if (m_BmiSrc->height() > 0) {
        // This bitmap is a top-down bitmap without compression.
        m_image = new QImage( (const uchar*)m_imageData.constData(),
                              m_BmiSrc->width(), m_BmiSrc->height(), format );

        // The WMF images are in the BGR color order.
        if (format == QImage::Format_RGB888)
            *m_image = m_image->rgbSwapped();

        // We have to mirror this bitmap in the X axis since WMF images are stored bottom-up.
        *m_image = m_image->mirrored(false, true);
    } else {
        // This bitmap is a bottom-up bitmap which uses compression.
        switch (m_BmiSrc->compression()) {
        case BI_RGB:
            m_image = new QImage( (const uchar*)m_imageData.constData(),
                                  m_BmiSrc->width(), -m_BmiSrc->height(), format );
            // The WMF images are in the BGR color order.
            *m_image = m_image->rgbSwapped();
            break;

        // These compressions are not yet supported, so return an empty image.
        case BI_RLE8:
        case BI_RLE4:
        case BI_BITFIELDS:
        case BI_JPEG:
        case BI_PNG:
        case BI_CMYK:
        case BI_CMYKRLE8:
        case BI_CMYKRLE4:
        default:
            m_image = new QImage(m_BmiSrc->width(), m_BmiSrc->height(), format);
            break;
        }
    }

    return m_image;
#endif
}
Пример #12
0
///Propagate the mime data
///@note This propagate like this: button -> tree item -> treewidget
void TranslucentButtons::dropEvent(QDropEvent *e)
{
   kDebug() << "Drop accepted";
   emit dataDropped((QMimeData*)e->mimeData());
}
Пример #13
0
void runRdb( uint flags )
{
  // Obtain the application palette that is about to be set.
  bool exportColors      = flags & KRdbExportColors;
  bool exportQtColors    = flags & KRdbExportQtColors;
  bool exportQtSettings  = flags & KRdbExportQtSettings;
  bool exportXftSettings = flags & KRdbExportXftSettings;
  bool exportGtkTheme    = flags & KRdbExportGtkTheme;

  KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig( "kdeglobals" );
  KConfigGroup kglobals(kglobalcfg, "KDE");
  QPalette newPal = KGlobalSettings::createApplicationPalette(kglobalcfg);

  KTemporaryFile tmpFile;
  if (!tmpFile.open())
  {
    kDebug() << "Couldn't open temp file";
    exit(0);
  }


  KConfigGroup generalCfgGroup(kglobalcfg, "General");

  QString gtkTheme;
  if (generalCfgGroup.hasKey("widgetStyle"))
    gtkTheme = generalCfgGroup.readEntry("widgetStyle");
  else
    gtkTheme = "oxygen";

  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 );
  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 );

  // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps)
  if (exportColors)
  {
    KGlobal::dirs()->addResourceType("appdefaults", "data", "kdisplay/app-defaults/");

    QString preproc;
    QColor backCol = newPal.color( QPalette::Active, QPalette::Background );
    addColorDef(preproc, "FOREGROUND"         , newPal.color( QPalette::Active, QPalette::Foreground ) );
    addColorDef(preproc, "BACKGROUND"         , backCol);
    addColorDef(preproc, "HIGHLIGHT"          , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1));
    addColorDef(preproc, "LOWLIGHT"           , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10));
    addColorDef(preproc, "SELECT_BACKGROUND"  , newPal.color( QPalette::Active, QPalette::Highlight));
    addColorDef(preproc, "SELECT_FOREGROUND"  , newPal.color( QPalette::Active, QPalette::HighlightedText));
    addColorDef(preproc, "WINDOW_BACKGROUND"  , newPal.color( QPalette::Active, QPalette::Base ) );
    addColorDef(preproc, "WINDOW_FOREGROUND"  , newPal.color( QPalette::Active, QPalette::Foreground ) );
    addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor());
    addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor());
    addColorDef(preproc, "ACTIVE_BACKGROUND"  , KGlobalSettings::activeTitleColor());
    addColorDef(preproc, "ACTIVE_FOREGROUND"  , KGlobalSettings::activeTitleColor());
    //---------------------------------------------------------------

    tmpFile.write( preproc.toLatin1(), preproc.length() );

    QStringList list;

    const QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", "");
    for (QStringList::ConstIterator it = adPaths.constBegin(); it != adPaths.constEnd(); ++it) {
      QDir dSys( *it );

      if ( dSys.exists() ) {
        dSys.setFilter( QDir::Files );
        dSys.setSorting( QDir::Name );
        dSys.setNameFilters(QStringList("*.ad"));
        list += dSys.entryList();
      }
    }

    for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
      copyFile(tmpFile, KStandardDirs::locate("appdefaults", *it ), true);
  }

  // Merge ~/.Xresources or fallback to ~/.Xdefaults
  QString homeDir = QDir::homePath();
  QString xResources = homeDir + "/.Xresources";

  // very primitive support for ~/.Xresources by appending it
  if ( QFile::exists( xResources ) )
    copyFile(tmpFile, xResources, true);
  else
    copyFile(tmpFile, homeDir + "/.Xdefaults", true);

  // Export the Xcursor theme & size settings
  KConfigGroup mousecfg(KSharedConfig::openConfig( "kcminputrc" ), "Mouse" );
  QString theme = mousecfg.readEntry("cursorTheme", QString());
  QString size  = mousecfg.readEntry("cursorSize", QString());
  QString contents;

  if (!theme.isNull())
    contents = "Xcursor.theme: " + theme + '\n';

  if (!size.isNull())
    contents += "Xcursor.size: " + size + '\n';

  if (exportXftSettings)
  {
    if (generalCfgGroup.hasKey("XftAntialias"))
    {
      contents += "Xft.antialias: ";
      if(generalCfgGroup.readEntry("XftAntialias", true))
        contents += "1\n";
      else
        contents += "0\n";
    }

    if (generalCfgGroup.hasKey("XftHintStyle"))
    {
      QString hintStyle = generalCfgGroup.readEntry("XftHintStyle", "hintmedium");
      contents += "Xft.hinting: ";
      if(hintStyle.isEmpty())
        contents += "-1\n";
      else
      {
        if(hintStyle!="hintnone")
          contents += "1\n";
        else
          contents += "0\n";
        contents += "Xft.hintstyle: " + hintStyle + '\n';
      }
    }

    if (generalCfgGroup.hasKey("XftSubPixel"))
    {
      QString subPixel = generalCfgGroup.readEntry("XftSubPixel");
      if(!subPixel.isEmpty())
        contents += "Xft.rgba: " + subPixel + '\n';
    }

    KConfig _cfgfonts( "kcmfonts" );
    KConfigGroup cfgfonts(&_cfgfonts, "General");

    if( cfgfonts.readEntry( "forceFontDPI", 0 ) != 0 )
      contents += "Xft.dpi: " + cfgfonts.readEntry( "forceFontDPI" ) + '\n';
    else
    {
      KProcess proc;
      proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
      proc.start();
      if (proc.waitForStarted())
      {
        proc.write( QByteArray( "Xft.dpi\n" ) );
        proc.closeWriteChannel();
        proc.waitForFinished();
      }
    }
  }

  if (contents.length() > 0)
    tmpFile.write( contents.toLatin1(), contents.length() );

  tmpFile.flush();

  KProcess proc;
#ifndef NDEBUG
  proc << "xrdb" << "-merge" << tmpFile.fileName();
#else
  proc << "xrdb" << "-quiet" << "-merge" << tmpFile.fileName();
#endif
  proc.execute();

  applyGtkStyles(exportColors, 1);
  applyGtkStyles(exportColors, 2);

  /* Qt exports */
  if ( exportQtColors || exportQtSettings )
  {
    QSettings* settings = new QSettings(QLatin1String("Trolltech"));

    if ( exportQtColors )
      applyQtColors( kglobalcfg, *settings, newPal );    // For kcmcolors

    if ( exportQtSettings )
      applyQtSettings( kglobalcfg, *settings );          // For kcmstyle

    delete settings;
    QApplication::flush();
#if HAVE_X11
    if (qApp->platformName() == QStringLiteral("xcb")) {
        // We let KIPC take care of ourselves, as we are in a KDE app with
        // QApp::setDesktopSettingsAware(false);
        // Instead of calling QApp::x11_apply_settings() directly, we instead
        // modify the timestamp which propagates the settings changes onto
        // Qt-only apps without adversely affecting ourselves.

        // Cheat and use the current timestamp, since we just saved to qtrc.
        QDateTime settingsstamp = QDateTime::currentDateTime();

        static Atom qt_settings_timestamp = 0;
        if (!qt_settings_timestamp) {
            QString atomname("_QT_SETTINGS_TIMESTAMP_");
            atomname += XDisplayName( 0 ); // Use the $DISPLAY envvar.
            qt_settings_timestamp = XInternAtom( QX11Info::display(), atomname.toLatin1(), False);
        }

        QBuffer stamp;
        QDataStream s(&stamp.buffer(), QIODevice::WriteOnly);
        s << settingsstamp;
        XChangeProperty( QX11Info::display(), QX11Info::appRootWindow(), qt_settings_timestamp,
                        qt_settings_timestamp, 8, PropModeReplace,
                        (unsigned char*) stamp.buffer().data(),
                        stamp.buffer().size() );
        QApplication::flush();
    }
#endif
  }
}
Пример #14
0
void FindFilesDialog::processErrorOutputReady()
{
	QByteArray outputBuffer = m_proc->readAllStandardError();
	m_errbuf += QString::fromLocal8Bit(outputBuffer.data(), outputBuffer.size());
	kDebug() << "err buffer " << m_errbuf;
}
Пример #15
0
bool KraftDB::dbConnect( const QString& driver, const QString& dbName,
                         const QString& dbUser, const QString& dbHost,
                         const QString& dbPasswd )
{
    mSuccess = true;

    mDatabaseDriver = driver;
    if( driver.isEmpty() ) {
        mDatabaseDriver = DatabaseSettings::self()->dbDriver().toUpper();
    }

    if( mDatabaseDriver.isEmpty() ) {
        kDebug() << "Database Driver is not specified, check katalog settings";
        mSuccess = false;
        return false;
    } else {
        kDebug() << "Using database Driver " << mDatabaseDriver;
    }

    QStringList list = QSqlDatabase::drivers();
    if( list.size() == 0 ) {
        kDebug() << "Database Drivers could not be loaded." << endl;
        mSuccess = false ;
    } else {
        if( list.indexOf( mDatabaseDriver ) == -1 ) {
            kDebug() << "Database Driver " << mDatabaseDriver << " could not be loaded!" << endl;
            mSuccess = false;
        }
    }

    if( mSuccess && m_db.isValid() ) {
        m_db.close();
    }

    if( mSuccess ) {
        m_db = QSqlDatabase::addDatabase( mDatabaseDriver );

        if ( ! m_db.isValid() || m_db.isOpenError() )
        {
            kDebug() <<  "Failed to connect to the database driver: "
                      << m_db.lastError().text() << endl;
            mSuccess = false;
        }
    }

    if ( mSuccess ) {
        int re = 0;
        if(mDatabaseDriver == "QMYSQL") {
            QString host = dbHost;
            if( host.isEmpty() ) host = DatabaseSettings::self()->dbServerName();
            QString name = dbName;
            if( name.isEmpty() ) name = DatabaseSettings::self()->dbDatabaseName();
            QString user = dbUser;
            if( user.isEmpty() ) user = DatabaseSettings::self()->dbUser();
            QString pwd = dbPasswd;
            if( pwd.isEmpty() ) pwd = DatabaseSettings::self()->dbPassword();
            kDebug() << "Try to open MySQL database " << name << endl;
            re = checkConnect( host, name , user, pwd );
        } else if(mDatabaseDriver == "QSQLITE") {
            // SqlLite only requires a valid file name which comes in as Database Name
            QString name = dbName;
            if( name.isEmpty() ) name = DatabaseSettings::self()->dbFile();
            kDebug() << "Try to open SqLite database " << name << endl;
            re = checkConnect( "", name, "", "");
        }
        if ( re == 0 ) {
            // Database successfully opened; we can now issue SQL commands.
            kDebug() << "** Database opened successfully" << endl;
        } else {
            kDebug() << "## Could not open database" << endl;
            mSuccess = false;
        }
    }
    return mSuccess;
}
Пример #16
0
void GypsySolver::undo_move(MOVE *m)
{
#if PRINT
    kDebug() << "\n\nundo_move\n";
    if ( m->totype == O_Type )
        fprintf( stderr, "move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();

#endif
    int from, to;
    //card_t card;

    from = m->from;
    to = m->to;

    if ( m->from == deck )
    {
        for ( int i = 7; i >= 0; --i )
        {
            card_t card = *Wp[i];
            Q_ASSERT( !DOWN( card ) );
            card = ( SUIT( card ) << 4 ) + RANK( card ) + ( 1 << 7 );
            ++Wp[from];
            --Wp[i];
            *Wp[from] = card;
            Wlen[from]++;
            Wlen[i]--;
            hashpile( i );
        }
        hashpile( from );
#if PRINT
        print_layout();
#endif
        return;
    }


    /* Add to 'from' pile. */
    if ( m->turn_index > 0 )
    {
        card_t card2 = *Wp[from];
        if ( !DOWN( card2 ) )
            card2 = ( SUIT( card2 ) << 4 ) + RANK( card2 ) + ( 1 << 7 );
        *Wp[from] = card2;
    }

    card_t card = NONE;

    if (m->totype == O_Type) {
        card = *Wp[to];
        if ( RANK( card ) == PS_ACE )
        {
            Wlen[to] = 0;
        } else {
            *Wp[to] = card - 1; // SUIT( card ) << 4 + RANK( card ) - 1;
        }
        Wp[from]++;
        *Wp[from] = card;
        Wlen[from]++;
        hashpile( to );
    } else {
        for ( int l = m->card_index; l >= 0; --l )
        {
            card = W[to][Wlen[to]-l-1];
            Wp[from]++;
            *Wp[from] = card;
            Wlen[from]++;
            Wp[to]--;
        }
        Wlen[to] -= m->card_index + 1;
        hashpile(to);
    }

    if ( m->turn_index == 0 )
    {
        card_t card = *Wp[from];
        if ( DOWN( card ) )
            card = ( SUIT( card ) << 4 ) + RANK( card );
        else
            card += ( 1 << 7 );
        *Wp[from] = card;
    }

    hashpile(from);


#if PRINT
    print_layout();
#endif
}
Пример #17
0
bool DatabaseConfigElementLoader::readConfig()
{
    QString filepath = KStandardDirs::locate("data", "digikam/database/dbconfig.xml");
    kDebug() << "Loading SQL code from config file" << filepath;
    QFile file(filepath);

    if (!file.exists())
    {
        errorMessage = i18n("Could not open the dbconfig.xml file. "
                            "This file is installed with the digikam application "
                            "and is absolutely required to run digikam. "
                            "Please check your installation.");
        return false;
    }

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        errorMessage = i18n("Could not open dbconfig.xml file <filename>%1</filename>", filepath);
        return false;
    }

    QDomDocument doc("DBConfig");

    if (!doc.setContent(&file))
    {
        file.close();
        errorMessage = i18n("The XML in the dbconfig.xml file <filename>%1</filename> is invalid and cannot be read.", filepath);
        return false;
    }

    file.close();

    QDomElement element = doc.namedItem("databaseconfig").toElement();

    if (element.isNull())
    {
        errorMessage = i18n("The XML in the dbconfig.xml file <filename>%1</filename> "
                            "is missing the required element <icode>%2</icode>",
                            filepath, element.tagName());
        return false;
    }

    QDomElement defaultDB =  element.namedItem("defaultDB").toElement();

    if (defaultDB.isNull())
    {
        errorMessage = i18n("The XML in the dbconfig.xml file <filename>%1</filename> "
                            "is missing the required element <icode>%2</icode>",
                            filepath, element.tagName());
        return false;
    }

    QDomElement versionElement = element.namedItem("version").toElement();
    int version                = 0;

    kDebug() << versionElement.isNull() << versionElement.text() << versionElement.text().toInt() << dbconfig_xml_version;

    if (!versionElement.isNull())
    {
        version = versionElement.text().toInt();
    }

    if (version < dbconfig_xml_version)
    {
        errorMessage = i18n("An old version of the dbconfig.xml file <filename>%1</filename> "
                            "is found. Please ensure that the version released "
                            "with the running version of digiKam is installed. ",
                            filepath);
        return false;
    }

#ifdef DATABASEPARAMETERS_DEBUG
    kDebug() << "Default DB Node contains: " << defaultDB.text();
#endif

    QDomElement databaseElement = element.firstChildElement("database");

    for ( ; !databaseElement.isNull();  databaseElement=databaseElement.nextSiblingElement("database"))
    {
        DatabaseConfigElement l_DBCfgElement = readDatabase(databaseElement);
        databaseConfigs.insert(l_DBCfgElement.databaseID, l_DBCfgElement);
    }

#ifdef DATABASEPARAMETERS_DEBUG
    kDebug() << "Found entries: " << databaseConfigs.size();
    
    foreach(const DatabaseConfigElement& configElement, databaseConfigs )
    {
        kDebug() << "DatabaseID: " << configElement.databaseID;
        kDebug() << "HostName: " << configElement.hostName;
        kDebug() << "DatabaseName: " << configElement.databaseName;
        kDebug() << "UserName: "******"Password: "******"Port: " << configElement.port;
        kDebug() << "ConnectOptions: " << configElement.connectOptions;
        kDebug() << "Database Server CMD: " << configElement.dbServerCmd;
        kDebug() << "Database Init CMD: " << configElement.dbInitCmd;

/*
        kDebug() << "Statements:";

        foreach(const QString actionKey, configElement.sqlStatements.keys())
        {
            QList<databaseActionElement> l_DBActionElement = configElement.sqlStatements[actionKey].dBActionElements;
            kDebug() << "DBAction [" << actionKey << "] has [" << l_DBActionElement.size() << "] actions";
            foreach(const databaseActionElement statement, l_DBActionElement)
            {
                kDebug() << "\tMode ["<< statement.mode <<"] Value ["<< statement.statement <<"]";
            }
        }
*/
    }
Пример #18
0
void GypsySolver::make_move(MOVE *m)
{
#if PRINT
    kDebug() << "\n\nmake_move\n";
    if ( m->totype == O_Type )
        fprintf( stderr, "move %d from %d out (at %d) Prio: %d\n\n", m->card_index, m->from, m->turn_index, m->pri );
    else
        fprintf( stderr, "move %d from %d to %d (%d) Prio: %d\n\n", m->card_index, m->from, m->to, m->turn_index, m->pri );
    print_layout();
#else
    //print_layout();
#endif

    int from, to;
    //card_t card = NONE;

    from = m->from;
    to = m->to;

    if ( m->from == deck )
    {
        for ( int i = 0; i < 8; ++i )
        {
            card_t card = *Wp[from];
            card = ( SUIT( card ) << 4 ) + RANK( card );
            ++Wp[i];
            *Wp[i] = card;
            --Wp[from];
            Wlen[i]++;
            hashpile( i );
            Wlen[from]--;
        }
        hashpile( from );
#if PRINT
        print_layout();
#endif
        return;
    }

    card_t card = NONE;
    for ( int l = m->card_index; l >= 0; --l )
    {
        card = W[from][Wlen[from]-l-1];
        Wp[from]--;
        if ( m->totype != O_Type )
        {
            Wp[to]++;
            *Wp[to] = card;
            Wlen[to]++;
        }
    }
    Wlen[from] -= m->card_index + 1;

    if ( m->turn_index == 0 )
    {
        if ( DOWN( card ) )
            card = ( SUIT( card ) << 4 ) + RANK( card );
        else
            card += ( 1 << 7 );
        W[to][Wlen[to]-m->card_index-1] = card;
    } else if ( m->turn_index != -1 )
    {
        card_t card2 = *Wp[from];
        if ( DOWN( card2 ) )
            card2 = ( SUIT( card2 ) << 4 ) + RANK( card2 );
        *Wp[from] = card2;
    }

    hashpile(from);
    /* Add to pile. */

    if (m->totype == O_Type) {
        if ( Wlen[to] )
            *Wp[to] = card;
        else {
            Wp[to]++;
            Wlen[to]++;
            *Wp[to] = card;
        }
        Q_ASSERT( m->card_index == 0 );
    }
    hashpile(to);

#if PRINT
    print_layout();
#endif
}
Пример #19
0
void SupernovaeComponent::loadData()
{
    QString serialNo, hostGalaxy, date, type, offset, SNPosition, discoverers ;
    dms ra, dec;
    float magnitude;
    kDebug()<<"Loading Supernovae data"<<endl;
    //m_ObjectList.clear();
    latest.clear();
    objectNames(SkyObject::SUPERNOVA).clear();
    
    KStarsData *m_data = KStarsData::Instance(); // to convert equatorial coordinate to horizontal

    //SN     ,Host Galaxy     ,Date       , R.A.  , Decl.,   Offset  ,Mag.,  Disc. Ref.     ,      SN Position      ,  Posn. Ref.      ,Typ,  SN     ,Discoverer(s)
    QList< QPair<QString,KSParser::DataTypes> > sequence;
    sequence.append(qMakePair(QString("serialNo"),      KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("hostGalaxy"),    KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("date"),          KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("ra"),            KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("dec"),           KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("offset"),        KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("magnitude"),     KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("ignore1"),       KSParser::D_SKIP));
    sequence.append(qMakePair(QString("SNPosition"),    KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("ignore2"),       KSParser::D_SKIP));
    sequence.append(qMakePair(QString("type"),          KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("ignore3"),       KSParser::D_SKIP));
    sequence.append(qMakePair(QString("discoverers"),   KSParser::D_QSTRING));

    QString file_name = KStandardDirs::locate("appdata",
                                               QString("supernovae.dat"));
    KSParser snParser(file_name, '#', sequence);

    QHash<QString, QVariant> row_content;
    while (snParser.HasNextRow()){
        Supernova *sup=0;
        row_content = snParser.ReadNextRow();

        if(row_content["serialNo"].toString() == "Null")
            continue;

        serialNo    = row_content["serialNo"].toString();
        hostGalaxy  = row_content["hostGalaxy"].toString();
        date        = row_content["date"].toString();
        ra          = dms(row_content["ra"].toString(), false);
        dec         = dms(row_content["dec"].toString());
        offset      = row_content["offset"].toString();
        magnitude   = row_content["magnitude"].toFloat();
        SNPosition  = row_content["SNPosition"].toString();
        type        = row_content["type"].toString();
        discoverers = row_content["discoverers"].toString();

        if (magnitude == KSParser::EBROKEN_FLOAT)
            magnitude = 99.9;

        sup=new Supernova(ra, dec, date, magnitude, serialNo, type, hostGalaxy, offset, discoverers);
        sup->EquatorialToHorizontal(m_data->lst(),m_data->geo()->lat());
        if (!m_ObjectList.empty())
        {
            if ( findByName(sup->name() ) == 0 )
            {
                //kDebug()<<"List of supernovae not empty. Found new supernova";
                m_ObjectList.append(sup);
                latest.append(sup);
            }/*
            else
                m_ObjectList.append(sup);*/
        }
        else             //if the list is empty
        {
            m_ObjectList.append(sup);
            latest.append(sup);
            //notifyNewSupernovae();
        }

        objectNames(SkyObject::SUPERNOVA).append(sup->name());
    }
    //notifyNewSupernovae();
}
Пример #20
0
GameBoardScene::~GameBoardScene()
{
	kDebug() << "GameBoardScene::~GameBoardScene()";
	delete indicatorLine;
}
Пример #21
0
void SkypeConnection::Notify(const QString &message){
	kDebug(SKYPE_DEBUG_GLOBAL) << "Got message:" << message;//show what we have got
	emit received(message);
}
Пример #22
0
void CASpreadsheetHandler::findNoMatchFound()
{
    d->matchFound = false;
    kDebug() << "Match for " << searchString() << " not found";
}
Пример #23
0
bool SkypeConnection::connected() const {
	kDebug(SKYPE_DEBUG_GLOBAL);

	return d->fase == cfConnected;
}
Пример #24
0
void ChoiceSearchComboBox::labelClicked()
{
    kDebug() << "labelClicked";
    showPopup();
}
Пример #25
0
	/**
	 * Start the request - ask for the wallet
	 */
	void begin()
	{
		kDebug( 14010 );

		Kopete::WalletManager::self()->openWallet( this, SLOT(walletReceived(KWallet::Wallet*)) );
	}
Пример #26
0
void
KexiDBAutoField::createEditor()
{
    if (subwidget()) {
        delete(QWidget *)subwidget();
    }

    QWidget *newSubwidget;
    kDebug() << "widgetType:" << d->widgetType;
    switch (d->widgetType) {
    case Text:
    case Double: //! @todo setup validator
    case Integer: //! @todo setup validator
    case Date:
    case Time:
    case DateTime: {
        KexiDBLineEdit *le = new KexiDBLineEdit(this);
        newSubwidget = le;
        le->setFrame(false);
        break;
    }
    case MultiLineText:
        newSubwidget = new KexiDBTextEdit(this);
        break;
    case Boolean:
        newSubwidget = new KexiDBCheckBox(dataSource(), this);
        break;
    case Image:
        newSubwidget = new KexiDBImageBox(designMode(), this);
        break;
    case ComboBox: {
        KexiDBComboBox *cbox = new KexiDBComboBox(this);
        newSubwidget = cbox;
        cbox->setDesignMode(designMode());
        break;
    }
    default:
        newSubwidget = 0;
        changeText(d->caption);
        //d->label->setText( d->dataSource.isEmpty() ? "<datasource>" : d->dataSource );
        break;
    }

    kDebug() << newSubwidget;
    setSubwidget(newSubwidget);   //this will also allow to declare subproperties, see KFormDesigner::WidgetWithSubpropertiesInterface
    if (newSubwidget) {
        newSubwidget->setObjectName(
            QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className());
        dynamic_cast<KexiDataItemInterface*>(newSubwidget)->setParentDataItemInterface(this);
        dynamic_cast<KexiFormDataItemInterface*>(newSubwidget)
        ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox
        dynamic_cast<KexiFormDataItemInterface*>(newSubwidget)
        ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox
        newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox
        KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this);
        newSubwidget->show();
        d->label->setBuddy(newSubwidget);
        if (d->focusPolicyChanged) {//if focusPolicy is changed at top level, editor inherits it
            newSubwidget->setFocusPolicy(focusPolicy());
        } else {//if focusPolicy is not changed at top level, inherit it from editor
            QWidget::setFocusPolicy(newSubwidget->focusPolicy());
        }
        setFocusProxy(newSubwidget); //ok?
        if (parentWidget())
            newSubwidget->setPalette(qApp->palette());
        copyPropertiesToEditor();
//  KFormDesigner::installRecursiveEventFilter(newSubwidget, this);
//        newSubwidget->hide();
    }

    setLabelPosition(labelPosition());
}
Пример #27
0
 //find the relevant channelRequest
 Q_FOREACH(const Tp::ChannelRequestPtr channelRequest, channelRequests) {
     kDebug() << channelRequest->hints().allHints();
     windowRaise = !channelRequest->hints().hint(QLatin1String("org.kde.telepathy"), QLatin1String("suppressWindowRaise")).toBool();
 }
Пример #28
0
SqlCommandList KraftDB::parseCommandFile( const QString& file )
{
    QString sqlFile;
    QString env = QString::fromUtf8( qgetenv( "KRAFT_HOME" ) );
    if( !env.isEmpty() && env.right(1) != QDir::separator () ) {
        env += QDir::separator ();
    }

    QString driverPrefix = "mysql"; // Default on mysql
    if( mDatabaseDriver.toLower() == "qsqlite") {
        driverPrefix = "sqlite3";
    }

    // kDebug() << "XXXXXXXXXX: " << stdDirs.resourceDirs("data");

    if( env.isEmpty() ) {
        // Environment-Variable is empty, search in KDE paths
        QString fragment = QString("kraft/dbmigrate/%1/%2").arg(driverPrefix).arg(file );
        sqlFile = KStandardDirs::locate("data", fragment );
        kDebug() << "Searching for this fragment: " << fragment;
        // search in dbcreate as well.
        if ( sqlFile.isEmpty() ) {
            fragment = QString("kraft/dbinit/%1/%2").arg(driverPrefix).arg(file );
            kDebug() << "Also searching in " << fragment;
            sqlFile = KStandardDirs::locate( "data", fragment );
        }
    } else {
        // read from environment variable path
        QString envPath = QString( "%1/database/%2/%3").arg(env).arg(driverPrefix).arg(file);
        kDebug() << "Environment variable KRAFT_HOME set, searching for DB setup files in " << envPath;
        if( QFile::exists( envPath ) ) {
            sqlFile = envPath;
        } else if( QFile::exists( QString( "%1/database/%2/migration/%3").arg(env).arg(driverPrefix).arg(file ) ) ){
            sqlFile = QString( "%1/database/%2/migration/%3").arg(env).arg(driverPrefix).arg(file );
        }
    }

    SqlCommandList retList;

    if ( ! sqlFile.isEmpty() ) {
        kDebug() << "Opening migration file " << sqlFile << endl;

        QFile f( sqlFile );
        if ( !f.open( QIODevice::ReadOnly ) ) {
            kDebug() << "Could not open " << sqlFile << endl;
        } else {
            QTextStream ts( &f );
            ts.setCodec("UTF-8");

            QString allSql = ts.readAll(); //Not sure of this one!
            QStringList sqlList = allSql.split(";");

            QRegExp reg( "\\s*(#|--)\\s*message:? ?(.*)\\s*\\n" );
            QRegExp failreg( "\\s*(#|--)\\s*mayfail\\s*\\n" );
            reg.setMinimal( true );

            QListIterator<QString> it(sqlList);

            while( it.hasNext() ) {
                QString msg, command;

                QString sqlFragment = it.next().trimmed();

                int pos = reg.indexIn( sqlFragment.toLower(),  0 );
                if ( pos > -1 ) {
                    msg = reg.cap( 2 );
                    // kDebug() << "SQL-Commands-Parser: Msg: >" << msg << "<" << endl;
                }

                bool mayfail = false;
                pos = failreg.indexIn( sqlFragment.toLower(), 0 );
                if( pos > -1 ) {
                    mayfail = true;
                }
                bool clean = false;
                while( ! clean ) {
                    if(  sqlFragment.startsWith("#") || sqlFragment.startsWith("--") ) {
                        // remove the comment line.
                        int newLinePos = sqlFragment.indexOf('\n');
                        // kDebug() << "Found newline in <" << sqlFragment << ">:" << newLinePos;
                        if(newLinePos > 0) {
                            sqlFragment = sqlFragment.remove( 0, 1+sqlFragment.indexOf('\n') );
                        } else {
                            sqlFragment = QString();
                        }
                        // kDebug() << "Left over SQL Fragment:" << sqlFragment;
                    } else {
                        clean = true;
                    }
                }

                if( !sqlFragment.isEmpty() ) {

                    if( sqlFragment.startsWith( "CREATE TRIGGER", Qt::CaseInsensitive )) {
                        // Triggers contain a ; which scares the parser. In case of triggers we pull
                        // the next item in the list which should be the END; keyword.
                        command = sqlFragment + ";";
                        if( it.hasNext())
                            command += it.next();
                    } else {
                        // ordinary command, we take it as it is.
                        command = sqlFragment;
                    }
                    if( !( command.isEmpty() && msg.isEmpty() ) ) {
                        retList.append( SqlCommand( command, msg, mayfail ) );
                    }
                }
            }
        }
    } else {
        kDebug() << "ERR: Can not find sql file " << file;
    }

    return retList;
}
Пример #29
0
void KonqOperations::asyncDrop( const KFileItem & destItem )
{
    assert(m_info); // setDropInfo should have been called before asyncDrop
    bool m_destIsLocal = false;
    m_destUrl = destItem.mostLocalUrl(m_destIsLocal); // #168154

    //kDebug(1203) << "destItem->mode=" << destItem->mode() << " url=" << m_destUrl;
    // Check what the destination is
    if ( destItem.isDir() )
    {
        doDropFileCopy();
        return;
    }
    if ( !m_destIsLocal )
    {
        // We dropped onto a remote URL that is not a directory!
        // (e.g. an HTTP link in the sidebar).
        // Can't do that, but we can't prevent it before stating the dest....
        kWarning(1203) << "Cannot drop onto " << m_destUrl ;
        deleteLater();
        return;
    }
    if ( destItem.isDesktopFile() )
    {
        // Local .desktop file. What type ?
        KDesktopFile desktopFile( m_destUrl.path() );
        KConfigGroup desktopGroup = desktopFile.desktopGroup();
        if ( desktopFile.hasApplicationType() )
        {
            QString error;
            const QStringList urlStrList = m_info->urls.toStringList();
            if ( KToolInvocation::startServiceByDesktopPath( m_destUrl.path(), urlStrList, &error ) > 0 )
                KMessageBox::error( parentWidget(), error );
        }
        else
        {
            // Device or Link -> adjust dest
            if ( desktopFile.hasDeviceType() && desktopGroup.hasKey("MountPoint") ) {
                QString point = desktopGroup.readEntry( "MountPoint" );
                m_destUrl.setPath( point );
                QString dev = desktopFile.readDevice();
                KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByDevice( dev );
                // Is the device already mounted ?
                if ( mp ) {
                    doDropFileCopy();
                }
                else
                {
                    const bool ro = desktopGroup.readEntry( "ReadOnly", false );
                    const QByteArray fstype = desktopGroup.readEntry( "FSType" ).toLatin1();
                    KAutoMount* am = new KAutoMount( ro, fstype, dev, point, m_destUrl.path(), false );
                    connect( am, SIGNAL(finished()), this, SLOT(doDropFileCopy()) );
                }
                return;
            }
            else if ( desktopFile.hasLinkType() && desktopGroup.hasKey("URL") ) {
                m_destUrl = desktopGroup.readPathEntry("URL", QString());
                doDropFileCopy();
                return;
            }
            // else, well: mimetype, service, servicetype or .directory. Can't really drop anything on those.
        }
    }
    else
    {
        // Should be a local executable
        // (If this fails, there is a bug in KFileItem::acceptsDrops / KDirModel::flags)
        kDebug(1203) << m_destUrl.path() << "should be an executable";
        Q_ASSERT ( access( QFile::encodeName(m_destUrl.path()), X_OK ) == 0 );
        // Launch executable for each of the files
        QStringList args;
        const KUrl::List lst = m_info->urls;
        KUrl::List::ConstIterator it = lst.begin();
        for ( ; it != lst.end() ; it++ )
            args << (*it).path(); // assume local files
        kDebug(1203) << "starting " << m_destUrl.path() << " with " << lst.count() << " arguments";
        QProcess::startDetached( m_destUrl.path(), args );
    }
    deleteLater();
}
void KonqSidebarTree::scanDir( KonqSidebarTreeItem *parent, const QString &path, bool isRoot )
{
    QDir dir( path );

    if ( !dir.isReadable() )
        return;

    kDebug(1201) << "scanDir" << path;

    QStringList entries = dir.entryList( QDir::Files );
    QStringList dirEntries = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);

    if ( isRoot )
    {
        bool copyConfig = (entries.isEmpty() && dirEntries.isEmpty());
        if (!copyConfig)
        {
            // Check version number
            // Version 1 was the dirtree of KDE 2.0.x (no versioning at that time, so default)
            // Version 2 includes the history
            // Version 3 includes the bookmarks
            // Version 4 includes lan.desktop and floppy.desktop, Alex
            // Version 5 includes the audiocd browser
            // Version 6 includes the printmanager and lan browser
            const int currentVersion = 6;
            QString key = QString::fromLatin1("X-KDE-DirTreeVersionNumber");
            KConfig versionCfg( path + "/.directory", KConfig::SimpleConfig);
            KConfigGroup generalGroup( &versionCfg, "General" );
            int versionNumber = generalGroup.readEntry( key, 1 );
            kDebug(1201) << "found version " << versionNumber;
            if ( versionNumber < currentVersion ) {
                generalGroup.writeEntry( key, currentVersion );
                versionCfg.sync();
                copyConfig = true;
            }
        }
        if (copyConfig) {
            // We will copy over the configuration for the dirtree, from the global directory
            const QStringList dirtree_dirs = KGlobal::dirs()->findDirs("data","konqsidebartng/virtual_folders/"+m_dirtreeDir.relDir+'/');


//            QString dirtree_dir = KGlobal::dirs()->findDirs("data","konqsidebartng/virtual_folders/"+m_dirtreeDir.relDir+"/").last();  // most global
//            kDebug(1201) << "dirtree_dir=" << dirtree_dir;

            /*
            // debug code

            const QStringList blah = m_sidebarModule->getInterfaces->componentData()->dirs()->dirs()->findDirs( "data", "konqueror/dirtree" );
            QStringList::ConstIterator eIt = blah.constBegin();
            QStringList::ConstIterator eEnd = blah.constEnd();
            for (; eIt != eEnd; ++eIt )
            kDebug(1201) << "findDirs got me " << *eIt;
            // end debug code
            */

            for (QStringList::const_iterator ddit=dirtree_dirs.constBegin(); ddit!=dirtree_dirs.constEnd(); ++ddit) {
                QString dirtree_dir=*ddit;
                if (dirtree_dir==path) continue;
                //    if ( !dirtree_dir.isEmpty() && dirtree_dir != path )
                {
                    QDir globalDir( dirtree_dir );
                    Q_ASSERT( globalDir.isReadable() );
                    // Only copy the entries that don't exist yet in the local dir
                    const QStringList globalDirEntries = globalDir.entryList();
                    QStringList::ConstIterator eIt = globalDirEntries.constBegin();
                    QStringList::ConstIterator eEnd = globalDirEntries.constEnd();
                    for (; eIt != eEnd; ++eIt )
                    {
                        //kDebug(1201) << "dirtree_dir contains " << *eIt;
                        if ( *eIt != "." && *eIt != ".."
                                && !entries.contains( *eIt ) && !dirEntries.contains( *eIt ) )
                        {   // we don't have that one yet -> copy it.
                            QString cp("cp -R -- ");
                            cp += KShell::quoteArg(dirtree_dir + *eIt);
                            cp += ' ';
                            cp += KShell::quoteArg(path);
                            kDebug(1201) << "executing " << cp;
                            ::system( QFile::encodeName(cp) );
                        }
                    }
                }
            }
            // hack to make QDir refresh the lists
            dir.setPath(path);
            entries = dir.entryList( QDir::Files );
            dirEntries = dir.entryList( QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot );
        }
    }


    // TODO: currently the filename order is used. Implement SortOrder? #69667

    QStringList::ConstIterator eIt = entries.constBegin();
    QStringList::ConstIterator eEnd = entries.constEnd();
    for (; eIt != eEnd; ++eIt ) {
        const QString filePath = path + *eIt;
        if (KDesktopFile::isDesktopFile(filePath)) {
            loadTopLevelItem(parent, filePath);
        }
    }

    eIt = dirEntries.constBegin();
    eEnd = dirEntries.constEnd();

    for (; eIt != eEnd; eIt++ )
    {
        const QString newPath = QString( path ).append( *eIt ).append( QLatin1Char( '/' ) );
        loadTopLevelGroup( parent, newPath );
    }
}