Added simple search capability to TemplatePicker.
This commit is contained in:
@@ -15,6 +15,7 @@ set (glabels_sources
|
|||||||
MergeField.cpp
|
MergeField.cpp
|
||||||
MergeRecord.cpp
|
MergeRecord.cpp
|
||||||
TemplatePicker.cpp
|
TemplatePicker.cpp
|
||||||
|
TemplatePickerItem.cpp
|
||||||
TextNode.cpp
|
TextNode.cpp
|
||||||
NewLabelDialog.cpp
|
NewLabelDialog.cpp
|
||||||
)
|
)
|
||||||
@@ -45,6 +46,7 @@ include (${QT_USE_FILE})
|
|||||||
|
|
||||||
include_directories (
|
include_directories (
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${glabels_qt_SOURCE_DIR}
|
${glabels_qt_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ namespace gLabels
|
|||||||
|
|
||||||
QList<libglabels::Template*> tmplates = libglabels::Db::templates();
|
QList<libglabels::Template*> tmplates = libglabels::Db::templates();
|
||||||
templatePicker->setTemplates( tmplates );
|
templatePicker->setTemplates( tmplates );
|
||||||
|
|
||||||
|
connect( searchEntry, SIGNAL(textChanged(const QString &)),
|
||||||
|
this, SLOT(searchEntryTextChanged(const QString &)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NewLabelDialog::searchEntryTextChanged( const QString &text )
|
||||||
|
{
|
||||||
|
templatePicker->applyFilter( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ namespace gLabels
|
|||||||
public:
|
public:
|
||||||
NewLabelDialog( QWidget *parent );
|
NewLabelDialog( QWidget *parent );
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
|
void searchEntryTextChanged( const QString &text );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+23
-3
@@ -20,9 +20,10 @@
|
|||||||
|
|
||||||
#include "TemplatePicker.h"
|
#include "TemplatePicker.h"
|
||||||
|
|
||||||
#include <QListWidgetItem>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include "TemplatePickerItem.h"
|
||||||
|
|
||||||
|
|
||||||
namespace gLabels
|
namespace gLabels
|
||||||
{
|
{
|
||||||
@@ -42,9 +43,28 @@ namespace gLabels
|
|||||||
{
|
{
|
||||||
foreach (libglabels::Template *tmplate, tmplates)
|
foreach (libglabels::Template *tmplate, tmplates)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = new QListWidgetItem( tmplate->name(), this );
|
TemplatePickerItem *item = new TemplatePickerItem( tmplate, this );
|
||||||
item->setIcon( QIcon(tmplate->preview()) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TemplatePicker::applyFilter( const QString &searchString )
|
||||||
|
{
|
||||||
|
foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) )
|
||||||
|
{
|
||||||
|
TemplatePickerItem *tPitem = dynamic_cast<TemplatePickerItem *>(item);
|
||||||
|
|
||||||
|
if ( tPitem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) )
|
||||||
|
{
|
||||||
|
item->setHidden( false );
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item->setHidden( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace gLabels
|
|||||||
|
|
||||||
void setTemplates( const QList <libglabels::Template*> &tmplates );
|
void setTemplates( const QList <libglabels::Template*> &tmplates );
|
||||||
|
|
||||||
|
void applyFilter( const QString &searchString );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/* TemplatePickerItem.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt 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.
|
||||||
|
*
|
||||||
|
* gLabels-qt 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 gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TemplatePickerItem.h"
|
||||||
|
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
|
namespace gLabels
|
||||||
|
{
|
||||||
|
|
||||||
|
TemplatePickerItem::TemplatePickerItem( libglabels::Template *tmplate,
|
||||||
|
QListWidget *parent = 0 )
|
||||||
|
: QListWidgetItem(parent)
|
||||||
|
{
|
||||||
|
mTmplate = tmplate;
|
||||||
|
|
||||||
|
setIcon( QIcon(tmplate->preview()) );
|
||||||
|
setText( tmplate->name() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/* TemplatePickerItem.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt 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.
|
||||||
|
*
|
||||||
|
* gLabels-qt 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 gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef glabels_TemplatePickerItem_h
|
||||||
|
#define glabels_TemplatePickerItem_h
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "libglabels/Template.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace gLabels
|
||||||
|
{
|
||||||
|
|
||||||
|
class TemplatePickerItem : public QListWidgetItem
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
TemplatePickerItem( libglabels::Template *tmplate, QListWidget *parent );
|
||||||
|
|
||||||
|
inline const libglabels::Template *tmplate() const { return mTmplate; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
libglabels::Template *mTmplate;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // glabels_TemplatePickerItem_h
|
||||||
@@ -38,10 +38,12 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
Db::init();
|
Db::init();
|
||||||
////// TEMPORARY TESTING ////////
|
////// TEMPORARY TESTING ////////
|
||||||
|
#if 0
|
||||||
Db::printKnownPapers();
|
Db::printKnownPapers();
|
||||||
Db::printKnownCategories();
|
Db::printKnownCategories();
|
||||||
Db::printKnownVendors();
|
Db::printKnownVendors();
|
||||||
Db::printKnownTemplates();
|
Db::printKnownTemplates();
|
||||||
|
#endif
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
MainWindow mainWin;
|
MainWindow mainWin;
|
||||||
|
|||||||
@@ -271,7 +271,7 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>gLabels::TemplatePicker</class>
|
<class>gLabels::TemplatePicker</class>
|
||||||
<extends>QListWidget</extends>
|
<extends>QListWidget</extends>
|
||||||
<header>../../app/TemplatePicker.h</header>
|
<header>TemplatePicker.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
Reference in New Issue
Block a user