You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.8 KiB
113 lines
3.8 KiB
#include <qlineedit.h>
|
|
#include <qcombobox.h>
|
|
#include <qtextbrowser.h>
|
|
#include <qcheckbox.h>
|
|
#include <klocale.h>
|
|
#include <kconfig.h>
|
|
|
|
#include <cmath>
|
|
|
|
#include <apt-front/cache/entity/desktop.h>
|
|
#include <apt-front/predicate/factory.h>
|
|
#include <ept/debtags/vocabulary.h>
|
|
#include <adept/installerview.h>
|
|
#include <adept/packageinfo.h>
|
|
#include <adept/utils.h>
|
|
|
|
using namespace adept;
|
|
using namespace aptFront;
|
|
using namespace cache;
|
|
|
|
void InstallerView::rebuild()
|
|
{
|
|
typedef predicate::Factory< entity::Desktop > Factory;
|
|
if ( m_inRebuild ) {
|
|
QTimer::singleShot( 500, this, SLOT( rebuild() ) );
|
|
return;
|
|
}
|
|
m_inRebuild = true;
|
|
|
|
component::Desktop &d = cache::Global::get().component< component::Desktop >();
|
|
ept::debtags::Vocabulary &t =
|
|
cache::Global::get().tags();
|
|
|
|
Predicate p = predicate::True< entity::Desktop >();
|
|
if ( m_search->text() != u8( "" ) ) {
|
|
Predicate tmp = Factory::name( u8( m_search->text() ) )
|
|
or Factory::description( u8( m_search->text() ) );
|
|
p = p and tmp;
|
|
}
|
|
|
|
std::string st = "";
|
|
int si = m_suite->currentItem();
|
|
|
|
if ( si == 0 ) st = "suite::kde";
|
|
if ( si == 1 ) st = "suite::gnome";
|
|
|
|
if ( st != "" )
|
|
p = p and Factory::tag( t.tagByName( st ) );
|
|
|
|
if ( !m_unsupported->isChecked() ) {
|
|
p = p and not Factory::sectionSubstring( "contrib" )
|
|
and not Factory::sectionSubstring( "universe" )
|
|
and not Factory::sectionSubstring( "multiverse" );
|
|
}
|
|
|
|
if ( !m_nonfree->isChecked() ) {
|
|
p = p and not Factory::sectionSubstring( "non-free" )
|
|
and not Factory::sectionSubstring( "multiverse" )
|
|
and not Factory::sectionSubstring( "restricted" );
|
|
}
|
|
|
|
selector()->fill( filteredRange( d.entries(), p ) );
|
|
|
|
m_inRebuild = false;
|
|
}
|
|
|
|
InstallerView::InstallerView( QWidget *p , const char *n )
|
|
: InstallerViewUi( p, n ), m_inRebuild( false )
|
|
{
|
|
connect( m_search, SIGNAL( textChanged( const QString & ) ),
|
|
this, SLOT( textChanged() ) );
|
|
connect( &timer, SIGNAL( timeout() ), this, SLOT( rebuild() ) );
|
|
connect( m_suite, SIGNAL( activated( int ) ), this, SLOT( rebuild() ) );
|
|
connect( m_unsupported, SIGNAL( toggled( bool ) ), this, SLOT( rebuild() ) );
|
|
connect( m_nonfree, SIGNAL( toggled( bool ) ), this, SLOT( rebuild() ) );
|
|
connect( selector(), SIGNAL( showDescription( cache::entity::Desktop ) ),
|
|
this, SLOT( showDescription( cache::entity::Desktop ) ) );
|
|
}
|
|
|
|
void InstallerView::textChanged() {
|
|
timer.start( 1000, true );
|
|
}
|
|
|
|
void InstallerView::showDescription( entity::Desktop e )
|
|
{
|
|
kdDebug() << "InstallerView::showDescription..." << endl;
|
|
QString file("/usr/share/app-install/desktop/" + e.package().name() + ".desktop");
|
|
KConfig desktopFile(QString("/usr/share/app-install/desktop/" + e.package().name() + ".desktop"), false, false);
|
|
QString name(desktopFile.name());
|
|
|
|
desktopFile.setGroup("Desktop Entry");
|
|
int popularity = desktopFile.readNumEntry("X-AppInstall-Popcon");
|
|
|
|
int popcon_max = 64284; //FIXME should be read at startup, this will change
|
|
int rank = 0;
|
|
if (popularity > 0) {
|
|
rank = (int)(5.0* log(popularity) / log(popcon_max+1));
|
|
}
|
|
|
|
QString rankText(" ");
|
|
for (int i = 0; i < rank; i++) {
|
|
rankText = rankText + "<img src='/usr/share/icons/crystalsvg/16x16/actions/bookmark.png' />";
|
|
}
|
|
|
|
QString l = u8(e.package().longDescription(
|
|
u8( i18n( "No long description available" ) ) ) );
|
|
|
|
m_description->setText( u8( "<b>" ) + e.name() + u8( "</b>" )
|
|
+ u8("<br /><b>") + i18n("Rank: ") + u8("</b>") + rankText.latin1()
|
|
+ i18n( "<br><b>Package:</b> " ) + e.package().name()
|
|
+ formatLongDescription( l ) );
|
|
}
|