void pListView::setHeaderText(const lstring& text) { QStringList labels; for(auto& column : text) labels << QString::fromUtf8(column); qtListView->setColumnCount(text.size()); qtListView->setAlternatingRowColors(text.size() >= 2); qtListView->setHeaderLabels(labels); autoSizeColumns(); }
std::vector<lstring> convert_split_words(const lstring <) { std::vector<lstring> ret; UBreakIterator* bi; int prev = -1, pos; UErrorCode err = U_ZERO_ERROR; bi = ubrk_open(UBRK_WORD, get_locale(), (UChar *)lt.data(), lt.size(), &err); if (U_FAILURE(err)) return ret; pos = ubrk_first(bi); while (pos != UBRK_DONE) { int rules = ubrk_getRuleStatus(bi); if ((rules == UBRK_WORD_NONE) || (prev == -1)) { prev = pos; } else { ret.emplace_back(lt.substr(prev, pos - prev)); prev = -1; } pos = ubrk_next(bi); } ubrk_close(bi); return ret; }
void pListView::append(const lstring& text) { GtkTreeIter iter; gtk_list_store_append(store, &iter); for(unsigned n = 0; n < text.size(); n++) { gtk_list_store_set(store, &iter, 1 + n * 2 + 1, (const char*)text[n], -1); } }
bool lstring::operator==(const lstring &source) const { if(this == &source) return true; if(size() != source.size()) return false; for(unsigned n = 0; n < size(); n++) { if(operator[](n) != source[n]) return false; } return true; }
//-----------------------------------------------------------------// bool probe_file(const lstring& fn, bool dir) { #ifdef WIN32 struct _stat st; wchar_t* wfn = new wchar_t[fn.size() + 1]; for(uint32_t i = 0; i < fn.size(); ++i) { wfn[i] = fn[i]; } wfn[fn.size()] = 0; int ret = _wstat(wfn, &st); delete[] wfn; if(ret == 0) { #else std::string s; utf32_to_utf8(fn, s); struct stat st; if(stat(s.c_str(), &st) == 0) { #endif if(dir) { bool d = S_ISDIR(st.st_mode); if(d) return true; } else { return true; } } return false; } //-----------------------------------------------------------------// /*! @brief ファイルのサイズを返す @param[in] fn ファイル名 @return ファイルサイズ */ //-----------------------------------------------------------------// size_t get_file_size(const std::string& fn) { size_t fsz = 0; struct stat st; if(stat(fn.c_str(), &st) == 0) { fsz = st.st_size; } return fsz; }
void pListView::modify(unsigned row, const lstring& text) { locked = true; QTreeWidgetItem* item = qtListView->topLevelItem(row); if(item == nullptr) return; for(unsigned n = 0; n < text.size(); n++) { item->setText(n, QString::fromUtf8(text[n])); } locked = false; }
void pListView::append(const lstring& text) { locked = true; auto items = qtListView->findItems("", Qt::MatchContains); QTreeWidgetItem* item = new QTreeWidgetItem(qtListView); item->setData(0, Qt::UserRole, (unsigned)items.size()); if(listView.state.checkable) item->setCheckState(0, Qt::Unchecked); for(unsigned position = 0; position < text.size(); position++) { item->setText(position, QString::fromUtf8(text[position])); } locked = false; }
void pListView::append(const lstring &list) { wchar_t empty[] = L""; unsigned row = ListView_GetItemCount(hwnd); LVITEM item; item.mask = LVIF_TEXT; item.iItem = row; item.iSubItem = 0; item.pszText = empty; locked = true; ListView_InsertItem(hwnd, &item); locked = false; for(unsigned column = 0; column < list.size(); column++) { utf16_t wtext(list(column, "")); ListView_SetItemText(hwnd, row, column, wtext); } }
std::vector<lstring> convert_split_words_allow_alphabet(const lstring <, const alphabet &allow) { lstring copy; lstring *ptr = (lstring *)< bool changed = false; static letter space(' '); for (size_t i = 0; i < lt.size(); ++i) { if (!allow.ok(lt[i])) { if (!changed) { copy = lt; ptr = © changed = true; } copy[i] = space; } } return convert_split_words(*ptr); }
void StateManager::list(lstring &l) const { l.reset(); for(unsigned x = 0; x < info.slotcount; x++) { for(unsigned y = 0; y < info.slotcount; y++) { if(info.slot[y] == x) { unsigned n = l.size(); char slot[8]; sprintf(slot, "%3u", x + 1); l[n] << slot << "\t"; char datetime[DateTimeSize + 1]; memcpy(datetime, &info.datetime[y * DateTimeSize], DateTimeSize); datetime[DateTimeSize] = 0; l[n] << datetime << "\t"; char desc[DescriptionSize + 1]; memcpy(desc, &info.description[y * DescriptionSize], DescriptionSize); desc[DescriptionSize] = 0; l[n] << desc; } } } }
void ListView::setText(unsigned selection, const lstring& text) { if(selection >= state.text.size()) return; for(unsigned position = 0; position < text.size(); position++) { setText(selection, position, text[position]); } }
void pListView::modify(unsigned row, const lstring &list) { for(unsigned n = 0; n < list.size(); n++) { utf16_t wtext(list(n, "")); ListView_SetItemText(hwnd, row, n, wtext); } }