void Shoter::onButtonSendClicked() { /*Create file */ QDate date = QDate::currentDate(); QString name_file = date.toString(); QString savedFile = name_file+".png"; QTemporaryFile file; file.setFileName(savedFile); if (!m_screenshot.save(&file)) { qDebug("file is not saved"); exit(1); } // qDebug()<<file.fileName(); QFile *openFile = new QFile(savedFile); openFile->open(QIODevice::ReadOnly); QHttpMultiPart *multi = new QHttpMultiPart(QHttpMultiPart::FormDataType); /* Upload to ipix.su */ if (ui->comboBox->currentIndex()== 0) { QHttpPart file; file.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("image/png")); file.setHeader(QNetworkRequest::ContentDispositionHeader,QVariant("form-data; name=\"file\"; filename=\""+savedFile+"\"")); file.setBodyDevice(openFile); openFile->setParent(multi); multi->append(file); this->upload("http://ipix.su/api/upload",multi); /* upload to pix.academ.org */ } else if (ui->comboBox->currentIndex() == 1) { QHttpPart action; action.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("name=\"action\"")); action.setBody("upload_image"); QHttpPart image; image.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png")); image.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\"; filename=\""+savedFile+"\"")); image.setBodyDevice(openFile); openFile->setParent(multi); multi->append(action); multi->append(image); upload("http://pix.academ.org", multi); /* Upload to ompldr.org*/ } else if (ui->comboBox->currentIndex() == 2) { QHttpPart file1; file1.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png")); file1.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file1\"; filename=\""+savedFile+"\"")); file1.setBodyDevice(openFile); openFile->setParent(multi); multi->append(file1); upload("http://ompldr.org/upload", multi); } }
void QuickOpenTest::testProjectFileFilter() { KTempDir dir; TestProject* project = new TestProject(KUrl(dir.name())); ProjectFolderItem* foo = createChild<ProjectFolderItem>(project->projectItem(), "foo"); createChild<ProjectFileItem>(foo, "bar"); createChild<ProjectFileItem>(foo, "asdf"); ProjectFolderItem* asdf = createChild<ProjectFolderItem>(project->projectItem(), "asdf"); createChild<ProjectFileItem>(asdf, "bar"); QTemporaryFile tmpFile; tmpFile.setFileName(dir.name() + "aaaa"); QVERIFY(tmpFile.open()); ProjectFileItem* aaaa = new ProjectFileItem(project, KUrl(tmpFile.fileName()), project->projectItem()); QCOMPARE(project->fileSet().size(), 4); ProjectFileDataProvider provider; QCOMPARE(provider.itemCount(), 0u); projectController->addProject(project); const QStringList original = QStringList() << "aaaa" << "asdf/bar" << "foo/asdf" << "foo/bar"; // lazy load QCOMPARE(provider.itemCount(), 0u); provider.reset(); QCOMPARE(items(provider), original); QCOMPARE(provider.itemText(provider.items().first()), aaaa->url().pathOrUrl()); QCOMPARE(provider.data(0)->text(), QString("aaaa")); // don't show opened file QVERIFY(core->documentController()->openDocument(KUrl(tmpFile.fileName()))); // lazy load again QCOMPARE(items(provider), original); provider.reset(); QCOMPARE(items(provider), QStringList() << "asdf/bar" << "foo/asdf" << "foo/bar"); // prefer files starting with filter provider.setFilterText("as"); qDebug() << items(provider); QCOMPARE(items(provider), QStringList() << "foo/asdf" << "asdf/bar"); // clear filter provider.reset(); QCOMPARE(items(provider), QStringList() << "asdf/bar" << "foo/asdf" << "foo/bar"); // update on document close, lazy load again core->documentController()->closeAllDocuments(); QCOMPARE(items(provider), QStringList() << "asdf/bar" << "foo/asdf" << "foo/bar"); provider.reset(); QCOMPARE(items(provider), original); ProjectFileItem* blub = createChild<ProjectFileItem>(project->projectItem(), "blub"); // lazy load QCOMPARE(provider.itemCount(), 4u); provider.reset(); QCOMPARE(provider.itemCount(), 5u); // ensure we don't add stuff multiple times QMetaObject::invokeMethod(&provider, "fileAddedToSet", Q_ARG(KDevelop::IProject*, project), Q_ARG(KDevelop::IndexedString, blub->indexedUrl())); QCOMPARE(provider.itemCount(), 5u); provider.reset(); QCOMPARE(provider.itemCount(), 5u); // lazy load in this implementation delete blub; QCOMPARE(provider.itemCount(), 5u); provider.reset(); QCOMPARE(provider.itemCount(), 4u); QCOMPARE(items(provider), original); projectController->closeProject(project); provider.reset(); QVERIFY(!provider.itemCount()); }