Exemple #1
0
long double bufferedReadLongDouble(struct BufferedInputStream * bis) {
  if(bis->bytesReadFromBuffer >= bis->bytesReadToBuffer - 1) {
    if(bis->eofRead) {
      setError(bis);
      return 0;
    }
    else {
      refreshBuffer(bis);
    }
  }

  char * tempPtr;
  long double value = (long double) strtod(bis->bufferPointer, &tempPtr);
  if(tempPtr == bis->bufferPointer) {
    setError(bis);
    return 0;
  }

  if (tempPtr >= (bis->bufferStream + bis->bytesReadToBuffer) - 1) {
    if (!bis->eofRead) {
      refreshBuffer(bis);
      value = (long double) strtod(bis->bufferPointer, &tempPtr);
    }
  }

  bis->bytesReadFromBuffer += (tempPtr - bis->bufferPointer);
  bis->bufferPointer = tempPtr;  
  return value;
}
Exemple #2
0
int bufferedReadInt(struct BufferedInputStream * bis) {
  if(bis->bytesReadFromBuffer >= bis->bytesReadToBuffer - 1) {
    if(bis->eofRead) {
      setError(bis);
      return 0;
    }
    else {
      refreshBuffer(bis);
    }
  }

  char * tempPtr;
  int value = (int) strtol(bis->bufferPointer, &tempPtr, 0);
  if(tempPtr == bis->bufferPointer) {
    setError(bis);
    return 0;
  }

  if (tempPtr >= (bis->bufferStream + bis->bytesReadToBuffer) - 1) {
    if (!bis->eofRead) {
      refreshBuffer(bis);
      value = (int) strtol(bis->bufferPointer, &tempPtr, 0);
    }
  }

  bis->bytesReadFromBuffer += (tempPtr - bis->bufferPointer);
  bis->bufferPointer = tempPtr;
  return value;
}
Exemple #3
0
void TabbedWidget::mouseReleaseEvent(QMouseEvent* e)
{
    if (QWhatsThis::inWhatsThisMode()) return;

    int position;
    int width;

    if (e->x() < 0)
        return ;

    for (position = 0, width = 0; (position < int(areas.count())) && (e->x() >= width); position++)
        width += areas[position];

    if ((e->x() <= width) && (e->button() == Qt::LeftButton) && !(current_position == position - 1))
    {
        if (pressed && pressed_position == (position - 1))
        {
            current_position = position - 1;

            refreshBuffer();

            emit itemSelected(items[current_position]);
        }
    }

    pressed = false;
}
Exemple #4
0
TabbedWidget::TabbedWidget(QWidget* parent, const char* name, bool translucency)
    : TranslucentWidget(parent, name, translucency)
{
    current_position = -1;
    pressed = false;
    pressed_position = -1;
    edited_position = -1;

    context_menu = 0;

    if (root_pixmap)
    {
        connect(root_pixmap, SIGNAL(backgroundUpdated(const QPixmap &)), this, SLOT(slotUpdateBuffer(const QPixmap &)));
        root_pixmap->setCustomPainting(true);
    }

    inline_edit = new QLineEdit(this);
    inline_edit->hide();

    connect(inline_edit, SIGNAL(returnPressed()), this, SLOT(slotRenameSelected()));
    connect(inline_edit, SIGNAL(lostFocus()), inline_edit, SLOT(hide()));
    connect(inline_edit, SIGNAL(lostFocus()), this, SLOT(slotResetEditedPosition()));

    selected_font = font();
    unselected_font = font();
    selected_font.setBold(true);

    refreshBuffer();
}
Exemple #5
0
void TabbedWidget::addItem(int session_id)
{
    items.append(session_id);
    areas.append(0);
    captions.append(lowestAvailableCaption());

    refreshBuffer();
}
Exemple #6
0
void TabbedWidget::selectItem(int session_id)
{
    int new_position = items.findIndex(session_id);

    if (new_position != -1)
    {
        current_position = new_position;
        refreshBuffer();
    }
}
Exemple #7
0
void TabbedWidget::selectPreviousItem()
{
    if (current_position != 0)
        current_position--;
    else
        current_position = items.count() - 1;

    refreshBuffer();

    emit itemSelected(items[current_position]);
}
Exemple #8
0
void TabbedWidget::selectNextItem()
{
    if (current_position != int(items.count()) - 1)
        current_position++;
    else
        current_position = 0;

    refreshBuffer();

    emit itemSelected(items[current_position]);
}
Exemple #9
0
void TabbedWidget::selectPosition(int position)
{
    if (position < int(items.count()) && !items.isEmpty())
    {
        current_position = position;

        refreshBuffer();

        emit itemSelected(items[current_position]);
    }
}
Exemple #10
0
void TabbedWidget::renameItem(int session_id, const QString& namep)
{
    int position = items.findIndex(session_id);

    if (position == -1) return;

    QString name = namep.stripWhiteSpace();
    captions[position] = !name.isEmpty() ? name : captions[position];

    refreshBuffer();
}
Exemple #11
0
void TabbedWidget::slotRenameSelected()
{
    if (edited_position >= 0 && edited_position < int(items.count()))
    {
        QString text = inline_edit->text().stripWhiteSpace();
        captions[edited_position] = !text.isEmpty() ? text : captions[edited_position];

        inline_edit->hide();

        edited_position = -1;

        refreshBuffer();
    }
}
Exemple #12
0
char bufferedReadChar(struct BufferedInputStream * bis) {
  if(bis->bytesReadToBuffer >= bis->bytesReadFromBuffer - 1){
    if(bis->eofRead) {
      setError(bis);
      return 0;
    }
    else {
      refreshBuffer(bis);
    }
  }

  char value = *(bis->bufferPointer);
  bis->bufferPointer += 1;
  bis->bytesReadFromBuffer += 1;
  return value;
}
Exemple #13
0
struct BufferedInputStream * bufferedInputStream_sb (FILE * inputStream, unsigned long long bufferSize) {
  struct BufferedInputStream * bis = (struct BufferedInputStream *) malloc(sizeof(struct BufferedInputStream));
  
  bis->inputStream = inputStream;
  bis->bufferStream = (char *) malloc(sizeof(char) * bufferSize);
  bis->bufferPointer = bis->bufferStream;
  bis->bufferSize = bufferSize;
  bis->bytesReadToBuffer = 0;
  bis->bytesReadFromBuffer = 0;
  bis->readError = 0;
  bis->eofRead = 0;
  
  refreshBuffer(bis);
  
  return bis;
}
Exemple #14
0
int TabbedWidget::removeItem(int session_id)
{
    uint position = items.findIndex(session_id);

    items.remove(items.at(position));
    areas.remove(areas.at(position));
    captions.remove(captions.at(position));

    if (position != items.count())
        current_position = position;
    else if (position != 0)
        current_position = position - 1;
    else
        current_position = -1;

    refreshBuffer();

    if (current_position != -1)
        emit itemSelected(items[current_position]);

    return current_position;
}
Exemple #15
0
void TabbedWidget::moveItemRight(int position)
{
    if (position < int(items.count()) - 1)
    {
        int session_id = items[position];
        QString caption = captions[position];

        int neighbor_session_id = items[position+1];
        QString neighbor_caption = captions[position+1];

        items[position+1] = session_id;
        captions[position+1] = caption;

        items[position] = neighbor_session_id;
        captions[position] = neighbor_caption;

        if (position == current_position)
            current_position++;
        else if (position == current_position - 1)
            current_position--;

        refreshBuffer();
    }
}
Exemple #16
0
void TabbedWidget::slotUpdateBuffer(const QPixmap& pixmap)
{
    desktop_image = pixmap;

    refreshBuffer();
}