Add menu and output box to generate the dele list

This commit is contained in:
King_DuckZ 2021-03-28 00:59:35 +01:00
parent 9319e27c5a
commit 5fd2ff2e28
10 changed files with 66 additions and 9 deletions

BIN
close_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
cog_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -18,3 +18,4 @@
#pragma once
#define APP_NAME "@APP_NAME@"
#define REMARKABLE_BASE_PATH "@DEF_DELE_PREFIX@"

View File

@ -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();
}

View File

@ -17,19 +17,56 @@
#include "main_window.hpp"
#include "notebook_tree_model.hpp"
#include "notebook_tree.hpp"
#include "config.h"
#include <QTreeView>
#include <QAction>
#include <QMenu>
#include <QMenuBar>
#include <QApplication>
#include <QHBoxLayout>
#include <QTextEdit>
#include <vector>
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<const NotebookInfo*> 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

View File

@ -20,9 +20,14 @@
#include <QMainWindow>
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

View File

@ -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',

View File

@ -187,4 +187,8 @@ std::vector<const NotebookInfo*> make_list_of_deleted (const std::vector<Node>&
}
return dele_list;
}
std::vector<const NotebookInfo*> make_list_of_deleted (const Node* root) {
return make_dele_list(*root);
}
} //namespace duck

View File

@ -73,4 +73,5 @@ private:
};
std::vector<const NotebookInfo*> make_list_of_deleted (const std::vector<Node>& roots);
std::vector<const NotebookInfo*> make_list_of_deleted (const Node* root);
} //namespace duck

View File

@ -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;
};