[kwin] Add a method longestCaption() in TabBox::DesktopModel.

REVIEW: 114585
This commit is contained in:
Mihail Ivchenko 2013-12-21 18:35:55 +04:00 committed by Martin Gräßlin
parent 22640e26f3
commit d7e2df674a
2 changed files with 13 additions and 0 deletions

View file

@ -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)

View file

@ -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.