public void editUser(String name, String password, String rights) throws InvalidPacketException {
    QByteArray data = new QByteArray();
    QByteArray value = new QByteArray(name + "\n" + password + "\n" + rights);
    QDataStream s = new QDataStream(data, QIODevice.OpenModeFlag.WriteOnly);

    s.writeInt(value.length());
    data.append(value);
    data.prepend(USER);

    sendData(data);

    while (socket.bytesAvailable() < 1) socket.waitForReadyRead(10000);

    if (socket.read(1).at(0) != 4) throw new InvalidPacketException();
  }
  public void editProduct(String pId, String pName, String pPrice) throws InvalidPacketException {
    QByteArray data = new QByteArray();
    QByteArray value = new QByteArray(pId + "\n" + pName + "\n" + pPrice);
    QDataStream s = new QDataStream(data, QIODevice.OpenModeFlag.WriteOnly);

    s.writeInt(value.length());
    data.append(value);
    data.prepend(PRODUCT);

    sendData(data);

    while (socket.bytesAvailable() < 1) socket.waitForReadyRead(10000);

    if (socket.read(1).at(0) != 4) throw new InvalidPacketException();
  }
Exemplo n.º 3
0
  void setData(String mimetype, QByteArray newData) {
    mimeType = mimetype;
    data = new QByteArray(newData);

    dragDropLabel.setText(String.valueOf(data.size()) + " bytes.");

    List<String> formats = new Vector<String>();
    formats.add(mimetype);
    mimeTypes.emit(formats);
  }
  public String addVoucher(double value) throws InvalidPacketException {
    QByteArray data = new QByteArray();
    QByteArray v = new QByteArray(value + "");
    QDataStream s = new QDataStream(data, QIODevice.OpenModeFlag.WriteOnly);

    s.writeInt(v.length());
    data.append(v);
    data.prepend(VOUCHER);

    sendData(data);

    while (socket.bytesAvailable() < 5) // int
    socket.waitForReadyRead(10000);

    if (socket.read(1).at(0) != 4) throw new InvalidPacketException();

    int length = (new QDataStream(socket)).readInt();
    while (socket.bytesAvailable() < length) socket.waitForReadyRead(10000);

    return socket.read(length).toString();
  }
Exemplo n.º 5
0
  private void createActions() {
    openAct = new QAction(tr("&Open..."), this);
    openAct.setShortcut(tr("Ctrl+O"));
    openAct.triggered.connect(this, "open()");

    saveAsActs = new LinkedList<QAction>();
    for (QByteArray format : QImageWriter.supportedImageFormats()) {
      String text = new String(format.toByteArray()).toUpperCase() + "...";

      QAction action = new QAction(text, this);
      action.setData(format);
      action.triggered.connect(this, "save()");
      saveAsActs.add(action);
    }

    printAct = new QAction(tr("&Print..."), this);
    printAct.triggered.connect(scribbleArea, "print()");

    exitAct = new QAction(tr("E&xit"), this);
    exitAct.setShortcut(tr("Ctrl+Q"));
    exitAct.triggered.connect(this, "close()");

    penColorAct = new QAction(tr("&Pen Color..."), this);
    penColorAct.triggered.connect(this, "penColor()");

    penWidthAct = new QAction(tr("Pen &Width..."), this);
    penWidthAct.triggered.connect(this, "penWidth()");

    clearScreenAct = new QAction(tr("&Clear Screen"), this);
    clearScreenAct.setShortcut(tr("Ctrl+L"));
    clearScreenAct.triggered.connect(scribbleArea, "clearImage()");

    aboutAct = new QAction(tr("&About"), this);
    aboutAct.triggered.connect(this, "about()");

    aboutQtAct = new QAction(tr("About &Qt"), this);
    aboutQtAct.triggered.connect(QApplication.instance(), "aboutQt()");
  }
Exemplo n.º 6
0
 private void save() {
   QAction action = (QAction) QSignalEmitter.signalSender();
   QByteArray fileFormat = QVariant.toByteArray(action.data());
   saveFile(new String(fileFormat.toByteArray()));
 }