Commit ac8a8daa authored by David Faure's avatar David Faure

add_definitions(-DQT_NO_URL_CAST_FROM_STRING) + fix compilation

+ remove an awful const_cast and QUrl * usage.
parent 6e0b40b2
......@@ -41,6 +41,7 @@ find_package(Phonon4Qt5 4.6.60 NO_MODULE)
find_package(LibKEduVocDocument REQUIRED)
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_subdirectory(doc)
add_subdirectory(src)
......
......@@ -413,7 +413,7 @@ void KWQCommandIdentifiers::redo()
KWQCommandImage::KWQCommandImage(KWQTableView *view, const QUrl &newUrl) : KWQUndoCommand(view), m_newUrl(newUrl)
{
setText(i18nc("@item:inmenu undo link image", "Link Image"));
m_oldUrl = view->model()->data(oldCurrentIndex(), KWQTableModel::ImageRole).toString();
m_oldUrl = QUrl(view->model()->data(oldCurrentIndex(), KWQTableModel::ImageRole).toString());
}
......@@ -432,7 +432,7 @@ void KWQCommandImage::redo()
KWQCommandSound::KWQCommandSound(KWQTableView *view, const QUrl &newUrl) : KWQUndoCommand(view), m_newUrl(newUrl)
{
setText(i18nc("@item:inmenu undo link sound", "Link Sound"));
m_oldUrl = view->model()->data(oldCurrentIndex(), KWQTableModel::SoundRole).toString();
m_oldUrl = QUrl(view->model()->data(oldCurrentIndex(), KWQTableModel::SoundRole).toString());
}
......
......@@ -402,16 +402,16 @@ QUrl KWQQuizModel::soundQuestion()
int col = column(row);
col == 0 ? col = 1 : col = 0;
QUrl soundUrl = data(index(qAbs(row), col, QModelIndex()), KWQTableModel::SoundRole).toString();
return soundUrl.toLocalFile();
QUrl soundUrl(data(index(qAbs(row), col, QModelIndex()), KWQTableModel::SoundRole).toString());
return soundUrl;
}
QUrl KWQQuizModel::soundAnswer()
{
int row = m_list.at(m_currentQuestion);
QUrl soundUrl = data(index(qAbs(row), column(row), QModelIndex()), KWQTableModel::SoundRole).toString();
return soundUrl.toLocalFile();
QUrl soundUrl(data(index(qAbs(row), column(row), QModelIndex()), KWQTableModel::SoundRole).toString());
return soundUrl;
}
......@@ -421,7 +421,7 @@ QPixmap KWQQuizModel::imageQuestion()
int col = column(row);
col == 0 ? col = 1 : col = 0;
QUrl imageUrl = data(index(qAbs(row), col, QModelIndex()), KWQTableModel::ImageRole).toString();
QUrl imageUrl(data(index(qAbs(row), col, QModelIndex()), KWQTableModel::ImageRole).toString());
return QPixmap(imageUrl.toLocalFile());
}
......@@ -429,7 +429,7 @@ QPixmap KWQQuizModel::imageQuestion()
QPixmap KWQQuizModel::imageAnswer()
{
int row = m_list.at(m_currentQuestion);
QUrl imageUrl = data(index(qAbs(row), column(row), QModelIndex()), KWQTableModel::ImageRole).toString();
QUrl imageUrl(data(index(qAbs(row), column(row), QModelIndex()), KWQTableModel::ImageRole).toString());
return QPixmap(imageUrl.toLocalFile());
}
......
......@@ -67,21 +67,22 @@ void KWQQuizView::audioPlayFile(const QUrl &soundUrl, bool overwrite)
{
static QUrl lastUrl;
QUrl *url = const_cast<QUrl *>(&soundUrl);
QUrl url = soundUrl;
if (overwrite)
lastUrl = *url;
lastUrl = soundUrl;
if (url->isEmpty()) {
if (url.isEmpty()) {
if (lastUrl.isEmpty()) {
m_actionCollection->action(QStringLiteral("quiz_audio_play"))->setEnabled(false);
return;
}
url = &lastUrl;
url = lastUrl;
} else {
lastUrl = url;
}
lastUrl = *url;
m_actionCollection->action(QStringLiteral("quiz_audio_play"))->setEnabled(true);
qDebug() << "Attempting to play sound: " << *url;
qDebug() << "Attempting to play sound: " << url;
if (!m_player) {
m_player = new Phonon::MediaObject(this);
......@@ -90,6 +91,6 @@ void KWQQuizView::audioPlayFile(const QUrl &soundUrl, bool overwrite)
} else {
m_player->stop();
}
m_player->setCurrentSource(*url);
m_player->setCurrentSource(url);
m_player->play();
}
......@@ -716,7 +716,7 @@ void KWQTableView::slotHeaderClicked(int column)
void KWQTableView::doVocabImage()
{
QUrl currentUrl = model()->data(currentIndex(), KWQTableModel::ImageRole).toString();
QUrl currentUrl(model()->data(currentIndex(), KWQTableModel::ImageRole).toString());
QUrl imageUrl = KFileDialog::getImageOpenUrl(currentUrl, this, i18n("Select Image"));
if (!imageUrl.isEmpty()) {
......@@ -728,7 +728,7 @@ void KWQTableView::doVocabImage()
void KWQTableView::doVocabSound()
{
QUrl currentUrl = model()->data(currentIndex(), KWQTableModel::SoundRole).toString();
QUrl currentUrl(model()->data(currentIndex(), KWQTableModel::SoundRole).toString());
QUrl soundUrl = QFileDialog::getOpenFileUrl(this, i18n("Select Sound"), currentUrl, i18n("*|All Files"));
if (!soundUrl.isEmpty()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment