Ejemplo n.º 1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void D3DProcessor::run()
{
  PreviewTableModel* model = PreviewTableModel::Instance();

  // Now run the chosen pipeline on each image file in the table
  for (int i = 0; i < model->rowCount(); i++)
  {
    QModelIndex index = model->index(i, PreviewTableModel::RawImagePath);
    QString imagePath = model->data(index, Qt::DisplayRole).toString();
    QFileInfo imageFi(imagePath);
    if (imagePath.isEmpty() == true)
    {
      QString s = tr("The image file path at row %1 is empty.").arg(QString::number(i + 1));
      QMessageBox::warning(NULL, "MDCTool Warning", s, QMessageBox::Ok);
      continue;
    }
    else if (imageFi.exists() == false)
    {
      QString s = tr("The image file path at row %1 does not exist.").arg(QString::number(i + 1));
      QMessageBox::warning(NULL, "MDCTool Warning", s, QMessageBox::Ok);
      continue;
    }

    model->setPipelineState(index.row(), PreviewTableItem::InProgress);
    emit processGeneratedMessage("Executing pipeline on \"" + imageFi.baseName() + "\"");

    // Run the pipeline
    delay(3);

    model->setPipelineState(index.row(), PreviewTableItem::DoneNoError);
    double value = (static_cast<double>(i + 1) / static_cast<double>(model->rowCount())) * 100;
    emit processGeneratedProgressValue(value);

    if (m_Stop == true)
    {
      break;
    }
  }

  if (m_Stop == true)
  {
    emit processGeneratedMessage("The process has been stopped.");
  }
  else
  {
    emit processGeneratedMessage("The process has finished.");
  }

  emit processFinished();
}
Ejemplo n.º 2
0
void PageModel::buildSingleImageModel(){

    IwsConfig *cfg = IwsConfig::getInstance();
    m_css = cfg->singleImageCss();

    QString absoluteFilePath = cfg->webRoot()+m_resourceUrl; // normaly this should contain
                                                             // a filename at the end
    QString relResourcePath; // no file name here
    QString fileName;

    QFileInfo imageFi(absoluteFilePath);
    if (! imageFi.exists())
        return;
    if (imageFi.isFile()){
        relResourcePath =  m_resourceUrl.left( m_resourceUrl.lastIndexOf(imageFi.fileName()));
        fileName = imageFi.fileName();
    }
    else
         relResourcePath = m_resourceUrl;

    QDir images =  imageFi.absoluteDir();

    images.setFilter(QDir::Files);


    images.setNameFilters(cfg->imageFileFilter());
    QFileInfoList imageInfoList=  images.entryInfoList(QDir::Files,QDir::Name);
    int p = imageInfoList.indexOf(imageFi);
    if (p == -1) return;
    int prv =  ((p==0) ?   imageInfoList.size()-1 :  p-1); // backward rotate
    int nxt = (p+1)%imageInfoList.size(); //forward rotate

    Item prev;
    prev.m_description = "Previous image";
    prev.m_href = "?single-image-view="+relResourcePath+imageInfoList.at(prv).fileName().toUtf8();
    prev.m_imgSrc = "?icon-file=previous.png";
    prev.m_itemType = Item::ItemNav;
    m_items.append(prev);

    Item upDir;
    upDir.m_description = "Return to  "+ relResourcePath;;
    upDir.m_href =relResourcePath; // m_resourceUrl.left(m_resourceUrl.lastIndexOf(imageFi.fileName()));
    upDir.m_imgSrc = "?icon-file=folder.png";
    upDir.m_itemType = Item::ItemNav;
    m_items.append(upDir);

    Item next;
    next.m_description = "Next image";
    next.m_href = "?single-image-view="+relResourcePath+imageInfoList.at(nxt).fileName();
    next.m_imgSrc = "?icon-file=next.png";
    next.m_itemType = Item::ItemNav;
    m_items.append(next);

    Item theImage;
    theImage.m_description = imageInfoList.at(p).fileName();
    theImage.m_href = m_resourceUrl;
    theImage.m_imgSrc = m_resourceUrl;
    theImage.m_itemType = Item::ItemImage;
    m_items.append(theImage);

    m_title = imageInfoList.at(p).fileName();
}