mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Elements panel: added methods to easily get the underlying filepath for a particular item.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2022 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -682,6 +682,53 @@ ElementsCategory *ElementsPanel::categoryForPos(const QPoint &pos) {
|
||||
return(categoryForItem(pos_qtwi));
|
||||
}
|
||||
|
||||
/**
|
||||
@param qtwi a QTreeWidgetItem
|
||||
@return the directory path of the object represented by \a qtwi
|
||||
*/
|
||||
QString ElementsPanel::dirPathForItem(QTreeWidgetItem *item) {
|
||||
QString file_path = filePathForItem(item);
|
||||
if (!file_path.isEmpty()) {
|
||||
QFileInfo path_info(file_path);
|
||||
if (path_info.isDir()) {
|
||||
return(file_path);
|
||||
}
|
||||
else {
|
||||
return(path_info.canonicalPath());
|
||||
}
|
||||
}
|
||||
return(QString());
|
||||
}
|
||||
|
||||
/**
|
||||
@param qtwi a QTreeWidgetItem
|
||||
@return the filepath of the object represented by \a qtwi
|
||||
*/
|
||||
QString ElementsPanel::filePathForItem(QTreeWidgetItem *item) {
|
||||
if (!item) return(QString());
|
||||
|
||||
ElementsCollectionItem *collection_item = collectionItemForItem(item);
|
||||
if (collection_item) {
|
||||
if (collection_item -> hasFilePath()) {
|
||||
return(collection_item -> filePath());
|
||||
}
|
||||
}
|
||||
else {
|
||||
TitleBlockTemplateLocation tbt_location = templateLocationForItem(item);
|
||||
TitleBlockTemplatesCollection *tbt_collection = tbt_location.parentCollection();
|
||||
if (tbt_collection && tbt_collection -> hasFilePath()) {
|
||||
return(tbt_collection -> filePath());
|
||||
}
|
||||
else {
|
||||
QETProject *project = projectForItem(item);
|
||||
if (project) {
|
||||
return(project -> filePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
return(QString());
|
||||
}
|
||||
|
||||
/**
|
||||
Hide items that do not match the provided string, ensure others are visible
|
||||
along with their parent hierarchy. When ending the filtering, restore the tree
|
||||
|
||||
Reference in New Issue
Block a user