Add menu and output box to generate the dele list
This commit is contained in:
parent
9319e27c5a
commit
5fd2ff2e28
10 changed files with 66 additions and 9 deletions
BIN
close_64.png
Normal file
BIN
close_64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
cog_64.png
Normal file
BIN
cog_64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -18,3 +18,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define APP_NAME "@APP_NAME@"
|
#define APP_NAME "@APP_NAME@"
|
||||||
|
#define REMARKABLE_BASE_PATH "@DEF_DELE_PREFIX@"
|
||||||
|
|
5
main.cpp
5
main.cpp
|
@ -52,10 +52,5 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
duck::MainWindow win(&roots.back());
|
duck::MainWindow win(&roots.back());
|
||||||
win.show();
|
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();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,56 @@
|
||||||
|
|
||||||
#include "main_window.hpp"
|
#include "main_window.hpp"
|
||||||
#include "notebook_tree_model.hpp"
|
#include "notebook_tree_model.hpp"
|
||||||
|
#include "notebook_tree.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace duck {
|
namespace duck {
|
||||||
MainWindow::MainWindow (Node* tree) :
|
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);
|
setWindowTitle(APP_NAME);
|
||||||
setCentralWidget(m_tree);
|
|
||||||
|
|
||||||
auto* model = new NotebookTreeModel(tree, m_tree);
|
QWidget* const main_widget = new QWidget;
|
||||||
m_tree->setModel(model);
|
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;
|
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
|
} //namespace duck
|
||||||
|
|
|
@ -20,9 +20,14 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
class QMenu;
|
||||||
|
class QAction;
|
||||||
|
class QHBoxLayout;
|
||||||
|
class QTextEdit;
|
||||||
|
|
||||||
namespace duck {
|
namespace duck {
|
||||||
class Node;
|
class Node;
|
||||||
|
class NotebookTreeModel;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -30,7 +35,17 @@ public:
|
||||||
MainWindow (Node* tree);
|
MainWindow (Node* tree);
|
||||||
virtual ~MainWindow() noexcept;
|
virtual ~MainWindow() noexcept;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void generate_dele_list();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTreeView* m_tree;
|
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
|
} //namespace duck
|
||||||
|
|
|
@ -10,6 +10,7 @@ project('remarkable_tool', 'cpp',
|
||||||
|
|
||||||
conf = configuration_data()
|
conf = configuration_data()
|
||||||
conf.set('APP_NAME', meson.project_name())
|
conf.set('APP_NAME', meson.project_name())
|
||||||
|
conf.set('DEF_DELE_PREFIX', '/home/root/.local/share/remarkable/xochitl/')
|
||||||
project_config_file = configure_file(
|
project_config_file = configure_file(
|
||||||
input: 'config.h.in',
|
input: 'config.h.in',
|
||||||
output: 'config.h',
|
output: 'config.h',
|
||||||
|
|
|
@ -187,4 +187,8 @@ std::vector<const NotebookInfo*> make_list_of_deleted (const std::vector<Node>&
|
||||||
}
|
}
|
||||||
return dele_list;
|
return dele_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<const NotebookInfo*> make_list_of_deleted (const Node* root) {
|
||||||
|
return make_dele_list(*root);
|
||||||
|
}
|
||||||
} //namespace duck
|
} //namespace duck
|
||||||
|
|
|
@ -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 std::vector<Node>& roots);
|
||||||
|
std::vector<const NotebookInfo*> make_list_of_deleted (const Node* root);
|
||||||
} //namespace duck
|
} //namespace duck
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
QModelIndex parent (const QModelIndex& index) const override;
|
QModelIndex parent (const QModelIndex& index) const override;
|
||||||
|
|
||||||
|
Node* root_node() { return m_tree; }
|
||||||
|
const Node* root_node() const { return m_tree; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node* m_tree;
|
Node* m_tree;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue