logic: Directory list box now restricts the user to select files, directories or both if required
* split QtDirectoryListBox and QtStringListBox * renamed QtDirectoryListBox to QtPathListBox * extracted QtListItemWidget class to own file * renamed QtListItemWidget to QtListBoxItem * added SelectionPolicyType to QtPathListBox to allow for specifying if selecting files, directories or both should be allowed.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#include "qt/element/QtStringListBox.h"
|
||||
|
||||
#include <QListWidget>
|
||||
|
||||
#include "qt/element/QtStringListBoxItem.h"
|
||||
|
||||
QtStringListBox::QtStringListBox(QWidget *parent, const QString& listName)
|
||||
: QtListBox(parent, listName)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::wstring> QtStringListBox::getStrings()
|
||||
{
|
||||
std::vector<std::wstring> strings;
|
||||
for (int i = 0; i < m_list->count(); ++i)
|
||||
{
|
||||
QtListBoxItem* widget = dynamic_cast<QtListBoxItem*>(m_list->itemWidget(m_list->item(i)));
|
||||
strings.push_back(widget->getText().toStdWString());
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
void QtStringListBox::setStrings(const std::vector<std::wstring>& strings, bool readOnly)
|
||||
{
|
||||
clear();
|
||||
|
||||
for (const std::wstring& str : strings)
|
||||
{
|
||||
QtListBoxItem* itemWidget = addListBoxItemWithText(QString::fromStdWString(str));
|
||||
itemWidget->setReadOnly(readOnly);
|
||||
}
|
||||
}
|
||||
|
||||
QtListBoxItem* QtStringListBox::createListBoxItem(QListWidgetItem* item)
|
||||
{
|
||||
return new QtStringListBoxItem(this, item);
|
||||
}
|
||||
Reference in New Issue
Block a user