From 9131125b58a9f140734f228f9f7bd033584892aa Mon Sep 17 00:00:00 2001 From: dlktdr Date: Sat, 3 Sep 2022 11:09:28 -0700 Subject: [PATCH] (cpn) Remove more un-unsed code, new set. add "Fav" lbl --- companion/src/labels.h | 4 +- companion/src/mdichild.cpp | 91 ++------------------------------------ companion/src/mdichild.h | 4 +- 3 files changed, 9 insertions(+), 90 deletions(-) diff --git a/companion/src/labels.h b/companion/src/labels.h index 6361f4cab..e39dda467 100644 --- a/companion/src/labels.h +++ b/companion/src/labels.h @@ -37,8 +37,10 @@ public: bool insertRows(int row, int count, const QModelIndex &parent) override; bool removeRows(int row, int count, const QModelIndex &parent) override; -private slots: +public slots: void buildLabelsList(); + +private slots: void modelsSelectionChanged(); signals: diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index c3e23927f..c57fff243 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -576,19 +576,6 @@ void MdiChild::onCurrentItemChanged(const QModelIndex &, const QModelIndex &) void MdiChild::onDataChanged(const QModelIndex & index) { return; - - // TODO *** - /*if (!modelsListModel->isCategoryType(index)) - return; - - int categoryIndex = modelsListModel->getCategoryIndex(index); - if (categoryIndex < 0 || categoryIndex >= (int)radioData.categories.size()) { - return; - } - strcpy(radioData.categories[categoryIndex].name, modelsListModel->data(index, 0).toString().left(sizeof(CategoryData::name)-1).toStdString().c_str()); - - setWindowModified(true); - emit modified();*/ } /* @@ -600,37 +587,6 @@ QModelIndex MdiChild::getCurrentIndex() const return ui->modelsList->selectionModel()->currentIndex(); } -/*int MdiChild::getCurrentCategory() const -{ - return modelsListModel->getCategoryIndex(getCurrentIndex()); -} - -int MdiChild::countSelectedCats() const -{ - int ret = 0; - - foreach (QModelIndex index, ui->modelsList->selectionModel()->selectedRows()) { - if (index.isValid() && modelsListModel->isCategoryType(index)) - ++ret; - } - return ret; -} - -bool MdiChild::hasSelectedCat() -{ - return modelsListModel->isCategoryType(getCurrentIndex()); -} - -QVector MdiChild::getSelectedCategories() const -{ - QVector cats; - foreach (QModelIndex index, ui->modelsList->selectionModel()->selectedRows()) { - if (index.isValid() && modelsListModel->isCategoryType(index)) - cats.append(modelsListModel->getCategoryIndex(index)); - } - return cats; -}*/ - int MdiChild::getCurrentModel() const { return modelsListModel->getModelIndex(getCurrentIndex()); @@ -857,7 +813,7 @@ int MdiChild::modelAppend(const ModelData model) return newIdx; } -int MdiChild::newModel(int modelIndex, int categoryIndex) +int MdiChild::newModel(int modelIndex) { if (modelIndex < 0) modelIndex = modelAppend(ModelData()); @@ -867,9 +823,6 @@ int MdiChild::newModel(int modelIndex, int categoryIndex) return -1; } - if (categoryIndex < 0) - categoryIndex = modelsListModel->getCategoryIndex(getCurrentIndex()); - bool isNewModel = radioData.models[modelIndex].isEmpty(); checkAndInitModel(modelIndex); // Only set the default model if we just added the first one. @@ -946,33 +899,7 @@ void MdiChild::deleteSelectedModels() deleteModels(getSelectedModels()); } -/* -void MdiChild::moveModelsToCategory(const QVector models, const int toCategoryId) -{ - if (toCategoryId < 0 || !models.size()) - return; - - bool modified = false; - //QVector models = getSelectedModels(); - foreach(const int model, models) { - if (model < 0 || model >= (int)radioData.models.size()) - continue; - - if (radioData.models[model].category != toCategoryId) { - radioData.models[model].category = toCategoryId; - modified = true; - } - } - if (modified) - setModified(); -} - -void MdiChild::moveSelectedModelsToCat(const int toCategoryId) -{ - moveModelsToCategory(getSelectedModels(), toCategoryId); -}*/ - -unsigned MdiChild::countUsedModels(const int categoryId) +unsigned MdiChild::countUsedModels() { unsigned count = 0; for (unsigned i=0; i < radioData.models.size(); ++i) { @@ -1226,18 +1153,6 @@ void MdiChild::modelDuplicate() } } -/*void MdiChild::onModelMoveToCategory() -{ - if (!sender()) { - return; - } - bool ok = false; - int toCatId = sender()->property("categoryId").toInt(&ok); - if (ok && toCatId >= 0) { - moveSelectedModelsToCat(toCatId); - } -}*/ - void MdiChild::modelEdit() { openModelEditWindow(getCurrentModel()); @@ -1333,6 +1248,8 @@ void MdiChild::newFile(bool createDefaults) isUntitled = true; curFile = QString("document%1.etx").arg(sequenceNumber++); updateTitle(); + radioData.addLabel(tr("Favorites")); + labelsListModel->buildLabelsList(); } bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile) diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index 8bf41155b..5289eb5de 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -169,11 +169,11 @@ class MdiChild : public QWidget void findNewDefaultModel(const unsigned startAt = 0); bool insertModelRows(int atModelIdx, int count); int modelAppend(const ModelData model); - int newModel(int modelIndex = -1, int categoryIndex = -1); + int newModel(int modelIndex = -1); unsigned deleteModels(const QVector modelIndices); bool deleteModel(const int modelIndex); void deleteSelectedModels(); - unsigned countUsedModels(const int categoryId = -1); + unsigned countUsedModels(); unsigned saveModels(const QVector modelIndices); bool saveModel(const int modelIndex); void saveSelectedModels();