//把从A文件读取出来的学生信息插入到链表中 void StudentInformation::Insert(string str) { char s[256]; strcpy(s, str.c_str()); char* arr[5] = {0}; int i = 0; //访问字符数组s int index = 0; //访问arr数组 arr[index++] = s; while(s[i] != '\0') { if(s[i] == ' ') { s[i] = '\0'; ++i; arr[index++] = &s[i]; } else { ++i; } } size_t id = atoi(arr[0]); string name(arr[1]); char sex[6]; strcpy(sex, arr[2]); size_t homeNum = atoi(arr[3]); string telephone(arr[4]); // cout << "id: " << id << endl; // cout << "name: " << name << endl; // cout << "sex: " << sex << endl; // cout << "homeNum: " << homeNum << endl; // cout << "telephone: " << telephone << endl; if(_list == NULL) { _list = new StudentNode(id, name, sex, homeNum, telephone); } else { StudentNode *end = _list; while(end->_next != NULL) { end = end->_next; } //找到最后一个结点 end->_next = new StudentNode(id, name, sex, homeNum, telephone); } }
QVariant EnabledLocalesModel::data( const QModelIndex& index, int role ) const { if ( index.row() < 0 || index.row() >= m_locales.count() ) return QVariant(); const QString& localeCode = m_locales[index.row()]; Locale locale( localeCode.toLatin1() ); // Get language and country in current system locale UnicodeString uDisplayLanguage; UnicodeString uDisplayCountry; locale.getDisplayLanguage( locale, uDisplayLanguage ); locale.getDisplayCountry( locale, uDisplayCountry ); // Capitalize language and country UErrorCode status; BreakIterator* titleIterator = BreakIterator::createTitleInstance( locale, status ); uDisplayLanguage = uDisplayLanguage.toTitle( titleIterator ); uDisplayCountry = uDisplayCountry.toTitle( titleIterator ); QString displayLanguage = unicodeStringToQString( uDisplayLanguage ); QString displayCountry = unicodeStringToQString( uDisplayCountry ); switch ( role ) { case Qt::DisplayRole: return QString( "%1 - %2 (%3)" ).arg( displayLanguage ).arg( displayCountry ).arg( localeCode ); case LocaleCodeRole: return localeCode; case CountryRole: return displayCountry; case LanguageRole: return displayLanguage; case AddressRole: return address(); case CollateRole: return collate(); case CtypeRole: return ctype(); case IdentificationRole: return identification(); case LangRole: return lang(); case LanguageLcRole: return language(); case MeasurementRole: return measurement(); case MonetaryRole: return monetary(); case MessagesRole: return messages(); case NameRole: return name(); case NumericRole: return numeric(); case PaperRole: return paper(); case TelephoneRole: return telephone(); case TimeRole: return time(); } return QVariant(); }