Beispiel #1
0
void VidStorAdd::TreeWidgetUpdate()
{
	VidStorList storList;
	m_pFactory.GetConfDB().GetStorListConf(storList);
	int storSize = storList.cvidstor_size();
	
	int nRowCnt = ui.tableWidget->rowCount();

	for (s32 j = nRowCnt - 1; j >= 0; j --)
	{
		ui.tableWidget->removeRow(j);
	}
	ui.tableWidget->clear();
	ui.tableWidget->clearSpans();

	
	for (s32 i = 0; i < storList.cvidstor_size(); i ++)
	{
		VidStor pStor = storList.cvidstor(i);
		//int insertRow = ui.tableWidget->rowCount();
		int insertRow = i;
    		ui.tableWidget->insertRow(insertRow);
    		QTableWidgetItem *firstCheck = new VidStorTableItem(pStor, false);
    		firstCheck->setCheckState(Qt::Checked);
		ui.tableWidget->setItem(insertRow, 0, firstCheck);
		ui.tableWidget->setItem(insertRow, 1, new QTableWidgetItem(pStor.strname().c_str()));
		ui.tableWidget->setItem(insertRow, 2, new QTableWidgetItem(pStor.strip().c_str()));
		ui.tableWidget->setItem(insertRow, 3, new QTableWidgetItem(pStor.struser().c_str()));
	}
}
Beispiel #2
0
inline bool ClientConfDB::AddStor(VidStor &pStor)
{
	XGuard guard(m_cMutex);
	
	VidStorList storList;

	GetStorListConf(storList);
	
	VidStor *pAddStor = storList.add_cvidstor();
	*pAddStor = pStor;
	UpdateStorListConf(storList);

	return true;
}
Beispiel #3
0
inline BOOL StorFactory::Init()
{

	/* Loop add the stor */
	VidStorList storList;
	m_pConf.GetStorListConf(storList);
	int storSize = storList.cvidstor_size();

	for (s32 i = 0; i < storList.cvidstor_size(); i ++)
	{
		VidStor pStor = storList.cvidstor(i);
		InitAddStor(pStor);
	}

	return TRUE;
}
Beispiel #4
0
inline BOOL ClientConfDB::GetStorListConf(VidStorList &pData)
{
	VSCConfVidStorKey sKey;
	astring strValue;
	
	XGuard guard(m_cMutex);

	leveldb::Slice key((char *)&sKey, sizeof(sKey));

	leveldb::Status s = m_pDb->Get(leveldb::ReadOptions(), 
					key,  &strValue);
	if (s.ok() == false)
	{
		strValue = "fake";
	}

	if (pData.ParseFromString(strValue) == false)
	{
		VidStorList listDefault;
		pData = listDefault;
		//VDC_DEBUG( "Stor List Config is not init\n");
		return TRUE;
	}

	return TRUE;

}
Beispiel #5
0
inline bool ClientConfDB::FindStor(astring strStorId)
{
	XGuard guard(m_cMutex);
	
	VidStorList storList;
	GetStorListConf(storList);
	int storSize = storList.cvidstor_size();

	for (s32 i = 0; i < storList.cvidstor_size(); i ++)
	{
		const VidStor &stor = storList.cvidstor(i);
		if (stor.strid() == strStorId)
		{
			return true;
		}
	}

	return false;
}
Beispiel #6
0
void VSCVidTreeCam::TreeUpdate()
{
	/* Delete all the child */
	qDeleteAll(m_pRoot->takeChildren());
	VidStorList storList;
	m_pFactory.GetConfDB().GetStorListConf(storList);
	int storSize = storList.cvidstor_size();
	
	for (s32 i = 0; i < storList.cvidstor_size(); i ++)
	{
		VidStor pStor = storList.cvidstor(i);
		VSCVidItemVidStor *pItemStor = new  VSCVidItemVidStor(pStor, 
								m_pFactory, m_pRoot);
		
		QIcon icon1;
		icon1.addFile(QStringLiteral(":/device/resources/computer.png"), QSize(), QIcon::Normal, QIcon::Off);
		
		pItemStor->setIcon(0, icon1);

		pItemStor->setText(0, QApplication::translate(" ",
			pStor.strname().c_str(), 0));
	}
	
}
Beispiel #7
0
inline BOOL ClientConfDB::UpdateStorListConf(VidStorList &pData)
{
	VSCConfVidStorKey sKey;

	XGuard guard(m_cMutex);

	leveldb::WriteOptions writeOptions;

	leveldb::Slice sysKey((char *)&sKey, sizeof(sKey));

	astring strOutput;
	if (pData.SerializeToString(&strOutput) != TRUE)
	{
		return FALSE;
	}
	leveldb::Slice sysValue(strOutput);

	m_pDb->Put(writeOptions, sysKey, sysValue);

	return TRUE;
}
Beispiel #8
0
inline bool ClientConfDB::DeleteStor(astring strStorId)
{
	XGuard guard(m_cMutex);

	VidStorList storList;
	VidStorList storListNew;
	GetStorListConf(storList);
	int storSize = storList.cvidstor_size();

	for (s32 i = 0; i < storList.cvidstor_size(); i ++)
	{
		const VidStor &stor = storList.cvidstor(i);
		if (stor.strid() != strStorId)
		{
			VidStor *pAddStor = storListNew.add_cvidstor();
			*pAddStor = stor;
		}
	}

	UpdateStorListConf(storListNew);
	return true;
}