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();
  }
  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();
  }