Ok, I am still learning Qt4 and trying to understand how to do things correctly, or as correct as they can be.
Here is my situation. I want to make use of QDirModel, but it doesn't have everything that I need, so I made an inherited class, MyDirModel.
MyDirModel adds a few extra columns to QDirModel on population.
Then I have a couple of QAbstractProxyModels because I want to display the data differently. I have a FolderTreeProxyModel and a FolderListTreeProxyModel. One displays only a few columns and folders only the other displays all columns and files and folders.
Finally I have two custom QTreeView classes. FolderTree and FolderListTree. Which I set the model FolderTreeProxyModel and FolderListProxyModel respectively.
Now here's where I am not sure if I am doing this correctly or not. How do I reference indexes from MyDirModel, do I have to reimplement all the sorting searching loading functions?
Example:
...
...
{
if (!myDirModel->isDir(dir))
{
dir = dir.parent();
}
if (dir != folderListTree->rootIndex() && myDirModel->isDir(dir))
{
folderListTree->setCurrentIndex(index);
folderListTree->setCurrentIndex(index);
lineEdit->setText(myDirModel->filePath(dir));
}
}
...
connect(folderTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(setRootIndex(QModelIndex)));
...
void mainwindow::setRootIndex(QModelIndex index)
{
QModelIndex dir = index.sibling(index.row(), 0);
if (!myDirModel->isDir(dir))
{
dir = dir.parent();
}
if (dir != folderListTree->rootIndex() && myDirModel->isDir(dir))
{
folderListTree->setCurrentIndex(index);
folderListTree->setCurrentIndex(index);
lineEdit->setText(myDirModel->filePath(dir));
}
}
To copy to clipboard, switch view to plain text mode
This won't work because the index is from MyDirModel? I am kinda confused on this abstraction process any ides/suggestions would be greatly appreciated!
-KW
Bookmarks