Commit f5eb21fa authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'mv/history' into 'master'

Mv/history

See merge request !7
parents e296d207 409dd977
#include "MatrixVisualizer.hpp"
#include "Configuration.hpp"
#include "common/Session.hpp"
#include <QFileDialog>
#define SESSION_FILENAME( fname ) QString::fromStdString( "plugins/mv/files/" + fname )
Matrix_visualizer* Matrix_visualizer::s_plugin = nullptr;
SymbolParser Matrix_visualizer::s_symbol_parser;
OrderParser Matrix_visualizer::s_order_parser;
......@@ -23,14 +26,31 @@ Matrix_visualizer* Matrix_visualizer::get_instance()
return s_plugin;
}
void
Matrix_visualizer::set_line_edit_defaults( QLineEdit *le, std::string name, std::string def_name )
{
Session &s = Session::getSession();
QString lineedit_fname;
QString session_fname;
session_fname = SESSION_FILENAME( name );
if (s.contains( session_fname ) ) {
lineedit_fname = s.value( session_fname ).toString();
}
else {
lineedit_fname = QString::fromStdString(def_name);
}
le->setText( lineedit_fname );
}
// Plugin implementation itself
Matrix_visualizer::Matrix_visualizer() {
setupUi(this);
s_plugin = this;
// For windows dev (pc: orange)
this->line_edit_symbol->setText("/home/mathieu/1-PaStiX/pastix/build/symbol_rank");
set_line_edit_defaults( this->line_edit_symbol, "symbol", "symbol.sps" );
set_line_edit_defaults( this->line_edit_order, "order", "order.ord" );
set_line_edit_defaults( this->line_edit_values, "values", "values.txt" );
}
Matrix_visualizer::~Matrix_visualizer(){
......@@ -54,6 +74,8 @@ std::string Matrix_visualizer::get_name(){
int Matrix_visualizer::update_matrix( QString filepath )
{
Session &s = Session::getSession();
symbol_matrix_t *new_matrix;
// Check if there is a symbol file
......@@ -72,6 +94,7 @@ int Matrix_visualizer::update_matrix( QString filepath )
Helper::log(LogStatus::FATAL, "Parsed matrix is empty");
return -1;
}
s.setValue( "plugins/mv/files/symbol", filepath );
if ( s_matrix != nullptr ) {
symbol_matrix_deinit( s_matrix );
......@@ -209,14 +232,24 @@ void Matrix_visualizer::set_infos(const char* format, va_list ap)
**********************/
void Matrix_visualizer::on_tool_button_symbol_clicked()
{
QString symbol_filepath = QFileDialog::getOpenFileName(s_plugin, tr("Open file"), "C://");
QString symbol_filepath = QFileDialog::getOpenFileName( s_plugin, tr("Open file"),
s_plugin->line_edit_symbol->text() );
s_plugin->line_edit_symbol->setText(symbol_filepath);
}
void Matrix_visualizer::on_tool_button_order_clicked()
{
QString order_filepath = QFileDialog::getOpenFileName( s_plugin, tr("Open file"),
s_plugin->line_edit_order->text() );
s_plugin->line_edit_order->setText(order_filepath);
}
void Matrix_visualizer::on_tool_button_values_clicked()
{
QString values_filepath = QFileDialog::getOpenFileName(s_plugin, tr("Open file"), "C://");
QString values_filepath = QFileDialog::getOpenFileName( s_plugin, tr("Open file"),
s_plugin->line_edit_values->text() );
s_plugin->line_edit_values->setText(values_filepath);
}
......
......@@ -34,12 +34,14 @@ private:
int update_values( QString filepath );
void connect_widgets();
void set_line_edit_defaults( QLineEdit *le, std::string name, std::string def_name );
public slots:
void execute();
private slots:
static void on_tool_button_symbol_clicked();
static void on_tool_button_order_clicked();
static void on_tool_button_values_clicked();
static void on_tool_button_infos_clicked();
static void on_tool_button_logs_clicked();
......
......@@ -189,9 +189,9 @@ void Session::add_recent_file(const QString &filename) {
// We delete if the file was already call in order to be on the top of the list
files.removeAll(filename);
files.prepend(filename);
while (files.size() > _MAX_NB_RECENT_FILES)
while (files.size() > _MAX_NB_RECENT_FILES) {
files.removeLast();
}
S->setValue(RECENT_FILES, files);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment