// SPDX-FileCopyrightText: 2021 Ernie Pasveer <epasveer@att.net>
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "SeerKeySettings.h"
#include <QtCore/QList>

SeerKeySettings::SeerKeySettings () {
}

SeerKeySettings::SeerKeySettings (const SeerKeySettings& other) {

    *this = other;
}

SeerKeySettings::~SeerKeySettings () {
}

SeerKeySettings& SeerKeySettings::operator= (const SeerKeySettings& rhs) {

    _keys = rhs._keys;

    return *this;
}

QStringList SeerKeySettings::keys () const {

    QList<QString> keylist = _keys.keys();

    QStringList keys;

    for (int i=0; i<keylist.count(); i++) {
        keys.push_back(keylist[i]);
    }

    return keys;
}

bool SeerKeySettings::has (const QString& action) const {

    return _keys.contains(action);
}

SeerKeySetting SeerKeySettings::get (const QString& action) const {

    return _keys[action];
}

void SeerKeySettings::add (const QString& action, const SeerKeySetting& setting) {

    _keys[action] = setting;
}

int SeerKeySettings::count () const {

    return _keys.size();
}

SeerKeySettings SeerKeySettings::populate () {

    SeerKeySettings keySettings;

    keySettings.add("Run",                      SeerKeySetting("Run",                   QKeySequence::fromString("F1"),                 "Run the program again. Do not break in \"main\"."));
    keySettings.add("Start",                    SeerKeySetting("Start",                 QKeySequence::fromString("F2"),                 "Run the program again. Break in \"main\"."));
    keySettings.add("Continue",                 SeerKeySetting("Continue",              QKeySequence::fromString("F8"),                 "Continue execution of the program."));
    keySettings.add("Next",                     SeerKeySetting("Next",                  QKeySequence::fromString("F5"),                 "Execute the next line. Step over functions."));
    keySettings.add("Step",                     SeerKeySetting("Step",                  QKeySequence::fromString("F6"),                 "Execute the next line. Step into functions."));
    keySettings.add("Nexti",                    SeerKeySetting("Nexti",                 QKeySequence::fromString("Ctrl+F5"),            "Execute the next instruction. Step over functions."));
    keySettings.add("Stepi",                    SeerKeySetting("Stepi",                 QKeySequence::fromString("Ctrl+F6"),            "Execute the next instruction. Step into functions."));
    keySettings.add("Finish",                   SeerKeySetting("Finish",                QKeySequence::fromString("F7"),                 "Finish the current function."));
    keySettings.add("Interrupt",                SeerKeySetting("Interrupt",             QKeySequence::fromString("Ctrl+I"),             "Interrupt the executing program."));
    keySettings.add("Terminate",                SeerKeySetting("Terminate",             QKeySequence::fromString("Alt+T"),              "Terminate the debugging session."));
    keySettings.add("Restart",                  SeerKeySetting("Restart",               QKeySequence::fromString("Alt+R"),              "Restart the debugging session."));
    keySettings.add("Debug",                    SeerKeySetting("Debug",                 QKeySequence::fromString("Alt+D"),              "Open the debug dialog."));
    keySettings.add("Arguments",                SeerKeySetting("Arguments",             QKeySequence::fromString("Alt+A"),              "Open the argument dialog."));
    keySettings.add("Quit",                     SeerKeySetting("Quit",                  QKeySequence::fromString("Alt+Q"),              "Quit Seer."));
    keySettings.add("SearchText",               SeerKeySetting("SearchText",            QKeySequence::fromString("Ctrl+F"),             "Seach for text in the code editor."));
    keySettings.add("SearchTextNext",           SeerKeySetting("SearchTextNext",        QKeySequence::fromString("Ctrl+G"),             "Seach for next text in the code editor."));
    keySettings.add("SearchTextPrev",           SeerKeySetting("SearchTextPrev",        QKeySequence::fromString("Ctrl+Shift+G"),       "Seach for previous text in the code editor."));
    keySettings.add("SearchLine",               SeerKeySetting("SearchLine",            QKeySequence::fromString("Ctrl+L"),             "Seach for line number in the code editor."));
    keySettings.add("AlternateDir",             SeerKeySetting("AlternateDir",          QKeySequence::fromString("Ctrl+O"),             "Look for source file in an alternate directory."));
    keySettings.add("ToggleBreakpoint",         SeerKeySetting("ToggleBreakpoint",      QKeySequence::fromString("Ctrl+B"),             "Toggle the breakpoint status of current line."));
    keySettings.add("ToggleRecordDirection",    SeerKeySetting("ToggleRecordDirection", QKeySequence::fromString("Ctrl+D"),             "Toggle the record playback direction."));
    keySettings.add("ReverseContinue",          SeerKeySetting("ReverseContinue",       QKeySequence::fromString("Shift+F8"),           "Continue execution of the program in reverse."));
    keySettings.add("ReverseNext",              SeerKeySetting("ReverseNext",           QKeySequence::fromString("Shift+F5"),           "Execute the previous line. Step over functions."));
    keySettings.add("ReverseStep",              SeerKeySetting("ReverseStep",           QKeySequence::fromString("Shift+F6"),           "Execute the previous line. Step into functions."));
    keySettings.add("ReverseNexti",             SeerKeySetting("ReverseNexti",          QKeySequence::fromString("Shift+Ctrl+F5"),      "Execute the previous instruction. Step over functions."));
    keySettings.add("ReverseStepi",             SeerKeySetting("ReverseStepi",          QKeySequence::fromString("Shift+Ctrl+F6"),      "Execute the previous instruction. Step into functions."));
    keySettings.add("ReverseFinish",            SeerKeySetting("ReverseFinish",         QKeySequence::fromString("Shift+F7"),           "Finish the current function in reverse."));
    keySettings.add("RunToLine",                SeerKeySetting("RunToLine",             QKeySequence::fromString("F9"),                 "Run to the currently selected line."));
    keySettings.add("GoToDefinition",           SeerKeySetting("GoToDefinition",        QKeySequence::fromString("F12"),                "Go to source file for symbol under cursor."));

    return keySettings;
}

