Exemplo n.º 1
0
	RESULT YaDiskRVFSDriver::uploadFile(const QString& path, const QString& title,  const QString& /*Id*/, const QString& parentId)
	{
		QString xmlResp;
		QString id = ROOT_ID;
		QFileInfo fInfo(path);
		if (fInfo.size() == 0)
		{
			return eNO_ERROR;
		}

        RESULT err = m_httpConnector->uploadFile(path, title, parentId, xmlResp);
		unsigned int retryUploadCounter = 0;

		while(err != eNO_ERROR && retryUploadCounter < MAX_UPLOAD_RETRY)
		{
            err = m_httpConnector->uploadFile(path, title, parentId, xmlResp);
			retryUploadCounter++;
		}

		VFSElement elem;
		if(!err)
		{
			QFileInfo fInfo(path);
			id = fInfo.fileName();

			VFSCache* vfsCache = WebMounter::getCache();
			elem = VFSElement(VFSElement::FILE
				, fInfo.absoluteFilePath()
				, title
				, ""
				, ""
				, id
				, id
				, parentId
				, ""
                , m_pluginName);

			vfsCache->insert(elem);

			QFile::Permissions permissions = QFile::permissions(elem.getPath());
			permissions &= ~(QFile::WriteGroup|QFile::WriteOwner|QFile::WriteUser|QFile::WriteOther);
			QFile::setPermissions(elem.getPath(), permissions);
		}
		else
		{
			notifyUser(Ui::Notification::eCRITICAL
				, tr("Error")
				, tr("File upload failed (") + elem.getName() + QString(")"));
		}

		WebMounter::getProxy()->fileUploaded(fInfo.absoluteFilePath(), err);
		return err;
	}
Exemplo n.º 2
0
/**
 * Task operation method
 */
void TTOpenVideoTask::operation()
{
	QFileInfo fInfo(mFileName);

	if (!fInfo.exists())
		throw new TTFileNotFoundException(__FILE__, __LINE__, QString(tr("file %1 does not exists!")).arg(fInfo.filePath()));

	mpVideoType = new TTVideoType(fInfo.absoluteFilePath());

	if (mpVideoType->avStreamType() != TTAVTypes::mpeg2_demuxed_video) 
		throw new TTDataFormatException(__FILE__, __LINE__, QString(tr("unsupported video type %1")).arg(fInfo.filePath()));

	mpVideoStream = new TTMpeg2VideoStream(fInfo);

	connect(mpVideoStream, SIGNAL(statusReport(int, const QString&, quint64)),
					this,          SLOT(onStatusReport(int, const QString&, quint64)));

  mpVideoStream->createHeaderList();
 	mpVideoStream->createIndexList();

	mpVideoStream->indexList()->sortDisplayOrder();

  if (mpVideoType != 0) delete mpVideoType;
  mpVideoType = 0;

	emit finished(mpAVItem, mpVideoStream, mOrder);
}
Exemplo n.º 3
0
void AnimationList::addNewFile()
{
  //// For some unknown reason passing "this" locks up the OSX qavimator window. Possibly a QT4 bug, needs investigation
#ifdef __APPLE__
  QStringList files=QFileDialog::getOpenFileNames(NULL, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER);
#else
  QStringList files=QFileDialog::getOpenFileNames(this, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER);
#endif

  if(files.isEmpty())
    return;
  else
  {
    QFileInfo fInfo(files.last());
    Settings::Instance()->setLastPath(fInfo.absoluteDir().absolutePath());
  }

  foreach(QString file, files)
  {
    if(file.isEmpty() || availableAnimations.contains(file))
      continue;
    else
    {
      if(file.endsWith(".avm", Qt::CaseInsensitive) || file.endsWith(".bvh", Qt::CaseInsensitive))
        availableAnimations.append(files);
    }
  }
  QStringListModel* model =  dynamic_cast<QStringListModel*>(ui->availableAnimsListView->model());
  model->setStringList(availableAnimations);                //TODO: this is sooo lame. Find a dignified way
  onSelectionChanged();
}
Exemplo n.º 4
0
void DirComparator::processFile(const QString &fileName)
{
    if(fileName.isEmpty() || fileName.isNull())
        return;
    #ifdef MYPREFIX_DEBUG
    qDebug() << "DuplicateFinder::processFile";
#endif
    QFileInfo fInfo(fileName);
    if( fInfo.isFile() && fInfo.isReadable() )
    {
        QByteArray qb = fileChecksum(fileName, hashAlgo);
        if(!qb.isNull() && !qb.isEmpty())
        {
            HashFileInfoStruct st;
            st.fileName = fileName;
            st.size = fInfo.size();
            st.checked = false;
            st.hash = QString(qb);
            hashByHash.insert(st.hash, st);
        }
    }
    ++processed_files;
    if(processed_files %10 == 0)
        emit currentProcessedFiles(processed_files);
}
Exemplo n.º 5
0
ChoosePic::ChoosePic(QWidget* parent, const char* name, bool modal, WFlags fl)
        : ChoosePicBase(parent, name, modal, fl)
{
#ifdef DESKTOP
    //QDir d(QString(IQNOTES_PICDIR) + "/iqnotes/items");
    QDir d(QDir(QString(IQNOTES_PICDIR) + "/iqnotes/items").absPath());
#else
    QDir d(QString("/opt/QtPalmtop/pics") + "/iqnotes/items");
#endif
    picNames = d.entryList();

    PicsList->insertItem("none");
    for(QStringList::Iterator it = picNames.begin(); it != picNames.end(); ++it )
    {
        QString fName = *it;
        QFileInfo fInfo(fName);

        QString fListName = fName.left(fName.length() - fInfo.extension().length() - 1);
        
#ifdef DESKTOP
        PicsList->insertItem(QPixmap(QString(IQNOTES_PICDIR) + "/iqnotes/items/" + *it), fListName);
#else
        PicsList->insertItem(QPixmap(QString("/opt/QtPalmtop/pics") + "/iqnotes/items/" + *it), fListName);
#endif
    }

    PicsList->setCurrentItem(0);
}
Exemplo n.º 6
0
QString copyFileToDir(const QString &srcPath, const QDir & targetDir)
{
    qDebug()<<"Copying file "<<srcPath<<" to dir "<<targetDir.absolutePath();

    int i =0;

    QFileInfo fInfo(srcPath);
    QString ext = fInfo.completeSuffix();
    QString basename = fInfo.baseName();
    QString fileName = fInfo.fileName();// ex: file.jpg

    //If the file already exists in the target dir attempt to generate a new one with a numeric suffix
    while(targetDir.exists(fileName)){
        fileName = QString("%1_%2.%3").arg(basename).arg(i).arg(ext);
        ++i;
    }

    QFile srcFile(srcPath);
    const QString & targetPath = targetDir.filePath(fileName);
    if(srcFile.copy(targetPath)){
        qDebug()<<"Copied file from "<<srcPath<<" to "<<targetPath;
        //If the original file is in a temporary directory we will move it
        if(srcPath.startsWith("tmp:")){
            qDebug("Removing file");
            if(!srcFile.remove()){
                qWarning()<<"Failed to remove file "<<srcPath<<" error "<< srcFile.errorString();
            }
        }
        return fileName;
    }
    else{
        qWarning()<<"Failed to copy file "<<srcPath<<" to "<<targetPath;
        return QString();
    }
}
Exemplo n.º 7
0
DTC::LiveStreamInfo *Content::AddRecordingLiveStream( int              nChanId,
                                                      const QDateTime &dtStartTime,
                                                      int              nMaxSegments,
                                                      int              nWidth,
                                                      int              nHeight,
                                                      int              nBitrate,
                                                      int              nAudioBitrate,
                                                      int              nSampleRate )
{
    if (!dtStartTime.isValid())
        throw( "StartTime is invalid" );

    // ------------------------------------------------------------------
    // Read Recording From Database
    // ------------------------------------------------------------------

    ProgramInfo pginfo( (uint)nChanId, dtStartTime );

    if (!pginfo.GetChanID())
    {
        LOG( VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed")
                                    .arg( nChanId )
                                    .arg( dtStartTime.toString() ));
        return NULL;
    }

    if ( pginfo.GetHostname().toLower() != gCoreContext->GetHostName().toLower())
    {
        // We only handle requests for local resources

        QString sMsg =
            QString("GetRecording: Wrong Host '%1' request from '%2'.")
                          .arg( gCoreContext->GetHostName())
                          .arg( pginfo.GetHostname() );

        LOG(VB_UPNP, LOG_ERR, sMsg);

        throw HttpRedirectException( pginfo.GetHostname() );
    }

    QString sFileName( GetPlaybackURL(&pginfo) );

    // ----------------------------------------------------------------------
    // check to see if the file exists
    // ----------------------------------------------------------------------

    if (!QFile::exists( sFileName ))
    {
        LOG( VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed")
                                    .arg( nChanId )
                                    .arg( dtStartTime.toString() ));
        return NULL;
    }

    QFileInfo fInfo( sFileName );

    return AddLiveStream( pginfo.GetStorageGroup(), fInfo.fileName(),
                          pginfo.GetHostname(), nMaxSegments, nWidth,
                          nHeight, nBitrate, nAudioBitrate, nSampleRate );
}
Exemplo n.º 8
0
// Returns a string list of details about the file
// in the order EXISTS, DATE, SIZE
QStringList StorageGroup::GetFileInfo(QString filename)
{
    LOG(VB_FILE, LOG_DEBUG, LOC + 
        QString("GetFileInfo: For '%1'") .arg(filename));

    QStringList details;
    bool searched = false;

    if (!FileExists(filename))
    {
        searched = true;
        filename = FindFile(filename);
    }

    if ((searched && !filename.isEmpty()) ||
        (FileExists(filename)))
    {
        QFileInfo fInfo(filename);

        details << filename;
        details << QString("%1").arg(fInfo.lastModified().toTime_t());
        details << QString("%1").arg(fInfo.size());
    }

    return details;
}
//! Add item to list
int TTAudioListData::addItem(QString fName, TTAudioStream* aStream)
{
  TTAudioHeader* header;
  QFileInfo fInfo(fName);

  TTAudioListDataItem item(fInfo, aStream);

  // audio stream have constant properties, so we can use the first header
  header = aStream->headerAt(0);

  item.audioLength = QString("%1 (%2 MB)")
  			.arg(aStream->streamLengthTime().toString("hh:mm:ss.zzz"))
  			.arg((double)aStream->streamLengthByte()/1024.0/1024.0);
  //item.audioLength.sprintf("%s (%0.2lf MB)",
  //    qPrintable(aStream->streamLengthTime().toString("hh:mm:ss.zzz")),
  //    (double)aStream->streamLengthByte()/1024.0/1024.0);
  
  item.audioVersion    = header->descString();
  item.audioBitrate    = header->bitRateString();
  item.audioSamplerate = header->sampleRateString();
  item.audioMode       = header->modeString();
  
  // FIXME: use real delay value for audio delay
  item.audioDelay      = "0";
  
  data.append(item);

  // return current index position in data list
  return data.count()-1;
}
/*
 * If a file is double-clicked, load it in a different thread to prevent locking the GUI
 */
void PlottingWidget::fileSelected(QListWidgetItem *item)
{
    tlbl->setText("Loading "+item->text());
    progBar->setVisible(true);
    progBar->setRange(0,0);
    progBar->setValue(0);

    LoadBigFile *loadFile = new LoadBigFile(item->text());

    connect(loadFile, SIGNAL(sendFileData(QVector<QVector<QPointF> >)), this, SLOT(initEcg(QVector<QVector<QPointF> >)));

    loadFile->start();

    //Read header file and display information about the recording
    QFileInfo fInfo(item->text());
    QFile headerFile(fInfo.baseName()+"_header.txt");
    if (headerFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream headerTextStream(&headerFile);
        QString headerText;

        while (!headerTextStream.atEnd()) {
            headerText += headerTextStream.readLine() + "\n";
        }

        headerTextArea->setText(headerText);
        headerTextStream.flush();
        headerFile.close();
    }
}
Exemplo n.º 11
0
void Editor::focusInEvent ( QFocusEvent * event )
{
	QsciScintilla::focusInEvent(event);

	// Check if file was modified
	QFileInfo fInfo(file);
	if (fInfo.exists()) {
		QDateTime fileTime = fInfo.lastModified();
        QString s1 = lastModifiedTime.toString();
		QString s2 = fileTime.toString();
        if (lastModifiedTime < fileTime) {
			lastModifiedTime = QDateTime::currentDateTime();
			QString name = QFileInfo(file).fileName().toLower();
			if (name != "mariamole_auto_generated.h") {
				if (GetUserConfirmation("File was modified outside editor. Do you want to reload it?\n" +file) == false)  {
					return;
				}
			}
		
			QFile inFile(file);
			if (!inFile.open(QFile::ReadOnly)) {
				ErrorMessage(tr("Cannot read file %1:\n%2.").arg(file).arg(inFile.errorString()));			
				return;
			}
			QTextStream in(&inFile);
			QApplication::setOverrideCursor(Qt::WaitCursor);
			QString txt(in.readAll());
			setText(txt);				
			setModified(false);
			QApplication::restoreOverrideCursor();
        }
	} // file exists
}
Exemplo n.º 12
0
void WidgetStrainVideo::deserializeShapes(const QString &path)
{
    QString fullpath = path + QDir::separator() + currentFilename + "_shapemap";
    qDebug() << "Loading shapes for" << currentFilename;

    QFileInfo fInfo(fullpath);
    if (!fInfo.exists()) return;
    shapes = Serialization::readShapeMap(fullpath);
}
Exemplo n.º 13
0
Responder::Responder(QHttpRequest *req, QHttpResponse *resp, QObject *parent) : QObject(parent)
{
    m_req = req;
    connect(req, SIGNAL(end()), resp, SLOT(end()));
    connect(resp, SIGNAL(done()), this, SLOT(deleteLater()));


    bool flag = false;
    QString ext;
    QByteArray blob;
    QString fName = req->path();
    if(fName.isEmpty()||(fName=="/")) fName = "index.html";
    fName = QApplication::applicationDirPath() +"/html/" + fName;
    QString reqBody = QUrlQuery(req->url()).queryItemValue("ob");
    if(QFile::exists(fName)) {

        QFile file(fName);
        QFileInfo fInfo(file);
        QRegExp extExpr("^.*\\.([^\\.]+)$");
        if(extExpr.indexIn(fInfo.fileName())!=-1) {
            ext = extExpr.cap(1);
        }
        if(file.open(QIODevice::ReadOnly)) {
            blob = file.readAll();
            flag = true;
            file.close();
        }
    }else if(!reqBody.isEmpty()){
        fName = req->url().fileName();
        if(fName=="din.txt") {
            blob = DynReqManager::getData(fName,reqBody).toUtf8();
            flag = true;
        }else if(fName=="ain.txt") {
            blob = DynReqManager::getData(fName,reqBody).toUtf8();
            flag = true;
        }else if(fName=="message.txt") {
            blob = DynReqManager::getData(fName,reqBody).toUtf8();
            flag = true;
        }else if(fName=="status.txt") {
            blob = DynReqManager::getData(fName,reqBody).toUtf8();
            flag = true;
        }
    }
    if(flag) {
        if(ext=="css") resp->setHeader("Content-Type", "text/css");
        else if(ext=="js") resp->setHeader("Content-Type", "text/javascript");
        else if(ext=="png") resp->setHeader("Content-Type", "image/png");
        else resp->setHeader("Content-Type", "text/html");
        resp->writeHead(200);
        resp->write(blob);
    }else {
        resp->writeHead(403);
        resp->write(QByteArray("File not found!"));
    }
}
Exemplo n.º 14
0
//! Set the mpeg stream
void TTCutOutFrame::initVideoStream(TTMpeg2VideoStream *vs)
{
  currentMpeg2Stream = vs;
  QFileInfo fInfo(vs->filePath());

  mpeg2Stream = new TTMpeg2VideoStream(fInfo);
  mpeg2Stream->makeSharedCopy( vs );

  mpegWindow->openVideoStream( mpeg2Stream );
  mpegWindow->moveToFirstFrame( false );
}
Exemplo n.º 15
0
void
Project::saveAs()
{
    if ( m_projectManagerUi == NULL )
        return ;
    QFileInfo fInfo( *m_projectFile );
    const QString& fileName = m_projectManagerUi->getProjectFileDestination( fInfo.absolutePath() );
    if ( fileName.isEmpty() )
        return ;
    saveProject( fileName );
    emit projectUpdated( name() );
}
Exemplo n.º 16
0
QString
Project::name()
{
    if ( m_projectName.isEmpty() == true )
    {
        Q_ASSERT( m_projectFile != NULL );

        QFileInfo       fInfo( *m_projectFile );
        return fInfo.baseName();
    }
    return m_projectName;
}
Exemplo n.º 17
0
	RESULT YaDiskRVFSDriver::getElements(QList<VFSElement>& elements)
	{
		RESULT err = eERROR_GENERAL;
		for(int i=0; i<elements.count()&&elements[i].getType()==VFSElement::DIRECTORY; i++)
		{
			QString xmlResp = "";
			QString path = elements[i].getSrcUrl();
            err = m_httpConnector->getTreeElements(path, xmlResp);
			if(err || xmlResp.length() == 0)
			{
				continue;
			}

			QDomDocument xml;
			xml.setContent(xmlResp);
			QDomElement  root         = xml.firstChildElement(); // <multistatus> root element
			QDomNode  responseElement = root.firstChildElement(); // <response>

			while(!responseElement.isNull())
			{
				VFSElement elem;

				parseEntry(responseElement, elem);
				if(elem.getSrcUrl() != elements[i].getSrcUrl()) // skip duplicates
				{
					elem.setParentId(elements[i].getId());
					QString path = elements[i].getPath() + QString(QDir::separator()) + elem.getName();
					QFileInfo fInfo(path);
					elem.setPath(fInfo.absoluteFilePath());

					elem.setDownloaded(false);
					elements.append(elem);
				}

				responseElement = responseElement.nextSibling(); //next element
			}
		}

		if(err == eNO_ERROR)
		{
			//Populate path for elemenets
			for(int k=0, count = elements.count(); k < count; k++)
			{
				elements[k].setPath(QFileInfo(getElementPath(elements, elements[k])).absoluteFilePath());
			}

			handleNameDuplicates(elements);
		}

		return err;
	}
Exemplo n.º 18
0
//! Sets up the default file dialog box.
//! @see Window()
void Window::openFileDialog()
{
	QString fileURI = QFileDialog::getOpenFileName(
			this, tr("Open data file"), comboInfile->currentText(),
			tr("All Files (*.*);;Data files (*.dat *.bin)"));
	QFileInfo fInfo(fileURI);
	if(fInfo.exists()) {
		int dupeIndex = comboInfile->findText(
				fileURI, Qt::MatchFixedString | Qt::MatchCaseSensitive);
		if(dupeIndex >= 0) comboInfile->removeItem(dupeIndex);
		comboInfile->insertItem(0, QDir::convertSeparators(fileURI));
		comboInfile->setCurrentIndex(0);
	}
}
Exemplo n.º 19
0
/*
 * Show the file open dialog 
 */
void TTVideoFileInfo::onFileOpen()
{
  QString fn = QFileDialog::getOpenFileName( this,
      tr("Open video file"),
      TTCut::lastDirPath,
      "Video (*.m2v *.mpv)" );

  if( !fn.isEmpty() )
  {
    QFileInfo fInfo( fn );
    TTCut::lastDirPath = fInfo.absolutePath();
    emit fileOpened( fn );
  }
}
Exemplo n.º 20
0
void FormPlaylist::sortMod()
{
	QList< quint64 > sList[2];
	quint64 tmp = 0;
	for ( int i = 0 ; i < playList[2].count() ; i++ )
	{
		QFileInfo fInfo( playList[2][i] );
		tmp = fInfo.lastModified().toTime_t();
		if ( tmp == 4294967295LL )
			tmp = 4294967296LL;
		sList[0] += tmp;
		sList[1] += tmp;
	}
	sortDattebayo( sList, 4294967297LL );
}
Exemplo n.º 21
0
ObjectData::ObjectData(const QString &fName):
    name(""),comment(""),htmlPageName(""),waitTime(0),period(1)
{
    QDomDocument doc("objConfig");
    QFile file(fName);
    if (!file.open(QIODevice::ReadOnly)) return;
    if (!doc.setContent(&file)) {
        return;
    }
    if(doc.elementsByTagName("objConf").count()!=1) return;
    QDomNodeList names = doc.elementsByTagName("name");
    if(names.count()==1) {
        QDomElement e = names.item(0).toElement();
        if(!e.isNull()) name = e.text();
    }
    QDomNodeList comments = doc.elementsByTagName("comment");
    if(comments.count()==1) {
        QDomElement e = comments.item(0).toElement();
        if(!e.isNull()) comment = e.text();
    }
    QDomNodeList pages = doc.elementsByTagName("pageName");
    if(pages.count()==1) {
        QDomElement e = pages.item(0).toElement();
        if(!e.isNull()) htmlPageName = e.text();
    }
    QDomNodeList perTime = doc.elementsByTagName("period");
    if(perTime.count()==1) {
        QDomElement e = perTime.item(0).toElement();
        if(!e.isNull()) period = e.text().toInt();
    }
    QDomNodeList wait = doc.elementsByTagName("wait");
    if(wait.count()==1) {
        QDomElement e = wait.item(0).toElement();
        if(!e.isNull()) waitTime = e.text().toInt();
    }
    QDomNodeList plcs = doc.elementsByTagName("controller");
    for(int i=0;i<plcs.count();i++) {
        QDomNode n = plcs.item(i);
        QDomElement e = n.toElement();
        if(!e.isNull()) {
            QFileInfo fInfo(file);
            QString plcFileName = fInfo.absoluteDir().absolutePath() + "/" + e.attribute("file");
            QSharedPointer<ControllerData> ptr = QSharedPointer<ControllerData>(new ControllerData(plcFileName));
            controllers.append(ptr);
        }
    }
}
Exemplo n.º 22
0
void CVSService::slotRemoveFromCVSIgnore()
{
  if (!m_defaultFile.isEmpty())
  {
    if (m_defaultFile.startsWith(m_repositoryPath))
    {
      emit clearMessages();
      QString content;
      QFileInfo fInfo(m_defaultFile);
      QFile f(fInfo.dirPath()+ "/.cvsignore");
      bool found = false;
      if (f.open(IO_ReadWrite))
      {
        QTextStream str(&f);
        str.setEncoding(QTextStream::UnicodeUTF8);
        QString line;
        while (!str.atEnd())
        {
          line = str.readLine().stripWhiteSpace();
          if (line != fInfo.fileName())
          {
            content += line + "\n";
          } else
            found = true;
        }       
        if (!found)
        {
          emit showMessage(i18n("\"%1\" is not in the CVS ignore list.").arg(fInfo.fileName()) + "\n", false);
        }
        f.close();
      }
      if (found && f.open(IO_WriteOnly))
      {
        QTextStream str(&f);
        str.setEncoding(QTextStream::UnicodeUTF8);
        str << content;
        emit showMessage(i18n("\"%1\" removed from the CVS ignore list.").arg(fInfo.fileName()) + "\n", false);
        f.close();
      }
      
    } else
    {
      notInRepository();
    }
  }
}
Exemplo n.º 23
0
/* ////////////////////////////////////////////////////////////////////////////
 * Write the video header list
 */
void TTMpeg2MainWnd::onWriteHeaderList()
{
  QString fn = QFileDialog::getSaveFileName( this,
      tr("Export header index list"),
      TTCut::lastDirPath,
      "Headerlist (*.txt)" );

  if (fn.isEmpty())
    return;

  QFileInfo fInfo( fn );
  TTCut::lastDirPath     = fInfo.absolutePath();
  TTHeaderWriter* writer = new TTHeaderWriter(videoIndexList, videoHeaderList);

  writer->writeHeaderListToFile(fn);

  delete writer;
}
Exemplo n.º 24
0
//! Set the mpeg stream
void TTCutOutFrame::initVideoStream(TTMpeg2VideoStream *vs)
{
  if ( currentMpeg2Stream == vs || vs == 0 )
    return;

  currentMpeg2Stream = vs;
  QFileInfo fInfo(vs->filePath());

  if ( !videoToSharedVideoMap.contains(vs) ) {
    mpeg2Stream = new TTMpeg2VideoStream(fInfo);
    mpeg2Stream->makeSharedCopy( vs );
    videoToSharedVideoMap[vs] = mpeg2Stream;
  }
  else
    mpeg2Stream = videoToSharedVideoMap[vs];

  mpegWindow->openVideoStream( mpeg2Stream );
  mpegWindow->moveToFirstFrame( false );
}
Exemplo n.º 25
0
	RESULT YaDiskRVFSDriver::moveElement(const QString& path, const QString& newParentId)
	{
		RESULT res = eERROR_GENERAL;
		QFileInfo qInfo(path);
		VFSCache* cache = WebMounter::getCache();
		VFSCache::iterator elem = cache->find(qInfo.absoluteFilePath());

		if(elem != cache->end())
		{
			QString response;
            res = m_httpConnector->moveElement(elem->getId(), elem->getParentId(), newParentId, elem->getType(), response);
			if(res == eNO_ERROR)
			{
				VFSElement newElem(elem->getType()
					, elem->getPath()
					, elem->getName()
					, elem->getEditMetaUrl()
					, elem->getEditMediaUrl()
					, elem->getSrcUrl()
					, elem->getId()
					, newParentId
					, elem->getModified()
					, elem->getPluginName());

				VFSCache::iterator iter = cache->begin();
				for(iter; iter != cache->end(); ++iter)
				{
					if(iter->getId() == newParentId)
						break;
				}

				QString path = iter->getPath() + QString(QDir::separator()) + newElem.getName();
				QFileInfo fInfo(path);
				newElem.setPath(fInfo.absoluteFilePath());

				cache->erase(elem);
				cache->insert(newElem);
			}
		}

		return res;
	}
Exemplo n.º 26
0
/* ////////////////////////////////////////////////////////////////////////////
 * Open the video
 */
bool TTMpeg2MainWnd::openVideoFile(QString fn)
{
  QFileInfo      fInfo(fn);

  if (!fInfo.exists()) 
  {
    // TODO: throw an exception!
    return false;
  }

  videoType = new TTVideoType(fn);

  if (videoType->avStreamType() != TTAVTypes::mpeg2_demuxed_video) {
    return false;
  }

  mpegStream = (TTMpeg2VideoStream*)videoType->createVideoStream();

  return true;
}
Exemplo n.º 27
0
QString PerfMon::saveGraph()
{
    QString strPicPath=QFileDialog::getSaveFileName(this,tr("Export Image"),".");

    if(strPicPath.isEmpty())
    {
        return QString();
    }
    QFileInfo fInfo(strPicPath);
    if(fInfo.suffix().toLower()!="png")
    {
        strPicPath+=".png";
    }

    QPixmap pixmap=QPixmap::grabWidget(this,this->rect());
    pixmap.save(strPicPath,"PNG");

    return strPicPath;

}
Exemplo n.º 28
0
/*!
 * This method finally writes the message to the logfile.
 * You must set the message type.
 */
void TTMessageLogger::logMsg(MsgType msgType, QString caller, int line, QString msgString, bool show)
{
    QString msgTypeStr;
    QFileInfo fInfo(caller);
    QString msgCaller = fInfo.baseName();

    //if (!logEnabled && msgType != ERROR) return;

    if (logLevel == NONE & ((msgType != ERROR) & (msgType != FATAL))) return;

    if (logLevel == MINIMAL & ((msgType != ERROR) & (msgType != FATAL) &
                               (msgType != WARNING))) return;

    if (logLevel == EXTENDED & ((msgType != ERROR)   & (msgType != FATAL) &
                                (msgType != WARNING) & (msgType != INFO))) return;

    if(msgType == INFO)
        msgTypeStr = "info";

    if(msgType == WARNING)
        msgTypeStr = "warning";

    if(msgType == ERROR)
        msgTypeStr = "error";

    if(msgType == DEBUG)
        msgTypeStr = "debug";

    QString logMsgStr = (line > 0)
                        ? QString("[%1][%2][%3:%4] %5").arg(msgTypeStr).arg(QDateTime::currentDateTime().toString("hh:mm:ss")).arg(msgCaller).arg(line).arg(msgString)
                        : QString("[%1][%2][%3] %4").arg(msgTypeStr).arg(QDateTime::currentDateTime().toString("hh:mm:ss")).arg(msgCaller).arg(msgString);

    // show message window
    if (show)
        ;

    if (logMode & CONSOLE || msgType == ERROR)
        qDebug(logMsgStr.toUtf8().data());

    writeMsg(logMsgStr);
}
Exemplo n.º 29
0
/* /////////////////////////////////////////////////////////////////////////////
 * Menu "File save as" action
 */
void TTCutMainWindow::onFileSaveAs()
{
  if (!TTCut::isVideoOpen)
    return;

  TTCut::projectFileName = ttChangeFileExt(mpegStream->fileName(), "prj");
  QFileInfo prjFileInfo(QDir(TTCut::lastDirPath), TTCut::projectFileName);

  TTCut::projectFileName = QFileDialog::getSaveFileName( this,
      tr("Save project-file as"),
      prjFileInfo.absoluteFilePath(),
      "Project(*.prj)" );

  if (!TTCut::projectFileName.isEmpty())
  {
    QFileInfo fInfo(TTCut::projectFileName);
    TTCut::lastDirPath = fInfo.absolutePath();
 
    onFileSave();
  }
}
Exemplo n.º 30
0
	RESULT YandexNarodRVFSDriver::getElements(QList<VFSElement>& elements)
	{
		RESULT err = eERROR_GENERAL;
		QString xmlResp = "";
        err = m_httpConnector->getFiles(xmlResp);

		if(!err)
		{
			xmlResp.replace("<wbr/>", "");
			int cpos=0;
			QRegExp rx("class=\"\\S+icon\\s(\\S+)\"[^<]+<img[^<]+</i[^<]+</td[^<]+<td[^<]+<input[^v]+value=\"(\\d+)\"[^<]+</td[^<]+<td[^<]+<span\\sclass='b-fname'><a\\shref=\"(\\S+)\">([^<]+)");
			cpos = rx.indexIn(xmlResp);
			while (cpos>0)
			{
				VFSElement elem;
				elem.setType(VFSElement::FILE);
                elem.setPluginName(m_pluginName);

				elem.setName(rx.cap(4));
				elem.setId(rx.cap(2));
				elem.setSrcUrl(rx.cap(3));

				elem.setParentId(ROOT_ID);
                QString pluginStoragePath = WebMounter::getSettingStorage()->getAppStoragePath() + QString(QDir::separator()) + m_pluginName;
				QString path = pluginStoragePath + QString(QDir::separator()) + elem.getName();
				QFileInfo fInfo(path);
				elem.setPath(fInfo.absoluteFilePath());

				QString pattern = QString("input type=\"checkbox\" name=\"fid\" value=\"%1\" data-token=\"(.*)\"").arg(elem.getId());
				elem.setEditMediaUrl(RegExp::getByPattern(pattern, xmlResp));

				elements.append(elem);

				cpos = rx.indexIn(xmlResp, cpos+1);
			}
		}

		return err;
	}