Adding additional IOutputViewModel
dukju ahn
dukjuahn at gmail.com
Mon Jun 11 13:46:18 UTC 2007
2007/6/11, Andreas Pakulat <apaku at gmx.de>:
> On 11.06.07 04:04:28, dukju ahn wrote:
> > I suggest that we provide model interface such as,
> >
> > class IOutputViewModel
> > {
> > void activate(QModelIndex)
> > QModelIndex highlightNext()
> > QModelIndex highlightPrev()
> > Qlist<QMenu> contextMenu(QModelIndex)
> > }
> > and make the users double-inherit with QAbsItemModel
>
> So the outputview then does some dynamic_casting if he wants to activate
> or highlight right?
Yes. right. Just think about how was the old IOutputViewItem used.
> > 1. think about makebuilders' show next error stuff, which I implemented.
> > Although the item can be activated, item cannot be selected in GUI
> > because item selection is done in QAbsItemView::setCurrentIndex().
> > And it's a bad idea to provides IOutputView::setCurrentIndex() stuff
> > because view are hided from outside world.
> > By above interface, outputview knows which item to highlight.
>
> I don't see how the above would help here, but maybe I just can't
> imagine enough :) Would you please provide a compilable patch for this
> part at least.
Some skelecton code would be more understandable than full code patch.
// user clicked menu, menu slot is executed.
StdOutputView::slotSearchNext()
{
emit searchNext();
}
OutputViewWidget::slotSearchNext()
{
foreach( each registered tab )
{
if( this tab was set default )
{
OutputListView view = dynamic_cast<OutputListView*> (tab->widget());
view->highlightNext();
}
}
}
class OutputListView : public QListView
{
void highlightNext()
{
OutputViewModel *model = dynamic_cast<OutputViewModel>(this->model());
QModelIndex tobeHighlightedIndex = model->highlightNext();
setCurrentIndex( tobeHighlightedIndex );
}
void activate( QModelIndex index )
{
OutputViewModel *model = dynamic_cast<OutputViewModel>(this->model());
model->activate( index );
}
}
class OutputViewModel : public QStandardItemModel, public IOutputViewModel
{
virtual QModelIndex hightlightNext() = 0;
virtual void activate( QModelIndex index ) = 0;
}
class MakeBuilderModel : public OutputViewModel
{
virtual QModelIndex highlightNext()
{
m_lastHighlight++;
// do some calcaulation.
return QModelIndex( m_lastHighlight );
}
int m_lastHighlight;
}
> > 2. Context menu is eaily retrieved.
>
> That part is wrong. We already have a way to let the plugins provide
> context actions. So if we need a context menu on the outputview (I don't
> see any users yet, so there's no need to do it right now, IMHO) we
> should create a new Context subclass and go the standard way of
> retrieving the context menu.
Yes. your approach is better.
More information about the KDevelop-devel
mailing list