Exemple #1
0
std::vector<WStandardItem *>
TreeViewExample::cityItems(const std::string& city,
			   WeatherIcon weather,
			   const std::string& drink,
			   bool useInternalPath, bool visited)
{
  std::vector<WStandardItem *> result;
  WStandardItem *item;
  
  // column 0: country
  item = new WStandardItem(WString::fromUTF8(city));
  result.push_back(item);
  
  // column 1: weather
  item = new WStandardItem();
  item->setIcon(std::string("icons/") + weatherIcons[weather]);
  result.push_back(item);
  
  // column 2: drink
  item = new WStandardItem(drink);
  if (useInternalPath)
    item->setLink(WLink(WLink::InternalPath, "/drinks/" + drink));
  result.push_back(item);
  
  // column 3: visited
  item = new WStandardItem();
  item->setCheckable(true);
  item->setChecked(visited);
  result.push_back(item);
  
  return result;
}
void gdContainerBar::doCheck()
{
  WStandardItemModel*  model = dynamic_cast<WStandardItemModel*>(view()->model());
  for (int row = 0; row < model->rowCount(); row++) {
    WStandardItem* wsi = model->invisibleRootItem()->child(row, 0);
    wsi->setChecked(m_pWCb->isChecked());
  }
}
Exemple #3
0
WStandardItem *TreeViewExample::countryItem(const std::string& country,
					    const std::string& code)
{
  WStandardItem *result = new WStandardItem(WString::fromUTF8(country));
  result->setIcon("icons/flag_" + code + ".png");
  
  return result;
}
Exemple #4
0
void FormWidgets::addColorElement(WStandardItemModel* model,
				  std::string name, 
				  std::string style)
{
  WStandardItem* item = new WStandardItem(name);
  item->setStyleClass(style);
  model->appendRow(item);
}
Exemple #5
0
bool WStandardItemModel::removeRows(int row, int count,
				    const WModelIndex& parent)
{
  WStandardItem *parentItem = itemFromIndex(parent, false);

  if (parentItem)
    parentItem->removeRows(row, count);

  return parentItem;  
}
Exemple #6
0
bool WStandardItemModel::setData(const WModelIndex& index,
				 const boost::any& value, int role)
{
  WStandardItem *item = itemFromIndex(index);

  if (item)
    item->setData(value, role);

  return item;
}
Exemple #7
0
bool WStandardItemModel::insertRows(int row, int count,
				    const WModelIndex& parent)
{
  WStandardItem *parentItem = itemFromIndex(parent); // lazy create ok

  if (parentItem)
    parentItem->insertRows(row, count);

  return parentItem;
}
Exemple #8
0
///
//  Create a file entry
//
WStandardItem* FileBrowser::createEntry(const std::string& baseName, int index)
{
    WStandardItem *result = new WStandardItem(baseName);

    result->setIcon("icons/file.gif");

    // Set the data for the entry index in the user roles
    result->setData(index, UserRole);

    return result;
}
Exemple #9
0
WModelIndex WStandardItemModel::index(int row, int column,
				      const WModelIndex& parent) const
{
  WStandardItem *parentItem = itemFromIndex(parent, false);

  if (parentItem
      && row >= 0
      && column >= 0
      && row < parentItem->rowCount()
      && column < parentItem->columnCount())
    return createIndex(row, column, static_cast<void *>(parentItem));

  return WModelIndex();
}
Wt::WStandardItem* VanetSpModelDump::treeNode(list< Node >& nodes)
{
    WStandardItem* result = new WStandardItem(tr("mappropertyeditor.group.spmodeldump"));
    result->setData(VanetSpatialModelDump);
    
    Node extNode("extension");
    Attribute classAttr("class", "de.uni_stuttgart.informatik.canu.spatialmodel.extensions.DumpSpatialModel");
    extNode.addAttribute(classAttr);
    Attribute outAttr("output", output_->valueText().toUTF8());
    extNode.addAttribute(outAttr);
    result->appendRow(propertyRow(string("output="), tr("mappropertyeditor.group.spmodeldump.output").toUTF8(), output_->valueText().toUTF8()));
    
    nodes.push_back(extNode);
    return result;
}
WStandardItem* VanetRoutingProtocolPropertyForm::treeNode(list< Node >& nodes)
{
    WStandardItem* result = new WStandardItem(tr("mappropertyeditor.group.glomosim"));
    result->setData(VanetGlomoSimProperties);

    Node routing("routingprotocol");
    routing.value(routingCombo_->currentText().toUTF8());
    result->appendRow(propertyRow(string("routingprotocol"), tr("mappropertyeditor.group.glomosim.routingprotocol").toUTF8(), routingCombo_->currentText().toUTF8()));
//     Node count("number_of_nodes");
//     count.value(nodesCount_->valueText().toUTF8());
//     result->appendRow(propertyRow(string("number_of_nodes"), tr("mappropertyeditor.group.glomosim.nodesnumber").toUTF8(), nodesCount_->valueText().toUTF8()));
    nodes.push_back(routing);
//     nodes.push_back(count);

    return result;
}
WStandardItem *VanetAreaPropertyForm::treeNode(std::list< Node >& nodes)
{
    WStandardItem *result = new WStandardItem(tr("mappropertyeditor.group.general"));
    result->setData(VanetArea);

    Node xNode = Node("dimx");
    xNode.value(boost::lexical_cast<std::string>(dimx_->value()));
    nodes.push_back(xNode);
    result->appendRow(propertyRow(std::string("dimx"), tr("mappropertyeditor.group.general.dimx").toUTF8(), boost::lexical_cast<std::string>(dimx_->value())));
    Node yNode = Node("dimy");
    yNode.value(boost::lexical_cast<std::string>(dimy_->value()));
    nodes.push_back(yNode);
    result->appendRow(propertyRow(std::string("dimy"), tr("mappropertyeditor.group.general.dimy").toUTF8(), boost::lexical_cast<std::string>(dimy_->value())));

    return result;
}
Exemple #13
0
WStandardItem *WStandardItemModel::itemFromIndex(const WModelIndex& index,
						 bool lazyCreate) const
{
  if (!index.isValid())
    return invisibleRootItem_;
  else
    if (index.model() != this)
      return 0;
    else {
      WStandardItem *parent
	= static_cast<WStandardItem *>(index.internalPointer());
      WStandardItem *c = parent->child(index.row(), index.column());

      if (lazyCreate && !c) {
	c = itemPrototype()->clone();
	parent->setChild(index.row(), index.column(), c);
      }
      
      return c;
    }
}
Wt::WStandardItem* VanetNodeForm::treeNode(std::list< Node >& nodes)
{
    
    WStandardItem* result = new WStandardItem(tr("mappropertyeditor.group.node").arg(id_->valueText()));
    result->setData(VanetNode);
    
    Node n("node");
    Attribute idAttr("id", id_->valueText().toUTF8());
    n.addAttribute(idAttr);
    Node posNode("position");
    Attribute rndAttr("random", "true");
    posNode.addAttribute(rndAttr);
    n.addChild(posNode);
    result->appendRow(propertyRow(string("id="), tr("mappropertyeditor.group.node.id").toUTF8(), id_->valueText().toUTF8()));;
    //result->appendRow(form_->treeNode(nodes));
    // Here we place the mobility model on the same level as everything else. Just a quick fix so we can properly persist the model in the PersistenceManager.
    form_->appendPropertyRows(result, nodes);
    Node extNode = nodes.back();
    nodes.pop_back();
    n.addChild(extNode);
    nodes.push_back(n);
    return result;

}
Exemple #15
0
  /*! \brief Create a folder item.
   *
   * Configures flags for drag and drop support.
   */
  WStandardItem *createFolderItem(const WString& location,
				  const std::string& folderId = std::string())
  {
    WStandardItem *result = new WStandardItem(location);

    if (!folderId.empty()) {
      result->setData(boost::any(folderId));
      result->setFlags(result->flags() | ItemIsDropEnabled);
      folderNameMap_[folderId] = location;
    } else
      result->setFlags(result->flags().clear(ItemIsSelectable));

    result->setIcon("icons/folder.gif");

    return result;
  }
Exemple #16
0
  /*! \brief Populate the files model.
   *
   * Data (and headers) is read from the CSV file data/files.csv. We
   * add icons to the first column, resolve the folder id to the
   * actual folder name, and configure item flags, and parse date
   * values.
   */
  void populateFiles() {
    fileModel_->invisibleRootItem()->setRowCount(0);

    std::ifstream f((appRoot() + "data/files.csv").c_str());

    if (!f)
      throw std::runtime_error("Could not read: data/files.csv");

    readFromCsv(f, fileModel_);

    for (int i = 0; i < fileModel_->rowCount(); ++i) {
      WStandardItem *item = fileModel_->item(i, 0);
      item->setFlags(item->flags() | ItemIsDragEnabled);
      item->setIcon("icons/file.gif");

      std::string folderId = item->text().toUTF8();

      item->setData(boost::any(folderId), UserRole);
      item->setText(folderNameMap_[folderId]);

      convertToDate(fileModel_->item(i, 4));
      convertToDate(fileModel_->item(i, 5));
    }
  }
Exemple #17
0
WStandardItem *TreeViewExample::continentItem(const std::string& continent)
{
  WStandardItem *result = new WStandardItem(continent);
  result->setColumnCount(4);
  return result;
}
Exemple #18
0
WFlags<ItemFlag> WStandardItemModel::flags(const WModelIndex& index) const
{
  WStandardItem *item = itemFromIndex(index, false);

  return item ? item->flags() : WFlags<ItemFlag>(0);
}
Exemple #19
0
///
//  Add an entry to the browser
//
bool FileBrowser::addEntry(bool rootDir, int entryDepth,
                           const std::string &baseDir,
                           const std::string &baseName,
                           int index)
{
    //
    //  The code below adds an entry into the tree such as follows:
    //
    //  + tract_meta.bash
    //  + dicom_seriesCollect.bash
    //  + tract_meta-stage-2-dcm2trk.bash
    //    |
    //    + stage-1-mri_convert
    //      |
    //      + diff_unpack
    //
    //   ...
    //
    //  The relatively convoluted logic below is responsible for
    //  adding a new item to this tree structure.

    // If it's not a root directory, add the unique folder names as
    // root folder entries
    if (!rootDir)
    {
        bool addEntry = true;

        int modelRow;

        // Iterate over all the rows in the root
        for (modelRow = 0; modelRow < mModel->rowCount(); modelRow++)
        {
            WStandardItem *item = mModel->item(modelRow);
            bool match = true;

            // For the depth of the folder, attempt to match as many folders
            // as possible.
            for (int depth = 0; depth <= entryDepth && item != NULL; depth++)
            {
                path dirPath = path(baseDir);
                for (int d = 0; d < (entryDepth - depth); d++)
                {
                    dirPath = dirPath.branch_path();
                }
                std::string folderLeafName = path(dirPath).leaf().string();

                boost::any displayData = item->data(DisplayRole);
                if (!displayData.empty())
                {
                    WString folderName = boost::any_cast<WString>(displayData);

                    // Folder did not match, this means we need to add it
                    // to the tree
                    if (folderName.toUTF8() != folderLeafName)
                    {
                        match = false;
                        break;
                    }
                }
            }

            // All folders matched, we do not need a new folder
            if (match)
            {
                addEntry = false;
            }
        }

        // Add all of the necessary folder entries to the tree
        if (addEntry)
        {
            WStandardItem *lastItem = mModel->invisibleRootItem();

            for (int depth = 0; depth <= entryDepth; depth++)
            {
                path dirPath = path(baseDir);
                for (int d = 0; d < (entryDepth - depth); d++)
                {
                    dirPath = dirPath.branch_path();
                }
                std::string folderLeafName = path(dirPath).leaf().string();

                bool addFolder = true;
                for (int row = 0; row < lastItem->rowCount(); row++)
                {
                    WStandardItem *item = lastItem->child(row);
                    std::string folderLeafName = path(dirPath).leaf().string();

                    boost::any displayData = item->data(DisplayRole);
                    if (!displayData.empty())
                    {
                        WString folderName = boost::any_cast<WString>(displayData);

                        if (folderName.toUTF8() == folderLeafName)
                        {
                           addFolder = false;
                           lastItem = item;
                           break;
                        }
                    }
                }

                if (addFolder)
                {
                    WStandardItem *newItem = new WStandardItem(folderLeafName);
                    newItem->setFlags(newItem->flags().clear(ItemIsSelectable));
                    newItem->setIcon("icons/folder.gif");
                    lastItem->appendRow(newItem);
                    lastItem = newItem;
                }
            }
        }
    }
    // For root entries, add the file logs
    else
    {
        mModel->appendRow(createEntry(baseName, index));
    }

    // Now add the items under the folders
    if (!rootDir)
    {
        WStandardItem *lastItem = mModel->invisibleRootItem();

        for (int depth = 0; depth <= entryDepth; depth++)
        {
            path dirPath = path(baseDir);
            for (int d = 0; d < (entryDepth - depth); d++)
            {
                dirPath = dirPath.branch_path();
            }
            std::string folderLeafName = path(dirPath).leaf().string();

            for (int row = 0; row < lastItem->rowCount(); row++)
            {
                WStandardItem *item = lastItem->child(row);
                std::string folderLeafName = path(dirPath).leaf().string();

                boost::any displayData = item->data(DisplayRole);
                if (!displayData.empty())
                {
                    WString folderName = boost::any_cast<WString>(displayData);

                    if (folderName.toUTF8() == folderLeafName)
                    {
                        lastItem = item;
                        break;
                    }
                }
            }
        }

        if (lastItem != NULL)
        {
            lastItem->appendRow(createEntry(baseName, index));
        }
    }

    // Add the directory to the watch list
    addWatchPath(baseDir);

    return true;
}
Exemple #20
0
boost::any WStandardItemModel::data(const WModelIndex& index, int role) const
{
  WStandardItem *item = itemFromIndex(index, false);

  return item ? item->data(role) : boost::any();
}
Exemple #21
0
int WStandardItemModel::rowCount(const WModelIndex& parent) const
{
  WStandardItem *parentItem = itemFromIndex(parent, false);

  return parentItem ? parentItem->rowCount() : 0;
}