示例#1
0
void Request::modifyProduct(const std::vector<std::string> &splitVector) {
	std::string id = splitVector[1];
	std::string nombre = splitVector[2];
	std::string descripcion = splitVector[3];
	std::string cant = splitVector[4];
	std::stringstream s;
	int cantImagenes;
	s << cant;
	s >> cantImagenes;
	/**/
	this->getCommunication()->send(utils::OK_MESSAGE);
	catalog->updateProduct(id,nombre,descripcion);
	std::string pathIcono = catalog->getPathProductIcons(id);
	utils::Directory dir (pathIcono);
	dir.remove();
	dir.make(pathIcono);
	receiveImage(pathIcono);
	std::string path = catalog->getPathProductImages(id);
	utils::Directory dir1 (path);
	dir1.remove();
	dir1.make(path);
	for(unsigned int i = 0; i < cantImagenes; i++){
		receiveImage(path);
	}
}
示例#2
0
void Client::receiveData(){
       if(type == -1)
           type = readType();
       switch(type){
       case Constants::STRING:
           receiveString();
           break;
       case Constants::IMAGE:
           receiveImage();
           break;
       };
}
示例#3
0
void Request::createProduct(const std::vector<std::string> &splitVector) {
	std::string nombre = splitVector[1];
	std::string descripcion = splitVector[2];
	std::string cantImagenes = splitVector[3];
	int cantidad;
	std::stringstream s;
	s << cantImagenes;
	s >> cantidad;

	std::string attributes;
	attributes = nombre + "|" + descripcion;
	const std::string id = catalog->addProduct(attributes);
	
	std::string path = catalog->getPathProductImages(id);
	std::string pathIconos = catalog ->getPathProductIcons(id);
	this->getCommunication()->send(utils::OK_MESSAGE);
	receiveImage(pathIconos);
	for (int i = 0; i < cantidad; i++){
		receiveImage(path);
	}
}
示例#4
0
文件: App.c 项目: francisquinha/RCOM
int leconnect(bool reconnect)
{
	if (can_reconect && reconnect==FALSE)
	{
		image_already_bytes = 0;
		free(image_bytes);
	}

	if (app.status == APP_STATUS_TRANSMITTER && image_bytes_length <= 0)
	{
		printf("\nNO IMAGE SELECTED!");
	}
	else if (connect() == 0)
	{
		conection_open = TRUE;

		if (
			(app.status == APP_STATUS_TRANSMITTER ?
			sendImage(reconnect) : receiveImage(reconnect)) == 0)
		{
			show_display = NO;
			llclose(app.fd);

			//save file if receiver
			if (app.status == APP_STATUS_RECEIVER){
				if (save2File(image_bytes, image_bytes_length, image_name) != OK){

					printf("\nImage was not saved sucessfully.\n");
					free(image_bytes);
					image_bytes_length = 0;
					return -1;
				}
				free(image_bytes);
				image_bytes_length = 0;
				printf("\nImage was saved sucessfully.\n");
			}

		}
		close_tio(app.fd);
		conection_open = FALSE;

		show_display = NO;

	}

	return 0;
}
示例#5
0
/*! Creates a \c ptImageView instance.
  \param parent
    The image view’s parent widget.
*/
ptImageView::ptImageView(QWidget *AParent):
  QGraphicsView(AParent),
  MinZoom(0.05),
  MaxZoom(4.0),
  MaxImageSize(std::numeric_limits<int>::max()),
  // Cache is split 60/40 between thumbnail list and image view
  FThumbGen(Settings->GetInt("FileMgrThumbCacheSize")*1024*1024 * 0.4, 1)
{
  Q_ASSERT_X(Theme != nullptr, __PRETTY_FUNCTION__, "ptTheme pointer is null.");
  Q_ASSERT_X(Settings != nullptr, __PRETTY_FUNCTION__, "ptSettings pointer is null.");

  ZoomFactors << MinZoom << 0.08 << 0.10 << 0.15 << 0.20 << 0.25 << 0.33 << 0.50 << 0.66 << 1.00
              << 1.50 << 2.00 << 3.00 << MaxZoom;

  this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  this->setFocusPolicy(Qt::NoFocus);

  FThumbGen.connectBroadcast(this, SLOT(receiveImage(uint,TThumbPtr)));

  // Layout to always fill the complete image pane with ViewWindow
  FParentLayout = new QGridLayout(AParent);
  FParentLayout->setContentsMargins(9,9,9,9);
  FParentLayout->setSpacing(0);
  FParentLayout->addWidget(this);
  this->setStyleSheet("QGraphicsView { border: none; }");

  // We create a Graphicsscene and connect it.
  FScene = new QGraphicsScene(0, 0, 0, 0, this);
  this->setScene(FScene);

  // Init
  FPixmapItem        = FScene->addPixmap(QPixmap());
  FPixmapItem->setPos(0,0);
  FZoomMode          = ptZoomMode_Fit;
  FZoomFactor        = 1.0;
  FZoom              = 100;
  FDragDelta         = new QLine();
  FLeftMousePressed  = false;
  FZoomSizeOverlay   = new ptReportOverlay(this, "", QColor(75,150,255), QColor(190,220,255),
                                            1000, Qt::AlignRight, 20);
  FStatusOverlay     = new ptReportOverlay(this, "", QColor(), QColor(), 0, Qt::AlignLeft, 20);
  FStatusOverlay->setColors(QColor(75,150,255), QColor(190,220,255)); // blue
  FStatusOverlay->setDuration(0);

  // timer for decoupling the mouse wheel
  FResizeTimeOut = 50;
  FResizeTimer   = new QTimer(this);
  FResizeTimer->setSingleShot(1);
  connect(FResizeTimer,SIGNAL(timeout()), this,SLOT(resizeTimerExpired()));

  FResizeEventTimer.setSingleShot(true);
  FResizeEventTimer.setInterval(100);
  connect(&FResizeEventTimer, SIGNAL(timeout()), this, SLOT(zoomFit()));

  //-------------------------------------

  // Create actions for context menu
  FZoomInAction = new QAction(tr("Zoom &in") + "\t" + tr("1"), this);
  FZoomInAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-in.png")));
  connect(FZoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));

  FZoom100Action = new QAction(tr("Zoom &100%") + "\t" + tr("2"), this);
  FZoom100Action->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-original.png")));
  connect(FZoom100Action, SIGNAL(triggered()), this, SLOT(zoom100()));

  FZoomOutAction = new QAction(tr("Zoom &out") + "\t" + tr("3"), this);
  FZoomOutAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-out.png")));
  connect(FZoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));

  FZoomFitAction = new QAction(tr("Zoom &fit") + "\t" + tr("4"), this);
  FZoomFitAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-fit.png")));
  connect(FZoomFitAction, SIGNAL(triggered()), this, SLOT(zoomFit()));
}