diff options
author | bd <bdunahu@operationnull.com> | 2025-04-27 13:53:21 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-27 13:53:21 -0400 |
commit | ad0557059bb83da52e1a5bd7ea608a29a4ab6346 (patch) | |
tree | a34dc15e882047ce4d252f1757c622750cb2160c /gui/dynamicwaysentry.cc | |
parent | c00703033380d68eeff47c40a9c7dc5f8cd7fb1f (diff) |
Use spinboxes to select cache levels
Diffstat (limited to 'gui/dynamicwaysentry.cc')
-rw-r--r-- | gui/dynamicwaysentry.cc | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc deleted file mode 100644 index cbd5342..0000000 --- a/gui/dynamicwaysentry.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Simulator for the RISC-V[ECTOR] mini-ISA -// Copyright (C) 2025 Siddarth Suresh -// Copyright (C) 2025 bdunahu - -// 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 <https://www.gnu.org/licenses/>. - -#include "dynamicwaysentry.h" -#include <QLabel> -#include <QLineEdit> -#include <QStringList> -#include <QVBoxLayout> -#include <QVector> -#include <QWidget> - -DynamicWaysEntry::DynamicWaysEntry(QWidget *parent) : QWidget(parent) -{ - this->l = new QVBoxLayout(this); - this->l->setAlignment(Qt::AlignTop); - this->l->setSpacing(6); - this->l->setContentsMargins(0, 0, 0, 0); - this->setLayout(l); - this->add_field(); -} - -QStringList DynamicWaysEntry::get_entries() const { return this->entries; } - -int DynamicWaysEntry::parse_valid_way(QString t) -{ - bool s; - int i; - i = t.toInt(&s); - return (s && i >= 0 && 5 > i) ? i : -1; -} - -// TODO if you enter something valid and then make it invalid, -// the next box still shows -void DynamicWaysEntry::on_number_enter(const QString &t) -{ - int i; - QLineEdit *sender_field; - - sender_field = qobject_cast<QLineEdit *>(sender()); - i = fields.indexOf(sender_field); - entries[i] = t; - - if (i == this->fields.size() - 1 && !t.isEmpty() && - (this->parse_valid_way(t) >= 0) && fields.size() < 4) - add_field(); - - // TODO, unlink, don't trash everything after - if (t.isEmpty()) { - while (this->fields.size() > i + 1) { - remove_last_field(); - } - while (entries.size() > fields.size()) { - entries.removeLast(); - } - } -} - -void DynamicWaysEntry::add_field() -{ - QLineEdit *f; - - f = new QLineEdit(this); - f->setPlaceholderText("# ways (a power of 2)"); - - this->l->addWidget(f);; - this->fields.append(f); - this->entries.append(QString()); - connect( - f, &QLineEdit::textChanged, this, &DynamicWaysEntry::on_number_enter); -} - -void DynamicWaysEntry::remove_last_field() -{ - QLineEdit *f; - - if (this->fields.isEmpty()) - return; - - f = this->fields.takeLast(); - this->l->removeWidget(f); - f->deleteLater(); - - if (!this->entries.isEmpty()) - entries.removeLast(); -} |