entrez_search_dlg.cpp

来自「ncbi源码」· C++ 代码 · 共 507 行 · 第 1/2 页

CPP
507
字号
void CEntrezSearchDlg::x_OnChangeVisible(){    m_Visible = m_VisibleRecords->mvalue()->argument();    x_OnSearch();}void CEntrezSearchDlg::x_OnChangeDB(){    // determine our database    m_Start = 0;    m_Table->SetDatabase(m_DB->text(m_DB->value()));    x_OnSearch();}void CEntrezSearchDlg::x_OnSearch(){    //    // first, retrieve a list of the docsums for our search    //    string query = m_QueryStr->value();    if ( query.empty() ) {        return;    }    try {        size_t total_count = 0;        m_Table->Query(query, total_count, m_Start, m_Visible);        m_Length = total_count;    }    catch (CException& e) {        string str("Query failed:\n");        str += e.GetMsg();        NcbiMessageBox(str);    }    catch (std::exception& e) {        string str("Query failed:\n");        str += e.what();        NcbiMessageBox(str);    }    catch (...) {        NcbiMessageBox("Query failed");    }#if 0    CFltkCursorGuard WAIT_GUARD;    CStatusBarGuard GUARD(*m_StatusBar, "Submitting search...");    //    // reset the list data    //    m_Table->Clear();    m_Table->redraw();    // get our handler    try {        const char* p = m_DB->text();        if (p) {            // set some limits - if num > 0, we assume it's correct            size_t start = 0;            size_t visible = 0;            size_t total = 0;            if (m_Visible > 0) {                start = m_Start;                visible = m_Visible;            }            IEntrezDBHandler& handler = m_DbManager.GetHandler(p);            CRef<objects::CEntrez2_docsum_list> docsums =                handler.Query(query, total, start, visible);            m_Length = total;            //            // set our columns up correctly            //            vector<IEntrezDBHandler::SHeaderInfo> headers;            handler.GetHeaders(headers);            m_Table->SetCols(0);            ITERATE (vector<IEntrezDBHandler::SHeaderInfo>, iter, headers) {                m_Table->SetColumn(iter - headers.begin(),                                   iter->name,                                   CEntrezRecordTable::eString,                                   FL_ALIGN_LEFT,                                   iter->rel_width);            }            //            // now, add the docsums to the list...            // we only want certain fields from each docsum            //            m_Table->SetRows(0);            if (visible) {                m_Table->Reserve(visible);            } else {                m_Table->Reserve(m_Length);            }            if (docsums.GetPointer()  &&                docsums->IsSetList()  &&                docsums->GetList().size() != 0) {                vector<string> cols;                size_t row = 0;                NON_CONST_ITERATE(CEntrez2_docsum_list::TList, iter,                                  docsums->SetList()) {                    const CEntrez2_docsum& docsum = **iter;                    cols.clear();                    handler.Format(docsum, cols);                    ITERATE (vector<string>, col_iter, cols) {                        m_Table->SetCell(row, col_iter - cols.begin(),                                         *col_iter);                    }                    m_Table->SetData(row).Reset(*iter);                    ++row;                }            }            //            // add a nice status message            //            m_TitleStr = "Search Results";            if (docsums.GetPointer()  &&  docsums->GetCount() != 0) {                int start = m_Start + 1;                int end   = start + m_Visible;                if (m_Visible == -1) {                    end = start + docsums->GetCount();                }                end -= 1;                end = min(end, m_Start + docsums->GetCount());                m_TitleStr += " - Showing ";                m_TitleStr += NStr::IntToString(start) + " - ";                m_TitleStr += NStr::IntToString(end) + " of ";                m_TitleStr += NStr::IntToString(m_Length);                m_TitleStr += " matching records.";            } else {                m_TitleStr += " - No records found.";            }            m_Window->label(m_TitleStr.c_str());            m_StatusBar->SetPctCompleted(0);        }    }    catch (CException& e) {        string str("Can't submit query:\n");        str += e.GetMsg();        NcbiMessageBox(str);    }    catch (std::exception& e) {        string str("Can't submit query:\n");        str += e.what();        NcbiMessageBox(str);    }    catch (...) {    }#endif}END_NCBI_SCOPE/* * =========================================================================== * $Log: entrez_search_dlg.cpp,v $ * Revision 1000.0  2004/06/01 21:27:00  gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3  2004/05/28 15:06:14  dicuccio * Adjusted .fl files: include ncbi_pch.hpp, added CVS Id tags, fixed fonts * * Revision 1.2  2004/05/26 02:06:29  ucko * Explicitly cast through int when converting between enum types. * * Revision 1.1  2004/05/25 17:15:40  dicuccio * Initial revision - moved over from old GenBank search * * Revision 1.21  2004/05/07 15:35:13  dicuccio * Fixed unsigned/signed comparison * * Revision 1.20  2004/03/05 17:36:41  dicuccio * Use sequence::GetId() instead of CSeq_id::GetStringDescr() * * Revision 1.19  2004/01/20 18:16:48  dicuccio * Chnaged to match new API in CTablePanel * * Revision 1.18  2004/01/06 20:15:54  dicuccio * Use CFltkCursorGuard on load / import / search * * Revision 1.17  2003/12/30 15:02:57  dicuccio * Fixed bug in progress bar - advance proportional to actual number of loaded sequences * * Revision 1.16  2003/12/22 19:29:20  dicuccio * Added explicit passing of query string and database * * Revision 1.15  2003/12/10 15:10:04  dicuccio * Fixed numerous bugs in search: forgot to assign docsum to data; fixed bugs in * resetting counts of docsums * * Revision 1.14  2003/12/09 15:47:21  dicuccio * Use CDialog::CenterOnActive() to center the window * * Revision 1.13  2003/12/05 13:07:53  dicuccio * Split management interface into a separate plugin.  Fixed linker error * introduced with status bar * * Revision 1.12  2003/12/04 18:14:07  dicuccio * Lots of updates.  Added a status bar to track actions.  General code-clean-up * * Revision 1.11  2003/11/24 15:45:35  dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.10  2003/11/04 17:49:24  dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.9  2003/10/14 12:48:11  dicuccio * Lots of clean-ups.  Added code for correctly handling client timeouts. * * Revision 1.8  2003/10/07 13:47:05  dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.7  2003/09/30 19:53:18  dicuccio * Wrap entrez query in try/catch to avoid unseemly errors on failed search * * Revision 1.6  2003/09/17 16:26:56  dicuccio * Removed lines between cells in table.  Removed cancel button * * Revision 1.5  2003/09/16 14:08:37  dicuccio * Changed retrieval to use UID as gi instead of searching for a docsum field * * Revision 1.4  2003/08/18 14:44:59  dicuccio * Added PopSet as a search database option.  Fixed mapping og genomes <-> * proteins * * Revision 1.3  2003/08/05 17:07:18  dicuccio * Changed calling semantics for the message queue - pass by reference, not * CConstRef<> * * Revision 1.2  2003/08/01 14:37:20  dicuccio * Solved issue with plugin communication - make sure that sequences are loaded * when the load button is clicked, not when the dialog closes * * Revision 1.1  2003/07/31 17:04:00  dicuccio * Added GenBank search * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?