예제 #1
0
void Downloader::slotFinished(QNetworkReply *reply)
{
    if(reply->error() != QNetworkReply::NoError){
        emit error(getStringError(reply->error()));
    } else {
        emit done(reply->url(), reply->readAll());
    }
    reply->deleteLater();
}
예제 #2
0
/* Recalculate the contents of the lcd display. 
 * note: we don't redraw the lcd here, that is done by drawStackLCD().
 */
void calcStackLCD(){
   int i, j;
   int strLen, pLen, curPos;
   char *c, *p;
   char *txt;     /* the number */
   char label[16];  /* the stack number label */
   int height;
   int indx;
   int row;       /* the row to start print the current number */
   int txtPos;    /* which col do we start printing in */
   int lines;     /* the number of lines this number has */
   int top;       /* which row is the top for drawing the stack */
   int bottom;    /* which row is the current bottom for drawing the stack */
   int labelLen;  /* the stack number label length */
   Number *num;

   if(isEditingEditor()){
      height = lcdHeight - 1;
   } else {
      height = lcdHeight;
   }

   if(height <= 0) return;

   /* clear the old display */
   for(i=0; i<lcdHeight; i++){
      for(j=0; j<lcdWidth; j++){
         lcdText[i][j] = ' ';
      }
   }

   /* check for an error */
   if(isError()){
      top = 1;
      c = getStringError();
      strLen = strlen(c);
      if(strLen > lcdWidth) strLen = lcdWidth;
      strncpy(lcdText[0], c, strLen);
   } else {
      top = 0;
   }
   bottom = height;

   /* print all of the numbers */
   for(indx=0; indx<stackLen(); indx++){

      /* get the number to print */
      if(NULL == (num = getStackEle(indx))) break;

      /* get the text of the number */
      if(indx == 0 || lcdDisplayMode == LONG_DISPLAY){
	 if(NULL == (txt = printNumber(num))) break;
      } else {
	 if(NULL == (txt = printNumberShort(num))) break;
      }
      
      /* how many lines is this number? */
      lines = 1;
      for(p=txt; *p!='\0'; p++) if(*p=='\n'){ lines++; *p='\0'; }

      /* find the starting line of the number */
      row = bottom - lines;
      if(row < top) row = top;

      /* print the stack number label */
      sprintf(label, "%d: ", indx+1);
      labelLen = strlen(label);
      if(labelLen > lcdWidth) labelLen = lcdWidth;
      strncpy(lcdText[row], label, labelLen);

      /* print the number */
      p = txt;         
      for(j=0, i=row; i<bottom && j<lines; i++, j++){
	 pLen = strlen(p);
	 txtPos = lcdWidth - pLen;
	 if(txtPos < labelLen) txtPos = labelLen;
         if(txtPos > lcdWidth) break;

	 strncpy(&(lcdText[i][txtPos]), p, lcdWidth-txtPos);
	 p = p + pLen + 1;
      }

      /* free the mem used to print the number */
      free(txt);

      bottom = bottom - j;

      if(bottom == top) break;

   }

   /* fill in the rest of the indexes */
   for(i=indx, j=bottom; j>top; i++, j--){
      sprintf(label, "%d: ", i+1);
      labelLen = strlen(label);
      if(labelLen > lcdWidth) labelLen = lcdWidth;
      strncpy(lcdText[j-1], label, labelLen);
   }

   if(isEditingEditor()){

      txt = getLineEditor();
      curPos = cursorPosEditor();

      if(curPos > lcdWidth){
         txt += (curPos - lcdWidth);
      }
      strLen = strlen(txt);
      if(strLen > lcdWidth) strLen = lcdWidth;

      strncpy(lcdText[lcdHeight-1], txt, strLen);
   }

}