Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addd CStdGadgetTree::setTitle() method #45

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Qt/QtGadgetTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void CQtTreeWidget::construct(const std::string &a_title)
{
/* Set some sensible default settings, such as the number of columns to display */
setColumnCount(1);
setHeaderLabels(QStringList(a_title.c_str()));
setHeaderLabel(a_title.c_str());
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

/* And connect the itemClicked() slot so that we are notified when an item is clicked */
Expand Down
5 changes: 5 additions & 0 deletions Qt/QtGadgetTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class CQtTreeWidget : public QTreeWidget

void construct(const std::string &a_title);

void setTitle(const std::string &a_title)
{
setHeaderLabel(a_title.c_str());
}

public slots:

void itemClicked();
Expand Down
28 changes: 28 additions & 0 deletions StdGadgetTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,31 @@ void CStdGadgetTree::setContent(StdList<CTreeNode> &a_items)
#endif /* ! QT_GUI_LIB */

}

/**
* Sets the title of the gadget tree.
* Sets or updates the title currently displayed in the gadget tree.
*
* @date Friday 29-Dec-2023 11:00 am, Code HQ @ Ashley's house
* @param a_title Title to be displayed at the top of the tree's column
*/

void CStdGadgetTree::setTitle(const std::string &a_title)
{

#ifdef __amigaos__

/* For Amiga OS the title string is not copied by the native gadget, so we copy it into our own persistent memory */
/* before assigning it to the tree */
m_title = a_title;
g_columnInfo[0].ci_Title = (STRPTR) m_title.c_str();

SetGadgetAttrs((struct Gadget *) m_poGadget, NULL, NULL, LISTBROWSER_ColumnInfo, (ULONG) g_columnInfo, TAG_DONE);

#elif defined(QT_GUI_LIB)

m_tree.setTitle(a_title);

#endif /* QT_GUI_LIB */

}
2 changes: 2 additions & 0 deletions StdGadgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ class CStdGadgetTree : public CStdGadget
std::string getSelectedItem();

void setContent(StdList<CTreeNode> &a_items);

void setTitle(const std::string &a_title);
};

/* Mixin class for the slider or proportional gadget to be able to notify its client */
Expand Down