Esempio n. 1
0
void SubMainFrame::UpdateHistory()
{
    ConfigFile *clientConfig = Globals::Instance()->GetConfig();

    int iHistorySize = clientConfig->getInteger("FileHistorySize", 4);
    std::vector<std::string> listFileHistory =  clientConfig->getArray("FileHistory");

    if(iHistorySize != 0 && listFileHistory.size() != 0)
    {
        //Clear the Recent Files menu
        wxMenuItemList menuItems = m_menuRecentImages->GetMenuItems();
        for ( wxMenuItemList::compatibility_iterator node = menuItems.GetFirst();
              node;
              node = node->GetNext() )
        {
            wxMenuItem *item = node->GetData();
            m_menuRecentImages->Delete(item);
        }
        
        //Add the recent history to the menu
        for(int i = 0; i < iHistorySize && i < listFileHistory.size(); i++)
        {
            //Add the previous files to the menu for opening
            wxMenuItem* menuItemTest = new wxMenuItem( m_menuRecentImages, IDX_MENU_HISTORYOPEN + i, wxString( listFileHistory.at(i).c_str(), wxConvLocal ), wxT("Open this file."), wxITEM_NORMAL );
            m_menuRecentImages->Insert(0,menuItemTest);
        }
    }
}
Esempio n. 2
0
//Add the file to the File History
void SubMainFrame::AddFileToHistory(wxString strFilename)
{
    ConfigFile *clientConfig = Globals::Instance()->GetConfig();

    std::vector<std::string> listFileHistory =  clientConfig->getArray("FileHistory");

    for(std::vector<std::string>::iterator iter = listFileHistory.begin(); iter != listFileHistory.end(); iter++)
    {
        if(strFilename == wxString((*iter).c_str(), wxConvLocal))
        {
            listFileHistory.erase(iter);
            break;
        }
    }
    listFileHistory.push_back(std::string(strFilename.mb_str()));

    while(listFileHistory.size() > clientConfig->getInteger("FileHistorySize",4))
    {
        listFileHistory.erase(listFileHistory.begin());
    }
    clientConfig->setArray("FileHistory", listFileHistory);

    UpdateHistory();
}