From: hama Date: Mon, 20 Apr 2015 22:09:30 +0000 (+0200) Subject: Icons, toolbar, clipboard actions X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=2902229b6aeb219af8049db9b9473b7f110bc785;p=reqt Icons, toolbar, clipboard actions --- diff --git a/appl/refind/icons/action_go.gif b/appl/refind/icons/action_go.gif new file mode 100644 index 0000000..82ae7ed Binary files /dev/null and b/appl/refind/icons/action_go.gif differ diff --git a/appl/refind/icons/action_paste.gif b/appl/refind/icons/action_paste.gif new file mode 100644 index 0000000..bffd6b0 Binary files /dev/null and b/appl/refind/icons/action_paste.gif differ diff --git a/appl/refind/icons/arrow_turn_left.png b/appl/refind/icons/arrow_turn_left.png new file mode 100644 index 0000000..a3d6c9e Binary files /dev/null and b/appl/refind/icons/arrow_turn_left.png differ diff --git a/appl/refind/icons/bullet_go.png b/appl/refind/icons/bullet_go.png new file mode 100644 index 0000000..bc4faa7 Binary files /dev/null and b/appl/refind/icons/bullet_go.png differ diff --git a/appl/refind/icons/door_in.png b/appl/refind/icons/door_in.png new file mode 100644 index 0000000..41676a0 Binary files /dev/null and b/appl/refind/icons/door_in.png differ diff --git a/appl/refind/icons/layout_add.png b/appl/refind/icons/layout_add.png new file mode 100644 index 0000000..6203722 Binary files /dev/null and b/appl/refind/icons/layout_add.png differ diff --git a/appl/refind/icons/resultset_next.png b/appl/refind/icons/resultset_next.png new file mode 100644 index 0000000..e252606 Binary files /dev/null and b/appl/refind/icons/resultset_next.png differ diff --git a/appl/refind/icons/sitemap_color.png b/appl/refind/icons/sitemap_color.png new file mode 100644 index 0000000..c64582b Binary files /dev/null and b/appl/refind/icons/sitemap_color.png differ diff --git a/appl/refind/icons/table.gif b/appl/refind/icons/table.gif new file mode 100644 index 0000000..e5daec4 Binary files /dev/null and b/appl/refind/icons/table.gif differ diff --git a/appl/refind/icons/tables.gif b/appl/refind/icons/tables.gif new file mode 100644 index 0000000..87246be Binary files /dev/null and b/appl/refind/icons/tables.gif differ diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index fa5075a..37b8ec6 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include "base/rebase.hpp" #include "textfinder.hpp" #include "mainwindow.hpp" @@ -45,6 +47,9 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) : connect(ui->pushButtonDirectory, SIGNAL(clicked()), this, SLOT(selectDirectory())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); + connect(ui->actionGetAbsPath, SIGNAL(triggered()), this, SLOT(absPathToClipboard())); + connect(ui->actionGetFullName, SIGNAL(triggered()), this, SLOT(fullNameToClipboard())); + connect(ui->actionGetBaseDirectory, SIGNAL(triggered()), this, SLOT(baseDirToClipboard())); ui->tableWidget->setColumnWidth(TC_NODE, 200); ui->tableWidget->setColumnWidth(TC_EXT, 40); ui->tableWidget->setColumnWidth(TC_SIZE, 125); @@ -69,6 +74,69 @@ void MainWindow::about(){ dialog.show(); } +/** + * Gets the absolute path of the file in the given row. + * + * @param row the row number + * @return the absolute path of the file given by the row + */ +QString MainWindow::buildAbsPath(int row){ + QString rc(m_lastBaseDir.absolutePath()); + QString value = cellAsText(row, TC_PATH); + if (! value.isEmpty()) + rc += "/" + value + "/"; + return rc; +} + +/** + * Puts the absolute path of the current (selected) file into the clipboard. + */ +void MainWindow::absPathToClipboard(){ + int row = ui->tableWidget->currentRow(); + if (row >= 0){ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(buildAbsPath(row)); + } +} + +/** + * Puts the base directory into the clipboard. + */ +void MainWindow::baseDirToClipboard() +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(m_lastBaseDir.absolutePath()); +} + +/** + * Gets the content of the given cell as string. + * + * @param row the row number: 0..R-1 + * @param col the column number: 0..C-1 + * @return the text of the given cell + */ +QString MainWindow::cellAsText(int row, int col){ + QTableWidgetItem* widget = ui->tableWidget->item(row, col); + QString rc; + if (widget != NULL) + rc = widget->text(); + return rc; +} + +/** + * Puts the absolute full name of the current (selected) file into the clipboard. + */ +void MainWindow::fullNameToClipboard() +{ + int row = ui->tableWidget->currentRow(); + if (row >= 0){ + QClipboard* clipboard = QApplication::clipboard(); + QString path = buildAbsPath(row); + path += cellAsText(row, TC_NODE); + clipboard->setText(path); + } +} + /** * Returns the date given as formula in a combobox. * @@ -206,42 +274,50 @@ void MainWindow::prepareTextFind(){ void MainWindow::search(){ m_errors = 0; QString path = ui->comboBoxDirectory->currentText(); - FileFinder finder; - finder.setBaseDir(path); - finder.setMaxSize(comboSize(ui->comboBoxMaxSize)); - finder.setMinSize(comboSize(ui->comboBoxMinSize)); - finder.setOlderThan(comboDate(ui->comboBoxOlder)); - finder.setYoungerThan(comboDate(ui->comboBoxYounger)); - finder.setMinDepth(comboInt(ui->comboBoxMinDepth, 0)); - finder.setMaxDepth(comboInt(ui->comboBoxMaxDepth, -1)); - finder.setFiletypes(buildFileTypes()); - QStringList patterns; - QString value = ui->comboBoxFilePatterns->currentText(); - if (!value.isEmpty()) - patterns = value.split(","); - finder.setPatterns(patterns); - value = ui->comboBoxExcludedDirs->currentText(); - if (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0) - guiError(ui->comboBoxExcludedDirs, tr("no path delimiter allowed")); - else if (value.indexOf('*') >= 0) - guiError(ui->comboBoxExcludedDirs, - tr("no patterns allowed. Do not use '*")); - else if (!value.isEmpty()) - patterns = value.split(","); - finder.setExcludedDirs(patterns); - prepareTextFind(); - if (m_errors == 0){ - if (!ui->comboBoxTextPattern->currentText().isEmpty()) - finder.setTextFinder(&m_textFinder); - clock_t start = clock(); - finder.fillTable(path, 0, ui->tableWidget); - QString msg; - msg.sprintf( - QObject::tr( - "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec").toUtf8(), - finder.countDirs(), finder.countFiles(), finder.bytes() / 1000000.0, - (double) (clock() - start) / CLOCKS_PER_SEC); - setStatusMessage(false, msg); + QFileInfo dir(path); + if (! dir.exists()) + guiError(ui->comboBoxDirectory, tr("directory not found: ") + path); + else if (! dir.isDir()) + guiError(ui->comboBoxDirectory, tr("not a directory: ") + path); + else { + m_lastBaseDir.cd(path); + FileFinder finder; + finder.setBaseDir(path); + finder.setMaxSize(comboSize(ui->comboBoxMaxSize)); + finder.setMinSize(comboSize(ui->comboBoxMinSize)); + finder.setOlderThan(comboDate(ui->comboBoxOlder)); + finder.setYoungerThan(comboDate(ui->comboBoxYounger)); + finder.setMinDepth(comboInt(ui->comboBoxMinDepth, 0)); + finder.setMaxDepth(comboInt(ui->comboBoxMaxDepth, -1)); + finder.setFiletypes(buildFileTypes()); + QStringList patterns; + QString value = ui->comboBoxFilePatterns->currentText(); + if (!value.isEmpty()) + patterns = value.split(","); + finder.setPatterns(patterns); + value = ui->comboBoxExcludedDirs->currentText(); + if (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0) + guiError(ui->comboBoxExcludedDirs, tr("no path delimiter allowed")); + else if (value.indexOf('*') >= 0) + guiError(ui->comboBoxExcludedDirs, + tr("no patterns allowed. Do not use '*")); + else if (!value.isEmpty()) + patterns = value.split(","); + finder.setExcludedDirs(patterns); + prepareTextFind(); + if (m_errors == 0){ + if (!ui->comboBoxTextPattern->currentText().isEmpty()) + finder.setTextFinder(&m_textFinder); + clock_t start = clock(); + finder.fillTable(path, 0, ui->tableWidget); + QString msg; + msg.sprintf( + QObject::tr( + "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec").toUtf8(), + finder.countDirs(), finder.countFiles(), finder.bytes() / 1000000.0, + (double) (clock() - start) / CLOCKS_PER_SEC); + setStatusMessage(false, msg); + } } } /** diff --git a/appl/refind/mainwindow.hpp b/appl/refind/mainwindow.hpp index 4869601..15ee751 100644 --- a/appl/refind/mainwindow.hpp +++ b/appl/refind/mainwindow.hpp @@ -38,12 +38,17 @@ public: private slots: void about(); + void absPathToClipboard(); + void baseDirToClipboard(); + void fullNameToClipboard(); void search(); void up(); void selectDirectory(); private: + QString buildAbsPath(int row); QDir::Filters buildFileTypes(); + QString cellAsText(int row, int col); QDateTime comboDate(QComboBox* combo); int comboInt(QComboBox* combo, int defaultValue); int64_t comboSize(QComboBox* combo); @@ -58,6 +63,8 @@ private: QPalette::ColorRole* m_stdLabelBackgroundRole; int m_errors; TextFinder m_textFinder; + // the directory of the last search + QDir m_lastBaseDir; }; #endif // MAINWINDOW_HPP diff --git a/appl/refind/mainwindow.ui b/appl/refind/mainwindow.ui index 0acc5a7..e24827b 100644 --- a/appl/refind/mainwindow.ui +++ b/appl/refind/mainwindow.ui @@ -291,6 +291,10 @@ &Search + + + :/main/icons/action_go.gif:/main/icons/action_go.gif + Ctrl+F @@ -316,7 +320,11 @@ Change to the parent directory - ⇑ + &Up + + + + :/main/icons/arrow_turn_left.png:/main/icons/arrow_turn_left.png @@ -340,6 +348,10 @@ ... + + + :/main/icons/sitemap_color.png:/main/icons/sitemap_color.png + @@ -591,6 +603,10 @@ &Search + + + :/main/icons/action_go.gif:/main/icons/action_go.gif + @@ -679,7 +695,17 @@ + + + &Edit + + + + + + + @@ -690,9 +716,33 @@ false + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + + + + + + :/main/icons/door_in.png:/main/icons/door_in.png + E&xit @@ -704,6 +754,10 @@ + + + :/main/icons/action_go.gif:/main/icons/action_go.gif + &Search @@ -731,6 +785,10 @@ + + + :/main/icons/arrow_turn_left.png:/main/icons/arrow_turn_left.png + &Up @@ -742,6 +800,10 @@ + + + :/main/icons/sitemap_color.png:/main/icons/sitemap_color.png + &Select directory @@ -752,6 +814,49 @@ Ctrl+D + + + + :/main/icons/tables.gif:/main/icons/tables.gif + + + Get absolute &path + + + Puts the absolute path of the selected file into the clipboard + + + Ctrl+P + + + + + + icons/table.gif + :/main/icons/table.gificons/table.gif + + + Get &full name + + + Ctrl+N + + + + + + :/main/icons/action_paste.gif:/main/icons/action_paste.gif + + + Get &base directory + + + Puts the base directory into the clipboard + + + Ctrl+B + + @@ -779,7 +884,9 @@ comboBoxMaxDepth comboBoxExcludedDirs - + + + actionExit diff --git a/appl/refind/refind.pro b/appl/refind/refind.pro index 1b3fe1a..b139d1f 100644 --- a/appl/refind/refind.pro +++ b/appl/refind/refind.pro @@ -33,3 +33,6 @@ HEADERS += mainwindow.hpp \ FORMS += mainwindow.ui \ aboutdialog.ui + +RESOURCES += \ + refind.qrc diff --git a/appl/refind/refind.qrc b/appl/refind/refind.qrc new file mode 100644 index 0000000..96c5aff --- /dev/null +++ b/appl/refind/refind.qrc @@ -0,0 +1,14 @@ + + + icons/bullet_go.png + icons/door_in.png + icons/layout_add.png + icons/resultset_next.png + icons/sitemap_color.png + icons/arrow_turn_left.png + icons/table.gif + icons/tables.gif + icons/action_go.gif + icons/action_paste.gif + +