mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +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));
|
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
|
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
|
along with their parent hierarchy. When ending the filtering, restore the tree
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class ElementsPanel : public GenericPanel {
|
|||||||
ElementsCollectionItem *selectedItem() const;
|
ElementsCollectionItem *selectedItem() const;
|
||||||
ElementsCategory *categoryForItem(QTreeWidgetItem *);
|
ElementsCategory *categoryForItem(QTreeWidgetItem *);
|
||||||
ElementsCategory *categoryForPos(const QPoint &);
|
ElementsCategory *categoryForPos(const QPoint &);
|
||||||
|
QString dirPathForItem(QTreeWidgetItem *);
|
||||||
|
QString filePathForItem(QTreeWidgetItem *);
|
||||||
|
|
||||||
void reloadCollections();
|
void reloadCollections();
|
||||||
int elementsCollectionItemsCount();
|
int elementsCollectionItemsCount();
|
||||||
|
|||||||
Reference in New Issue
Block a user