Ejemplo n.º 1
0
 boost::any data(const Wt::WModelIndex& index,
                 int role=Wt::DisplayRole) const {
     dbo::Transaction t(fApp->session());
     const CommentPtr& o = resultRow(index.row());
     if (index.column() == deleted_column) {
         if (role == Wt::DisplayRole) {
             return "";
         } else if (role == Wt::CheckStateRole) {
             return o->deleted();
         }
     } else if (index.column() == index_column) {
         if (role == Wt::LinkRole) {
             return Wt::WLink(Wt::WLink::InternalPath, fApp->comment_path(o));
         } else if (role == Wt::DisplayRole) {
             return tr("facts.common.id_format").arg(o.id().index);
         }
     } else if (index.column() == ip_column && role == Wt::LinkRole) {
         return  Wt::WLink(Wt::WLink::InternalPath, fApp->ip_path(o->ip()));
     } else if (index.column() == text_column && role == Wt::DisplayRole) {
         if (o->deleted()) {
             return tr("facts.comment.deleted");
         } else {
             return tr("facts.comment.format").arg(o->username()).arg(o->email())
                    .arg(o->when_added().toString()).arg(o->text());
         }
     }
     return BaseQM::data(index, role);
 }
Ejemplo n.º 2
0
Wt::cpp17::any SombreroData::data(const Wt::WModelIndex& index, Wt::ItemDataRole role) const
{
  if (role != Wt::ItemDataRole::Display) {
    return WStandardItemModel::data(index, role);
  }

  double delta_y = (yEnd_ - yStart_)/(columnCount()-2);
  if (index.row() == 0) { // give back y-abscis
    if (index.column() == 0)
      return 0.0;
    return yStart_ + (index.column()-1)*delta_y;
  }
  
  double delta_x = (xEnd_ - xStart_)/(rowCount()-2);
  if (index.column() == 0) { // give back x-abscis
    if (index.row() == 0)
      return 0.0;
    return xStart_ + (index.row()-1)*delta_x;
  }

  double x, y;
  y = yStart_ + (index.column()-1)*delta_y;
  x = xStart_ + (index.row()-1)*delta_x;
  return 4*std::sin(std::sqrt(std::pow(x,2) + std::pow(y,2))) 
    / (std::sqrt (std::pow(x,2) + std::pow(y,2)));
}
Ejemplo n.º 3
0
boost::any SombreroData::data(const Wt::WModelIndex& index,
			      int role) const
{
  if (role != DisplayRole) {
    return boost::any();
  }

  double delta_y = (yEnd_ - yStart_)/(nbYPts_-1);
  if (index.row() == 0) { // give back y-abscis
    if (index.column() == 0)
      return 0.0;
    return yStart_ + (index.column()-1)*delta_y;
  }
  
  double delta_x = (xEnd_ - xStart_)/(nbXPts_-1);
  if (index.column() == 0) { // give back x-abscis
    if (index.row() == 0)
      return 0.0;
    return xStart_ + (index.row()-1)*delta_x;
  }

  double x, y;
  y = yStart_ + (index.column()-1)*delta_y;
  x = xStart_ + (index.row()-1)*delta_x;
  return 4*std::sin(std::sqrt(std::pow(x,2) + std::pow(y,2))) 
    / (std::sqrt (std::pow(x,2) + std::pow(y,2)));
}
Ejemplo n.º 4
0
		virtual boost::any data(const Wt::WModelIndex& index, int role = Wt::DisplayRole) const
		{
			RsStackMutex mtx(_mtx) ;
			std::cerr << "data row: " << index.row() << std::endl;
			if(index.column() >= 6 || index.row() >= (int)_searchResults.size())
				return boost::any();

			//DirDetails dd;
			//dd.count;
			switch (role) 
			{
				case Wt::DisplayRole:
					switch(index.column())
					{
						case COLUMN_FILENAME  : return Wt::WString(_searchResults[index.row()].name) ;
						case COLUMN_SIZE  : return make_big_number(_searchResults[index.row()].count) ;
						case COLUMN_AGE: return make_big_number(_searchResults[index.row()].age);
						default:
														return boost::any();
					}
				case Wt::UserRole:
					switch(index.column())
					{

					default: return Wt::WString(_searchResults[index.row()].hash) ;
					}
				case Wt::ToolTipRole:
						Wt::WString(_searchResults[index.row()].hash) ;
				default:
					return boost::any();
			}
		}
 virtual boost::any data(const Wt::WModelIndex& index, int role = Wt::DisplayRole) const
 {
   switch (role) {
     case Wt::DisplayRole:
       if(index.column()==0)
         return Wt::WString(_profiles[index.row()].uuid);
       if(index.column()==1)
         return Wt::WString(_profiles[index.row()].name);
     default:
       return boost::any();
   }
 }
Ejemplo n.º 6
0
  virtual boost::any data(const Wt::WModelIndex& index, int role = Wt::DisplayRole) const
  {
    switch (role) {
    case Wt::DisplayRole:
      if (index.column() == 0)
	return Wt::WString("Row {1}").arg(index.row());
      else
	return Wt::WString("Item row {1}, col {2}")
	  .arg(index.row()).arg(index.column());
    default:
      return boost::any();
    }
  }
Ejemplo n.º 7
0
 Wt::WFlags<Wt::ItemFlag> flags(const Wt::WModelIndex& i) const {
     Wt::WFlags<Wt::ItemFlag> f = ULP::BaseQM::flags(i);
     if (i.column() == NAME_COLUMN) {
         f |= Wt::ItemIsXHTMLText;
     }
     return f;
 }
Ejemplo n.º 8
0
std::size_t hash_value(const Wt::WModelIndex& index) {
  boost::hash<int> intHasher;
  boost::hash< ::uint64_t > longHasher;

  return intHasher(index.row()) + intHasher(index.column())
    + longHasher(index.internalId());
}
Ejemplo n.º 9
0
 boost::any data(const Wt::WModelIndex& index,
                 int role=Wt::DisplayRole) const {
     dbo::Transaction t(fApp->session());
     if (role == Wt::LinkRole && index.column() == N_COLUMN) {
         const FactPtr& o = resultRow(index.row());
         return Wt::WLink(Wt::WLink::InternalPath, fApp->fact_path(o));
     }
     return BaseQM::data(index, role);
 }
boost::any
InstructionListModel::data(const Wt::WModelIndex &index, int role) const {
    ASSERT_require(index.isValid());
    ASSERT_require(index.row()>=0 && (size_t)index.row() < insns_.size());
    SgAsmInstruction *insn = insns_[index.row()];
    if (Wt::DisplayRole == role) {
        switch (index.column()) {
            case C_ADDR: {
                return Wt::WString(StringUtility::addrToString(insn->get_address()));
            }
            case C_BYTES: {
                std::string s;
                for (size_t i=0; i<insn->get_raw_bytes().size(); ++i) {
                    uint8_t byte = insn->get_raw_bytes()[i];
                    char buf[32];
                    sprintf(buf, "%02x", byte);
                    s += std::string(i?" ":"") + buf;
                }
                return Wt::WString(s);
            }
            case C_CHARS: {
                std::string s;
                for (size_t i=0; i<insn->get_raw_bytes().size(); ++i) {
                    char ch = insn->get_raw_bytes()[i];
                    s += std::string(i?" ":"") + (isgraph(ch) ? std::string(1, ch) : std::string(" "));
                }
                return Wt::WString(s);
            }
            case C_STACKDELTA: {
                int64_t delta = insn->get_stackDelta();
                if (delta == SgAsmInstruction::INVALID_STACK_DELTA)
                    return Wt::WString("");
                std::string s = (delta >= 0 ? "+" : "") + boost::lexical_cast<std::string>(delta);
                return Wt::WString(s);
            }
            case C_NAME: {
                return Wt::WString(unparseMnemonic(insn));
            }
            case C_ARGS: {
                std::string s;
                const RegisterDictionary *regs = ctx_.partitioner.instructionProvider().registerDictionary();
                const SgAsmExpressionPtrList &operands = insn->get_operandList()->get_operands();
                for (size_t i=0; i<operands.size(); ++i)
                    s += (i?", ":"") + unparseExpression(operands[i], NULL, regs);
                return Wt::WString(s);
            }
            case C_COMMENT: {
                return Wt::WString(insn->get_comment());
            }
            default:
                ASSERT_not_reachable("invalid column number");
        }
    }
    return boost::any();
}
Ejemplo n.º 11
0
Wt::cpp17::any SpiralData::data(const Wt::WModelIndex& index, Wt::ItemDataRole role) const
{
  if (role != Wt::ItemDataRole::Display) {
    return WStandardItemModel::data(index, role);
  }

  const double pi = 3.141592;
  double XYangle = index.row() * (8*pi/nbPts_);
  double heightRatio = (float)index.row() / rowCount();
  double radius = 1.0 + heightRatio * 5.0;
  if (index.column() == 0) {
    return radius * std::cos(XYangle);
  } else if (index.column() == 1) {
    return radius * std::sin(XYangle);
  } else if (index.column() == 2) {
    return 5.0 - index.row() * (10.0/nbPts_);
  } else {
    return Wt::cpp17::any();
  }
}
Ejemplo n.º 12
0
boost::any PlaneData::data(const Wt::WModelIndex& index,
			   int role) const
{
  if (role != DisplayRole) {
    return boost::any();
  }

  double x, y;
  y = yStart_ + index.column() * yDelta_;
  x = xStart_ + index.row() * xDelta_;
  return 0.5*y;
}
Ejemplo n.º 13
0
 boost::any data(const Wt::WModelIndex& index,
                 int role = Wt::DisplayRole) const {
     dbo::Transaction t(tApp->session());
     const BDPtr& o = resultRow(index.row());
     if (role == Wt::DisplayRole) {
         if (index.column() == BAN) {
             if (o->type() == Wt::Wc::Gather::IP) {
                 if (IpBan::is_banned(o->value())) {
                     return tr("tc.user.Already_banned");
                 } else {
                     return tr("tc.user.New_ban");
                 }
             } else {
                 return "";
             }
         } else if (index.column() == USER) {
             return o->user()->username();
         } else if (index.column() == TYPE) {
             return Wt::Wc::Gather::type_to_str(o->type());
         }
     } else if (role == Wt::LinkRole) {
         if (index.column() == VALUE && o->type() == Wt::Wc::Gather::IP) {
             return tApp->path().banned_ip()->get_link(o->value());
         } else if (index.column() == BAN &&
                    o->type() == Wt::Wc::Gather::IP &&
                    !IpBan::is_banned(o->value())) {
             tApp->path().user_view()->set_integer_value(o->user().id());
             return tApp->path().new_ip_ban()->get_link(o->value());
         } else if (index.column() == USER) {
             return tApp->path().user_view()->get_link(o->user().id());
         }
     }
     return ILP::BaseQM::data(index, role);
 }
Ejemplo n.º 14
0
Sawyer::Optional<rose_addr_t>
HexDumpModel::cellAddress(const Wt::WModelIndex &idx) const {
    if (!idx.isValid())
        return Sawyer::Nothing();
    size_t column = idx.column();
    size_t row = idx.row();

    if (column >= bytesColumn && column < bytesColumn + bytesPerRow)
        return cellAddress(row, column - bytesColumn);
    if (column >= asciiColumn && column < asciiColumn + bytesPerRow)
        return cellAddress(row, column - asciiColumn);
    return Sawyer::Nothing();
}
Ejemplo n.º 15
0
Wt::cpp17::any PlaneData::data(const Wt::WModelIndex& index, Wt::ItemDataRole role) const
{
  if (role != Wt::ItemDataRole::Display) {
    return WStandardItemModel::data(index, role);
  }

  double delta_x = (xEnd_ - xStart_)/(rowCount()-2);
  double delta_y = (yEnd_ - yStart_)/(columnCount()-2);
  double x = xStart_ + index.row() * delta_x;
  double y = yStart_ + index.column() * delta_y;

  return 0.2*x - 0.2*y;
}
Ejemplo n.º 16
0
		virtual boost::any data(const Wt::WModelIndex& index, int role = Wt::DisplayRole) const
		{
			if(index.column() >= 6 || index.row() >= (int)_friends.size())
				return boost::any();

			switch (role) 
			{
				case Wt::DisplayRole:
					switch(index.column())
					{
						case COLUMN_AVATAR: return Wt::WString("") ;
						case COLUMN_NAME: return Wt::WString(_friends[index.row()].name) + " (" + Wt::WString(_friends[index.row()].location)+")" ;
						case COLUMN_PGP_ID: return Wt::WString(_friends[index.row()].gpg_id) ;
						case COLUMN_SSL_ID: return Wt::WString(_friends[index.row()].id) ;
						case COLUMN_LAST_S: if(_friends[index.row()].state & RS_PEER_STATE_CONNECTED)
									  return Wt::WString("Now") ;
								  else
									  return lastSeenString(_friends[index.row()].lastConnect) ;
						case COLUMN_IP: 
								  if(_friends[index.row()].state & RS_PEER_STATE_CONNECTED)
								  {
									  std::string s_ip = _friends[index.row()].connectAddr ;

									  return Wt::WString(s_ip + ":{1}").arg(_friends[index.row()].connectPort) ;
								  }
								  else
									  return Wt::WString("---") ;
					}

				case Wt::UserRole:
					return Wt::WString(_friends[index.row()].id) ;

				default:
					return boost::any();
			}
		}
Ejemplo n.º 17
0
boost::any PointsData::data(const Wt::WModelIndex& index,
			    int role) const
{
  if (role == MarkerBrushColorRole) {
    //return WColor(rand()%256, rand()%256, rand()%256);
    return WColor(0, 255, 0);
  } else if (role != DisplayRole) {
    return boost::any();
  }


  const double pi = 3.141592;
  double XYangle = index.row() * (8*pi/nbPts_);
  if (index.column() == 0) {
    return std::cos(XYangle);
  }
  if (index.column() == 1) {
    return std::sin(XYangle);
  }
  if (index.column() == 2) {
    return -5.0 + index.row() * (10.0/nbPts_);
  }
  return boost::any();
}
void ProfileList::doubleClicked(Wt::WModelIndex index, Wt::WMouseEvent event)
{
  LOGDEBUG("cell double clicked:"<< boost::any_cast<Wt::WString>(tableView->model()->data(index.row(),index.column())));
  tableView->select(index);
  db::Preset preset=((ProfileTableModel*)tableView->model())->getPresetAtIndex(index.row());
  openEditDialog(preset);
}
Ejemplo n.º 19
0
 boost::any data(const Wt::WModelIndex& index,
                 int role = Wt::DisplayRole) const {
     dbo::Transaction t(tApp->session());
     const UserPtr& o = resultRow(index.row());
     if (role == Wt::DisplayRole) {
         if (index.column() == NUMBER_COL) {
             return index.row() + 1;
         } else if (index.column() == NAME_COLUMN) {
             return tr("tc.user.User_template")
                    .arg(o->safe_username())
                    .arg(Gravatar::path(o))
                    .arg(o->online() ? tr("tc.user.Online") : "");
         } else if (index.column() == CLASSIFICATION_COLUMN) {
             return o->classification_str();
         } else if (index.column() == DRAWS_COLUMN) {
             return o->games_stat().draws();
         } else if (index.column() == ONLINE_TIME) {
             return td2str(o->online_time());
         }
     } else if (role == Wt::LinkRole) {
         if (index.column() == NAME_COLUMN) {
             return tApp->path().user_view()->get_link(o.id());
         }
     } else if (role == Wt::StyleClassRole) {
         if (index.column() == NAME_COLUMN) {
             return "thechess-user-anchor";
         } else if (index.column() == ALL_COLUMN) {
             return "thechess-games-all";
         } else if (index.column() == WINS_COLUMN) {
             return "thechess-games-wins";
         } else if (index.column() == FAILS_COLUMN) {
             return "thechess-games-fails";
         } else if (index.column() == DRAWS_COLUMN) {
             return "thechess-games-draws";
         } else if (index.column() == RATING_COLUMN) {
             return "thechess-games-rating";
         } else if (index.column() == ONLINE_TIME ||
                    index.column() == REGISTRATION_DATE) {
             return "thechess-datetime";
         }
     }
     t.commit();
     return ULP::BaseQM::data(index, role);
 }
Ejemplo n.º 20
0
boost::any
HexDumpModel::data(const Wt::WModelIndex &index, int role) const {
    ASSERT_require(index.isValid());
    ASSERT_require(index.row() >= 0);                   // Why signed when a valid row is non-negative?
    size_t row = index.row();
    ASSERT_require(row < nRows_);
    ASSERT_require(index.column() >= 0);                // Why signed when a valid column is non-negative?
    size_t column = index.column();
    ASSERT_require(column < endColumn);

    if (role == Wt::DisplayRole) {
        if (column == addressColumn) {
            rose_addr_t va = 0;
            if (rowAddress(row).assignTo(va))
                return Wt::WString(StringUtility::addrToString(va));
            return Wt::WString("");
        } else if (column >= bytesColumn && column < bytesColumn + bytesPerRow) {
            uint8_t byte = 0;
            if (readByte(cellAddress(row, column-bytesColumn)).assignTo(byte) && byte!=0) {
                char buf[8];
                sprintf(buf, "%02x", (unsigned)byte);
                return Wt::WString(buf);
            }
            return Wt::WString("");
        } else if (column >= asciiColumn && column < asciiColumn + bytesPerRow) {
            uint8_t byte = 0;
            std::string s;
            if (readByte(cellAddress(row, column-asciiColumn)).assignTo(byte))
                s = charToString(byte);
            return Wt::WString(s);
        } else if (column == sep1Column || column == sep2Column) {
            return Wt::WString("");
        } else {
            ASSERT_not_reachable("this column needs data");
        }
    } else if (role == Wt::ToolTipRole) {
        MemoryMap::ConstNodeIterator mmNode = memoryMap_->nodes().end();
        rose_addr_t va = 0;
        if (column == addressColumn) {
            mmNode = rowSegment(row);
            va = cellAddress(row, 0).orElse(0);
        } else if (column >= bytesColumn && column < bytesColumn + bytesPerRow &&
                   cellAddress(row, column-bytesColumn).assignTo(va)) {
            mmNode = memoryMap_->at(va).findNode();
        } else if (column >= asciiColumn && column < asciiColumn + bytesPerRow &&
                   cellAddress(row, column-asciiColumn).assignTo(va)) {
            mmNode = memoryMap_->at(va).findNode();
        }
        if (mmNode != memoryMap_->nodes().end()) {
            const AddressInterval &interval = mmNode->key();
            const MemoryMap::Segment &segment = mmNode->value();
            std::string tip = StringUtility::htmlEscape(segment.name());
            if (interval.isContaining(va))
                tip += "+" + StringUtility::addrToString(va-interval.least());
            return Wt::WString(tip);
        }
    } else if (role == Wt::StyleClassRole) {
        if (column==sep1Column || column==sep2Column || !rowAddress(row)) {
            return Wt::WString("hexdump_unmapped");
        } else if (column >= bytesColumn && column < bytesColumn + bytesPerRow && !cellAddress(row, column-bytesColumn)) {
            return Wt::WString("hexdump_unmapped");
        } else if (column >= asciiColumn && column < asciiColumn + bytesPerRow) {
            if (!cellAddress(row, column-asciiColumn)) {
                return Wt::WString("hexdump_unmapped");
            } else if (charToString(*readByte(cellAddress(row, column-asciiColumn))).empty()) {
                return Wt::WString("hexdump_nochar");
            }
        } else if (column == addressColumn) {
            MemoryMap::ConstNodeIterator mmIter = rowSegment(row);
            ASSERT_require(mmIter != memoryMap_->nodes().end()); // would have been caught above
            unsigned a = mmIter->value().accessibility();
            std::string style;
            if (0!=(a & MemoryMap::READABLE))
                style += "r";
            if (0!=(a & MemoryMap::WRITABLE))
                style += "w";
            if (0!=(a & MemoryMap::EXECUTABLE))
                style += "x";
            if (style.empty())
                style = "none";
            return Wt::WString("hexdump_addr_" + style);
        } else if (row % 2) {
            return Wt::WString("hexdump_oddrow");
        } else {
            return Wt::WString("hexdump_evenrow");
        }
    }
    return boost::any();
}