reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit ccfb047a612493f9feb30c9c86ff7acdfe79ce53
parent 3a9a8b543f08560406ad678125f97c0d4a680859
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri,  2 Jun 2017 21:34:03 -0400

rename query.{h,c}pp to obsquery.{h,c}pp

Diffstat:
Asrc/obsquery.cpp | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/obsquery.hpp | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/query.cpp | 97-------------------------------------------------------------------------------
Dsrc/query.hpp | 49-------------------------------------------------
Msrc/reapack.cpp | 2+-
Msrc/resource.hpp | 2+-
Msrc/resource.rc | 2+-
7 files changed, 149 insertions(+), 149 deletions(-)

diff --git a/src/obsquery.cpp b/src/obsquery.cpp @@ -0,0 +1,97 @@ +/* ReaPack: Package manager for REAPER + * Copyright (C) 2015-2017 Christian Fillion + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "obsquery.hpp" + +#include "encoding.hpp" +#include "listview.hpp" +#include "menu.hpp" +#include "package.hpp" +#include "resource.hpp" + +#include <sstream> + +using namespace std; + +enum { ACTION_SELECT_ALL = 300, ACTION_UNSELECT_ALL }; + +ObsoleteQuery::ObsoleteQuery(vector<Registry::Entry> *entries, bool *enable) + : Dialog(IDD_OBSQUERY_DIALOG), m_entries(entries), m_enable(enable) +{ +} + +void ObsoleteQuery::onInit() +{ + Dialog::onInit(); + + m_enableCtrl = getControl(IDC_ENABLE); + m_okBtn = getControl(IDOK); + + m_list = createControl<ListView>(IDC_LIST, ListView::Columns{ + {AUTO_STR("Package"), 550} + }); + + m_list->onSelect([=] { setEnabled(m_list->hasSelection(), m_okBtn); }); + m_list->onContextMenu([=] (Menu &menu, int) { + menu.addAction(AUTO_STR("Select &all"), ACTION_SELECT_ALL); + menu.addAction(AUTO_STR("&Unselect all"), ACTION_UNSELECT_ALL); + return true; + }); + + for(const Registry::Entry &entry : *m_entries) { + ostringstream stream; + stream << entry.remote << '/' << entry.category << '/' + << Package::displayName(entry.package, entry.description); + m_list->addRow({make_autostring(stream.str())}); + } + + m_list->autoSizeHeader(); + + SendMessage(m_enableCtrl, BM_SETCHECK, BST_CHECKED, 0); + + disable(m_okBtn); +} + +void ObsoleteQuery::onCommand(const int id, int event) +{ + switch(id) { + case IDOK: + prepare(); + break; + case IDC_ENABLE: + *m_enable = SendMessage(m_enableCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED; + break; + case ACTION_SELECT_ALL: + m_list->selectAll(); + break; + case ACTION_UNSELECT_ALL: + m_list->unselectAll(); + break; + } + + Dialog::onCommand(id, event); +} + +void ObsoleteQuery::prepare() +{ + vector<Registry::Entry> selected; + + for(int index : m_list->selection()) + selected.emplace_back(m_entries->at(index)); + + m_entries->swap(selected); +} diff --git a/src/obsquery.hpp b/src/obsquery.hpp @@ -0,0 +1,49 @@ +/* ReaPack: Package manager for REAPER + * Copyright (C) 2015-2017 Christian Fillion + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef REAPACK_OBSOLETE_QUERY_HPP +#define REAPACK_OBSOLETE_QUERY_HPP + +#include "dialog.hpp" + +#include "registry.hpp" + +#include <vector> + +class Config; +class ListView; + +class ObsoleteQuery : public Dialog { +public: + ObsoleteQuery(std::vector<Registry::Entry> *, bool *enable); + +protected: + void onInit() override; + void onCommand(int, int) override; + +private: + void prepare(); + + std::vector<Registry::Entry> *m_entries; + bool *m_enable; + + HWND m_enableCtrl; + HWND m_okBtn; + ListView *m_list; +}; + +#endif diff --git a/src/query.cpp b/src/query.cpp @@ -1,97 +0,0 @@ -/* ReaPack: Package manager for REAPER - * Copyright (C) 2015-2017 Christian Fillion - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "query.hpp" - -#include "encoding.hpp" -#include "listview.hpp" -#include "menu.hpp" -#include "package.hpp" -#include "resource.hpp" - -#include <sstream> - -using namespace std; - -enum { ACTION_SELECT_ALL = 300, ACTION_UNSELECT_ALL }; - -ObsoleteQuery::ObsoleteQuery(vector<Registry::Entry> *entries, bool *enable) - : Dialog(IDD_QUERY_DIALOG), m_entries(entries), m_enable(enable) -{ -} - -void ObsoleteQuery::onInit() -{ - Dialog::onInit(); - - m_enableCtrl = getControl(IDC_ENABLE); - m_okBtn = getControl(IDOK); - - m_list = createControl<ListView>(IDC_LIST, ListView::Columns{ - {AUTO_STR("Package"), 550} - }); - - m_list->onSelect([=] { setEnabled(m_list->hasSelection(), m_okBtn); }); - m_list->onContextMenu([=] (Menu &menu, int) { - menu.addAction(AUTO_STR("Select &all"), ACTION_SELECT_ALL); - menu.addAction(AUTO_STR("&Unselect all"), ACTION_UNSELECT_ALL); - return true; - }); - - for(const Registry::Entry &entry : *m_entries) { - ostringstream stream; - stream << entry.remote << '/' << entry.category << '/' - << Package::displayName(entry.package, entry.description); - m_list->addRow({make_autostring(stream.str())}); - } - - m_list->autoSizeHeader(); - - SendMessage(m_enableCtrl, BM_SETCHECK, BST_CHECKED, 0); - - disable(m_okBtn); -} - -void ObsoleteQuery::onCommand(const int id, int event) -{ - switch(id) { - case IDOK: - prepare(); - break; - case IDC_ENABLE: - *m_enable = SendMessage(m_enableCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED; - break; - case ACTION_SELECT_ALL: - m_list->selectAll(); - break; - case ACTION_UNSELECT_ALL: - m_list->unselectAll(); - break; - } - - Dialog::onCommand(id, event); -} - -void ObsoleteQuery::prepare() -{ - vector<Registry::Entry> selected; - - for(int index : m_list->selection()) - selected.emplace_back(m_entries->at(index)); - - m_entries->swap(selected); -} diff --git a/src/query.hpp b/src/query.hpp @@ -1,49 +0,0 @@ -/* ReaPack: Package manager for REAPER - * Copyright (C) 2015-2017 Christian Fillion - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef REAPACK_QUERY_HPP -#define REAPACK_QUERY_HPP - -#include "dialog.hpp" - -#include "registry.hpp" - -#include <vector> - -class Config; -class ListView; - -class ObsoleteQuery : public Dialog { -public: - ObsoleteQuery(std::vector<Registry::Entry> *, bool *enable); - -protected: - void onInit() override; - void onCommand(int, int) override; - -private: - void prepare(); - - std::vector<Registry::Entry> *m_entries; - bool *m_enable; - - HWND m_enableCtrl; - HWND m_okBtn; - ListView *m_list; -}; - -#endif diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -26,8 +26,8 @@ #include "filesystem.hpp" #include "index.hpp" #include "manager.hpp" +#include "obsquery.hpp" #include "progress.hpp" -#include "query.hpp" #include "report.hpp" #include "richedit.hpp" #include "transaction.hpp" diff --git a/src/resource.hpp b/src/resource.hpp @@ -41,7 +41,7 @@ #define IDD_IMPORT_DIALOG 104 #define IDD_BROWSER_DIALOG 105 #define IDD_NETCONF_DIALOG 106 -#define IDD_QUERY_DIALOG 107 +#define IDD_OBSQUERY_DIALOG 107 #define IDC_LABEL 200 #define IDC_LABEL2 201 diff --git a/src/resource.rc b/src/resource.rc @@ -120,7 +120,7 @@ BEGIN PUSHBUTTON "&Cancel", IDCANCEL, 175, 50, 40, 14 END -IDD_QUERY_DIALOG DIALOGEX 0, 0, 350, 200 +IDD_OBSQUERY_DIALOG DIALOGEX 0, 0, 350, 200 STYLE DIALOG_STYLE FONT DIALOG_FONT CAPTION "ReaPack Query"