📄 registry.cpp
字号:
/* * =========================================================================== * PRODUCTION $Log: registry.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 20:47:00 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * PRODUCTION * =========================================================================== *//* $Id: registry.cpp,v 1000.2 2004/06/01 20:47:00 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software / database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software / database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include <gui/dialogs/registry/registry.hpp>#include <gui/widgets/fl/tree_browser.hpp>#include "registry_item_panel.hpp"BEGIN_NCBI_SCOPE#include "registry_.cpp"CRegistryDlg::CRegistryDlg(IRegistryData& data) : m_Data(&data){ m_Window.reset(x_CreateWindow()); m_List->SetData(data); m_Tree->set_root(data.GetRootLabel().c_str()); // // retrieve our key/value pairs and add them // list<string> keys; m_Data->GetKeys(keys); x_FillTree(keys);}void CRegistryDlg::x_FillTree(const list<string>& keys){ ITERATE (list<string>, iter, keys) { x_AddKey(*iter); }}void CRegistryDlg::x_AddKey(const string& key, CTreeBrowser::Node* parent){ if (key.empty()) { return; } list<string> toks; NStr::Split(key, ".", toks); string leaf = toks.back(); toks.pop_back(); CTreeBrowser::Node* node = m_Tree->get_root(); ITERATE (list<string>, iter, toks) { node = m_Tree->AddChild(*iter, node); } node = m_Tree->AddLeaf(leaf, node); // split the trailing item off - this will be edited in the list _TRACE("k = " << key << " v = " << leaf); multimap<string, string>::value_type item(key, leaf); m_Keys.insert(item);}void CRegistryDlg::x_OnChooseKey(){ CTreeBrowser::Node* node = m_Tree->GetSelected(); if (node) { string key = x_NodeToKey(node); list<string> keys; typedef multimap<string, string> TKeyMap; pair<TKeyMap::iterator, TKeyMap::iterator> range = m_Keys.equal_range(key); for ( ; range.first != range.second; ++range.first) { keys.push_back(range.first->first + "." + range.first->second); } m_List->Update(keys); }};string CRegistryDlg::x_NodeToKey(CTreeBrowser::Node* node){ string str = node->find_path(); string::size_type pos = 0; while ( (pos = str.find_first_of("/", pos)) != string::npos) { if (pos > 0 && str[pos-1] != '\\') { str[pos] = '.'; } ++pos; } return str;}END_NCBI_SCOPE/* * =========================================================================== * $Log: registry.cpp,v $ * Revision 1000.2 2004/06/01 20:47:00 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * * Revision 1.5 2004/05/21 22:27:42 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.4 2003/12/09 15:51:20 dicuccio * Deprecated Fl_Toggle_Tree - replaced with Flu_Tree_Browser. Added CTreeBrowser * as a standard tree interface * * Revision 1.3 2003/10/23 16:19:14 dicuccio * Fixed thinko in determining whether an item can be opened * * Revision 1.2 2003/09/29 15:31:41 dicuccio * Inherit dialog from CDialog * * Revision 1.1 2003/09/12 19:48:43 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -