Example #1
0
void QgsLayoutItemHtml::refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property )
{
  QgsExpressionContext context = createExpressionContext();

  //updates data defined properties and redraws item to match
  if ( property == QgsLayoutObject::SourceUrl || property == QgsLayoutObject::AllProperties )
  {
    loadHtml( true, &context );
  }
}
Example #2
0
void QgsComposerHtml::setUrl( const QUrl& url )
{
  if ( !mWebPage )
  {
    return;
  }

  mUrl = url;
  loadHtml();
}
Example #3
0
void QgsComposerHtml::setUrl( const QUrl& url )
{
  if ( !mWebPage )
  {
    return;
  }

  mUrl = url;
  loadHtml( true );
  emit changed();
}
Example #4
0
void QgsLayoutItemHtml::setUrl( const QUrl &url )
{
  if ( !mWebPage )
  {
    return;
  }

  mUrl = url;
  loadHtml( true );
  emit changed();
}
Example #5
0
void QgsComposerHtml::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext* context )
{
  QgsExpressionContext scopedContext = createExpressionContext();
  const QgsExpressionContext* evalContext = context ? context : &scopedContext;


  //updates data defined properties and redraws item to match
  if ( property == QgsComposerObject::SourceUrl || property == QgsComposerObject::AllProperties )
  {
    loadHtml( true, evalContext );
  }
  QgsComposerObject::refreshDataDefinedProperty( property, context );
}
Example #6
0
QgsComposerHtml::QgsComposerHtml( QgsComposition* c, bool createUndoCommands ): QgsComposerMultiFrame( c, createUndoCommands ),
    mWebPage( 0 ),
    mLoaded( false ),
    mHtmlUnitsToMM( 1.0 ),
    mRenderedPage( 0 ),
    mUseSmartBreaks( true )
{
  mHtmlUnitsToMM = htmlUnitsToMM();
  mWebPage = new QWebPage();
  QObject::connect( mWebPage, SIGNAL( loadFinished( bool ) ), this, SLOT( frameLoaded( bool ) ) );
  if ( mComposition )
  {
    QObject::connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( handleFrameRemoval( QgsComposerItem* ) ) );
    connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( loadHtml() ) );
  }
}
Example #7
0
void QgsComposerHtml::refreshExpressionContext()
{
  QgsVectorLayer * vl = nullptr;
  QgsFeature feature;

  if ( mComposition->atlasComposition().enabled() )
  {
    vl = mComposition->atlasComposition().coverageLayer();
  }
  if ( mComposition->atlasMode() != QgsComposition::AtlasOff )
  {
    feature = mComposition->atlasComposition().feature();
  }

  setExpressionContext( feature, vl );
  loadHtml( true );
}
Example #8
0
void QgsComposerHtml::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext* context )
{
  const QgsExpressionContext* evalContext = context;
  QScopedPointer< QgsExpressionContext > scopedContext;
  if ( !evalContext )
  {
    scopedContext.reset( createExpressionContext() );
    evalContext = scopedContext.data();
  }

  //updates data defined properties and redraws item to match
  if ( property == QgsComposerObject::SourceUrl || property == QgsComposerObject::AllProperties )
  {
    loadHtml( true, evalContext );
  }
  QgsComposerObject::refreshDataDefinedProperty( property, context );
}
Example #9
0
bool QgsComposerHtml::readXml( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames )
{
  if ( !ignoreFrames )
  {
    deleteFrames();
  }

  //first create the frames
  if ( !_readXml( itemElem, doc, ignoreFrames ) )
  {
    return false;
  }

  bool contentModeOK;
  mContentMode = static_cast< QgsComposerHtml::ContentMode >( itemElem.attribute( "contentMode" ).toInt( &contentModeOK ) );
  if ( !contentModeOK )
  {
    mContentMode = QgsComposerHtml::Url;
  }
  mEvaluateExpressions = itemElem.attribute( "evaluateExpressions", "true" ) == "true" ? true : false;
  mUseSmartBreaks = itemElem.attribute( "useSmartBreaks", "true" ) == "true" ? true : false;
  mMaxBreakDistance = itemElem.attribute( "maxBreakDistance", "10" ).toDouble();
  mHtml = itemElem.attribute( "html" );
  mUserStylesheet = itemElem.attribute( "stylesheet" );
  mEnableUserStylesheet = itemElem.attribute( "stylesheetEnabled", "false" ) == "true" ? true : false;

  //finally load the set url
  QString urlString = itemElem.attribute( "url" );
  if ( !urlString.isEmpty() )
  {
    mUrl = urlString;
  }
  loadHtml( true );

  //since frames had to be created before, we need to emit a changed signal to refresh the widget
  emit changed();
  return true;
}
    bool getPageList()
    {
        loadHtml("<script type=\"text/javascript\">\n"
            "var pages;\n"
            "var xhr = new XMLHttpRequest;\n"
            "xhr.open(\"GET\", \"/pagelist.json\");\n"
            "xhr.onload = function(e) {\n"
                "if (xhr.status == 200) {\n"
                    "pages = JSON.parse(xhr.responseText);\n"
                    "document.title = \"OK\";\n"
                "} else \n"
                    "document.title = \"FAIL\";\n"
                "}\n"
            "xhr.send();\n"
            "</script>\n",
            "http://127.0.0.1:2999/");

        waitUntilTitleChanged();

        if (!strcmp(webkit_web_view_get_title(m_webView), "OK"))
            return true;

        return false;
    }
Example #11
0
void QgsComposerHtml::setEvaluateExpressions( bool evaluateExpressions )
{
  mEvaluateExpressions = evaluateExpressions;
  loadHtml( true );
  emit changed();
}
Example #12
0
void QgsLayoutItemHtml::setEvaluateExpressions( bool evaluateExpressions )
{
  mEvaluateExpressions = evaluateExpressions;
  loadHtml( true );
  emit changed();
}
void CommandParser::parseAndSendCommand(const QString &channelName, const QString &msg)
{
    QStringList commandParts = msg.split(' ', QString::SkipEmptyParts);
    int n = commandParts.count();

    if (commandParts[0] == "/join" || commandParts[0] == "/j")
    {
        if (n == 2 || n == 3)
        {
            QString channelKey;

            // Allow the user to spare the '#' character which is handy for VKB
            if (!commandParts[1].startsWith('#'))
                commandParts[1].insert(0, '#');
            if (n == 3)
                channelKey = commandParts[2];

            static_cast<ServerModel*>(parent()->parent())->joinChannel(commandParts[1], channelKey);
        }
        else
        {
            emit commandParseError("Invalid command. Correct usage: '/join &lt;channelname&gt; [&lt;channelkey&gt;]'");
        }
    }
    else if (channelName.startsWith('#') && (commandParts[0] == "/part" || commandParts[0] == "/p"))
    {
        if (n == 1)
            _ircClient->partChannel(channelName, _appSettings->partMessage());
        else if (n == 2)
            _ircClient->partChannel(commandParts[1], commandParts[2]);
        else
            emit commandParseError("Invalid command. Correct usage: '/part' or '/part &lt;channelname&gt'';");
    }
    else if (!channelName.startsWith('#') && commandParts[0] == "/close")
    {
        if (n == 1)
            _ircClient->closeUser(channelName);
        else if (n == 2)
            _ircClient->closeUser(commandParts[1]);
        else
            emit commandParseError("Invalid command. Correct usage: '/close' or '/close &lt;username&gt'';");
    }
    else if (commandParts[0] == "/quit")
    {
        if (n == 1)
        {
            _ircClient->quit(_appSettings->quitMessage());
            _ircClient->disconnectFromServer();
            QCoreApplication::instance()->processEvents();
            QCoreApplication::instance()->quit();
        }
        else
            emit commandParseError("Invalid command. Correct usage: '/quit'");
    }
    else if (commandParts[0] == "/me")
    {
        if (n > 1)
        {
            QString action = msg.mid(4);
            _ircClient->sendCtcpAction(channelName, action);
        }
        else
            emit commandParseError("Invalid command. Correct usage: '/me &lt;message&gt;'");
    }
    else if (commandParts[0] == "/msg" || commandParts[0] == "/m")
    {
        if (n > 2)
        {
            int length = commandParts[0].length() + commandParts[1].length();
            QString message = msg.mid(length + 2);
            _ircClient->queryUser(commandParts[1]);
            _ircClient->sendMessage(commandParts[1], message);
        }
        else
            emit commandParseError("Invalid command. Correct usage: '/msg &lt;username&gt; &lt;message&gt;'");
    }
    else if (commandParts[0] == "/nick" || commandParts[0] == "/n")
    {
        if (n == 2)
            _ircClient->changeNick(commandParts[1]);
        else
            emit commandParseError("Invalid command. Correct usage: '/nick &lt;new nick&gt;' ");
    }
    else if (commandParts[0] == "/topic")
    {
        if (n == 1)
            _ircClient->requestTopic(channelName);
        else
        {
            commandParts.removeAt(0);
            QString topic = commandParts.join(' ');
            _ircClient->setTopic(channelName, topic);
        }
    }
    else if (commandParts[0] == "/query" || commandParts[0] == "/q")
    {
        if (n == 2)
            static_cast<ServerModel*>(parent()->parent())->joinChannel(commandParts[1]);
        else
            emit commandParseError("Invalid command. Correct usage: '/query &lt;username&gt;' ");
    }
    else if (commandParts[0] == "/kick" || commandParts[0] == "/k")
    {
        if (n == 2)
            _ircClient->kick(channelName, commandParts[1], _appSettings->kickMessage());
        else if (n == 3)
            _ircClient->kick(commandParts[2], commandParts[1], _appSettings->kickMessage());
        else if (n != 1)
        {
            QString reason = msg.mid(commandParts[0].length() + commandParts[1].length() + commandParts[2].length() + 3);
            _ircClient->kick(commandParts[2], commandParts[1], reason);
        }
        else
            emit commandParseError("Invalid command. Correct usage: '/kick &lt;nick&gt; [channel] [reason]'");
    }
    else if (commandParts[0] == "/ctcp")
    {
        if (n == 2)
            _ircClient->sendCtcpRequest(commandParts[1], QString("VERSION"));
        else if (n == 3)
            _ircClient->sendCtcpRequest(commandParts[1], commandParts[2]);
        else
            emit commandParseError("Invalid command. Correct usage: '/ctcp &lt;user name&gt; [request]'");
    }
    else if (commandParts[0] == "/raw")
    {
        QString rawCommand = msg.mid(5);
        emit commandParseError("Sending raw command '" + rawCommand + "' to the server.");
        _ircClient->sendRaw(rawCommand);
    }
    else if (commandParts[0] == "/whois")
    {
        if (n == 2)
            _ircClient->sendWhois(commandParts[1]);
        else
            emit commandParseError("Invalid command. Correct usage: '/whois &lt;user name&gt;'");
    }
    else if (commandParts[0] == "/dumphtml")
    {
        if (n > 1)
        {
            commandParts.removeAt(0);
            QString path = commandParts.join(' ');
            emit dumpHtml(path);
        }
    }
    else if (commandParts[0] == "/loadhtml")
    {
        if (n > 1)
        {
            commandParts.removeAt(0);
            QString path = commandParts.join(' ');
            emit loadHtml(path);
        }
    }
    // TODO
//    else if (commandParts[0] == "/quote")
//    {
//        QString rawCommand = msg.mid(7);
//        emit commandParseError("Sending raw command '" + rawCommand + "' to the server.");
//        _backend->sendRaw(rawCommand);
//    }
    else
    {
        emit commandParseError("Sending raw command '" + msg + "' to the server.");
        _ircClient->sendRaw(msg);
    }
}
Example #14
0
void QgsComposerHtml::setEvaluateExpressions( bool evaluateExpressions )
{
  mEvaluateExpressions = evaluateExpressions;
  loadHtml();
}