Originally Posted by
fullmetalcoder
There is no helper for this, you'll have to implement this on your own. I suggest you perform this at model level by keeping a record of columns state (shown or hidden), possibly through a QSet<bool> whoses indexes would correspond to columns. Then you should return a columnCount() according to the number of hidden columns and finally you should make sure that hidden columns do not mess up the data by modifying the data() setData() functions.
It should not be too hard but, as you pointed out, there is one limitation : the first column should not be hidden (unless the way you store hierarchy allows it...). If you still have problems you should send some code...
Implementing this as a part of model will lose all the flexibility mode/view framework provides. This model needs to connect to two views.
Which code do you want? For model class data is basically represented like in qt's example of simpletreemodel. It is further worked on to extend the functionality of sorting, filtering, and drag&drop moving. All this means relevant code is of about 1000 lines.
For how columns are shown/hidden/managed is like this:
void GMediaBrowser::updateViewColumnsSetup(Gravity::PlaylistViewType view_type){
if(view_type != mViewType)
return;
QList<GPlaylistViewColumns::Arrangement> arrangement = Gravity::self()->playlistViewColumns()->arrangement(mViewType);
for(int i = 0; i < arrangement.size(); ++i){
const GPlaylistViewColumns::Arrangement arr = arrangement.at(i);
header->setResizeMode(arr.colId - 1, arr.resizeMode);
header->moveSection(header->visualIndex(arr.colId - 1), i);
header->setSectionHidden(arr.colId - 1, !arr.isVisible);
}
}
void GMediaBrowser::updateViewColumnsSetup(Gravity::PlaylistViewType view_type){
if(view_type != mViewType)
return;
QHeaderView *header = m_pModelView->header();
QList<GPlaylistViewColumns::Arrangement> arrangement = Gravity::self()->playlistViewColumns()->arrangement(mViewType);
for(int i = 0; i < arrangement.size(); ++i){
const GPlaylistViewColumns::Arrangement arr = arrangement.at(i);
header->setResizeMode(arr.colId - 1, arr.resizeMode);
header->moveSection(header->visualIndex(arr.colId - 1), i);
header->setSectionHidden(arr.colId - 1, !arr.isVisible);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks