Commit 2f3875f7 authored by Sascha Peilicke's avatar Sascha Peilicke

Removed unused class ListViewContainer from src/ViewContainer.[h|cpp].

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=1098792
parent 13bc81e1
......@@ -803,141 +803,4 @@ void StackedViewContainer::removeViewWidget( QWidget* view )
_stackWidget->removeWidget(view);
}
ListViewContainer::ListViewContainer(NavigationPosition position,QObject* parent)
: ViewContainer(position,parent)
{
_splitter = new QSplitter;
_listWidget = new ProfileListWidget(_splitter);
QWidget *contentArea = new QWidget(_splitter);
QVBoxLayout *layout = new QVBoxLayout(contentArea);
_stackWidget = new QStackedWidget(contentArea);
searchBar()->setParent(contentArea);
layout->addWidget(_stackWidget);
layout->addWidget(searchBar());
layout->setContentsMargins(0, 0, 0, 0);
// elide left is used because the most informative part of the session name is often
// the rightmost part
//
// this means you get entries looking like:
//
// ...dirA ...dirB ...dirC ( helpful )
//
// instead of
//
// johnSmith@comput... johnSmith@comput... ( not so helpful )
//
_listWidget->setTextElideMode( Qt::ElideLeft );
_listWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
_listWidget->setDragDropMode(QAbstractItemView::DragDrop);
_splitter->addWidget(_listWidget);
_splitter->addWidget(contentArea);
connect( _listWidget , SIGNAL(currentRowChanged(int)) , this , SLOT(rowChanged(int)) );
}
ListViewContainer::~ListViewContainer()
{
_splitter->deleteLater();
}
QWidget* ListViewContainer::containerWidget() const
{
return _splitter;
}
QWidget* ListViewContainer::activeView() const
{
return _stackWidget->currentWidget();
}
QBrush ListViewContainer::randomItemBackground(int r)
{
int i = r%6;
//and now for something truly unpleasant:
static const int r1[] = {255,190,190,255,190,255};
static const int r2[] = {255,180,180,255,180,255};
static const int b1[] = {190,255,190,255,255,190};
static const int b2[] = {180,255,180,255,255,180};
static const int g1[] = {190,190,255,190,255,255};
static const int g2[] = {180,180,255,180,255,255};
// hardcoded assumes item height is 32px
QLinearGradient gradient( QPoint(0,0) , QPoint(0,32) );
gradient.setColorAt(0,QColor(r1[i],g1[i],b1[i],100));
gradient.setColorAt(0.5,QColor(r2[i],g2[i],b2[i],100));
gradient.setColorAt(1,QColor(r1[i],g1[i],b1[i],100));
return QBrush(gradient);
}
void ListViewContainer::addViewWidget( QWidget* view , int )
{
_stackWidget->addWidget(view);
ViewProperties* properties = viewProperties(view);
QListWidgetItem* item = new QListWidgetItem(_listWidget);
item->setText( properties->title() );
item->setIcon( properties->icon() );
const int randomIndex = _listWidget->count();
item->setData( Qt::BackgroundRole , randomItemBackground(randomIndex) );
connect( properties , SIGNAL(titleChanged(ViewProperties*)) , this , SLOT(updateTitle(ViewProperties*)));
connect( properties , SIGNAL(iconChanged(ViewProperties*)) , this , SLOT(updateIcon(ViewProperties*)));
}
void ListViewContainer::removeViewWidget( QWidget* view )
{
if (!_stackWidget)
return;
int index = _stackWidget->indexOf(view);
_stackWidget->removeWidget(view);
delete _listWidget->takeItem( index );
}
void ListViewContainer::setActiveView( QWidget* view )
{
_stackWidget->setCurrentWidget(view);
_listWidget->setCurrentRow(_stackWidget->indexOf(view));
}
void ListViewContainer::rowChanged( int row )
{
// row may be -1 if the last row has been removed from the model
if ( row >= 0 )
{
_stackWidget->setCurrentIndex( row );
emit activeViewChanged( _stackWidget->currentWidget() );
}
}
void ListViewContainer::updateTitle( ViewProperties* properties )
{
QList<QWidget*> items = widgetsForItem(properties);
QListIterator<QWidget*> itemIter(items);
while ( itemIter.hasNext() )
{
int index = _stackWidget->indexOf( itemIter.next() );
_listWidget->item( index )->setText( properties->title() );
}
}
void ListViewContainer::updateIcon( ViewProperties* properties )
{
QList<QWidget*> items = widgetsForItem(properties);
QListIterator<QWidget*> itemIter(items);
while ( itemIter.hasNext() )
{
int index = _stackWidget->indexOf( itemIter.next() );
_listWidget->item( index )->setIcon( properties->icon() );
}
}
#include "ViewContainer.moc"
......@@ -477,38 +477,5 @@ private:
QPointer<QStackedWidget> _stackWidget;
};
/**
* A view container which uses a list instead of tabs to provide navigation
* between sessions.
*/
class ListViewContainer : public ViewContainer
{
Q_OBJECT
public:
ListViewContainer(NavigationPosition position , QObject* parent);
virtual ~ListViewContainer();
virtual QWidget* containerWidget() const;
virtual QWidget* activeView() const;
virtual void setActiveView(QWidget* view);
protected:
virtual void addViewWidget( QWidget* view , int index);
virtual void removeViewWidget( QWidget* view );
private slots:
void rowChanged( int row );
void updateTitle( ViewProperties* );
void updateIcon( ViewProperties* );
private:
QBrush randomItemBackground(int randomIndex);
QPointer<QStackedWidget> _stackWidget;
QSplitter* _splitter;
QListWidget* _listWidget;
};
}
#endif //VIEWCONTAINER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment