From 7b7fc8c9081de99643ae7fe3bbfc603a66e9917d Mon Sep 17 00:00:00 2001 From: hama Date: Sat, 31 Oct 2015 03:19:48 +0100 Subject: [PATCH] ReFileTable works --- appl/reidos/idosmain.cpp | 49 ++----- appl/reidos/idosmain.hpp | 1 - appl/reidos/idosmain.ui | 292 +++++--------------------------------- appl/reidos/reidos.pro | 7 +- guiwidget/ReFileTable.cpp | 118 +++++++++++++++ guiwidget/ReFileTable.hpp | 46 ++++++ guiwidget/reguiwidget.hpp | 31 ++++ 7 files changed, 247 insertions(+), 297 deletions(-) create mode 100644 guiwidget/ReFileTable.cpp create mode 100644 guiwidget/ReFileTable.hpp create mode 100644 guiwidget/reguiwidget.hpp diff --git a/appl/reidos/idosmain.cpp b/appl/reidos/idosmain.cpp index e2e64f4..4067d3b 100644 --- a/appl/reidos/idosmain.cpp +++ b/appl/reidos/idosmain.cpp @@ -23,22 +23,17 @@ IDosMain::IDosMain(const QString& startDir, const QString& homeDir, 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); - QString dir(ui->comboBoxPathTop->currentText()); + ui->fileTableTop->comboBoxPath->setCurrentText(startDir); + ui->fileTableTop->fileSystem = new ReLocalFileSystem("/", m_logger); + ui->fileTableTop->fillTable(); + ui->fileTableBottom->fileSystem = new ReLocalFileSystem("/", m_logger); + ui->fileTableBottom->fillTable(); + QString dir(ui->fileTableTop->comboBoxPath->currentText()); if (dir.isEmpty()) dir = startDir; if (dir.isEmpty()) dir = QDir::homePath(); changeDirectory(dir); - fillTable(ui->tableWidgetTop); } /** @@ -70,21 +65,6 @@ 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. @@ -102,11 +82,10 @@ void IDosMain::setStatusMessage(bool error, const QString& message){ void IDosMain::restoreState(){ ReStateStorage storage(m_storageFile, m_logger); storage.setForm("main"); - storage.restore(ui->comboBoxPathTop, "comboBoxPathTop", true); - storage.restore(ui->comboBoxPatternTop, "comboBoxPatternTop", false); - storage.restore(ui->comboBoxPathBottom, "comboBoxPathBottom", true); - storage.restore(ui->comboBoxPatternBottom, "comboBoxPatternBottom", false); - + storage.restore(ui->fileTableTop->comboBoxPath, "comboBoxPathTop", true); + storage.restore(ui->fileTableTop->comboBoxPatterns, "comboBoxPatternTop", false); + storage.restore(ui->fileTableBottom->comboBoxPath, "comboBoxPathBottom", true); + storage.restore(ui->fileTableBottom->comboBoxPatterns, "comboBoxPatternBottom", false); storage.close(); } @@ -116,9 +95,9 @@ void IDosMain::restoreState(){ void IDosMain::saveState(){ ReStateStorage storage(m_storageFile, m_logger); storage.setForm("main"); - storage.store(ui->comboBoxPathTop, "comboBoxPathTop"); - storage.store(ui->comboBoxPatternTop, "comboBoxPatternTop"); - storage.store(ui->comboBoxPathBottom, "comboBoxPathBottom"); - storage.store(ui->comboBoxPatternBottom, "comboBoxPatternBottom"); + storage.store(ui->fileTableTop->comboBoxPath, "comboBoxPathTop"); + storage.store(ui->fileTableTop->comboBoxPatterns, "comboBoxPatternTop"); + storage.store(ui->fileTableBottom->comboBoxPath, "comboBoxPathBottom"); + storage.store(ui->fileTableBottom->comboBoxPatterns, "comboBoxPatternBottom"); storage.close(); } diff --git a/appl/reidos/idosmain.hpp b/appl/reidos/idosmain.hpp index adc14c0..37739d4 100644 --- a/appl/reidos/idosmain.hpp +++ b/appl/reidos/idosmain.hpp @@ -33,7 +33,6 @@ protected: void restoreState(); void saveState(); protected slots: - void keyPress(QKeyEvent* event); private: Ui::IDosMain *ui; diff --git a/appl/reidos/idosmain.ui b/appl/reidos/idosmain.ui index af6ef6f..a0d918a 100644 --- a/appl/reidos/idosmain.ui +++ b/appl/reidos/idosmain.ui @@ -14,248 +14,14 @@ IDosMain - + Qt::Vertical - - - - - - 0 - - - - - - 25 - 16777215 - - - - Select the device of the upper region - - - ... - - - - - - - The path of the lower region - - - true - - - - - - - - 25 - 16777215 - - - - Change to the parent directory of the lower region - - - ^ - - - - - - - - 150 - 16777215 - - - - A pattern list for visible file types, e.g. "*.png,*.jpg,-test*", for the lower region - - - true - - - - - - - - 25 - 16777215 - - - - Change to the root directory of the lower region - - - / - - - - - - - - - Display the files of the lower region (filtered by the pattern) - - - true - - - true - - - - Modified - - - - - Size - - - - - Type - - - - - Name - - - - - - - - - - - - 0 - - - - - - 25 - 16777215 - - - - Select the device of the lower region - - - ... - - - - - - - The path of the upper region - - - true - - - - - - - - 25 - 16777215 - - - - Change to the parent directory of the upper region - - - ^ - - - - - - - - 150 - 16777215 - - - - A pattern list for visible file types, e.g. "*.png,*.jpg,-test*", for the upper region" - - - true - - - - - - - - 25 - 16777215 - - - - Change to the root directory of the upper region - - - / - - - - - - - - - Display the files of the upper region (filtered by the pattern) - - - true - - - true - - - - Modified - - - - - Size - - - - - Type - - - - - Name - - - - - - + + @@ -266,12 +32,12 @@ 0 0 787 - 20 + 35 - File + Fi&le @@ -279,7 +45,7 @@ - Edit + Edi&t @@ -295,14 +61,14 @@ - Places + &Places - Bookmarks + Book&marks @@ -311,7 +77,7 @@ - Programms + P&rogramms @@ -341,22 +107,22 @@ - Save configuration + &Save configuration - Exit + &Exit - Select different files + &Select different files - Select equal files + Select &equal files @@ -366,66 +132,74 @@ - Edit bookmark + &Edit bookmark - Add bookmark + &Add bookmark - Configure programs + &Configure programs - Edit programs + &Edit programs - About + &About - Options + &Options - Home + &Home - Temp + &Temp - Create file + &Create file - Create directory + C&reate directory - Delete + &Delete - Copy + Co&py + + + ReFileTable + QWidget +
guiwidget/reguiwidget.hpp
+ 1 +
+
diff --git a/appl/reidos/reidos.pro b/appl/reidos/reidos.pro index 34f7400..d7a3ecc 100644 --- a/appl/reidos/reidos.pro +++ b/appl/reidos/reidos.pro @@ -31,7 +31,8 @@ SOURCES += \ ../../base/ReException.cpp \ idosmain.cpp \ main.cpp \ - FileCommander.cpp + FileCommander.cpp \ + ../../guiwidget/ReFileTable.cpp HEADERS += ../../base/rebase.hpp \ ../../gui/regui.hpp \ @@ -44,6 +45,8 @@ HEADERS += ../../base/rebase.hpp \ ../../os/reos.hpp \ idosmain.hpp \ FileCommander.hpp \ - reidos.hpp + reidos.hpp \ + ../../guiwidget/ReFileTable.hpp \ + ../../guiwidget/reguiwidget.hpp FORMS += idosmain.ui diff --git a/guiwidget/ReFileTable.cpp b/guiwidget/ReFileTable.cpp new file mode 100644 index 0000000..7b78e3e --- /dev/null +++ b/guiwidget/ReFileTable.cpp @@ -0,0 +1,118 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + + +#include "guiwidget/reguiwidget.hpp" + +ReFileTable::ReFileTable(QWidget *parent) : + QWidget(parent), + mainLayout(new QVBoxLayout(this)), + horizontalLayout(new QHBoxLayout(this)), + comboBoxPath(new QComboBox(this)), + comboBoxPatterns(new QComboBox(this)), + pushButtonDevice(new QPushButton("...", this)), + pushButtonUp(new QPushButton("^", this)), + pushButtonRoot(new QPushButton("/", this)), + tableWidget(new QTableWidget(this)), + fileSystem(NULL), + matcher("*"), + m_dateFormat("yyyy.MM.dd hh:mm:ss") +{ + setLayout(mainLayout); + mainLayout->setSpacing(0); + mainLayout->addLayout(horizontalLayout); + horizontalLayout->addWidget(pushButtonDevice); + pushButtonDevice->setMaximumWidth(25); + horizontalLayout->addWidget(comboBoxPath); + comboBoxPath->setEditable(true); + horizontalLayout->addWidget(pushButtonUp); + pushButtonUp->setMaximumWidth(25); + horizontalLayout->addWidget(comboBoxPatterns); + horizontalLayout->setSpacing(0); + comboBoxPatterns->setEditable(true); + comboBoxPatterns->setMaximumWidth(150); + horizontalLayout->addWidget(pushButtonRoot); + pushButtonRoot->setMaximumWidth(25); + mainLayout->addWidget(tableWidget); + QStringList labels; + labels.append(tr("Type")); + labels.append(tr("Modified")); + labels.append(tr("Size")); + labels.append(tr("Name")); + tableWidget->setColumnCount(COL_COUNT); + tableWidget->setColumnWidth(TYPE, 60); + tableWidget->setColumnWidth(SIZE, 125); + tableWidget->setColumnWidth(MODIFIED, 175); + connect(this, SIGNAL(keyPress(QKeyEvent*)), SLOT(keyPressEvent(QKeyEvent*))); + + tableWidget->setHorizontalHeaderLabels(labels); + tableWidget->horizontalHeader()->setStretchLastSection(true); +} + +/** + * Destructor. + */ +ReFileTable::~ReFileTable() +{ + +} + +/** + * Fills the table with the file data of the filesystem. + * + * @param table OUT: table to fill + */ +void ReFileTable::fillTable() +{ + if (fileSystem != NULL){ + ReFileMetaDataList list; + fileSystem->listInfos(matcher, list); + ReFileMetaDataList::const_iterator it; + tableWidget->setRowCount(list.length()); + int row = 0; + for (it = list.cbegin(); it != list.cend(); ++it){ + // TC_EXT, TC_SIZE, TC_MODIFIED, TC_NODE + QString modified = it->m_modified.toString(m_dateFormat); + QString size = QString::number(it->m_size); + QString ext = ReFileUtils::extensionOf(it->m_node); + if (tableWidget->item(row, 0) == NULL){ + tableWidget->setItem(row, NAME, new QTableWidgetItem(it->m_node)); + tableWidget->setItem(row, MODIFIED, new QTableWidgetItem(modified)); + tableWidget->setItem(row, TYPE, new QTableWidgetItem(ext)); + QTableWidgetItem* item = new QTableWidgetItem(size); + item->setTextAlignment(Qt::AlignRight); + tableWidget->setItem(row, SIZE, item); + } else { + tableWidget->item(row, NAME)->setText(it->m_node); + tableWidget->item(row, MODIFIED)->setText(modified); + tableWidget->item(row, TYPE)->setText(ext); + tableWidget->item(row, SIZE)->setText(size); + } + row++; + } + } +} + +/** + * Handles the key press event. + * + * @param event + */ +void ReFileTable::keyPress(QKeyEvent* event){ + if (event->key() == Qt::Key_Return){ + /* + if (changeDirectory(box->currentText())){ + comboText(box); + fillTable(m_topIsActive ? ui->tableWidgetTop : ui->tableWidgetTop); + } + */ + } + +} + + diff --git a/guiwidget/ReFileTable.hpp b/guiwidget/ReFileTable.hpp new file mode 100644 index 0000000..94e4f64 --- /dev/null +++ b/guiwidget/ReFileTable.hpp @@ -0,0 +1,46 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + +#ifndef REFILETABLE_HPP +#define REFILETABLE_HPP +#ifndef REGUIWIDGET_HPP +// needed for moc_ReFileTable.cpp +#include "guiwidget/reguiwidget.hpp" +#endif +class ReFileTable : public QWidget +{ +public: + enum { TYPE, MODIFIED, SIZE, NAME, COL_COUNT }; + Q_OBJECT +public: + explicit ReFileTable(QWidget *parent = 0); + ~ReFileTable(); +signals: + +public slots: + +public: + void fillTable(); + void keyPress(QKeyEvent* event); + +protected: + QVBoxLayout* mainLayout; + QHBoxLayout* horizontalLayout; + QString m_dateFormat; +public: + QComboBox* comboBoxPath; + QComboBox* comboBoxPatterns; + QPushButton* pushButtonDevice; + QPushButton* pushButtonUp; + QPushButton* pushButtonRoot; + QTableWidget* tableWidget; + ReFileSystem* fileSystem; + ReIncludeExcludeMatcher matcher; +}; + +#endif // REFILETABLE_HPP diff --git a/guiwidget/reguiwidget.hpp b/guiwidget/reguiwidget.hpp new file mode 100644 index 0000000..b5291db --- /dev/null +++ b/guiwidget/reguiwidget.hpp @@ -0,0 +1,31 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + + +#ifndef REGUIWIDGET_HPP +#define REGUIWIDGET_HPP +#ifndef REBASE_HPP +#include "base/rebase.hpp" +#endif +#ifndef REGUI_HPP +#include "gui/regui.hpp" +#endif +#ifndef OS_REOS_HPP_ +#include "os/reos.hpp" +#endif +#include "QWidget" +#include "QComboBox" +#include "QPushButton" +#include "QHBoxLayout" +#include "QVBoxLayout" +#include "QTableWidget" +#include "QHeaderView" +#include "QKeyEvent" +#include "guiwidget/ReFileTable.hpp" +#endif // REGUIWIDGET_HPP + -- 2.39.5