本文整理汇总了C++中kio::StoredTransferJob::setUiDelegate方法的典型用法代码示例。如果您正苦于以下问题:C++ StoredTransferJob::setUiDelegate方法的具体用法?C++ StoredTransferJob::setUiDelegate怎么用?C++ StoredTransferJob::setUiDelegate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kio::StoredTransferJob
的用法示例。
在下文中一共展示了StoredTransferJob::setUiDelegate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: putAndGet
void JobRemoteTest::putAndGet()
{
const QString filePath = remoteTmpDir() + "putAndGetFile";
KUrl u(filePath);
KIO::TransferJob* job = KIO::put( u, 0600, KIO::Overwrite | KIO::HideProgressInfo );
QDateTime mtime = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago
mtime.setTime_t(mtime.toTime_t()); // hack for losing the milliseconds
job->setModificationTime(mtime);
job->setUiDelegate( 0 );
connect( job, SIGNAL( result(KJob*) ),
this, SLOT( slotResult(KJob*) ) );
connect( job, SIGNAL(dataReq(KIO::Job*, QByteArray&)),
this, SLOT(slotDataReq(KIO::Job*, QByteArray&)) );
m_result = -1;
m_dataReqCount = 0;
enterLoop();
QVERIFY( m_result == 0 ); // no error
m_result = -1;
KIO::StoredTransferJob* getJob = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
getJob->setUiDelegate( 0 );
connect( getJob, SIGNAL( result( KJob* ) ),
this, SLOT( slotGetResult( KJob* ) ) );
enterLoop();
QCOMPARE( m_result, 0 ); // no error
QCOMPARE( m_data, QByteArray("This is a test for KIO::put()\n") );
//QCOMPARE( m_data.size(), 11 );
}
示例2: slotProcessGoogleResult
void ThumbnailPicker::slotProcessGoogleResult(KJob *result)
{
//Preload ImageList with the URLs in the object's ImageList:
QStringList ImageList( Object->ImageList() );
if (result->error())
{
result->uiDelegate()->showErrorMessage();
result->kill();
return;
}
QString PageHTML(static_cast<KIO::StoredTransferJob*>(result)->data());
int index = PageHTML.indexOf( "src=\"http:", 0 );
while ( index >= 0 )
{
index += 5; //move to end of "src=\"http:" marker
//Image URL is everything from index to next occurrence of "\""
ImageList.append( PageHTML.mid( index, PageHTML.indexOf( "\"", index ) - index ) );
index = PageHTML.indexOf( "src=\"http:", index );
}
//Total Number of images to be loaded:
int nImages = ImageList.count();
if ( nImages )
{
ui->SearchProgress->setMinimum( 0 );
ui->SearchProgress->setMaximum( nImages-1 );
ui->SearchLabel->setText( i18n( "Loading images..." ) );
}
else
{
close();
return;
}
//Add images from the ImageList
for ( int i=0; i<ImageList.size(); ++i ) {
QString s( ImageList[i] );
QUrl u( ImageList[i] );
if ( u.isValid() ) {
KIO::StoredTransferJob *j = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
j->setUiDelegate(0);
connect( j, SIGNAL( result(KJob*) ), SLOT( slotJobResult(KJob*) ) );
}
}
}
示例3: openFileReading
void JobRemoteTest::openFileReading()
{
const QString filePath = remoteTmpDir() + "openFileReading";
KUrl u(filePath);
const QByteArray putData("test1test2test3test4test5");
KIO::StoredTransferJob * putJob = KIO::storedPut( putData,
u,
0600, KIO::Overwrite | KIO::HideProgressInfo
);
QDateTime mtime = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago
mtime.setTime_t(mtime.toTime_t()); // hack for losing the milliseconds
putJob->setModificationTime(mtime);
putJob->setUiDelegate( 0 );
connect( putJob, SIGNAL( result(KJob*) ),
this, SLOT( slotResult(KJob*) ) );
m_result = -1;
enterLoop();
QVERIFY( m_result == 0 ); // no error
m_rwCount = 4;
m_data = QByteArray();
fileJob = KIO::open(u, QIODevice::ReadOnly);
fileJob->setUiDelegate( 0 );
connect( fileJob, SIGNAL( result(KJob*) ),
this, SLOT( slotResult(KJob*) ) );
connect( fileJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
this, SLOT(slotFileJob2Data(KIO::Job*, const QByteArray&)) );
connect( fileJob, SIGNAL(open(KIO::Job*)),
this, SLOT(slotFileJob2Open(KIO::Job*)) );
connect( fileJob, SIGNAL(written(KIO::Job *, KIO::filesize_t)),
this, SLOT(slotFileJob2Written (KIO::Job *, KIO::filesize_t)) );
connect( fileJob, SIGNAL(position (KIO::Job *, KIO::filesize_t)),
this, SLOT(slotFileJob2Position (KIO::Job *, KIO::filesize_t)) );
connect( fileJob, SIGNAL(close(KIO::Job*)),
this, SLOT(slotFileJob2Close(KIO::Job*)) );
m_result = -1;
enterLoop();
QVERIFY( m_result == 0 ); // no error
kDebug() << "resulting m_data: " << QString(m_data);
QCOMPARE( m_data, QByteArray("test5test4test3test2test1"));
}
示例4: slotSetFromURL
void ThumbnailPicker::slotSetFromURL() {
//Attempt to load the specified URL
QUrl u = ui->ImageURLBox->url();
if ( u.isValid() ) {
if ( u.isLocalFile() ) {
QFile localFile( u.toLocalFile() );
//Add image to list
//If image is taller than desktop, rescale it.
QImage im( localFile.fileName() );
if ( im.isNull() ) {
KMessageBox::sorry( 0,
i18n("Failed to load image at %1", localFile.fileName() ),
i18n("Failed to load image") );
return;
}
uint w = im.width();
uint h = im.height();
uint pad = 0;/* FIXME later 4*marginHint() + 2*ui->SearchLabel->height() + actionButton( Ok )->height() + 25; */
uint hDesk = QApplication::desktop()->availableGeometry().height() - pad;
if ( h > hDesk )
im = im.scaled( w*hDesk/h, hDesk, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
//Add Image to top of list and 50x50 thumbnail image and URL to top of listbox
PixList.insert( 0, new QPixmap( QPixmap::fromImage( im ) ) );
ui->ImageList->insertItem( 0, new QListWidgetItem ( QIcon(shrinkImage( PixList.last(), 50 )), u.url() ));
//Select the new image
ui->ImageList->setCurrentRow( 0 );
slotSetFromList(0);
} else {
KIO::StoredTransferJob *j = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
j->setUiDelegate(0);
connect( j, SIGNAL( result(KJob*) ), SLOT( slotJobResult(KJob*) ) );
}
}
}
示例5: openFileWriting
void JobRemoteTest::openFileWriting()
{
m_rwCount = 0;
const QString filePath = remoteTmpDir() + "openFileWriting";
KUrl u(filePath);
fileJob = KIO::open(u, QIODevice::WriteOnly);
fileJob->setUiDelegate( 0 );
connect( fileJob, SIGNAL( result(KJob*) ),
this, SLOT( slotResult(KJob*) ) );
connect( fileJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
this, SLOT(slotFileJobData(KIO::Job*, const QByteArray&)) );
connect( fileJob, SIGNAL(open(KIO::Job*)),
this, SLOT(slotFileJobOpen(KIO::Job*)) );
connect( fileJob, SIGNAL(written(KIO::Job *, KIO::filesize_t)),
this, SLOT(slotFileJobWritten (KIO::Job *, KIO::filesize_t)) );
connect( fileJob, SIGNAL(position (KIO::Job *, KIO::filesize_t)),
this, SLOT(slotFileJobPosition (KIO::Job *, KIO::filesize_t)) );
connect( fileJob, SIGNAL(close(KIO::Job*)),
this, SLOT(slotFileJobClose(KIO::Job*)) );
m_result = -1;
enterLoop();
QEXPECT_FAIL("", "Needs fixing in kio_file", Abort);
QVERIFY( m_result == 0 ); // no error
KIO::StoredTransferJob* getJob = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
getJob->setUiDelegate( 0 );
connect( getJob, SIGNAL( result( KJob* ) ),
this, SLOT( slotGetResult( KJob* ) ) );
enterLoop();
QCOMPARE( m_result, 0 ); // no error
kDebug() << "m_data: " << m_data;
QCOMPARE( m_data, QByteArray("test....test....test....test....test....test....end") );
}
示例6: slotFillList
//Query online sources for images of the object
void ThumbnailPicker::slotFillList() {
//Preload ImageList with the URLs in the object's ImageList:
QStringList ImageList( Object->ImageList() );
//Query Google Image Search:
KUrl gURL( "http://images.google.com/images" );
//Search for the primary name, or longname and primary name
QString sName = QString("%1 ").arg( Object->name() );
if ( Object->longname() != Object->name() ) {
sName = QString("%1 ").arg( Object->longname() ) + sName;
}
gURL.addQueryItem( "q", sName ); //add the Google-image query string
//Download the google page and parse it for image URLs
parseGooglePage( ImageList, gURL.prettyUrl() );
//Total Number of images to be loaded:
int nImages = ImageList.count();
if ( nImages ) {
ui->SearchProgress->setMinimum( 0 );
ui->SearchProgress->setMaximum( nImages-1 );
ui->SearchLabel->setText( i18n( "Loading images..." ) );
}
//Add images from the ImageList
for ( int i=0; i<ImageList.size(); ++i ) {
QString s( ImageList[i] );
KUrl u( ImageList[i] );
if ( u.isValid() ) {
KIO::StoredTransferJob *j = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
j->setUiDelegate(0);
connect( j, SIGNAL( result(KJob*) ), SLOT( slotJobResult(KJob*) ) );
}
}
}