Replace some uses of static_cast with qobject_cast

This commit is contained in:
Jonas Kvinge
2020-07-17 01:32:07 +02:00
parent 9e32f0d778
commit 71a1ea481b
12 changed files with 21 additions and 21 deletions

View File

@@ -72,7 +72,7 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
QList<QUrl> urls;
for (const QModelIndex& index : menu_selection_.indexes()) {
if (index.column() == 0)
urls << QUrl::fromLocalFile(static_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
urls << QUrl::fromLocalFile(qobject_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
}
std::sort(urls.begin(), urls.end());
@@ -98,7 +98,7 @@ MimeData *FileViewList::MimeDataFromSelection() const {
}
// otherwise, use the current root path
else {
QString path = static_cast<QFileSystemModel*>(model())->rootPath();
QString path = qobject_cast<QFileSystemModel*>(model())->rootPath();
if (path.length() > 20) {
QFileInfo info(path);
if (info.isDir()) {
@@ -122,7 +122,7 @@ QStringList FileViewList::FilenamesFromSelection() const {
QStringList filenames;
for (const QModelIndex& index : menu_selection_.indexes()) {
if (index.column() == 0)
filenames << static_cast<QFileSystemModel*>(model())->filePath(index);
filenames << qobject_cast<QFileSystemModel*>(model())->filePath(index);
}
return filenames;

View File

@@ -145,7 +145,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
background_ = QPixmap(":/pictures/osd_background.png");
// Set the margins to allow for the drop shadow
QBoxLayout *l = static_cast<QBoxLayout*>(layout());
QBoxLayout *l = qobject_cast<QBoxLayout*>(layout());
int margin = l->margin() + kDropShadowSize;
l->setMargin(margin);