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 0000000..2bc48d8 Binary files /dev/null and b/resources/edit-clear-locationbar-rtl.png differ diff --git a/resources/translations/qcma.es.ts b/resources/translations/qcma.es.ts index 5bf5a76..4d4cb58 100644 --- a/resources/translations/qcma.es.ts +++ b/resources/translations/qcma.es.ts @@ -72,22 +72,28 @@ Uso 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