Example #1
0
void SQLCommandPanel::SaveSqlHistory()
{
    wxArrayString sqls = ParseSql( m_scintillaSQL->GetText() );
    if ( sqls.IsEmpty() )
        return;
    
    DbExplorerSettings s;
    clConfig conf(DBE_CONFIG_FILE);
    conf.ReadItem( &s );
    const wxArrayString &history = s.GetSqlHistory();
    
    // Append the current history to the new sqls (exclude dups)
    for(size_t i=0; i<history.GetCount(); ++i) {
        if ( sqls.Index(history.Item(i) ) == wxNOT_FOUND ) {
            sqls.Add( history.Item(i) );
        }
    }

    // Truncate the buffer
    while( sqls.GetCount() > 15 ) {
        sqls.RemoveAt(sqls.GetCount()-1);
    }
    
    s.SetSqlHistory( sqls );
    conf.WriteItem( &s );
}