add comparing on the UString

This commit is contained in:
Edouard Dupin 2012-02-15 23:08:34 +01:00
parent ce3c976f02
commit be4970ecc6
3 changed files with 56 additions and 10 deletions

View File

@ -314,6 +314,24 @@ const etk::UString& etk::UString::operator= (etk::VectorType<uniChar_t> inputDat
return *this; return *this;
} }
bool etk::UString::operator> (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
if (m_data[iii] > etkS.m_data[iii] ) {
return true;
}
}
if (m_data.Size() > etkS.m_data.Size()) {
return true;
}
}
return false;
}
/** /**
* @brief * @brief
* *
@ -803,7 +821,7 @@ bool etk::UString::StartWith(const etk::UString& data)
return false; return false;
} }
} }
return false; return true;
} }

View File

@ -66,6 +66,10 @@ namespace etk
bool operator!= (const etk::UString& etkS) const; bool operator!= (const etk::UString& etkS) const;
bool operator!= (const uniChar_t * inputData) const; bool operator!= (const uniChar_t * inputData) const;
bool operator!= (const char * inputData) const; bool operator!= (const char * inputData) const;
/*****************************************************
* > operator
*****************************************************/
bool operator> (const etk::UString& etkS) const;
/***************************************************** /*****************************************************
* += operator * += operator
*****************************************************/ *****************************************************/

View File

@ -49,7 +49,15 @@ void SortList(etk::VectorType<etk::UString *> &m_listDirectory)
etk::VectorType<etk::UString *> tmpList = m_listDirectory; etk::VectorType<etk::UString *> tmpList = m_listDirectory;
m_listDirectory.Clear(); m_listDirectory.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) { for(int32_t iii=0; iii<tmpList.Size(); iii++) {
m_listDirectory.PushBack(tmpList[iii]);
int32_t findPos = 0;
for(int32_t jjj=0; jjj<m_listDirectory.Size(); jjj++) {
if (*tmpList[iii] > *m_listDirectory[jjj]) {
findPos = jjj;
}
}
//EWOL_DEBUG("position="<<findPos);
m_listDirectory.Insert(findPos, tmpList[iii]);
} }
} }
@ -80,6 +88,7 @@ class FileChooserFolderList : public ewol::List
m_listDirectory.PushBack(tmpEmement); m_listDirectory.PushBack(tmpEmement);
MarkToReedraw(); MarkToReedraw();
} }
void ClearElements(void) { void ClearElements(void) {
for (int32_t iii=0; iii<m_listDirectory.Size(); iii++) { for (int32_t iii=0; iii<m_listDirectory.Size(); iii++) {
if (NULL != m_listDirectory[iii]) { if (NULL != m_listDirectory[iii]) {
@ -212,6 +221,22 @@ class FileChooserFileList : public ewol::List
{ {
etk::UString* tmpEmement = new etk::UString(element); etk::UString* tmpEmement = new etk::UString(element);
m_listFile.PushBack(tmpEmement); m_listFile.PushBack(tmpEmement);
}
void endGenerating(void)
{
/*
EWOL_DEBUG("list before");
for (int32_t iii=0; iii<m_listFile.Size(); iii++) {
EWOL_DEBUG(" " << *m_listFile[iii] );
}
*/
SortList(m_listFile);
/*
EWOL_DEBUG("list after");
for (int32_t iii=0; iii<m_listFile.Size(); iii++) {
EWOL_DEBUG(" " << *m_listFile[iii] );
}
*/
MarkToReedraw(); MarkToReedraw();
} }
void ClearElements(void) { void ClearElements(void) {
@ -576,14 +601,12 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
while ((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
etk::UString tmpString(ent->d_name); etk::UString tmpString(ent->d_name);
if (DT_REG == ent->d_type) { if (DT_REG == ent->d_type) {
if (false == tmpString.StartWith(".") || true==ShowHidenFile) if (false == tmpString.StartWith(".") || true==ShowHidenFile) {
{
myListFile->AddElement(tmpString); myListFile->AddElement(tmpString);
} }
} else if (DT_DIR == ent->d_type) { } else if (DT_DIR == ent->d_type) {
if (tmpString != "." && tmpString != "..") { if (tmpString != "." && tmpString != "..") {
if (false == tmpString.StartWith(".") || true==ShowHidenFile) if (false == tmpString.StartWith(".") || true==ShowHidenFile) {
{
myListFolder->AddElement(tmpString); myListFolder->AddElement(tmpString);
} }
} }
@ -593,6 +616,7 @@ void ewol::FileChooser::UpdateCurrentFolder(void)
} else { } else {
EWOL_ERROR("could not open directory : \"" << m_folder << "\""); EWOL_ERROR("could not open directory : \"" << m_folder << "\"");
} }
myListFile->endGenerating();
MarkToReedraw(); MarkToReedraw();
} }