Silence -Woverloaded-virtual warnings in QFileDialog

The QPaintDevice::init() virtual, reimplemented in QWidget, is hidden by
these declarations, and clang (and gcc with -Woverloaded-virtual) warns
about this. There is no need to overload the init() name, use more
descriptive names instead.

dialogs/qsidebar_p.h:124:10: warning: 'QSidebar::init' hides overloaded
virtual
      function [-Woverloaded-virtual]
    void init(QFileSystemModel *model, const QList<QUrl> &newUrls);
         ^
dialogs/qfiledialog_p.h:303:10: warning: 'QFileDialogLineEdit::init'
hides
      overloaded virtual function [-Woverloaded-virtual]
    void init(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; }
         ^
dialogs/qfiledialog_p.h:314:10: warning: 'QFileDialogComboBox::init'
hides
      overloaded virtual function [-Woverloaded-virtual]
    void init(QFileDialogPrivate *d_pointer);
         ^
dialogs/qfiledialog_p.h:330:10: warning: 'QFileDialogListView::init'
hides
      overloaded virtual function [-Woverloaded-virtual]
    void init(QFileDialogPrivate *d_pointer);
         ^
dialogs/qfiledialog_p.h:342:10: warning: 'QFileDialogTreeView::init'
hides
      overloaded virtual function [-Woverloaded-virtual]
    void init(QFileDialogPrivate *d_pointer);
         ^
kernel/qwidget.h:682:10: note:
      hidden overloaded virtual function 'QWidget::init' declared here
    void init(QPainter *painter) const;
         ^

Change-Id: I7a317a551b92fde966e61958dcaf25dea94d69b4
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Bradley T. Hughes 2011-12-09 14:36:33 +01:00 committed by Qt by Nokia
parent c07b840739
commit 77f41a68b3
6 changed files with 19 additions and 20 deletions

View File

@ -2290,22 +2290,21 @@ void QFileDialogPrivate::createWidgets()
QList<QUrl> initialBookmarks;
initialBookmarks << QUrl::fromLocalFile(QLatin1String(""))
<< QUrl::fromLocalFile(QDir::homePath());
qFileDialogUi->sidebar->init(model, initialBookmarks);
qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks);
QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)),
q, SLOT(_q_goToUrl(QUrl)));
QObject::connect(qFileDialogUi->buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
QObject::connect(qFileDialogUi->buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
qFileDialogUi->lookInCombo->init(this);
qFileDialogUi->lookInCombo->setFileDialogPrivate(this);
QObject::connect(qFileDialogUi->lookInCombo, SIGNAL(activated(QString)), q, SLOT(_q_goToDirectory(QString)));
qFileDialogUi->lookInCombo->setInsertPolicy(QComboBox::NoInsert);
qFileDialogUi->lookInCombo->setDuplicatesEnabled(false);
// filename
qFileDialogUi->fileNameEdit->init(this);
qFileDialogUi->fileNameEdit->setFileDialogPrivate(this);
#ifndef QT_NO_SHORTCUT
qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit);
#endif
@ -2329,7 +2328,7 @@ void QFileDialogPrivate::createWidgets()
QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(QString)),
q, SIGNAL(filterSelected(QString)));
qFileDialogUi->listView->init(this);
qFileDialogUi->listView->setFileDialogPrivate(this);
qFileDialogUi->listView->setModel(model);
QObject::connect(qFileDialogUi->listView, SIGNAL(activated(QModelIndex)),
q, SLOT(_q_enterDirectory(QModelIndex)));
@ -2341,7 +2340,7 @@ void QFileDialogPrivate::createWidgets()
QObject::connect(shortcut, SIGNAL(activated()), q, SLOT(_q_deleteCurrent()));
#endif
qFileDialogUi->treeView->init(this);
qFileDialogUi->treeView->setFileDialogPrivate(this);
qFileDialogUi->treeView->setModel(model);
QHeaderView *treeHeader = qFileDialogUi->treeView->header();
QFontMetrics fm(q->font());
@ -3181,7 +3180,7 @@ QString QFileDialogPrivate::getEnvironmentVariable(const QString &string)
return string;
}
void QFileDialogComboBox::init(QFileDialogPrivate *d_pointer) {
void QFileDialogComboBox::setFileDialogPrivate(QFileDialogPrivate *d_pointer) {
d_ptr = d_pointer;
urlModel = new QUrlModel(this);
urlModel->showFullPath = true;
@ -3257,7 +3256,7 @@ QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent)
{
}
void QFileDialogListView::init(QFileDialogPrivate *d_pointer)
void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)
{
d_ptr = d_pointer;
setSelectionBehavior(QAbstractItemView::SelectRows);
@ -3294,7 +3293,7 @@ QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent)
{
}
void QFileDialogTreeView::init(QFileDialogPrivate *d_pointer)
void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)
{
d_ptr = d_pointer;
setSelectionBehavior(QAbstractItemView::SelectRows);

View File

@ -300,7 +300,7 @@ class QFileDialogLineEdit : public QLineEdit
{
public:
QFileDialogLineEdit(QWidget *parent = 0) : QLineEdit(parent), hideOnEsc(false), d_ptr(0){}
void init(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; }
void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; }
void keyPressEvent(QKeyEvent *e);
bool hideOnEsc;
private:
@ -311,7 +311,7 @@ class QFileDialogComboBox : public QComboBox
{
public:
QFileDialogComboBox(QWidget *parent = 0) : QComboBox(parent), urlModel(0) {}
void init(QFileDialogPrivate *d_pointer);
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
void showPopup();
void setHistory(const QStringList &paths);
QStringList history() const { return m_history; }
@ -327,7 +327,7 @@ class QFileDialogListView : public QListView
{
public:
QFileDialogListView(QWidget *parent = 0);
void init(QFileDialogPrivate *d_pointer);
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
QSize sizeHint() const;
protected:
void keyPressEvent(QKeyEvent *e);
@ -339,7 +339,7 @@ class QFileDialogTreeView : public QTreeView
{
public:
QFileDialogTreeView(QWidget *parent);
void init(QFileDialogPrivate *d_pointer);
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
QSize sizeHint() const;
protected:

View File

@ -371,7 +371,7 @@ QSidebar::QSidebar(QWidget *parent) : QListView(parent)
{
}
void QSidebar::init(QFileSystemModel *model, const QList<QUrl> &newUrls)
void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls)
{
// ### TODO make icon size dynamic
setIconSize(QSize(24,24));

View File

@ -121,7 +121,7 @@ Q_SIGNALS:
public:
QSidebar(QWidget *parent = 0);
void init(QFileSystemModel *model, const QList<QUrl> &newUrls);
void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls);
~QSidebar();
QSize sizeHint() const;

View File

@ -931,7 +931,7 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
QCOMPARE(qvariant_cast<bool>(value), false);
MyQSideBar mySideBar;
mySideBar.init(model, urls);
mySideBar.setModelAndUrls(model, urls);
mySideBar.show();
mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
QTest::qWait(1000);

View File

@ -84,7 +84,7 @@ void tst_QSidebar::setUrls()
QList<QUrl> urls;
QFileSystemModel fsmodel;
QSidebar qsidebar;
qsidebar.init(&fsmodel, urls);
qsidebar.setModelAndUrls(&fsmodel, urls);
QAbstractItemModel *model = qsidebar.model();
urls << QUrl::fromLocalFile(QDir::rootPath())
@ -105,7 +105,7 @@ void tst_QSidebar::selectUrls()
<< QUrl::fromLocalFile(QDir::temp().absolutePath());
QFileSystemModel fsmodel;
QSidebar qsidebar;
qsidebar.init(&fsmodel, urls);
qsidebar.setModelAndUrls(&fsmodel, urls);
QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(const QUrl &)));
qsidebar.selectUrl(urls.at(0));
@ -117,7 +117,7 @@ void tst_QSidebar::addUrls()
QList<QUrl> emptyUrls;
QFileSystemModel fsmodel;
QSidebar qsidebar;
qsidebar.init(&fsmodel, emptyUrls);
qsidebar.setModelAndUrls(&fsmodel, emptyUrls);
QAbstractItemModel *model = qsidebar.model();
QDir testDir = QDir::home();
@ -214,7 +214,7 @@ void tst_QSidebar::goToUrl()
<< QUrl::fromLocalFile(QDir::temp().absolutePath());
QFileSystemModel fsmodel;
QSidebar qsidebar;
qsidebar.init(&fsmodel, urls);
qsidebar.setModelAndUrls(&fsmodel, urls);
qsidebar.show();
QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(const QUrl &)));