diff --git a/tabbox/desktopmodel.cpp b/tabbox/desktopmodel.cpp index 8415536de3..dbb4a70147 100644 --- a/tabbox/desktopmodel.cpp +++ b/tabbox/desktopmodel.cpp @@ -73,6 +73,18 @@ QVariant DesktopModel::data(const QModelIndex& index, int role) const } } +QString DesktopModel::longestCaption() const +{ + QString caption; + for (int desktop : m_desktopList) { + QString desktopName = tabBox->desktopName(desktop); + if (desktopName.size() > caption.size()) { + caption = desktopName; + } + } + return caption; +} + int DesktopModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent) diff --git a/tabbox/desktopmodel.h b/tabbox/desktopmodel.h index c412e2cde0..a069e47092 100644 --- a/tabbox/desktopmodel.h +++ b/tabbox/desktopmodel.h @@ -59,6 +59,7 @@ public: virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; virtual QModelIndex parent(const QModelIndex& child) const; virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; + Q_INVOKABLE QString longestCaption() const; /** * Generates a new list of desktops based on the current config.