コード例 #1
0
ファイル: qsqlcachedresult.cpp プロジェクト: aroraujjwal/qt3
bool QtSqlCachedResult::fetch(int i)
{
    if ((!isActive()) || (i < 0))
	return FALSE;
    if (at() == i)
	return TRUE;
    if (d->forwardOnly) {
	// speed hack - do not copy values if not needed
	if (at() > i || at() == QSql::AfterLast)
	    return FALSE;
	while(at() < i - 1) {
	    if (!gotoNext(0))
		return FALSE;
	    setAt(at() + 1);
	}
	if (!gotoNext(d->current))
	    return FALSE;
	setAt(at() + 1);
	return TRUE;
    }
    if (d->seek(i)) {
	setAt(i);
	return TRUE;
    }
    setAt(d->rowCacheEnd - 1);
    while (at() < i) {
	if (!cacheNext())
	    return FALSE;
    }
    return TRUE;
}
コード例 #2
0
void DownloadOperation::onDownloadDataReply()
{
  if (isTerminating()) {
    gotoNext();
    return ;
  }

  UINT32 bufferSize = 1024 * 8;

  try {
    DataOutputStream dos(m_fos);
    dos.writeFully(m_replyBuffer->getDownloadBuffer(),
              m_replyBuffer->getDownloadBufferSize());
  } catch (IOException &ioEx) {
    notifyFailedToDownload(ioEx.getMessage());
    gotoNext();
    return ;
  }

  m_totalBytesCopied += m_replyBuffer->getDownloadBufferSize();

  if (m_copyListener != NULL) {
    m_copyListener->dataChunkCopied(m_totalBytesCopied, m_totalBytesToCopy);
  }

  bool compression = m_replyBuffer->isCompressionSupported();

  m_sender->sendDownloadDataRequest(bufferSize, compression);
}
コード例 #3
0
ファイル: goals.cpp プロジェクト: utcoupe/coupe14
void Fifo::killGoal(int ID){
	if(current_goal != 0){
		struct goal *seek_goal, *deleted_goal;

		seek_goal = current_goal;

		while(seek_goal->next != 0){ //on passe tout les goals a partir du deuxieme en revue
			if(seek_goal->next->ID == ID){ //et on supprime les bons ID
				deleted_goal = seek_goal->next;
				seek_goal->next = deleted_goal->next;

				if(deleted_goal == last_goal)//Si dernier, goal, traiter le cas
					last_goal = seek_goal;

				delete deleted_goal;
				nbrGoals--;
			}
			else
				seek_goal = seek_goal->next;
		}
		
		if(current_goal->ID == ID) //puis on s'occupe du premier
			gotoNext();
	}
}
コード例 #4
0
void DownloadOperation::processFile()
{
  m_fileOffset = 0;

  File targetFile(m_pathToTargetFile.getString());

  if (targetFile.exists()) {
    FileInfo *sourceFileInfo = m_toCopy->getFileInfo();
    FileInfo targetFileInfo(&targetFile);

    int action = m_copyListener->targetFileExists(sourceFileInfo,
                                                  &targetFileInfo,
                                                  m_pathToTargetFile.getString());
    switch (action) {
    case CopyFileEventListener::TFE_OVERWRITE:
      break;
    case CopyFileEventListener::TFE_SKIP:
      m_totalBytesCopied += sourceFileInfo->getSize();
      gotoNext();
      return ;
    case CopyFileEventListener::TFE_APPEND:
      m_fileOffset = targetFileInfo.getSize();
      break;
    case CopyFileEventListener::TFE_CANCEL:
      if (!isTerminating()) {
        terminate();
      } 
      return ;
    default:
      _ASSERT(FALSE);
    } 
  } 

  m_sender->sendDownloadRequest(m_pathToSourceFile.getString(), m_fileOffset);
}
コード例 #5
0
void DownloadOperation::gotoNext()
{
  FileInfoList *current = m_toCopy;

  bool hasChild = current->getChild() != NULL;
  bool hasNext = current->getNext() != NULL;
  bool hasParent = current->getFirst()->getParent() != NULL;

  if (hasChild) {
    // If it has child, we must download child file list first
    changeFileToDownload(current->getChild());
    startDownload();
  } else if (hasNext) {
    // If it has no child, but has next file, we must download next file
    changeFileToDownload(current->getNext());
    startDownload();
  } else {

    //
    // If it has no child and not next, but has parent file,
    // we must go to parent file (folder i mean), set childs to NULL
    // cause we already download child files and go to next file.
    //

    FileInfoList *first = current->getFirst();
    if (hasParent) {
      changeFileToDownload(first->getParent());
      m_toCopy->setChild(NULL, 0);

      gotoNext();
    } else {
      killOp();
    } // if / else
  } // if / else
} // void
コード例 #6
0
void DownloadOperation::gotoNext()
{
  FileInfoList *current = m_toCopy;

  bool hasChild = current->getChild() != NULL;
  bool hasNext = current->getNext() != NULL;
  bool hasParent = current->getFirst()->getParent() != NULL;

  if (hasChild) {
    changeFileToDownload(current->getChild());
    startDownload();
  } else if (hasNext) {
    changeFileToDownload(current->getNext());
    startDownload();
  } else {

    FileInfoList *first = current->getFirst();
    if (hasParent) {
      changeFileToDownload(first->getParent());
      m_toCopy->setChild(NULL, 0);

      gotoNext();
    } else {
      killOp();
    } 
  } 
} 
コード例 #7
0
ファイル: arghintwidget.cpp プロジェクト: aschet/qsaqt5
ArgHintWidget::ArgHintWidget( QWidget *parent, const char*name )
    : QFrame( parent, Qt::Popup ), curFunc( 0 ), numFuncs( 0 )
{
	setObjectName( name );
	setFrameStyle( QFrame::Box | QFrame::Plain );
    setLineWidth( 1 );
	QPalette palette;
	palette.setColor( backgroundRole(), Qt::white );
	setPalette( palette );
    QHBoxLayout *hbox = new QHBoxLayout( this );
    hbox->setMargin( 1 );
    hbox->addWidget( ( prev = new ArrowButton( this, "editor_left_btn", ArrowButton::Left ) ) );
    hbox->addWidget( ( funcLabel = new QLabel( this ) ) );
	funcLabel->setObjectName( "editor_func_lbl" );
    hbox->addWidget( ( next = new ArrowButton( this, "editor_right_btn", ArrowButton::Right ) ) );
    funcLabel->setPalette( palette );
    funcLabel->setAlignment( Qt::AlignCenter );
    connect( prev, SIGNAL( clicked() ), this, SLOT( gotoPrev() ) );
    connect( next, SIGNAL( clicked() ), this, SLOT( gotoNext() ) );
    updateState();
    setFocusPolicy( Qt::NoFocus );
    prev->setFocusPolicy( Qt::NoFocus );
    next->setFocusPolicy( Qt::NoFocus );
    funcLabel->setFocusPolicy( Qt::NoFocus );
}
コード例 #8
0
void MediaSlideshow::setMediaSlideshow(const std::vector<ds::Resource>& resources){
	clearSlideshow();

	mCurItemIndex = 0;

	for(auto it = resources.begin(); it < resources.end(); ++it){
		MediaViewer* mv = new MediaViewer(mEngine, (*it));
		mv->setSettings(mMediaViewerSettings); 
		mv->setDefaultBounds(getWidth(), getHeight());
		mv->setDefaultSize(ci::Vec2f(getWidth(), getHeight()));
		mHolder->addChildPtr(mv);
		mv->setSwipeCallback([this](ds::ui::Sprite* spr, const ci::Vec3f& amount){
			// don't advance if we're zoomed in
			if(spr->getWidth() <= getWidth()){
				if(amount.x > 20.0f){
					gotoPrev(false);
				} else if(amount.x < -20.0f){
					gotoNext(false);
				}
			}
		});
		mv->setAnimateDuration(mAnimateDuration);
		mv->setDoubleTapCallback([this, mv](ds::ui::Sprite* bs, const ci::Vec3f& pos){
			callAfterDelay([this]{recenterSlides(); }, 0.01f);
		});
		mViewers.push_back(mv);
	}

	loadCurrentAndAdjacent();
	layout();
	recenterSlides();
}
コード例 #9
0
ファイル: listarray.cpp プロジェクト: mitchellreyes/CS202
bool List::insertBefore(int number){
	if(full()){
		return false;
	}
	//will take care of empty
	if(empty()){
		cursor+=1;
		actual+=1;
		data[cursor] = number;
		return true;
	}else{
		if(cursor > actual){
			cursor = actual;
		}
		if(cursor == 0){
			gotoNext();
		}
		for(int i = actual+1; i > cursor-1; i--){
			data[i] = data[i-1];
		}
		cursor -= 1;
		data[cursor] = number;
		return true;
	}

}
コード例 #10
0
ファイル: cutScenes.cpp プロジェクト: kidsang/GlassTD2
bool cutScenes::run(float timeSinceLastFrame){ 
	if(!mDirectshowControl->mDirectshowTexture->isPlayingMovie())
	{
		gotoNext();
	}

	return true;
};
コード例 #11
0
ファイル: cutScenes.cpp プロジェクト: kidsang/GlassTD2
bool cutScenes::onKeyPressed(const OIS::KeyEvent &arg)
{
	if(arg.key == OIS::KC_ESCAPE)
	{
		gotoNext();
	}
	return true;
};
コード例 #12
0
bool dbAnyCursor::moveNext() 
{
    if (!removed) { 
        return gotoNext(); 
    } else {
        removed = false;
        return !lastRecordWasDeleted;
    }
}
コード例 #13
0
ファイル: qsqlcachedresult.cpp プロジェクト: aroraujjwal/qt3
bool QtSqlCachedResult::cacheNext()
{
    if (!gotoNext(d->next())) {
	d->revertLast();
	return FALSE;
    }
    setAt(at() + 1);
    return TRUE;
}
コード例 #14
0
ファイル: UploadOperation.cpp プロジェクト: sim0629/tightvnc
void UploadOperation::onUploadDataReply()
{
    if (isTerminating()) {
        gotoNext();
        return ;
    }

    sendFileDataChunk();
}
コード例 #15
0
ファイル: UploadOperation.cpp プロジェクト: sim0629/tightvnc
bool UploadOperation::specialHandler()
{
    // If first upload that start real upload operation
    if (m_firstUpload) {
        m_firstUpload = false;
        startUpload();
        return true;
    }
    // Call real gotoNext method
    if (m_gotoChild) {
        m_gotoChild = false;
        gotoNext(false);
        return true;
    }
    if (m_gotoParent) {
        m_gotoParent = false;
        gotoNext(false);
        return true;
    }
    return false;
}
コード例 #16
0
void DownloadOperation::onDownloadDataReply(DataInputStream *input)
{
  if (isTerminating()) {
    gotoNext();
    return ;
  }

  UINT32 bufferSize = 1024*64;

  try {
    DataOutputStream dos(m_fos);
    if (!m_replyBuffer->getDownloadBuffer().empty()) {
      dos.writeFully(&m_replyBuffer->getDownloadBuffer().front(),
                     m_replyBuffer->getDownloadBufferSize());
    }
  } catch (IOException &ioEx) {
    notifyFailedToDownload(ioEx.getMessage());
    gotoNext();
    return ;
  }

  //
  // Notify that we receive some data
  //

  m_totalBytesCopied += m_replyBuffer->getDownloadBufferSize();

  if (m_copyListener != NULL) {
    m_copyListener->dataChunkCopied(m_totalBytesCopied, m_totalBytesToCopy);
  }

  //
  // Send next download data request
  //

  bool compression = m_replyBuffer->isCompressionSupported();

  m_sender->sendDownloadDataRequest(bufferSize, compression);
}
コード例 #17
0
bool ZSqliteCipherCachedResult::fetch(int i)
{
    if ((!isActive()) || (i < 0))
        return false;
    if (at() == i)
        return true;
    if (d->forwardOnly) {
        // speed hack - do not copy values if not needed
        if (at() > i || at() == QSql::AfterLastRow)
            return false;
        while(at() < i - 1) {
            if (!gotoNext(d->cache, -1))
                return false;
            setAt(at() + 1);
        }
        if (!gotoNext(d->cache, 0))
            return false;
        setAt(at() + 1);
        return true;
    }
    if (d->canSeek(i)) {
        setAt(i);
        return true;
    }
    if (d->rowCacheEnd > 0)
        setAt(d->cacheCount());
    while (at() < i + 1) {
        if (!cacheNext()) {
            if (d->canSeek(i))
                break;
            return false;
        }
    }
    setAt(i);

    return true;
}
コード例 #18
0
void DownloadOperation::onLastRequestFailedReply()
{

  if (m_foldersToCalcSizeLeft > 0) {
    decFoldersToCalcSizeCount();
  } else {
    StringStorage message;

    m_replyBuffer->getLastErrorMessage(&message);

    notifyFailedToDownload(message.getString());

    gotoNext();
  }
}
コード例 #19
0
int dbAnyCursor::seek(oid_t oid)
{
    int pos = 0;
    if (gotoFirst()) { 
        do { 
            if (currId == oid) { 
                if (prefetch) { 
                    fetch();
                }
                return pos;
            }
            pos += 1;
        } while (gotoNext());
    }
    return -1;
}
コード例 #20
0
ファイル: UploadOperation.cpp プロジェクト: sim0629/tightvnc
void UploadOperation::onUploadEndReply()
{
    // Cleanup
    try {
        m_fis->close();
    }
    catch (...) { }
    delete m_fis;
    m_fis = NULL;

    delete m_file;
    m_file = NULL;

    // Upload next file in the list
    gotoNext();
}
コード例 #21
0
ファイル: UploadOperation.cpp プロジェクト: sim0629/tightvnc
void UploadOperation::sendFileDataChunk()
{
    _ASSERT(m_fis != NULL);

    const size_t bufferSize = 1024 * 8;
    vector<char> buffer(bufferSize);
    UINT32 read = 0;
    try {
        size_t portion = m_fis->read(&buffer.front(), bufferSize);
        _ASSERT((UINT32)portion == portion);
        read = (UINT32)portion;
    } catch (EOFException) {

        //
        // End of file.
        //

        m_fis->close();

        UINT64 lastModified = 0;

        try {
            lastModified = m_file->lastModified();
        } catch (IOException) { } // try / catch

        m_sender->sendUploadEndRequest(0, lastModified);
        return ;

    } catch (IOException &ioEx) {
        notifyFailedToUpload(ioEx.getMessage());
        gotoNext();
        return ;
    } // try / catch

    try {
        m_sender->sendUploadDataRequest(&buffer.front(), read, false);
        m_totalBytesCopied += read;

        // Notify listener, that data chunk is copied
        if (m_copyListener != NULL) {
            m_copyListener->dataChunkCopied(m_totalBytesCopied,
                                            m_totalBytesToCopy);
        }
    } catch (IOException &ioEx) {
        throw ioEx;
    } // try / catch
}
コード例 #22
0
void DownloadOperation::onDownloadReply(DataInputStream *input)
{
  //
  // Cleanup
  //

  if (m_fos != NULL) {
    try { m_fos->close(); } catch (...) { }
    delete m_fos;
  }
  if (m_file != NULL) {
    delete m_file;
  }

  //
  // Try to create file on local file system and open it for writting
  //

  m_file = new File(m_pathToTargetFile.getString());

  if (m_fileOffset == 0) {
    m_file->truncate();
  }

  try {
    StringStorage path;
    m_file->getPath(&path);
    m_fos = new WinFileChannel(path.getString(), F_WRITE, FM_OPEN);
    // Seek to initial file position to continue writting
    m_fos->seek((INT64)m_fileOffset);
    m_totalBytesCopied += m_fileOffset;
  } catch (Exception &ioEx) {
    notifyFailedToDownload(ioEx.getMessage());
    gotoNext();
    return;
  }

  //
  // Send first request for file data
  //

  UINT32 dataSize = 1024*64;
  bool compression = m_replyBuffer->isCompressionSupported();

  m_sender->sendDownloadDataRequest(dataSize,
                                    compression);
}
コード例 #23
0
bool ZSqliteCipherCachedResult::cacheNext()
{
    if (d->atEnd)
        return false;

    if(isForwardOnly()) {
        d->cache.clear();
        d->cache.resize(d->colCount);
    }

    if (!gotoNext(d->cache, d->nextIndex())) {
        d->revertLast();
        d->atEnd = true;
        return false;
    }
    setAt(at() + 1);
    return true;
}
コード例 #24
0
bool dbAnyCursor::skip(int n) { 
    while (n > 0) { 
        if (!gotoNext()) { 
            return false;
        }
        n -= 1;
    } 
    while (n < 0) { 
        if (!gotoPrev()) { 
            return false;
        }
        n += 1;
    } 
    if (prefetch) { 
        fetch();
    }
    return true;
}
コード例 #25
0
byte* dbAnyCursor::fetchNext()
{
    if (!removed) {
        if (gotoNext()) {
            fetch();
            return record;
        }
    } else { 
        removed = false; 
        if (currId != 0 && !lastRecordWasDeleted) { 
            if (!prefetch) { 
                fetch();
            }
            return record;
        }
    }
    return NULL;
}
コード例 #26
0
void DownloadOperation::onDownloadEndReply()
{

  try { m_fos->close(); } catch (...) { }
  delete m_fos;
  m_fos = NULL;

  try {
    m_file->setLastModified(m_replyBuffer->getDownloadLastModified());
  } catch (...) {
    notifyFailedToDownload(_T("Cannot set modification time"));
  }

  delete m_file;
  m_file = NULL;

  gotoNext();
}
コード例 #27
0
ファイル: UploadOperation.cpp プロジェクト: sim0629/tightvnc
void UploadOperation::onLastRequestFailedReply()
{
    StringStorage errDesc;

    m_replyBuffer->getLastErrorMessage(&errDesc);

    notifyFailedToUpload(errDesc.getString());

    //
    // If this LRF message comes to file list request, then
    // don't need to upload next file, we must execute "special message handler".
    //

    if (specialHandler()) {
        return ;
    }

    gotoNext();
}
コード例 #28
0
void RemoteFilesDeleteOperation::onLastRequestFailedReply()
{
  //
  // Logging
  //

  StringStorage errorMessage;
  m_replyBuffer->getLastErrorMessage(&errorMessage);

  StringStorage remotePath;
  getRemotePath(m_toDelete, m_pathToTargetRoot.getString(), &remotePath);

  StringStorage message;
  message.format(_T("Error: %s ('%s')"), errorMessage.getString(),
                 remotePath.getString());

  notifyError(message.getString());

  // Delete next file
  gotoNext();
}
コード例 #29
0
void DownloadOperation::processFolder()
{
  File local(m_pathToTargetFile.getString());
  if (local.exists() && local.isDirectory()) {
  } else {
    if (!local.mkdir()) {
      StringStorage message;

      message.format(_T("Error: failed to create local '%s' folder"),
                     m_pathToTargetFile.getString());

      notifyError(message.getString());

      gotoNext();
      return ;
    }
  }

  m_sender->sendFileListRequest(m_pathToSourceFile.getString(),
                                m_replyBuffer->isCompressionSupported());
}
コード例 #30
0
void DownloadOperation::onLastRequestFailedReply(DataInputStream *input)
{
  //
  // This LRF message received from get folder size request
  // we do need to download next file
  //

  if (m_foldersToCalcSizeLeft > 0) {
    decFoldersToCalcSizeCount();
  } else {
    // Logging
    StringStorage message;

    m_replyBuffer->getLastErrorMessage(&message);

    notifyFailedToDownload(message.getString());

    // Download next file
    gotoNext();
  }
}