beginning of keys setting

This commit is contained in:
Blue 2023-11-16 21:08:40 -03:00
parent 75554c7451
commit 8f5325b291
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
11 changed files with 385 additions and 323 deletions

View file

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "keys.h"
@ -37,18 +39,34 @@ Models::Keys::~Keys() {
delete pair.second;
}
std::deque<Shared::KeyInfo> Models::Keys::modifiedKeys() const {
std::deque<Shared::KeyInfo> response(modified.size());
std::list<Shared::KeyInfo> Models::Keys::modifiedKeys() const {
std::list<Shared::KeyInfo> response;
for (const std::pair<const int, Shared::KeyInfo*>& pair: modified)
response.push_back(*(pair.second));
int i = 0;
for (const std::pair<const int, Shared::KeyInfo*>& pair: modified) {
response[i] = *(pair.second);
++i;
}
return response;
}
std::list<Shared::KeyInfo> Models::Keys::finalKeys() const {
std::list<Shared::KeyInfo> result;
finalKeys(result);
return result;
}
void Models::Keys::finalKeys(std::list<Shared::KeyInfo>& out) const {
for (int i = 0; i < rowCount(); ++i)
out.push_back(key(i));
}
const Shared::KeyInfo & Models::Keys::key(unsigned int i) const {
std::map<int, Shared::KeyInfo*>::const_iterator itr = modified.find(i);
if (itr != modified.end())
return*(itr->second);
else
return *(keys[i]);
}
void Models::Keys::addKey(const Shared::KeyInfo& info) {
beginInsertRows(QModelIndex(), keys.size(), keys.size());
keys.push_back(new Shared::KeyInfo(info));