void RedisConnectionsManager::AddConnection(ConnectionBridge * c)
{
    //add connection to internal container
    connections.push_back(c);

    //add connection to view container    
    RedisServerItem * item = new RedisServerItem(c);
    QObject::connect(item, SIGNAL(databasesLoaded()), this, SLOT(updateFilter()));
    MainWin * errorViewForm = (MainWin *) parent();
    QObject::connect(item, SIGNAL(error(QString)), errorViewForm, SLOT(OnError(QString)));
    QObject::connect(item, SIGNAL(unlockUI()), errorViewForm, SLOT(OnUIUnlock()));
    QObject::connect(item, SIGNAL(statusMessage(QString)), errorViewForm, SLOT(OnStatusMessage(QString)));

    appendRow(item);

    //mark settings as unsaved
    connectionSettingsChanged = true;    
}
Exemplo n.º 2
0
bool DlgMain::OnClickSearch()
{
	double maxCloud = QBeforeLast(m_ComboBox_MaxCloud->currentText(), '%').toDouble();
	vector<MTLParser> selectedMTLParsers;
	QStringList selectedMTLFiles;
	QString inputPath = m_Edit_InputPath->text();
	m_StartDate = m_DateEdit_StartDate->date();
	m_EndDate = m_DateEdit_EndDate->date();
	QStringList filter;
	QStringList MTLFiles;
	filter<<"*MTL.txt";
	FindFile(inputPath, filter, MTLFiles);
	int nFiles = (int)MTLFiles.size();
	if (nFiles < 1)
	{
#ifdef debug
		cout<<"no MTL files are found!"<<endl;
#endif
		return false;
	}

	vector<MTLParser> MTLParserList;
	for (int i = 0;i < nFiles;++i)
	{
		MTLParser psr;
		psr.parse(MTLFiles[i]);
		if (psr.DATE_ACQUIRED > m_StartDate && psr.DATE_ACQUIRED < m_EndDate)
		{
			MTLParserList.push_back(psr);
		}
	}
	nFiles = (int)MTLParserList.size();
	if (nFiles < 1)
	{
#ifdef debug
		cout<<"no MTL files are found!"<<endl;
#endif
		return false;
	}

	// 按Path Row排序
	std::sort(MTLParserList.begin(), MTLParserList.end(), comparePathRow);

	vector<MTLParser> MTLParserListTemp;
	MTLParserListTemp.push_back(MTLParserList[0]);
	QString currentPathRow = MTLParserList[0].m_strPathRow;
	for (int i = 1;i < nFiles;++i)
	{
		if (0 == MTLParserList[i].m_strPathRow.compare(currentPathRow))
		{
			MTLParserListTemp.push_back(MTLParserList[i]);
		}
		else
		{
			MTLParser bestMTL = Best(MTLParserListTemp, m_StartDate, m_EndDate);
			if (bestMTL.CLOUD_COVER <= maxCloud)
			{
				selectedMTLParsers.push_back(bestMTL);
				selectedMTLFiles.push_back(bestMTL.m_PathMTL);
			}

			MTLParserListTemp.clear();
			MTLParserListTemp.push_back(MTLParserList[i]);
		}
		currentPathRow = MTLParserListTemp.back().m_strPathRow;
	}
	MTLParser bestMTL = Best(MTLParserListTemp, m_StartDate, m_EndDate);
	if (bestMTL.CLOUD_COVER <= maxCloud)
	{
		selectedMTLParsers.push_back(bestMTL);
		selectedMTLFiles.push_back(bestMTL.m_PathMTL);
	}

	// 将挑选的数据写入日志文件
	QString outLogFile = QDir::toNativeSeparators(m_Edit_OutputPath->text() + QDir::separator() + logFile);
	FILE* pf;
	QString dateFormat("yyyy.MM.dd");
	fopen_s(&pf, outLogFile.toUtf8(), "w+");
	int nSelected = (int)selectedMTLParsers.size();
	fprintf(pf, "起始时间:%s\n", m_StartDate.toString(dateFormat).toUtf8().data());
	fprintf(pf, "截止时间:%s\n", m_EndDate.toString(dateFormat).toUtf8().data());
	fprintf(pf, "共挑选 %d 景\n", nSelected);
	for (int i = 0;i < nSelected;++i)
	{
		// 轨道号 日期 云量 路径
		fprintf(pf, "%s\t%s\t%lf\t%s\n", selectedMTLParsers[i].m_strPathRow.toUtf8().data(), selectedMTLParsers[i].DATE_ACQUIRED.toString(dateFormat).toUtf8().data(),
			selectedMTLParsers[i].CLOUD_COVER, selectedMTLParsers[i].m_PathMTL.toUtf8().data());
	}
	fclose(pf);
	//////////////////////////////////////////////////////////////////////////
	// 开始复制数据

	FileCopyProcessThread *fileCopyProcess = new FileCopyProcessThread;
	//m_progressListener = new DemConvertListener;

	//connect(m_progressListener,SIGNAL(updateProgress(double)),this,SLOT(OnUpdateProgress(double)));
	//connect(fileCopyProcess, SIGNAL(addLog(QString)),this,SLOT(OnAddLog(QString)));
	connect(fileCopyProcess, SIGNAL(taskProgress(double)),this,SLOT(OnTaskProgress(double)));
	//connect(fileCopyProcess, SIGNAL(newProgressListener()),this,SLOT(OnNewProgressListener()));
	//connect(fileCopyProcess, SIGNAL(releaseProgressListener()),this,SLOT(OnReleaseProgressListener()));
	connect(fileCopyProcess, SIGNAL(beginUI()),this,SLOT(lockUI()));
	connect(fileCopyProcess, SIGNAL(endUI()),this,SLOT(unlockUI()));


	//demListener->start();
	//demListener->demListener(demProcess->m_progressListener);//监视进度线程
	//demProcess->m_pDEMListenerThread = demListener;
	//double could = m_ComboBox_MaxCloud->currentText().toDouble();
	bool bOverWrite = false;
	if (Qt::CheckState::Checked == m_CheckBox_OverWrite->checkState())
	{
		bOverWrite = true;
	}
	fileCopyProcess->Process(selectedMTLFiles, m_Edit_OutputPath->text(), bOverWrite);	//数据处理线程


	return true;
}