Merged feature-filter into master

This commit is contained in:
Xian Nox
2013-11-28 07:07:57 +01:00
parent 8c083ea0a4
commit 698f12e2d7
10 changed files with 178 additions and 10 deletions

View File

@@ -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);
}
}
}
}

View File

@@ -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

View File

@@ -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>

53
filterlineedit.cpp Normal file
View File

@@ -0,0 +1,53 @@
#include "filterlineedit.h"
#include <QStyle>
#include <QIcon>
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);
}

31
filterlineedit.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef FILTERLINEEDIT_H
#define FILTERLINEEDIT_H
#include <QLineEdit>
#include <QToolButton>
class FilterLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit FilterLineEdit(QWidget *parent = 0);
signals:
public slots:
private slots:
void updateCloseButton(const QString &text);
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
void resizeEvent(QResizeEvent *e);
private:
QToolButton *clearButton;
};
#endif // FILTERLINEEDIT_H

View File

@@ -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

View File

@@ -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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

View File

@@ -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 type="unfinished"></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="21"/>
<location filename="../../filterlineedit.cpp" line="40"/>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>
<message>

View File

@@ -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="21"/>
<location filename="../../filterlineedit.cpp" line="40"/>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWidget</name>
<message>