Added feature-filter from Xian Nox (with minor formatting changes)
This commit is contained in:
		@@ -23,6 +23,7 @@
 | 
			
		||||
#include "sforeader.h"
 | 
			
		||||
#include "confirmdialog.h"
 | 
			
		||||
#include "utils.h"
 | 
			
		||||
#include "filterlineedit.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDialogButtonBox>
 | 
			
		||||
@@ -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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -100,10 +100,40 @@
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>40</width>
 | 
			
		||||
         <height>20</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="FilterLineEdit" name="filterLineEdit">
 | 
			
		||||
       <property name="styleSheet">
 | 
			
		||||
        <string notr="true">color:gray;font-style:italic</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Filter</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <customwidgets>
 | 
			
		||||
  <customwidget>
 | 
			
		||||
   <class>FilterLineEdit</class>
 | 
			
		||||
   <extends>QLineEdit</extends>
 | 
			
		||||
   <header>filterlineedit.h</header>
 | 
			
		||||
  </customwidget>
 | 
			
		||||
 </customwidgets>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										74
									
								
								filterlineedit.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								filterlineedit.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "filterlineedit.h"
 | 
			
		||||
 | 
			
		||||
#include <QIcon>
 | 
			
		||||
#include <QStyle>
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								filterlineedit.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								filterlineedit.h
									
									
									
									
									
										Normal file
									
								
							@@ -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 <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef FILTERLINEEDIT_H
 | 
			
		||||
#define FILTERLINEEDIT_H
 | 
			
		||||
 | 
			
		||||
#include <QLineEdit>
 | 
			
		||||
#include <QToolButton>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										6
									
								
								qcma.pro
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
@@ -6,5 +6,6 @@
 | 
			
		||||
        <file>resources/translations/qcma.ja.qm</file>
 | 
			
		||||
        <file>resources/psv_icon_16.png</file>
 | 
			
		||||
        <file>resources/qcma.png</file>
 | 
			
		||||
        <file>resources/edit-clear-locationbar-rtl.png</file>
 | 
			
		||||
    </qresource>
 | 
			
		||||
</RCC>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								resources/edit-clear-locationbar-rtl.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/edit-clear-locationbar-rtl.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 859 B  | 
@@ -72,22 +72,28 @@
 | 
			
		||||
        <translation>Uso de disco en respaldos</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="54"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.ui" line="122"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="210"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation>Filtro</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="55"/>
 | 
			
		||||
        <source>Default account</source>
 | 
			
		||||
        <translation>Cuenta por defecto</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="61"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="62"/>
 | 
			
		||||
        <source>Are you sure to remove the backup of the following entry?</source>
 | 
			
		||||
        <translation>¿Estas seguro de borrar la siguiente entrada?</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="84"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="85"/>
 | 
			
		||||
        <source>Backup disk usage: %1</source>
 | 
			
		||||
        <translation>Uso de disco en respaldos: %1</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="175"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="176"/>
 | 
			
		||||
        <source> - (Launcher only)</source>
 | 
			
		||||
        <translation> - (Solo lanzador LiveArea)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -293,6 +299,15 @@
 | 
			
		||||
        <translation></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
</context>
 | 
			
		||||
<context>
 | 
			
		||||
    <name>FilterLineEdit</name>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../filterlineedit.cpp" line="40"/>
 | 
			
		||||
        <location filename="../../filterlineedit.cpp" line="61"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation>Filtro</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
</context>
 | 
			
		||||
<context>
 | 
			
		||||
    <name>MainWidget</name>
 | 
			
		||||
    <message>
 | 
			
		||||
 
 | 
			
		||||
@@ -72,22 +72,28 @@
 | 
			
		||||
        <translation>バックアップディスク使用容量</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="54"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.ui" line="122"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="210"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="55"/>
 | 
			
		||||
        <source>Default account</source>
 | 
			
		||||
        <translation>標準アカウント</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="61"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="62"/>
 | 
			
		||||
        <source>Are you sure to remove the backup of the following entry?</source>
 | 
			
		||||
        <translation>次の項目のバックアップを削除してもよろしいですか?</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="84"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="85"/>
 | 
			
		||||
        <source>Backup disk usage: %1</source>
 | 
			
		||||
        <translation>バックアップディスク使用容量: %1</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="175"/>
 | 
			
		||||
        <location filename="../../backupmanagerform.cpp" line="176"/>
 | 
			
		||||
        <source> - (Launcher only)</source>
 | 
			
		||||
        <translation> - (LiveArea専用)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -294,6 +300,15 @@
 | 
			
		||||
</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
</context>
 | 
			
		||||
<context>
 | 
			
		||||
    <name>FilterLineEdit</name>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../filterlineedit.cpp" line="40"/>
 | 
			
		||||
        <location filename="../../filterlineedit.cpp" line="61"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
</context>
 | 
			
		||||
<context>
 | 
			
		||||
    <name>MainWidget</name>
 | 
			
		||||
    <message>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user