void AddTask::on_buttonBox_clicked(QAbstractButton* button)
{
    QDir dir_m(ui->pathtomedia->text());
    if(ui->buttonBox->buttonRole(button)==0 ){
        if(!ui->taskname->text().isEmpty() && !ui->pathtomedia->text().isEmpty() &&
          dir_m.exists() &&  !ui->taskurl->text().isEmpty() && validateUrl(ui->taskurl->text()))
         {

             map.insert("taskname", ui->taskname->text());
             map.insert("url", ui->taskurl->text());
             map.insert("media_path",ui->pathtomedia->text());
             this->accept();
         }
         else
            {
                QMessageBox msgBox;
                msgBox.setText(tr("Please fill al fields."));
                msgBox.exec();
            }
        }
        else
        {
            this->close();
        }
}
Beispiel #2
0
    /* The parse function is invoked after the loadFinished signal is received 
     * from  the webkit code upon successfully parsing a page. From here, the 
     * entire DOM can be manipulated and traversed really conveniently. The 
     * code right now just traverses the DOM looking for link tags, and queues 
     * them if they are valid, but this function is where all of the 
     * interesting development will take place in the future. 
     */
   void Parser::parse() {
      QUrl currentUrl;
      QWebElementCollection linkTags =
         page->mainFrame()->findAllElements("a");

      foreach(QWebElement current, linkTags) {
         currentUrl = QUrl(current.attribute("href"));
         /* This discards the fragment. It is useless in this context and
          * will complicate our visited hashtable.
          */
         currentUrl.setEncodedFragment(QByteArray());

         if (currentUrl.isEmpty()) {
            continue;
         }

         /* Prepend the parent URL if we have a relative link in an attempt
          * to validate it for retrieval.
          */
         if (currentUrl.isRelative() &&
            currentUrl.host() == "" && currentUrl.path() != "") {
            qDebug() << currentUrl << " is relative path. prepending host";
            currentUrl.setHost(url.host());
            currentUrl.setScheme(url.scheme());
            qDebug() << "with host fix: " << currentUrl;
         }

         /* Finally, check to make sure it's valid before queueing it */
         if (validateUrl(currentUrl)) {
            parsedUrls.push_back(currentUrl);
         }
      }
Beispiel #3
0
SoundSource::SoundSource(QUrl url, QString type)
        : AudioSource(validateUrl(url)),
          MetadataSourceTagLib(getLocalFileName()),
          m_type(type) {
}
Beispiel #4
0
/*static*/ QString SoundSource::getFileExtensionFromUrl(QUrl url) {
    return validateUrl(url).toString().section(".", -1).toLower().trimmed();
}