Exemplo n.º 1
0
/**
 * Initialize this object.
 */
PakooView::PakooView( QWidget *parent )
    : DCOPObject("pakooIface"), QWidget(parent)
{
    m_backend = new PortageBackend();

    // Overall layout

    QHBoxLayout* topLayout = new QHBoxLayout( this );
    topLayout->setAutoAdd( true );

    m_hSplitter = new QSplitter( this );
    m_hSplitter->setOpaqueResize( true );

    QToolBox* toolBox = new QToolBox( m_hSplitter, "toolBox" );

    m_vSplitter = new QSplitter( m_hSplitter );
    m_vSplitter->setOrientation( QSplitter::Vertical );
    m_vSplitter->setOpaqueResize( true );


    // Adding the individual widgets

    m_treeView = new PackageTreeView( this, "treeView", m_backend );

    int sectionIndex = toolBox->addItem( m_treeView, TREEVIEWTEXT );
    m_sectionIndexes[sectionIndex] = BrowseSection;

    sectionIndex = toolBox->addItem(
                       new QLabel("Action View", 0, "tempactionlabel"), ACTIONVIEWTEXT );
    m_sectionIndexes[sectionIndex] = ActionSection;
    toolBox->setCurrentIndex( 1 );

    sectionIndex = toolBox->addItem(
                       new QLabel("Config View", 0, "tempconfiglabel"), CONFIGVIEWTEXT );
    m_sectionIndexes[sectionIndex] = ConfigSection;

    m_viewAreas = new QWidgetStack( m_vSplitter, "viewArea" );
    m_packageView = new PackageView( m_viewAreas, "packageView", m_backend );
    m_actionArea = new QWidgetStack( m_viewAreas, "actionArea" );
    JobView* jobView = new JobView( new EmergeProcess(), "title", m_actionArea, "jobView" );
    jobView->start();
    m_configArea = new QWidgetStack( m_viewAreas, "configArea" );
    new QLabel( "Config View", m_viewAreas, "configView" );
    m_viewAreas->raiseWidget( m_actionArea );

    m_packageInfoView = new PackageInfoView( m_vSplitter, "packageInfoView" );

    m_hSplitter->setResizeMode( toolBox, QSplitter::KeepSize );
    m_vSplitter->setResizeMode( m_packageInfoView->view(), QSplitter::KeepSize );

    m_vSplitter->setSizes( PakooConfig::vSplitterSizes() );
    m_hSplitter->setSizes( PakooConfig::hSplitterSizes() );


    //
    // Here comes the big connection creator
    //

    // Connect the QToolBox signals so the right side follows the left one
    connect(
        toolBox, SIGNAL( currentChanged(int) ),
        this,      SLOT( showSection(int) )
    );

    // Connect the package displaying widgets to work together
    connect(
        m_treeView,            SIGNAL( packageListChanged(PackageList&) ),
        m_packageView->listView, SLOT( setPackageList(PackageList&) )
    );
    connect(
        m_treeView,            SIGNAL( selectionChanged(PackageSelector&) ),
        m_packageView->listView, SLOT( setPackageSelector(PackageSelector&) )
    );
    connect(
        m_packageView->listView, SIGNAL( selectionChanged(Package*) ),
        m_packageInfoView, SLOT( displayPackage(Package*) )
    );
    connect(
        m_packageView->listView, SIGNAL(selectionChanged(Package*, PackageVersion*)),
        m_packageInfoView, SLOT(displayPackage(Package*, PackageVersion*))
    );

    // Connect the convenience method for copying text,
    // like pointed out by Scott Wheeler on the kde-core mailing list
    KStdAction::copy( KApplication::kApplication(), SLOT(copy()), NULL );

    // Connect the package list view with the status bar,
    // so the latter one is updated properly
    //TODO: adapt
    /*connect(
    	m_packageView->listView, SIGNAL(loadingPackageInfo(int,int)),
    	this, SLOT(handleLoadingPackageInfo(int,int))
    );
    connect(
    	m_packageView->listView, SIGNAL(finishedLoadingPackageDetails(PackageList&)),
    	this, SLOT(handleFinishedLoadingPackageDetails(PackageList&))
    );*/
}