ui: fixed QtDirectoryListBox not sized correctly when overwriting list

This commit is contained in:
Eberhard Graether
2016-04-14 12:57:13 +02:00
parent 23fbe6c384
commit 9534ccb454
3 changed files with 14 additions and 11 deletions
@@ -5,6 +5,7 @@
#include <QMimeData>
#include <QScrollBar>
#include <QSysInfo>
#include <QTimer>
#include <QTreeView>
#include "utility/ResourcePaths.h"
@@ -243,13 +244,15 @@ std::vector<std::string> QtDirectoryListBox::getStringList()
void QtDirectoryListBox::setStringList(const std::vector<std::string>& list)
{
m_list->clear();
clear();
for (const std::string& str : list)
{
QtListItemWidget* widget = addListBoxItem();
widget->setText(QString::fromStdString(str));
}
QTimer::singleShot(1, this, SLOT(resize()));
}
void QtDirectoryListBox::selectItem(QListWidgetItem* item)
@@ -292,10 +295,10 @@ QtListItemWidget* QtDirectoryListBox::addListBoxItem()
QtListItemWidget* widget = new QtListItemWidget(this, item);
m_list->setItemWidget(item, widget);
resize();
widget->setFocus();
resize();
return widget;
}
@@ -315,12 +318,12 @@ void QtDirectoryListBox::removeListBoxItem()
rowIndex -= 1;
}
resize();
if (rowIndex >= 0)
{
m_list->setCurrentRow(rowIndex);
}
resize();
}
void QtDirectoryListBox::dragEnterEvent(QDragEnterEvent *event)
+5 -5
View File
@@ -68,18 +68,18 @@ protected:
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
private:
private slots:
void resize();
QtListItemWidget* addListBoxItem();
void removeListBoxItem();
private:
QPushButton* m_addButton;
QPushButton* m_removeButton;
QListWidget* m_list;
bool m_forStrings;
private slots:
QtListItemWidget* addListBoxItem();
void removeListBoxItem();
};
#endif // QT_DIRECTORY_LIST_BOX_H
@@ -185,7 +185,7 @@ QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource(
QSize QtProjectWizzardContentPathsSource::preferredWindowSize() const
{
return QSize(750, 370);
return QSize(750, 400);
}
void QtProjectWizzardContentPathsSource::load()