diff --git a/close_64.png b/close_64.png new file mode 100644 index 0000000..7bec782 Binary files /dev/null and b/close_64.png differ diff --git a/cog_64.png b/cog_64.png new file mode 100644 index 0000000..4f2ad2b Binary files /dev/null and b/cog_64.png differ diff --git a/config.h.in b/config.h.in index c941a68..fd1546e 100644 --- a/config.h.in +++ b/config.h.in @@ -18,3 +18,4 @@ #pragma once #define APP_NAME "@APP_NAME@" +#define REMARKABLE_BASE_PATH "@DEF_DELE_PREFIX@" diff --git a/main.cpp b/main.cpp index f154339..beb89cc 100644 --- a/main.cpp +++ b/main.cpp @@ -52,10 +52,5 @@ int main (int argc, char* argv[]) { duck::MainWindow win(&roots.back()); win.show(); - for (const duck::NotebookInfo* nb : dele_list) { - for (const auto& f : nb->files) { - std::cout << "/home/root/.local/share/remarkable/xochitl/" << f << '\n'; - } - } return app.exec(); } diff --git a/main_window.cpp b/main_window.cpp index 7d7a3fe..924a4e0 100644 --- a/main_window.cpp +++ b/main_window.cpp @@ -17,19 +17,56 @@ #include "main_window.hpp" #include "notebook_tree_model.hpp" +#include "notebook_tree.hpp" #include "config.h" #include +#include +#include +#include +#include +#include +#include +#include namespace duck { MainWindow::MainWindow (Node* tree) : - m_tree(new QTreeView) + m_tree(new QTreeView), + m_tree_model(new NotebookTreeModel(tree, m_tree)), + m_file_menu(menuBar()->addMenu("&File")), + m_gen_dele_list(new QAction(QPixmap("cog_64.png"), "Generate list", this)), + m_quit_action(new QAction(QPixmap("close_64.png"), "Quit", this)), + m_central_layout(new QHBoxLayout), + m_output(new QTextEdit) { setWindowTitle(APP_NAME); - setCentralWidget(m_tree); - auto* model = new NotebookTreeModel(tree, m_tree); - m_tree->setModel(model); + QWidget* const main_widget = new QWidget; + setCentralWidget(main_widget); + + main_widget->setLayout(m_central_layout); + m_central_layout->addWidget(m_tree); + m_central_layout->addWidget(m_output); + + m_tree->setModel(m_tree_model); + + m_file_menu->addAction(m_gen_dele_list); + connect(m_gen_dele_list, &QAction::triggered, this, &MainWindow::generate_dele_list); + m_quit_action->setShortcuts(QKeySequence::Quit); + m_file_menu->addAction(m_quit_action); + connect(m_quit_action, &QAction::triggered, this, &QApplication::quit); } MainWindow::~MainWindow() noexcept = default; + +void MainWindow::generate_dele_list() { + std::vector list(make_list_of_deleted(m_tree_model->root_node())); + QString out_text; + + for (const auto& nb : list) { + for (const auto& f : nb->files) { + out_text += QString(REMARKABLE_BASE_PATH) + QString::fromStdString(f) + "/n"; + } + } + m_output->setText(out_text); +} } //namespace duck diff --git a/main_window.hpp b/main_window.hpp index 26fbb0e..1f181d4 100644 --- a/main_window.hpp +++ b/main_window.hpp @@ -20,9 +20,14 @@ #include class QTreeView; +class QMenu; +class QAction; +class QHBoxLayout; +class QTextEdit; namespace duck { class Node; +class NotebookTreeModel; class MainWindow : public QMainWindow { Q_OBJECT @@ -30,7 +35,17 @@ public: MainWindow (Node* tree); virtual ~MainWindow() noexcept; +private slots: + void generate_dele_list(); + private: QTreeView* m_tree; + NotebookTreeModel* m_tree_model; + + QMenu* m_file_menu; + QAction* m_gen_dele_list; + QAction* m_quit_action; + QHBoxLayout* m_central_layout; + QTextEdit* m_output; }; } //namespace duck diff --git a/meson.build b/meson.build index dbbe024..61dc547 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,7 @@ project('remarkable_tool', 'cpp', conf = configuration_data() conf.set('APP_NAME', meson.project_name()) +conf.set('DEF_DELE_PREFIX', '/home/root/.local/share/remarkable/xochitl/') project_config_file = configure_file( input: 'config.h.in', output: 'config.h', diff --git a/notebook_tree.cpp b/notebook_tree.cpp index f24be28..bce9a39 100644 --- a/notebook_tree.cpp +++ b/notebook_tree.cpp @@ -187,4 +187,8 @@ std::vector make_list_of_deleted (const std::vector& } return dele_list; } + +std::vector make_list_of_deleted (const Node* root) { + return make_dele_list(*root); +} } //namespace duck diff --git a/notebook_tree.hpp b/notebook_tree.hpp index 31b3893..eb5d876 100644 --- a/notebook_tree.hpp +++ b/notebook_tree.hpp @@ -73,4 +73,5 @@ private: }; std::vector make_list_of_deleted (const std::vector& roots); +std::vector make_list_of_deleted (const Node* root); } //namespace duck diff --git a/notebook_tree_model.hpp b/notebook_tree_model.hpp index 851a6a3..000571d 100644 --- a/notebook_tree_model.hpp +++ b/notebook_tree_model.hpp @@ -36,6 +36,9 @@ public: QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QModelIndex parent (const QModelIndex& index) const override; + Node* root_node() { return m_tree; } + const Node* root_node() const { return m_tree; } + private: Node* m_tree; };