diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-22 14:14:17 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-22 14:14:17 (GMT) |
| commit | 9abe51526cac2634af0541c3de69834dd30e9f78 (patch) | |
| tree | 6ae4deadfe00a83094b9d288d8c11d8ce823577a /src/console/ConsoleModel.cpp | |
| parent | 2c311b9a36a88fadd96f3d39acb1ab2590835d81 (diff) | |
| download | powder-9abe51526cac2634af0541c3de69834dd30e9f78.zip powder-9abe51526cac2634af0541c3de69834dd30e9f78.tar.gz | |
Move all GUI source files into gui/
Diffstat (limited to 'src/console/ConsoleModel.cpp')
| -rw-r--r-- | src/console/ConsoleModel.cpp | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/console/ConsoleModel.cpp b/src/console/ConsoleModel.cpp deleted file mode 100644 index ceb6b32..0000000 --- a/src/console/ConsoleModel.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "client/Client.h" -#include "ConsoleModel.h" - -ConsoleModel::ConsoleModel() { - std::vector<std::string> previousHistory = Client::Ref().GetPrefStringArray("Console.History"); - for(std::vector<std::string>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter) - { - if(previousCommands.size()<25) - { - previousCommands.push_front(ConsoleCommand(*iter, 0, "")); - currentCommandIndex = previousCommands.size(); - } - } -} - -void ConsoleModel::AddObserver(ConsoleView * observer) -{ - observers.push_back(observer); - observer->NotifyPreviousCommandsChanged(this); -} - -int ConsoleModel::GetCurrentCommandIndex() -{ - return currentCommandIndex; -} - -void ConsoleModel::SetCurrentCommandIndex(int index) -{ - currentCommandIndex = index; - notifyCurrentCommandChanged(); -} - -ConsoleCommand ConsoleModel::GetCurrentCommand() -{ - if(currentCommandIndex < 0 || currentCommandIndex >= previousCommands.size()) - { - return ConsoleCommand("", 0, ""); - } - return previousCommands[currentCommandIndex]; -} - -void ConsoleModel::AddLastCommand(ConsoleCommand command) -{ - previousCommands.push_back(command); - if(previousCommands.size()>25) - previousCommands.pop_front(); - currentCommandIndex = previousCommands.size(); - notifyPreviousCommandsChanged(); -} - -std::deque<ConsoleCommand> ConsoleModel::GetPreviousCommands() -{ - return previousCommands; -} - -void ConsoleModel::notifyPreviousCommandsChanged() -{ - for(int i = 0; i < observers.size(); i++) - { - observers[i]->NotifyPreviousCommandsChanged(this); - } -} - -void ConsoleModel::notifyCurrentCommandChanged() -{ - for(int i = 0; i < observers.size(); i++) - { - observers[i]->NotifyCurrentCommandChanged(this); - } -} - -ConsoleModel::~ConsoleModel() { - Client::Ref().SetPref("Console.History", std::vector<std::string>(previousCommands.begin(), previousCommands.end())); -} - |
