示例#1
0
bool KMiniEdit::saveFile(KURL newurl)
{
  if (newurl.isEmpty())
    newurl = KFileDialog::getSaveURL();

  if (newurl.isEmpty())
    return false;

  if (newurl.isMalformed())
  {
    QString text = i18n("<b>THe URL %1 is not correct!</b>");
    KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
    return false;
  }

  if (newurl.isLocalFile())
  {
    QFile file(newurl.path());
    file.open(IO_WriteOnly);
    saveToLocalFile(&file);
  }

  else
  {
    KTempFile tempfile;
    saveToLocalFile(tempfile.file());
    if (!KIO::NetAccess::upload(tempfile.name(), newurl))
    {
      QString text = i18n("<b>Error uploading %1!</b>");
      KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
      tempfile.unlink();
      return false;
    }

    tempfile.unlink();
  }

  url = newurl;
  
  addURLtoRecent();
  
  resetEdited();
  return true;
}
示例#2
0
bool MyMoneyTemplate::saveTemplate(const KUrl& url)
{
  QString filename;

  if (!url.isValid()) {
    qDebug("Invalid template URL '%s'", qPrintable(url.url()));
    return false;
  }

  if (url.isLocalFile()) {
    filename = url.toLocalFile();
    KSaveFile qfile(filename/*, 0600*/);
    if (qfile.open()) {
      saveToLocalFile(&qfile);
      if (!qfile.finalize()) {
        throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
      }
    } else {
      throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
    }
  } else {
    KTemporaryFile tmpfile;
    KSaveFile qfile(tmpfile.fileName());
    if (qfile.open()) {
      saveToLocalFile(&qfile);
      if (!qfile.finalize()) {
        throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
      }
    } else {
      throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
    }
    if (!KIO::NetAccess::upload(tmpfile.fileName(), url, 0))
      throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
  }
  return true;
}
示例#3
0
/**
* @brief 开始识别
*/
void BllDataIdentity::start()
{
	Global::stopIdentityTag = false;//开始跑
	int width = IMAGE_WIDTH;
	int height = IMAGE_HEIGHT;
	 
	uchar* data = new uchar[IMAGE_BUFF_LENGTH];
	//注册该对象为元对象可识别系统,元对象将会将该参数保存起来,供队列连接调用。特别针对多线程
	qRegisterMetaType<DataOutput>("DataOutput");

	//算法
	DataIdentity dataIdentity;

	while (!Global::stopIdentityTag)
	{
	 		
		if (Global::S_CCycleBuffer->getUsedSize() >= IMAGE_BUFF_LENGTH)
		{
			Global::S_CCycleBuffer->read((char*)data, IMAGE_BUFF_LENGTH);

			QString path = "./acqImages/";
			saveToLocalFile((char*)data, path);

			//算法
			//DataIdentity dataIdentity;
			bool emptyData = dataIdentity.read(data, (IMAGE_BUFF_LENGTH-BMP_HEADER), height, width);
			if (emptyData == true)								// empty == true, 无图像数据
			{
				//qDebug() << "empty image data" << endl;
				break;
			}
			
			dataIdentity.isHistoryVideo = false;// live video or history video
			dataIdentity.haveData();
		
			QByteArray byteArray;
			byteArray.append((char *)data, IMAGE_BUFF_LENGTH);

			if (dataIdentity.haveDataFlag)
			{

				if (true)// need to get the position of origin			
					dataIdentity.originPosition();

				if (true)													//
				{
					if (dataIdentity.isHistoryVideo)
					{
						dataIdentity.setRect1_history();// need to get each rect of region 1, region 2 and region 3
						dataIdentity.setRect2_history();
						dataIdentity.setRect3_history();
					}
					else
					{
						dataIdentity.setRect1_live();// need to get each rect of region 1, region 2 and region 3
						dataIdentity.setRect2_live();
						dataIdentity.setRect3_live();
					}
				}


				if (dataIdentity.haveDataFlag == true)					// dataIdentity.haveDataFlag == false, 无实际数据(AD time)
				{

					if (dataIdentity.Identity() == EXIT_THIS_OCR)
					{
						//显示图片,但是不输出结果
						emit readyReadBmp(dataIdentity.dataOutput, byteArray);
						 
					} 
					else 
					{
						//获取算法数据
						DataOutput outputStruct = dataIdentity.dataOutput;
						//数据处理,屏蔽无效数据为-1

						//Global::session = outputStruct.session;//更新全局场次号
						//Global::raceTime = outputStruct.raceTime;//更新全局比赛时间

						isDataOutputNew(outputStruct);

						
						//数据有改变才会发送信号
						if (outputStruct.changeStatus >= 0)
						{

							emit readyRead(outputStruct, byteArray);
						}

						qDebug() << "【BllDataIdentity】一帧图像识别时间:" << endl;
					}

				
				}
			}
			else
			{
				emit readyReadBmp(dataIdentity.dataOutput, byteArray);
			}
				

			
		}

		//else如果没有这个等待,就会有很多空循环,CPU会很高。
		//{
		//	Global::S_CCycleBuffer->waitNotEmpty();

		//}
		

	}

	delete[] data;
	qDebug() << "【BllDataIdentity】退出识别";

}