From 5827c6ad0c03062676a641b0ab09c20467896f96 Mon Sep 17 00:00:00 2001 From: codestation Date: Wed, 11 Dec 2013 21:15:57 -0430 Subject: [PATCH] Added feature-filter from Xian Nox (with minor formatting changes) --- backupmanagerform.cpp | 19 ++++++ backupmanagerform.h | 2 + backupmanagerform.ui | 30 +++++++++ filterlineedit.cpp | 74 +++++++++++++++++++++++ filterlineedit.h | 46 ++++++++++++++ qcma.pro | 6 +- qcmares.qrc | 1 + resources/edit-clear-locationbar-rtl.png | Bin 0 -> 859 bytes resources/translations/qcma.es.ts | 23 +++++-- resources/translations/qcma.ja.ts | 23 +++++-- 10 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 filterlineedit.cpp create mode 100644 filterlineedit.h create mode 100644 resources/edit-clear-locationbar-rtl.png diff --git a/backupmanagerform.cpp b/backupmanagerform.cpp index 428ba35..d50f9c5 100644 --- a/backupmanagerform.cpp +++ b/backupmanagerform.cpp @@ -23,6 +23,7 @@ #include "sforeader.h" #include "confirmdialog.h" #include "utils.h" +#include "filterlineedit.h" #include #include @@ -199,4 +200,22 @@ void BackupManagerForm::loadBackupListing(int index) vert_header->setUpdatesEnabled(true); db->mutex.unlock(); + + // apply filter + this->on_filterLineEdit_textChanged(ui->filterLineEdit->text()); +} + +void BackupManagerForm::on_filterLineEdit_textChanged(const QString &arg1) +{ + if(arg1 != tr("Filter")) { + for(int i = 0; i < ui->tableWidget->rowCount(); ++i) { + BackupItem *item = (BackupItem*) ui->tableWidget->cellWidget(i, 0); + + if(item->title.contains(arg1, Qt::CaseInsensitive)) { + ui->tableWidget->setRowHidden(i, false); + } else { + ui->tableWidget->setRowHidden(i, true); + } + } + } } diff --git a/backupmanagerform.h b/backupmanagerform.h index d892eae..e09fef7 100644 --- a/backupmanagerform.h +++ b/backupmanagerform.h @@ -48,6 +48,8 @@ private: public slots: void loadBackupListing(int index); void removeEntry(BackupItem *item); +private slots: + void on_filterLineEdit_textChanged(const QString &arg1); }; #endif // BACKUPMANAGERFORM_H diff --git a/backupmanagerform.ui b/backupmanagerform.ui index ad69167..24555ba 100644 --- a/backupmanagerform.ui +++ b/backupmanagerform.ui @@ -100,10 +100,40 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + color:gray;font-style:italic + + + Filter + + + + + + FilterLineEdit + QLineEdit +
filterlineedit.h
+
+
diff --git a/filterlineedit.cpp b/filterlineedit.cpp new file mode 100644 index 0000000..8d23741 --- /dev/null +++ b/filterlineedit.cpp @@ -0,0 +1,74 @@ +/* + * QCMA: Cross-platform content manager assistant for the PS Vita + * + * Copyright (C) 2013 Xian Nox + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "filterlineedit.h" + +#include +#include + +FilterLineEdit::FilterLineEdit(QWidget *parent) : + QLineEdit(parent) +{ + clearButton = new QToolButton(this); + QIcon clearIcon(":/main/resources/edit-clear-locationbar-rtl.png"); + clearButton->setIcon(clearIcon); + clearButton->setCursor(Qt::ArrowCursor); + clearButton->setStyleSheet("border:none;padding:0px"); + clearButton->hide(); + connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); +} + +void FilterLineEdit::updateCloseButton(const QString& text) +{ + if(text.isEmpty() || text == tr("Filter")) { + clearButton->setVisible(false); + } else { + clearButton->setVisible(true); + } +} + +void FilterLineEdit::focusInEvent(QFocusEvent *e) +{ + if(this->styleSheet() == "color:gray;font-style:italic") { + this->clear(); + } + + this->setStyleSheet(QString("color:black;font-style:normal;padding-right:%1").arg(clearButton->sizeHint().width())); + + QLineEdit::focusInEvent(e); +} + +void FilterLineEdit::focusOutEvent(QFocusEvent *e) +{ + if(this->text().isEmpty()) { + this->setText(tr("Filter")); + this->setStyleSheet("color:gray;font-style:italic"); + } + + QLineEdit::focusOutEvent(e); +} + +void FilterLineEdit::resizeEvent(QResizeEvent *e) +{ + QSize sz = clearButton->sizeHint(); + clearButton->move(rect().right() - sz.width(), (rect().bottom() - sz.height()) / 2); + + QLineEdit::resizeEvent(e); +} diff --git a/filterlineedit.h b/filterlineedit.h new file mode 100644 index 0000000..ff97948 --- /dev/null +++ b/filterlineedit.h @@ -0,0 +1,46 @@ +/* + * QCMA: Cross-platform content manager assistant for the PS Vita + * + * Copyright (C) 2013 Xian Nox + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FILTERLINEEDIT_H +#define FILTERLINEEDIT_H + +#include +#include + +class FilterLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + explicit FilterLineEdit(QWidget *parent = 0); + +protected: + void focusInEvent(QFocusEvent *e); + void focusOutEvent(QFocusEvent *e); + void resizeEvent(QResizeEvent *e); + +private: + QToolButton *clearButton; + +private slots: + void updateCloseButton(const QString &text); + +}; + +#endif // FILTERLINEEDIT_H diff --git a/qcma.pro b/qcma.pro index 699f9ec..34e7ebc 100644 --- a/qcma.pro +++ b/qcma.pro @@ -32,7 +32,8 @@ SOURCES += main.cpp \ backupitem.cpp \ confirmdialog.cpp \ progressform.cpp \ - pinform.cpp + pinform.cpp \ + filterlineedit.cpp HEADERS += \ capability.h \ @@ -53,7 +54,8 @@ HEADERS += \ backupitem.h \ confirmdialog.h \ progressform.h \ - pinform.h + pinform.h \ + filterlineedit.h CONFIG += link_pkgconfig PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale diff --git a/qcmares.qrc b/qcmares.qrc index 9be88cd..7e5a977 100644 --- a/qcmares.qrc +++ b/qcmares.qrc @@ -6,5 +6,6 @@ resources/translations/qcma.ja.qm resources/psv_icon_16.png resources/qcma.png + resources/edit-clear-locationbar-rtl.png diff --git a/resources/edit-clear-locationbar-rtl.png b/resources/edit-clear-locationbar-rtl.png new file mode 100644 index 0000000000000000000000000000000000000000..2bc48d860751ed430633f496731d379277f5ce66 GIT binary patch literal 859 zcmV-h1ElA!$=f?BY=9fsgxp zob%m#zw_PSPeMevj*v3`6JIZ}99Kktf4^;DVBqb?6PV`r{HMlioU+S zhY~4;?%jRR;&QogaBzTfxhzmBm7vqSAO$CG?M_uh5; zPRqo^1V%?kVK5kwN~MrYCehT?gt4(PjE|2)tJUJ<Bs9$;nANJw2sju}HjfIzB$8!NEc5zSTulo;r;?J3DW*8d_h; zWy&Fk-3czl!omWqRx6A~BUCCCyk0K~g#t7h4NEE!*MUF)*=!b>O!l%X)M~Xco&NSo ztJV(LtTyCwIh>!LV}E}iQ&Uq&r_+K+sZ>@;h0Z>o4~vV7kjv#PMdmUw&-l8d!+5`^ zr$@}rq%~}9ZDDS1PLOf4Y6yqJ2!%qTnUP3@7nA>^-DIpI_V)HfkxVA5jH1YHw_{{v z1pL0v6(*AjPNx&|^YfKS1uiv@ql>ZG+}upOEdn6G`cgC+CGNUFB9WkYJYKtJsmSed z6YEb3g`(EH-yNZ0ykl~a$Sa^=Fi31Mft{TlVtdi>@MDU_VzuY1tE*(OT8Ql{8kXrOD^8s{=EH$ z?WL=%Sg+T!)znb&sgp^iOjUso de disco en respaldos - + + + Filter + Filtro + + + Default account Cuenta por defecto - + Are you sure to remove the backup of the following entry? ¿Estas seguro de borrar la siguiente entrada? - + Backup disk usage: %1 Uso de disco en respaldos: %1 - + - (Launcher only) - (Solo lanzador LiveArea) @@ -293,6 +299,15 @@ + + FilterLineEdit + + + + Filter + Filtro + + MainWidget diff --git a/resources/translations/qcma.ja.ts b/resources/translations/qcma.ja.ts index c17daf9..ddf3129 100644 --- a/resources/translations/qcma.ja.ts +++ b/resources/translations/qcma.ja.ts @@ -72,22 +72,28 @@ バックアップディスク使用容量 - + + + Filter + + + + Default account 標準アカウント - + Are you sure to remove the backup of the following entry? 次の項目のバックアップを削除してもよろしいですか? - + Backup disk usage: %1 バックアップディスク使用容量: %1 - + - (Launcher only) - (LiveArea専用) @@ -294,6 +300,15 @@ + + FilterLineEdit + + + + Filter + + + MainWidget