QString FilterableFacebookRelatedDataFilterInterface::dataSection(const QVariantMap &data)
{
    if (sectionField().isEmpty()) {
        return QString();
    }

    QString section = data.value(sectionField()).toString();

    if (sectionField() == "rsvp_status") {
        QString trueSection;


        if (section == "attending") {
            //: A section header for people attending an event
            //% "Attending"
            trueSection = qtTrId("facebook_event_attending");
        } else if (section == "unsure") {
            //: A section header for people that are unsure about attending to an event
            //% "Unsure"
            trueSection = qtTrId("facebook_event_unsure");
        } else if (section == "declined") {
            //: A section header for people who declined an event
            //% "Declined"
            trueSection = qtTrId("facebook_event_declined");
        } else if (section == "not_replied") {
            //: A section header for people who did not replied yet
            //% "Not replied"
            trueSection = qtTrId("facebook_event_not_replied");
        }

        return trueSection;
    }

    return section.left(1);
}
Esempio n. 2
0
bool QtRPT::isFieldVisible(const QDomElement &e) {
    bool visible;
    QString formulaStr = e.attribute("printing","1");
    if (formulaStr.size() > 1) {
        //qDebug()<<formulaStr;
        formulaStr = sectionField(formulaStr,true);
        //qDebug()<<formulaStr;

        QScriptEngine myEngine;
        //myEngine.globalObject().setProperty("quant1","3");
        //qDebug()<<myEngine.evaluate("quant1;").toString();
        visible = myEngine.evaluate(formulaStr).toInteger();


        //QScriptValue fun = myEngine.evaluate("(function(a, b) { return a == b; })");
        //QScriptValue fun = myEngine.evaluate("if (1>2) true else false");
        //QScriptValueList args;
        /*args << "k" << "k";
        QScriptValue threeAgain = fun.call(QScriptValue(), args);
        qDebug()<<threeAgain.toString();*/

    } else {
        visible = formulaStr.toInt();
    }
    return visible;
}
Esempio n. 3
0
void QtRPT::fillListOfValue(QDomNode n) {
    //В качестве параметра подается нод бэнда
    QDomNode c = n.firstChild();
    while(!c.isNull()) {
        QDomElement e = c.toElement(); // try to convert the node to an element.
        if ((!e.isNull()) && (e.tagName() == "TContainerField")) {
            if (isFieldVisible(e)) {
                if (e.attribute("type","label") == "label") { //NOT Proccess if field set as ImageField
                    QString txt = sectionField(e.attribute("value"),false,true);
                }
            }
        }
        c = c.nextSibling();
    }
}
Esempio n. 4
0
void QtRPT::drawField(QDomNode n, int bandTop) {
    //В качестве параметра подается нод бэнда
    QDomNode c = n.firstChild();
    while(!c.isNull()) {
        QDomElement e = c.toElement(); // try to convert the node to an element.
        if ((!e.isNull()) && (e.tagName() == "TContainerField")) {
            if (isFieldVisible(e)) {
                QFont font(e.attribute("fontFamily"),e.attribute("fontSize").toInt());
                font.setBold(processHighligthing(e, FontBold).toInt());
                font.setItalic(processHighligthing(e, FontItalic).toInt());
                font.setUnderline(processHighligthing(e, FontUnderline).toInt());

                painter.setFont(font);
                painter.setPen(Qt::black);

                int left_ = e.attribute("left").toInt()*koefRes_w;
                int top_ = (bandTop+e.attribute("top").toInt())*koefRes_h;
                int width_ = (e.attribute("width").toInt()-1)*koefRes_w;;
                int height_ = e.attribute("height").toInt()*koefRes_h;

                int cor = QFontMetrics(font).height() * koefRes_h;
                QRect textRect(left_, top_-height_, width_, height_);
                textRect.translate(0, cor );

                QPen pen = painter.pen();

                Qt::Alignment al;
                Qt::Alignment alH, alV;
                if (e.attribute("aligmentH") == "hRight")   alH = Qt::AlignRight;
                if (e.attribute("aligmentH") == "hLeft")    alH = Qt::AlignLeft;
                if (e.attribute("aligmentH") == "hCenter")  alH = Qt::AlignHCenter;
                if (e.attribute("aligmentH") == "hJustify") alH = Qt::AlignJustify;
                if (e.attribute("aligmentV") == "vTop")     alV = Qt::AlignTop;
                if (e.attribute("aligmentV") == "vBottom")  alV = Qt::AlignBottom;
                if (e.attribute("aligmentV") == "vCenter")  alV = Qt::AlignVCenter;
                al = alH | alV;

                if ( colorFromString(processHighligthing(e, BgColor).toString() )  != QColor(255,255,255,0))
                    painter.fillRect(left_+1,top_+1,width_-2,height_-2,colorFromString(processHighligthing(e, BgColor).toString()));

                /*if ( colorFromString(e.attribute("backgroundColor")) != QColor(255,255,255,0))
                    painter.fillRect(left_+1,top_+1,width_-2,height_-2,colorFromString(e.attribute("backgroundColor")));*/

                //Set border width
                pen.setWidth(e.attribute("borderWidth","1").replace("px","").toInt()*5);
                //Set border style
                QString borderStyle = e.attribute("borderStyle","solid");
                if (borderStyle == "dashed")
                    pen.setStyle(Qt::DashLine);
                else if (borderStyle == "dotted")
                    pen.setStyle(Qt::DotLine);
                else if (borderStyle == "dot-dash")
                    pen.setStyle(Qt::DashDotLine);
                else if (borderStyle == "dot-dot-dash")
                    pen.setStyle(Qt::DashDotDotLine);
                else
                    pen.setStyle(Qt::SolidLine);

                if ( colorFromString(e.attribute("borderTop")) != QColor(255,255,255,0) ) {
                    pen.setColor(colorFromString(e.attribute("borderTop")));
                    painter.setPen(pen);
                    painter.drawLine(left_, top_, left_ + width_, top_);
                }
                if ( colorFromString(e.attribute("borderBottom")) != QColor(255,255,255,0) ) {
                    pen.setColor(colorFromString(e.attribute("borderBottom")));
                    painter.setPen(pen);
                    painter.drawLine(left_, top_ + height_, left_ + width_, top_ + height_);
                }
                if ( colorFromString(e.attribute("borderLeft")) != QColor(255,255,255,0) ) {
                    pen.setColor(colorFromString(e.attribute("borderLeft")));
                    painter.setPen(pen);
                    painter.drawLine(left_, top_, left_, top_ + height_);
                }
                if ( colorFromString(e.attribute("borderRight")) != QColor(255,255,255,0) ) {
                    pen.setColor(colorFromString(e.attribute("borderRight")));
                    painter.setPen(pen);
                    painter.drawLine(left_ + width_, top_, left_ + width_, top_ + height_);
                }
                if (e.attribute("type","label") == "label") { //NOT Proccess if field set as ImageField
                    QString txt = sectionField(e.attribute("value"),false);
                    //pen.setColor(colorFromString(e.attribute("fontColor")));
                    pen.setColor(colorFromString(processHighligthing(e, FontColor).toString()));

                    painter.setPen(pen);
                    painter.drawText(left_+10,top_,width_-10,height_, al | Qt::TextDontClip | Qt::TextWordWrap, txt);
                }
                if (e.attribute("type","label") == "labelImage") { //Proccess field as ImageField
                    QImage image = sectionFieldImage(e.attribute("value"));
                    if (!image.isNull()) {
                        QRectF target(left_, top_, width_, height_);
                        painter.drawImage(target,image);
                    }
                }
                if (e.attribute("type","label") == "image") {  //Proccess as static ImageField
                    QByteArray byteArray;
                    byteArray = QByteArray::fromBase64(e.attribute("picture","text").toLatin1());
                    QPixmap pixmap = QPixmap::fromImage(QImage::fromData(byteArray, "PNG"));
                    painter.drawPixmap(left_,top_,width_,height_,pixmap);
                }
            }
        }
        c = c.nextSibling();
    }
}
Esempio n. 5
0
QVariant QtRPT::processHighligthing(QDomElement e, HiType type) {
    QString tmpStr = e.attribute("highlighting","");
    if (tmpStr.isEmpty() || tmpStr.isNull()) {
        switch (type) {
            case FontBold: {
                return e.attribute("fontBold").toInt();
                break;
            }
            case FontItalic: {
                return e.attribute("fontItalic").toInt();
                break;
            }
            case FontUnderline: {
                return e.attribute("fontUnderline").toInt();
                break;
            }
            case FontColor: {
                return e.attribute("fontColor");
                break;
            }
            case BgColor: {
                return e.attribute("backgroundColor");
                break;
            }
        }
    } else {
        QStringList list = tmpStr.split(";");
        const QString cond = list.at(0);
        for (int i = 1; i < list.size(); i++) {
            if (list.at(i).isEmpty()) continue;
            QString exp = list.at(i);
            if (list.at(i).contains("bold") && type == FontBold) {
                exp.remove("bold=");
                QString formulaStr = exp.insert(0,cond);
                formulaStr = sectionField(formulaStr,true);
                QScriptEngine myEngine;
                return myEngine.evaluate(formulaStr).toInteger();
            }
            if (list.at(i).contains("italic") && type == FontItalic) {
                exp.remove("italic=");
                QString formulaStr = exp.insert(0,cond);
                formulaStr = sectionField(formulaStr,true);
                QScriptEngine myEngine;
                return myEngine.evaluate(formulaStr).toInteger();
            }
            if (list.at(i).contains("underline") && type == FontUnderline) {
                exp.remove("underline=");
                QString formulaStr = exp.insert(0,cond);
                formulaStr = sectionField(formulaStr,true);
                QScriptEngine myEngine;
                return myEngine.evaluate(formulaStr).toInteger();
            }
            if (list.at(i).contains("fontColor") && type == FontColor) {
                exp.remove("fontColor=");
                QString formulaStr = exp.insert(1,"'");
                formulaStr = exp.insert(0,cond);
                formulaStr = sectionField(formulaStr,true)+"':'"+e.attribute("fontColor")+"'";
                QScriptEngine myEngine;
                return myEngine.evaluate(formulaStr).toString();
            }
            if (list.at(i).contains("backgroundColor") && type == BgColor) {
                exp.remove("backgroundColor=");
                QString formulaStr = exp.insert(1,"'");
                formulaStr = exp.insert(0,cond);
                formulaStr = sectionField(formulaStr,true)+"':'"+e.attribute("backgroundColor")+"'";
                QScriptEngine myEngine;
                return myEngine.evaluate(formulaStr).toString();
            }
        }
    }
    return QVariant();
}