void PackageModel::packageInstalled( const InstallControl::PackageInfo &pkg )
{
    // the row of member variable installed is 0, hence index(0, ...); start searching from first child
    QModelIndexList matchList = match( this->index(0, 0).child(0,0),AbstractPackageController::Md5Sum ,QVariant(pkg.md5Sum), 1);
    if ( matchList.size() > 0  )
        emit newlyInstalled( matchList[0] );
}
Beispiel #2
0
PackageView::PackageView( QWidget *parent, Qt::WFlags flags )
    : QMainWindow( parent, flags )
{
    setWindowTitle( tr( "Package Manager" ));
    model = new PackageModel( this );

    connect(model, SIGNAL(targetsUpdated(QStringList)),
            this, SLOT(targetsChanged(QStringList)));
    connect(model, SIGNAL(serversUpdated(QStringList)),
            this, SLOT(serversChanged(QStringList)));
    connect(this, SIGNAL(targetChoiceChanged(QString)),
            model, SLOT(userTargetChoice(QString)));
    connect(model, SIGNAL(serverStatus(QString)),
            this, SLOT(postServerStatus(QString)));
    connect(model,  SIGNAL(newlyInstalled(QModelIndex)),
            this, SLOT(selectNewlyInstalled(QModelIndex)));

    //setup view for installed packages
    installedView = new QTreeView( this );
    installedView->setModel( model  );
    installedView->setRootIndex( model->index(InstalledIndex,0,QModelIndex()) );
    installedView->setRootIsDecorated( false );
    installedView->setFrameStyle(QFrame::NoFrame);
    connect( installedView, SIGNAL(activated(QModelIndex)),
            this, SLOT(activateItem(QModelIndex)) );
    connect( model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
            installedView, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
    connect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
            installedView, SLOT(rowsRemoved(QModelIndex,int,int)));

    //setup page for installed packages
    QWidget *installedPage = new QWidget;
    QVBoxLayout *vbInstalledPage = new QVBoxLayout( installedPage );
    vbInstalledPage->setMargin( 0 );
    vbInstalledPage->addWidget( installedView );

    //setup view for downloadable packages
    downloadView = new QTreeView( this );
    downloadView->setModel( model );
    downloadView->setRootIndex( model->index(DownloadIndex,0,QModelIndex()) );
    downloadView->setRootIsDecorated( false );
    downloadView->setFrameStyle(QFrame::NoFrame);
    connect( downloadView, SIGNAL(activated(QModelIndex)),
            this, SLOT(activateItem(QModelIndex)) );
    connect( model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
            downloadView, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
    connect( model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
            downloadView, SLOT(rowsRemoved(QModelIndex,int,int)));
    downloadView->setItemDelegate(new DownloadViewDelegate(this));
    installedView->setItemDelegate(new ViewDelegate(this));

    //setup page for downloadable packages
    QWidget *downloadPage = new QWidget(this);
    QVBoxLayout *vbDownloadPage = new QVBoxLayout( downloadPage );
    vbDownloadPage->setSpacing( 2 );
    vbDownloadPage->setMargin( 2 );
    vbDownloadPage->addWidget( downloadView );
    statusLabel = new QLabel( "No Server Chosen", this );
    statusLabel->setWordWrap( true );
    vbDownloadPage->addWidget( statusLabel );

    installedView->hideColumn( 1 );
    installedView->header()->hide();
    downloadView->hideColumn( 1 );
    downloadView->header()->hide();
//TODO: install to media card
     menuTarget = new QMenu( tr( "Install to" ), this );
    new PackageManagerService( this );

    tabWidget = new QTabWidget( this );
    tabWidget->addTab( installedPage, tr( "Installed" ) );
    tabWidget->addTab( downloadPage, tr( "Downloads" ) );
    setCentralWidget( tabWidget );

    KeyFilter *keyFilter = new KeyFilter(tabWidget, this);
    installedView->installEventFilter(keyFilter);
    downloadView->installEventFilter(keyFilter);

    QTimer::singleShot( 0, this, SLOT(init()) );
}