From fd985842eaf6021ffdbc33d5a53b73709aa581ce Mon Sep 17 00:00:00 2001 From: hama Date: Thu, 29 Oct 2015 00:00:39 +0100 Subject: [PATCH] Temp commit --- appl/reidos/FileCommander.cpp | 35 +++++++++++++++++++++++++++++++++- appl/reidos/FileCommander.hpp | 9 +++++++-- appl/reidos/idosmain.cpp | 36 +++++++++++++++++++++++++++++------ appl/reidos/idosmain.hpp | 5 ++++- appl/reidos/main.cpp | 5 +++-- base/ReLogger.cpp | 5 +++-- 6 files changed, 81 insertions(+), 14 deletions(-) diff --git a/appl/reidos/FileCommander.cpp b/appl/reidos/FileCommander.cpp index a1bb704..9132c6c 100644 --- a/appl/reidos/FileCommander.cpp +++ b/appl/reidos/FileCommander.cpp @@ -18,10 +18,43 @@ FileCommander::FileCommander(IDosMain* main) : m_bottomFS(NULL), m_activeFS(NULL), m_inactiveFS(NULL), - m_logger(new ReMemoryLogger) + m_logger(new ReMemoryLogger()), + m_topIsActive(true) { } +/** + * Sets the active directory. + * + * @param path the path to set + * @return true: directory has changed + */ +bool FileCommander::changeDirectory(const QString& path){ + bool rc = false; + QString current = m_activeFS->directory(); + if (m_activeFS->setDirectory(path) == ReFileSystem::EC_SUCCESS){ + rc = current != m_activeFS->directory(); + } + return rc; +} + +/** + * Fills the table with the file data of the active filesystem. + * + * @param table OUT: table to fill + */ +void FileCommander::fillTable(QTableWidget* table) +{ + ReFileMetaDataList list; + ReFileSystem* fs = m_topIsActive ? m_topFS : m_bottomFS; + fs->listInfos(m_topIsActive ? m_topMatcher : m_bottomMatcher, list); + ReFileMetaDataList::const_iterator it; + table->setCount(list.length()); + for (it = list.cbegin(); it != list.cend(); ++list){ + table-> + } +} + /** * Sets a filesystem to a filesystem given by its url. * diff --git a/appl/reidos/FileCommander.hpp b/appl/reidos/FileCommander.hpp index 5df917b..87c949e 100644 --- a/appl/reidos/FileCommander.hpp +++ b/appl/reidos/FileCommander.hpp @@ -14,17 +14,22 @@ class IDosMain; class FileCommander { + enum TableColumns { + TC_EXT, TC_SIZE, TC_MODIFIED, TC_NODE, + }; public: FileCommander(IDosMain* m_main); public: void buildFs(const QString& url, ReFileSystem& filesystem); + bool changeDirectory(const QString& path); + void fillTable(QTableWidget* table); protected: IDosMain* m_main; ReFileSystem* m_topFS; ReFileSystem* m_bottomFS; - ReFileSystem* m_activeFS; - ReFileSystem* m_inactiveFS; + ReIncludeExcludeMatcher m_topMatcher; ReLogger* m_logger; + bool m_topIsActive; }; #endif // FILECOMMANDER_HPP diff --git a/appl/reidos/idosmain.cpp b/appl/reidos/idosmain.cpp index e76926f..a487c71 100644 --- a/appl/reidos/idosmain.cpp +++ b/appl/reidos/idosmain.cpp @@ -17,23 +17,31 @@ IDosMain::IDosMain(const QString& startDir, const QString& homeDir, ui(new Ui::IDosMain), m_statusMessage(NULL), m_homeDir(homeDir) - //m_storageFile(), + //m_storageFile(), { ui->setupUi(this); initializeHome(); m_statusMessage = new QLabel(tr("Welcome at reidos")); + if (!startDir.isEmpty()) + ui->comboBoxPathTop->setCurrentText(startDir); + connect(ui->comboBoxPathTop, SIGNAL(keyPress(QKeyEvent*)), SLOT(keyPressEvent(QKeyEvent*))); + connect(ui->comboBoxPathBottom, SIGNAL(keyPress(QKeyEvent*)), SLOT(keyPressEvent(QKeyEvent*))); + ui->tableWidgetTop->setColumnWidth(TC_EXT, 40); + ui->tableWidgetTop->setColumnWidth(TC_SIZE, 125); + ui->tableWidgetTop->setColumnWidth(TC_MODIFIED, 175); + ui->tableWidgetBottom->setColumnWidth(TC_EXT, 40); + ui->tableWidgetBottom->setColumnWidth(TC_SIZE, 125); + ui->tableWidgetBottom->setColumnWidth(TC_MODIFIED, 175); } +/** + * Destructor. + */ IDosMain::~IDosMain() { delete ui; } -void IDosMain::error(const QString& message) -{ - m_statusMessage->setText("+++ " + message); -} - /** * initializeHomeializes the program home directory. */ @@ -55,6 +63,22 @@ void IDosMain::initializeHome(){ restoreState(); } +/** + * Handles the key press event. + * + * @param event + */ +void IDosMain::keyPress(QKeyEvent* event){ + if (event->key() == Qt::Key_Return){ + QComboBox* box = m_topIsActive ? ui->comboBoxPathTop : ui->comboBoxPatternBottom; + if (changeDirectory(box->currentText())){ + comboText(box); + fillTable(m_topIsActive ? ui->tableWidgetTop : ui->tableWidgetBottom); + } + } + +} + /** * Writes a text to the status line. * diff --git a/appl/reidos/idosmain.hpp b/appl/reidos/idosmain.hpp index 7aa8612..feb3426 100644 --- a/appl/reidos/idosmain.hpp +++ b/appl/reidos/idosmain.hpp @@ -32,12 +32,15 @@ protected: void initializeHome(); void restoreState(); void saveState(); +protected: +signals: + void keyPress(QKeyEvent* event); + private: Ui::IDosMain *ui; QLabel* m_statusMessage; QString m_homeDir; QString m_storageFile; - ReLogger* m_logger; }; #endif // IDOSMAIN_HPP diff --git a/appl/reidos/main.cpp b/appl/reidos/main.cpp index 4010211..055ec2e 100644 --- a/appl/reidos/main.cpp +++ b/appl/reidos/main.cpp @@ -13,8 +13,9 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - QString startDir; - QString homeDir; + QString startDir = argc > 1 ? argv[1] : ""; + QString homeDir = argc > 2 ? argv[2] : ""; + IDosMain w(startDir, homeDir); w.show(); diff --git a/base/ReLogger.cpp b/base/ReLogger.cpp index 955963f..234bc65 100644 --- a/base/ReLogger.cpp +++ b/base/ReLogger.cpp @@ -62,8 +62,9 @@ void ReLogger::destroyGlobalLogger() { */ ReAppender::ReAppender(const QByteArray& name) : m_name(name), - m_level(LOG_INFO) { - + m_level(LOG_INFO), + m_autoDelete(false) +{ } /** * @brief Destructor. -- 2.39.5