Beispiel #1
0
SignatureDlg::SignatureDlg(TransferHandler *transfer, const KUrl &dest, QWidget *parent, Qt::WFlags flags)
  : KGetSaveSizeDialog("SignatureDlg", parent, flags),
    m_signature(transfer->signature(dest)),
    m_fileModel(transfer->fileModel())
{
    setCaption(i18nc("Signature here is meant in cryptographic terms, so the signature of a file.", "Signature of %1.", dest.fileName()));
    QWidget *widget = new QWidget(this);
    ui.setupUi(widget);
    ui.loadSignature->setIcon(KIcon("document-open"));
    ui.verify->setIcon(KIcon("document-encrypt"));
    setMainWidget(widget);

    ui.information->setCloseButtonVisible(false);
    ui.information->setWordWrap(true);
    if (m_signature) {
        connect(ui.loadSignature, SIGNAL(clicked(bool)), this, SLOT(loadSignatureClicked()));
        connect(ui.verify, SIGNAL(clicked()), this, SLOT(verifyClicked()));
        connect(ui.signature, SIGNAL(textChanged()), this, SLOT(textChanged()));
        connect(m_signature, SIGNAL(verified(int)), this, SLOT(updateData()));

        if (m_fileModel) {
            m_file = m_fileModel->index(dest, FileItem::File);
            connect(m_fileModel, SIGNAL(fileFinished(KUrl)), this, SLOT(fileFinished(KUrl)));
        }

        updateData();
        updateButtons();
    } else {
void DJDownloadManager::httpDone( bool error )
{
	djDebug() << "httpDone error = " << error << m_http->state();
	djDebug() << "error string = "<<m_http->errorString();
	if ( error ) {
		m_file->setFileName("");
	}
	m_file->close();
	m_progress->cancel();
	
	if ( QHttp::Unconnected == m_http->state() ) {
		djDebug() << "emit fileFinished";
		QHttpResponseHeader response	= m_http->lastResponse();
		int lastStatusCode	= 0;
		if ( response.isValid() ) {
			lastStatusCode	= response.statusCode();
		}
		m_isDownloading	= false;
		emit fileFinished( m_file, m_localFile, m_fileType, m_id, m_name, lastStatusCode );
	}else {
		djDebug() << "close http";
		m_http->close();
	}
}
Beispiel #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    thread = new QThread();
    reader = new Reader();

    reader->moveToThread(thread);
    connect(reader, SIGNAL(sendPoint(int,int,double)),
            this, SLOT(setPointProb(int,int,double)));
    connect(reader, SIGNAL(workRequested()), thread, SLOT(start()));
    connect(thread, SIGNAL(started()), reader, SLOT(doWork()));
    connect(reader, SIGNAL(finished()),
            thread, SLOT(quit()) , Qt::DirectConnection);
    connect(reader, SIGNAL(finished()),
            this, SLOT(fileFinished()));
    connect(reader, SIGNAL(sendReset()), this, SLOT(resetPositions()));

    setFixedSize(800,600);
    p_scene = new QGraphicsScene(this);
    p_view = new QGraphicsView(p_scene, this);

    QPixmap background(QCoreApplication::applicationDirPath() +
                                   "/img/sol.png");
    if (background.isNull()) {
        std::cout << "Ouverture de sol.png échouée, ouverture de sol.jpg" << std::endl;
        background = QPixmap(QCoreApplication::applicationDirPath() +
                                       "/img/sol.jpg");
    }

    p_scene->setBackgroundBrush(QBrush(background));
    p_view->setGeometry(10,10,505,505);

    p_addPosition = new QPushButton("Ajouter position", this);
    p_addPosition->setGeometry(590,90, 120, 30);

    p_deletePos = new QPushButton("Réinitialiser positions", this);
    p_deletePos->setGeometry(590,130, 120, 30);

    p_openFile = new QPushButton("Ouvrir fichier", this);
    p_openFile->setGeometry(590, 170, 120, 30);

    p_changeTableSize = new QPushButton("Changer taille table", this);
    p_changeTableSize->setGeometry(50, 560, 120, 30);

    pauseButton = new QPushButton("", this);
    QIcon pauseIcon(QCoreApplication::applicationDirPath() + "/img/pause.png");
    if (pauseIcon.isNull()) {
        std::cout << "Ouverture de pause.png échouée, ouverture de pause.jpg" << std::endl;
        pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/pause.jpg"));
    }
    pauseButton->setIcon(pauseIcon);
    pauseButton->setGeometry(590, 250, 30, 30);
    pauseButton->setDisabled(true);

    stopButton = new QPushButton("", this);
    QIcon stopIcon(QCoreApplication::applicationDirPath() + "/img/stop.png");
    if (stopIcon.isNull()) {
        std::cout << "Ouverture de stop.png échouée, ouverture de stop.jpg" << std::endl;
        pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/stop.jpg"));
    }
    stopButton->setIcon(stopIcon);
    stopButton->setGeometry(630, 250, 30, 30);
    stopButton->setDisabled(true);

    stepButton = new QPushButton("", this);
    QIcon stepIcon(QCoreApplication::applicationDirPath() + "/img/step.png");
    if (stepIcon.isNull()) {
        std::cout << "Ouverture de step.png échouée, ouverture de step.jpg" << std::endl;
        stepIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/step.jpg"));
    }
    stepButton->setIcon(stepIcon);
    stepButton->setGeometry(670, 250, 30, 30);
    stepButton->setDisabled(true);

    p_quit = new QPushButton("Quitter", this);
    p_quit->setGeometry(600, 560, 100, 30);

    p_addPosX = new QLineEdit(this);
    p_addPosY = new QLineEdit(this);
    p_addPosP = new QLineEdit(this);

    p_addPosX->setGeometry(580, 50, 40, 30);
    p_addPosY->setGeometry(630, 50, 40, 30);
    p_addPosP->setGeometry(680, 50, 40, 30);

    p_addPosX->setPlaceholderText("Abscisse");
    p_addPosY->setPlaceholderText("Ordonnée");
    p_addPosP->setPlaceholderText("Proba");

    currentDate = new QLabel("Pas de fichier en cours", this);
    currentDate->setGeometry(580, 300, 140, 30);


    QObject::connect(p_addPosition, SIGNAL(clicked()),
                     this, SLOT(sendPointProbValues()));
    QObject::connect(this, SIGNAL(pointProbValues(int,int,double)),
                     this, SLOT(setPointProb(int,int,double)));
    QObject::connect(p_deletePos, SIGNAL(clicked()),
                     this, SLOT(resetPositions()));
    QObject::connect(p_quit, SIGNAL(clicked()),
                     qApp, SLOT(quit()));
    QObject::connect(p_openFile, SIGNAL(clicked()),
                     this, SLOT(readMatrixFromFile()));
    QObject::connect(p_changeTableSize, SIGNAL(clicked()),
                     this, SLOT(changeTableSize()));
    QObject::connect(pauseButton, SIGNAL(clicked()),
                     this, SLOT(pauseRead()));
    QObject::connect(stopButton, SIGNAL(clicked()),
                     this, SLOT(stopRead()));
    QObject::connect(reader, SIGNAL(sendDate(QString)),
                     this, SLOT(setDate(QString)));
    QObject::connect(stepButton, SIGNAL(clicked()),
                     this, SLOT(clickNextDate()));


}
Beispiel #4
0
void AttachFileItem::updateItem()
{
	/* fill in */
#ifdef DEBUG_ITEM
	std::cerr << "AttachFileItem::updateItem():" << mFileName;
	std::cerr << std::endl;
#endif

	/* Extract File Details */
	/* Update State if necessary */

	FileInfo fi;
	bool stateChanged = false;
	int msec_rate = 1000;

	if ((mMode == AFI_STATE_ERROR) || (mMode == AFI_STATE_LOCAL))
	{
#ifdef DEBUG_ITEM
		std::cerr << "AttachFileItem::updateItem() STATE=Local/Error ignore";
		std::cerr << std::endl;
#endif
		/* ignore - dead file, or done */
	}
	else if (mMode == AFI_STATE_EXTRA)
	{
#ifdef DEBUG_ITEM
		std::cerr << "AttachFileItem::updateItem() STATE=Extra File";
		std::cerr << std::endl;
#endif
		/* check for file status */
		if (rsFiles->ExtraFileStatus(mPath.toUtf8().constData(), fi))
		{
#ifdef DEBUG_ITEM
			std::cerr << "AttachFileItem::updateItem() STATE=>Local";
			std::cerr << std::endl;
#endif
			mMode = AFI_STATE_LOCAL;

			/* fill in file details */
			mFileName = QString::fromUtf8(fi.fname.c_str());
			mFileSize = fi.size;
			mFileHash = fi.hash;

			/* have path already! */

			stateChanged = true;
		}
	}
	else
	{
		FileSearchFlags hintflags(0u);
		switch(mMode)
		{
			case AFI_STATE_REMOTE:
				hintflags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY;
				break;
			case AFI_STATE_DOWNLOAD:
				hintflags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY;
				break;
			case AFI_STATE_UPLOAD:
				hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_SPEC_ONLY;
				break;
		}

		bool detailsOk = rsFiles->FileDetails(mFileHash, hintflags, fi);

		/* have details - see if state has changed */
		switch(mMode)
		{
			case AFI_STATE_REMOTE:
#ifdef DEBUG_ITEM
				std::cerr << "AttachFileItem::updateItem() STATE=Remote";
				std::cerr << std::endl;
#endif
				/* is it downloading? */
				if (detailsOk)
				{
#ifdef DEBUG_ITEM
					std::cerr << "AttachFileItem::updateItem() STATE=>Download";
					std::cerr << std::endl;
#endif
					/* downloading */
					mMode = AFI_STATE_DOWNLOAD;
					stateChanged = true;
				}
				break;
			case AFI_STATE_DOWNLOAD:
#ifdef DEBUG_ITEM
					std::cerr << "AttachFileItem::updateItem() STATE=Download";
					std::cerr << std::endl;
#endif

				if (!detailsOk)
				{
#ifdef DEBUG_ITEM
					std::cerr << "AttachFileItem::updateItem() STATE=>Remote";
					std::cerr << std::endl;
#endif
					mMode = AFI_STATE_REMOTE;
					stateChanged = true;
				}
				else
				{
					/* has it completed? */
					if (fi.avail == mFileSize)
					{
#ifdef DEBUG_ITEM
						std::cerr << "AttachFileItem::updateItem() STATE=>Local";
						std::cerr << std::endl;
#endif
						/* save path */
						/* update progress */
						mMode = AFI_STATE_LOCAL;
						mPath = QString::fromUtf8(fi.path.c_str());
						stateChanged = true;
					}
					progressBar->setValue(fi.avail / mDivisor);
				}
				break;
			case AFI_STATE_UPLOAD:
#ifdef DEBUG_ITEM
				std::cerr << "AttachFileItem::updateItem() STATE=Upload";
				std::cerr << std::endl;
#endif

				if (detailsOk)
				{
					progressBar->setValue(fi.avail / mDivisor);
				}

				/* update progress */
				break;
		}
	}

	/****** update based on new state ******/
	if (stateChanged)
	{
		updateItemStatic();
	}

	uint32_t repeat = 0;

	switch (mMode)
	{
		case AFI_STATE_ERROR:
			repeat = 0;
			break;

		case AFI_STATE_EXTRA:
			repeat = 1;
			msec_rate = 5000; /* slow */
			break;

		case AFI_STATE_REMOTE:
			repeat = 1;
			msec_rate = 30000; /* very slow */
			break;

		case AFI_STATE_DOWNLOAD:
			repeat = 1;
			msec_rate = 2000; /* should be download rate dependent */
			break;

		case AFI_STATE_LOCAL:
			repeat = 0;
			emit fileFinished(this);
			hide(); // auto hide
			break;

		case AFI_STATE_UPLOAD:
			repeat = 1;
			msec_rate = 2000; /* should be download rate dependent */
			break;
	}
	
	if (repeat)
	{
#ifdef DEBUG_ITEM
		std::cerr << "AttachFileItem::updateItem() callback for update!";
		std::cerr << std::endl;
#endif
	  	QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
	}
}