correctly map root folder to source model
This commit is contained in:
@@ -103,9 +103,9 @@ void ProjectPanel::set_project(Project* p)
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex ProjectPanel::get_root_index() const
|
||||
Folder *ProjectPanel::get_root() const
|
||||
{
|
||||
return explorer_->get_root_index();
|
||||
return explorer_->get_root();
|
||||
}
|
||||
|
||||
void ProjectPanel::set_root(Folder *item)
|
||||
@@ -170,7 +170,7 @@ void ProjectPanel::Edit(Node* item)
|
||||
|
||||
void ProjectPanel::Retranslate()
|
||||
{
|
||||
if (explorer_->get_root_index().isValid()) {
|
||||
if (project() && explorer_->get_root() != project()->root()) {
|
||||
SetTitle(tr("Folder"));
|
||||
} else {
|
||||
SetTitle(tr("Project"));
|
||||
@@ -207,10 +207,10 @@ void ProjectPanel::UpdateSubtitle()
|
||||
if (project()) {
|
||||
QString project_title = QStringLiteral("[*]%1").arg(project()->name());
|
||||
|
||||
if (explorer_->get_root_index().isValid()) {
|
||||
if (explorer_->get_root() != project()->root()) {
|
||||
QString folder_path;
|
||||
|
||||
Folder* item = static_cast<Folder*>(explorer_->get_root_index().internalPointer());
|
||||
Folder* item = explorer_->get_root();
|
||||
|
||||
do {
|
||||
folder_path.prepend(QStringLiteral("/%1").arg(item->GetLabel()));
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
Project* project() const;
|
||||
void set_project(Project* p);
|
||||
|
||||
QModelIndex get_root_index() const;
|
||||
Folder *get_root() const;
|
||||
|
||||
void set_root(Folder* item);
|
||||
|
||||
|
||||
@@ -511,9 +511,15 @@ void ProjectExplorer::set_project(Project *p)
|
||||
model_.set_project(p);
|
||||
}
|
||||
|
||||
QModelIndex ProjectExplorer::get_root_index() const
|
||||
Folder *ProjectExplorer::get_root() const
|
||||
{
|
||||
return tree_view_->rootIndex();
|
||||
QModelIndex root_index = sort_model_.mapToSource(tree_view_->rootIndex());
|
||||
|
||||
if (!root_index.isValid()) {
|
||||
return project()->root();
|
||||
}
|
||||
|
||||
return static_cast<Folder *>(root_index.internalPointer());
|
||||
}
|
||||
|
||||
void ProjectExplorer::set_root(Folder *item)
|
||||
|
||||
@@ -55,8 +55,7 @@ public:
|
||||
Project* project() const;
|
||||
void set_project(Project* p);
|
||||
|
||||
QModelIndex get_root_index() const;
|
||||
|
||||
Folder *get_root() const;
|
||||
void set_root(Folder *item);
|
||||
|
||||
QVector<Node *> SelectedItems() const;
|
||||
|
||||
@@ -154,7 +154,7 @@ MainWindowLayoutInfo MainWindow::SaveLayout() const
|
||||
|
||||
foreach (ProjectPanel* panel, folder_panels_) {
|
||||
if (panel->project()) {
|
||||
info.add_folder(static_cast<Folder*>(panel->get_root_index().internalPointer()));
|
||||
info.add_folder(panel->get_root());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user