From 2902229b6aeb219af8049db9b9473b7f110bc785 Mon Sep 17 00:00:00 2001 From: hama Date: Tue, 21 Apr 2015 00:09:30 +0200 Subject: [PATCH] Icons, toolbar, clipboard actions --- appl/refind/icons/action_go.gif | Bin 0 -> 268 bytes appl/refind/icons/action_paste.gif | Bin 0 -> 274 bytes appl/refind/icons/arrow_turn_left.png | Bin 0 -> 516 bytes appl/refind/icons/bullet_go.png | Bin 0 -> 410 bytes appl/refind/icons/door_in.png | Bin 0 -> 693 bytes appl/refind/icons/layout_add.png | Bin 0 -> 577 bytes appl/refind/icons/resultset_next.png | Bin 0 -> 395 bytes appl/refind/icons/sitemap_color.png | Bin 0 -> 406 bytes appl/refind/icons/table.gif | Bin 0 -> 270 bytes appl/refind/icons/tables.gif | Bin 0 -> 276 bytes appl/refind/mainwindow.cpp | 148 +++++++++++++++++++------- appl/refind/mainwindow.hpp | 7 ++ appl/refind/mainwindow.ui | 111 ++++++++++++++++++- appl/refind/refind.pro | 3 + appl/refind/refind.qrc | 14 +++ 15 files changed, 245 insertions(+), 38 deletions(-) create mode 100644 appl/refind/icons/action_go.gif create mode 100644 appl/refind/icons/action_paste.gif create mode 100644 appl/refind/icons/arrow_turn_left.png create mode 100644 appl/refind/icons/bullet_go.png create mode 100644 appl/refind/icons/door_in.png create mode 100644 appl/refind/icons/layout_add.png create mode 100644 appl/refind/icons/resultset_next.png create mode 100644 appl/refind/icons/sitemap_color.png create mode 100644 appl/refind/icons/table.gif create mode 100644 appl/refind/icons/tables.gif create mode 100644 appl/refind/refind.qrc diff --git a/appl/refind/icons/action_go.gif b/appl/refind/icons/action_go.gif new file mode 100644 index 0000000000000000000000000000000000000000..82ae7ed821f7524c0356e40f79a0379fc634d535 GIT binary patch literal 268 zcmV+n0rUPxNk%w1VGsZi0K^{vM3g9B!ajxBR(;h{C|4L|#z9W1FZTQNam`88@5?V| z96pC8chOCN)>Mw(T#DRUiQ8Fv(@#mEENRI^ZOca`PZo5~OEz>Nz2>iuw1BeWp~dOA zBTNzi%BC{z2#%%nWDQ(& zkP#APQYdIRbsbb52orn(e?S)hq@3`_GZWxsgc6wuY_I|DqoH8bn30I(0O$fBih|XHm}oQ>h<5;KkIUzbx;v;t z-eyB#UUxVk0wQGwdTM=s4S{3}6%_8-a>7*bay4g1#tO$)YSGB-# z09u8rA}2Xye`S%*{zU3D^_fPdmiyPg-%=noKoSatC_xfp1wO}z@<18F!7w5ZBTtQy zk>Q?#Vu_u^$z|>m7x@d+R@cH9d2;6$#K=oAGXHn~_+m9`^0Ksl zybr&x6m>QAki2vjRQTUKo@})pZ5^O0;;V6NP3$@V;4k*yCND4)s8xvJbzU?;j6jsI zmJlOe00i|<1M%2^mY^!=O@UVms-Tw!6e7N`0#c#W>-;y{_WlDAEgOIU0000ZD2*!*kie8d0ob9Fh%G9Y=r;n&8^QUAkdX#Dq|D$hyKfc&Ml|8p0c z|4m?!%b@Oan%jHPb>P21W3>NYd-<1_&1WU%JGUHShzcVz!>-In&hVRPdDrmgA!XB=w& zAG5&bziK_hADjk6&({3E^3;U?OHcIvUwEwR|Gc9eKtr;M1&07*qoM6N<$ Ef*qF6bpQYW literal 0 HcmV?d00001 diff --git a/appl/refind/icons/door_in.png b/appl/refind/icons/door_in.png new file mode 100644 index 0000000000000000000000000000000000000000..41676a0a5be0f026fb136315fafb6c4566522d7a GIT binary patch literal 693 zcmV;m0!safP)vaG^ z2pyX9GZt*w3IyWpBqouZ9TBDUCjj71ahpsggwSp?!_6p~6Ug^zToTz0k=O|cA@C)B z=4SI+2S7F9CYUB%6Rwf$PD%xpU1zsvH^-J3qhIec&_95xadrGMyZiUG;F`#)xFk#y zurJ!PJ?Af*(aYIc}SHy&e#bYkLxyZiN`;lMHCXuWKOBa9QbyiY}R8)+l!c;Lu zGC@p$z~K6Ij22J0)wsbx511;JB7MDISvY@^uJR9Nq@bi~L`zglHEQK03t2do(0Qs6*PW_{1G!HjEs!rv9U46 z$HzPJ|EKO<)u6Ypk6L#x)$Sg;sx@Y2o4k8D`Z@f|JD)qaVu_iqHj_a!UF&Z3Ql+}r bBu@VX$p^JhV-$eD00000NkvXXu0mjfw@)|D literal 0 HcmV?d00001 diff --git a/appl/refind/icons/layout_add.png b/appl/refind/icons/layout_add.png new file mode 100644 index 0000000000000000000000000000000000000000..62037221c08c5a022b6614b5c6763b74fbe0618e GIT binary patch literal 577 zcmV-H0>1r;P) zZezzV10q@u{(~D3H{r}Lkl<_rHY2+rym24G3$cBt|B)I7p>=x@2E_E70t<%J@A>aj zyX(JK%`Pzi-qR0QF<5QQPJ{u`T_?bT4rSZ_H!r*R-=cUM+<@2bzoB550l^j95C%kb z90v;;=WY34xAek)y_`)b20VN7_5YfKEB}|wO!%MH=l?&k%j>^yc@dHe+Kz%X=%laz zU%KGzf9;gDCcszBu1x)Z;n}YL{kyaNhxhCLH_w*rfw-XU2;6{@`IrWP zY}|Nx!vBreCV|C!_N4yr-;)k9;5*oWh^9mTUIO8de(|Ml<%@O-40!dwX61{2C5s-llVw2V@@N0oo_PPieZ!0Y2~+R( zk!(QTf=B;X9DnzJ@u9c>OP4(U@7{849!UlyO@H`*;lVfmCvAW6f9CF&{}ZR*{jXDW zb_vl21ozzrYJBy-Vb$aRjjJF3@7nm}zjw#A|58cE9uZ}LbIY~=6ShA8U$XeY|MDdd zfQCH!?_7WRzhvaG%|sbsT7Kz&`}!yUix%Do#>T_{_Ei`DO9UTSBkH=Hg(w4*^UnUS zTk-IJ<+2C=ZObqG7Z2FGlB7VCN;>(!bn*TFHYMl(i+Sx`L~=ArL>~EXU3lidsO!!J pWF;gqzXSh89JkLNxXeT<1_12n>%V}Y6R`jQ002ovPDHLkV1iLCz99er literal 0 HcmV?d00001 diff --git a/appl/refind/icons/sitemap_color.png b/appl/refind/icons/sitemap_color.png new file mode 100644 index 0000000000000000000000000000000000000000..c64582bcd4f2c8d04451e6ca914ab06df6ac211c GIT binary patch literal 406 zcmV;H0crk;P) zk}*reKp2Lbf0AEO7ypA}amXNqYyp>Y;Fci-g4`}4WOLWH+9@cGQs}0F*iEjOG*W}4 zm%wK(ZQw2m_=MnyjyI)bdn5JojW9_ApWwoHWG)HAlBv>up3c{Bd7V)Nj z@iR8U_45rBpRWSDU5?-*Tkw3&gP5hEC2ui07*qoM6N<$f(bUU AHUIzs literal 0 HcmV?d00001 diff --git a/appl/refind/icons/table.gif b/appl/refind/icons/table.gif new file mode 100644 index 0000000000000000000000000000000000000000..e5daec441e2b1e16812e7ae0a2bdc7bb4716b402 GIT binary patch literal 270 zcmV+p0rCDvNk%w1VGsZi0K@>(BfBbkK5_=bdav(>+?xfYwPj$o4nUlk-2!E zx;=NfjI-HMVS9nC*+WZQ^7Z)Y@A~KN^@FO#jI+$q*4-&FLq0`SW}w+Vg1MKs%aOFV z;OOt_^#8uv_5c6>A^8LV00000EC2ui01yBW000Gx;3tk`DGou3Ak?HN1R)S&Fi1nL z=Tgj?BLG6I(bUaRI$07NB5E6uE%iS^xRzyS-ElJ UtPKqY1`iJx7Zz3~xFR6{JAYbm8~^|S literal 0 HcmV?d00001 diff --git a/appl/refind/icons/tables.gif b/appl/refind/icons/tables.gif new file mode 100644 index 0000000000000000000000000000000000000000..87246be87fa2d14ad215816bcbc9f201cd44e905 GIT binary patch literal 276 zcmV+v0qg!pNk%w1VGsZi0K@q`-``%vyP#mb}xS#Mr3I-qF_GDKSGnMOD1n|3rVz z;OOti;Qx4{&j0`aA^8LV00000EC2ui01yBW000G%;3tk`DFRJnRg@IHf-nhU11vzU z=g?);2?AnxC~g7)#qVQLcs?Cb)Psa9D-cg-%k?A@1BQt5ct)Wg&tef4Ny;4|(KslG zB3aK #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 + + -- 2.39.5