Qt: C89 changes and other cleanups.

This commit is contained in:
CozmoP 2018-12-19 01:11:52 +01:00
parent f5840ae6f2
commit 95ed844d81
6 changed files with 14 additions and 18 deletions

View File

@ -27,17 +27,17 @@ void ThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem &opt
initStyleOption(&opt, index);
// draw the background
/* draw the background */
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, widget);
// draw the image
/* draw the image */
if (!pixmap.isNull())
{
QPixmap pixmapScaled = pixmap.scaled(adjusted.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
style->drawItemPixmap(painter, adjusted, Qt::AlignHCenter | Qt::AlignBottom, pixmapScaled);
}
// draw the text
/* draw the text */
if (!opt.text.isEmpty())
{
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
@ -195,6 +195,7 @@ void GridView::scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint)
viewport()->update();
}
/* TODO: Make this more efficient by changing m_rectForRow for another data structure. Look at how Qt's own views do it. */
QModelIndex GridView::indexAt(const QPoint &point_) const
{
QPoint point(point_);
@ -298,6 +299,7 @@ void GridView::scrollContentsBy(int dx, int dy)
emit(visibleItemsChangedMaybe());
}
/* TODO: Maybe add a way to get the previous/next visible indexes. */
QVector<QModelIndex> GridView::visibleIndexes() const {
return m_visibleIndexes;
}
@ -340,12 +342,16 @@ QRegion GridView::visualRegionForSelection(const QItemSelection &selection) cons
{
QRegion region;
QItemSelectionRange range;
int i = 0;
foreach(range, selection)
for (i; i < selection.size(); i++)
{
for (int row = range.top(); row <= range.bottom(); ++row)
range = selection.at(i);
int row = range.top();
for (row; row <= range.bottom(); ++row)
{
for (int column = range.left(); column < range.right(); ++column)
int column = range.left();
for (column; column < range.right(); ++column)
{
QModelIndex index = model()->index(row, column, rootIndex());
region += visualRect(index);

View File

@ -71,4 +71,4 @@ private:
mutable bool m_hashIsDirty;
};
#endif // GRIDVIEW_H
#endif

View File

@ -1177,7 +1177,6 @@ void MainWindow::reloadPlaylists()
QString MainWindow::getCurrentPlaylistPath()
{
QListWidgetItem *playlistItem = m_listWidget->currentItem();
QHash<QString, QString> contentHash;
QString playlistPath;
if (!playlistItem)

View File

@ -191,7 +191,6 @@ void MainWindow::onThumbnailPackDownloadFinished()
reply->disconnect();
reply->close();
//reply->deleteLater();
}
void MainWindow::onThumbnailPackDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)

View File

@ -247,7 +247,6 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
,m_loadCoreWindow(new LoadCoreWindow(this))
,m_timer(new QTimer(this))
,m_thumbnailTimer(new QTimer(this))
,m_currentCore()
,m_currentCoreVersion()
,m_statusLabel(new QLabel(this))
@ -322,6 +321,7 @@ MainWindow::MainWindow(QWidget *parent) :
,m_failedThumbnails(0)
,m_playlistThumbnailDownloadWasCanceled(false)
,m_pendingDirScrollPath()
,m_thumbnailTimer(new QTimer(this))
{
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
@ -338,8 +338,6 @@ MainWindow::MainWindow(QWidget *parent) :
QLabel *gridProgressLabel = NULL;
QHBoxLayout *gridFooterLayout = NULL;
//QApplication::setStyle(QStyleFactory::create("windowsvista"));
qRegisterMetaType<QPointer<ThumbnailWidget> >("ThumbnailWidget");
qRegisterMetaType<retro_task_callback_t>("retro_task_callback_t");
@ -1514,11 +1512,6 @@ QHash<QString, QString> MainWindow::getCurrentContentHash()
return getCurrentContentIndex().data(PlaylistModel::HASH).value<QHash<QString, QString> >();
}
void MainWindow::onContentItemDoubleClicked(QTableWidgetItem*)
{
onRunClicked();
}
void MainWindow::onContentItemDoubleClicked(const QModelIndex &index)
{
Q_UNUSED(index);

View File

@ -422,7 +422,6 @@ private slots:
void onSearchEnterPressed();
void onSearchLineEditEdited(const QString &text);
void onContentItemDoubleClicked(const QModelIndex &index);
void onContentItemDoubleClicked(QTableWidgetItem *item);
void onCoreLoadWindowClosed();
void onTreeViewItemsSelected(QModelIndexList selectedIndexes);
void onSearchResetClicked();