Changeset View
Changeset View
Standalone View
Standalone View
kimagemapeditor.cpp
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | 107 | // K3DockWidget* parentDock = mainDock->getMainDockWidget(); | |||
---|---|---|---|---|---|
160 | connect( mapsListView, SIGNAL(mapRenamed(QString)), | 160 | connect( mapsListView, SIGNAL(mapRenamed(QString)), | ||
161 | this, SLOT(setMapName(QString))); | 161 | this, SLOT(setMapName(QString))); | ||
162 | 162 | | |||
163 | connect( mapsListView->listView(), | 163 | connect( mapsListView->listView(), | ||
164 | SIGNAL(customContextMenuRequested(QPoint)), | 164 | SIGNAL(customContextMenuRequested(QPoint)), | ||
165 | this, | 165 | this, | ||
166 | SLOT(slotShowMapPopupMenu(QPoint))); | 166 | SLOT(slotShowMapPopupMenu(QPoint))); | ||
167 | 167 | | |||
168 | connect( imagesListView, SIGNAL(imageSelected(KUrl)), | 168 | connect( imagesListView, &ImagesListView::imageSelected, | ||
aacid: While at it can you change this connect to new style syntax to make sure it's not breaking with… | |||||
setPicture is overloaded (twice). Can we leave it as is without esotheric casting? I have wasted an hour but cannot find an answer what to choose in overload of "connect( imagesListView, &ImagesListView::imageSelected, this, &KImageMapEditor::setPicture);" Please advise on how to resolve this. Thanks in advance. yurchor: setPicture is overloaded (twice). Can we leave it as is without esotheric casting?
I have… | |||||
Sorry i didn't answer earlier, but QOverload<QUrl>::of(&KImageMapEditor::setPicture) should also work, it's a bit less ugly than the static_cast (may need to be const QUrl & instead of QUrl, not sure) aacid: Sorry i didn't answer earlier, but QOverload<QUrl>::of(&KImageMapEditor::setPicture) should… | |||||
169 | this, SLOT(setPicture(KUrl))); | 169 | this, QOverload<const QUrl &>::of(&KImageMapEditor::setPicture)); | ||
170 | 170 | | |||
171 | connect( imagesListView, | 171 | connect( imagesListView, | ||
172 | SIGNAL(customContextMenuRequested(QPoint)), | 172 | SIGNAL(customContextMenuRequested(QPoint)), | ||
173 | this, | 173 | this, | ||
174 | SLOT(slotShowImagePopupMenu(QPoint))); | 174 | SLOT(slotShowImagePopupMenu(QPoint))); | ||
175 | 175 | | |||
176 | if (splitter) { | 176 | if (splitter) { | ||
177 | drawZone = new DrawZone(splitter,this); | 177 | drawZone = new DrawZone(splitter,this); | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 395 | if (maxAreaPreviewHeight!=newHeight) { | |||
397 | areaListView->listView->setIconSize(QSize(newHeight,newHeight)); | 397 | areaListView->listView->setIconSize(QSize(newHeight,newHeight)); | ||
398 | } | 398 | } | ||
399 | 399 | | |||
400 | updateAllAreas(); | 400 | updateAllAreas(); | ||
401 | drawZone->repaint(); | 401 | drawZone->repaint(); | ||
402 | } | 402 | } | ||
403 | 403 | | |||
404 | void KImageMapEditor::openLastURL(const KConfigGroup & config) { | 404 | void KImageMapEditor::openLastURL(const KConfigGroup & config) { | ||
405 | KUrl lastURL ( config.readPathEntry("lastopenurl", QString()) ); | 405 | QUrl lastURL ( config.readPathEntry("lastopenurl", QString()) ); | ||
406 | QString lastMap = config.readEntry("lastactivemap"); | 406 | QString lastMap = config.readEntry("lastactivemap"); | ||
407 | QString lastImage = config.readPathEntry("lastactiveimage", QString()); | 407 | QString lastImage = config.readPathEntry("lastactiveimage", QString()); | ||
408 | 408 | | |||
409 | 409 | | |||
410 | // qCDebug(KIMAGEMAPEDITOR_LOG) << "loading from group : " << config.group(); | 410 | // qCDebug(KIMAGEMAPEDITOR_LOG) << "loading from group : " << config.group(); | ||
411 | 411 | | |||
412 | // qCDebug(KIMAGEMAPEDITOR_LOG) << "loading entry lastopenurl : " << lastURL.path(); | 412 | // qCDebug(KIMAGEMAPEDITOR_LOG) << "loading entry lastopenurl : " << lastURL.path(); | ||
413 | // KMessageBox::information(0L, config.group()+" "+lastURL.path()); | 413 | // KMessageBox::information(0L, config.group()+" "+lastURL.path()); | ||
▲ Show 20 Lines • Show All 1017 Lines • ▼ Show 20 Line(s) | |||||
1431 | 1431 | | |||
1432 | void KImageMapEditor::setMapName(const QString & s) { | 1432 | void KImageMapEditor::setMapName(const QString & s) { | ||
1433 | mapsListView->changeMapName(_mapName, s); | 1433 | mapsListView->changeMapName(_mapName, s); | ||
1434 | _mapName=s; | 1434 | _mapName=s; | ||
1435 | currentMapElement->mapTag->name = s; | 1435 | currentMapElement->mapTag->name = s; | ||
1436 | } | 1436 | } | ||
1437 | 1437 | | |||
1438 | 1438 | | |||
1439 | void KImageMapEditor::setPicture(const KUrl & url) { | 1439 | void KImageMapEditor::setPicture(const QUrl & url) { | ||
1440 | _imageUrl=url; | 1440 | _imageUrl=url; | ||
1441 | if (QFileInfo(url.path()).exists()) { | 1441 | if (QFileInfo(url.path()).exists()) { | ||
1442 | QImage img(url.path()); | 1442 | QImage img(url.path()); | ||
1443 | 1443 | | |||
1444 | if (!img.isNull()) { | 1444 | if (!img.isNull()) { | ||
1445 | setPicture(img); | 1445 | setPicture(img); | ||
1446 | imageRemoveAction->setEnabled(true); | 1446 | imageRemoveAction->setEnabled(true); | ||
1447 | imageUsemapAction->setEnabled(true); | 1447 | imageUsemapAction->setEnabled(true); | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 1581 | // dialog->adjustSize(); | |||
1587 | connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); | 1587 | connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); | ||
1588 | mainLayout->addWidget(buttonBox); | 1588 | mainLayout->addWidget(buttonBox); | ||
1589 | 1589 | | |||
1590 | dialog->resize(600,400); | 1590 | dialog->resize(600,400); | ||
1591 | dialog->exec(); | 1591 | dialog->exec(); | ||
1592 | delete dialog; | 1592 | delete dialog; | ||
1593 | } | 1593 | } | ||
1594 | 1594 | | |||
1595 | void KImageMapEditor::openFile(const KUrl & url) { | 1595 | void KImageMapEditor::openFile(const QUrl & url) { | ||
1596 | if ( ! url.isEmpty()) { | 1596 | if ( ! url.isEmpty()) { | ||
1597 | QMimeDatabase db; | 1597 | QMimeDatabase db; | ||
1598 | QMimeType openedFileType = db.mimeTypeForUrl(url); | 1598 | QMimeType openedFileType = db.mimeTypeForUrl(url); | ||
1599 | if (openedFileType.name().left(6) == "image/") { | 1599 | if (openedFileType.name().left(6) == "image/") { | ||
1600 | addImage(url); | 1600 | addImage(url); | ||
1601 | } else { | 1601 | } else { | ||
1602 | openURL(url); | 1602 | openURL(url); | ||
1603 | } | 1603 | } | ||
Show All 13 Lines | |||||
1617 | } | 1617 | } | ||
1618 | 1618 | | |||
1619 | void KImageMapEditor::fileOpen() { | 1619 | void KImageMapEditor::fileOpen() { | ||
1620 | 1620 | | |||
1621 | QString fileName = QFileDialog::getOpenFileName(widget(), i18n("Choose File to Open"), QString(), | 1621 | QString fileName = QFileDialog::getOpenFileName(widget(), i18n("Choose File to Open"), QString(), | ||
1622 | i18n("Web File (*.png *.jpg *.jpeg *.gif *.htm *.html);;Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;" | 1622 | i18n("Web File (*.png *.jpg *.jpeg *.gif *.htm *.html);;Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;" | ||
1623 | "HTML Files (*.htm *.html);;All Files (*)")); | 1623 | "HTML Files (*.htm *.html);;All Files (*)")); | ||
1624 | 1624 | | |||
1625 | openFile(KUrl( fileName )); | 1625 | openFile(QUrl::fromUserInput( fileName )); | ||
1626 | } | 1626 | } | ||
1627 | 1627 | | |||
1628 | 1628 | | |||
1629 | 1629 | | |||
1630 | void KImageMapEditor::fileClose() | 1630 | void KImageMapEditor::fileClose() | ||
1631 | { | 1631 | { | ||
1632 | if (! closeUrl()) | 1632 | if (! closeUrl()) | ||
1633 | return; | 1633 | return; | ||
Show All 18 Lines | 1650 | else { | |||
1652 | setModified(false); | 1652 | setModified(false); | ||
1653 | } | 1653 | } | ||
1654 | 1654 | | |||
1655 | 1655 | | |||
1656 | } | 1656 | } | ||
1657 | 1657 | | |||
1658 | void KImageMapEditor::fileSaveAs() { | 1658 | void KImageMapEditor::fileSaveAs() { | ||
1659 | 1659 | | |||
1660 | KUrl url = QFileDialog::getSaveFileUrl(widget(), QString(), QUrl(), i18n("HTML File (*.htm *.html);;Text File (*.txt);;All Files (*)" )); | 1660 | QUrl url = QFileDialog::getSaveFileUrl(widget(), QString(), QUrl(), i18n("HTML File (*.htm *.html);;Text File (*.txt);;All Files (*)" )); | ||
1661 | if (url.isEmpty() || !url.isValid()) { | 1661 | if (url.isEmpty() || !url.isValid()) { | ||
1662 | return; | 1662 | return; | ||
1663 | } | 1663 | } | ||
1664 | 1664 | | |||
1665 | 1665 | | |||
1666 | QFileInfo fileInfo(url.path()); | 1666 | QFileInfo fileInfo(url.path()); | ||
1667 | 1667 | | |||
1668 | if ( fileInfo.exists() ) | | |||
1669 | { | | |||
1670 | if (KMessageBox::warningContinueCancel(widget(), | | |||
1671 | i18n("<qt>The file <em>%1</em> already exists.<br />Do you want to overwrite it?</qt>", fileInfo.fileName()), | | |||
1672 | i18n("Overwrite File?"), KGuiItem(i18n("Overwrite")))==KMessageBox::Cancel) | | |||
1673 | return; | | |||
1674 | | ||||
1675 | if(!fileInfo.isWritable()) { | | |||
1676 | KMessageBox::sorry(widget(), i18n("<qt>You do not have write permission for the file <em>%1</em>.</qt>", fileInfo.fileName())); | | |||
1677 | return; | | |||
1678 | } | | |||
1679 | } | | |||
1680 | | ||||
1681 | | ||||
1682 | saveAs(url); | 1668 | saveAs(url); | ||
1683 | recentFilesAction->addUrl(url); | 1669 | recentFilesAction->addUrl(url); | ||
1684 | 1670 | | |||
1685 | } | 1671 | } | ||
1686 | 1672 | | |||
1687 | 1673 | | |||
1688 | bool KImageMapEditor::openFile() | 1674 | bool KImageMapEditor::openFile() | ||
1689 | { | 1675 | { | ||
1690 | KUrl u = url(); | 1676 | QUrl u = url(); | ||
1691 | QFileInfo fileInfo(u.path()); | 1677 | QFileInfo fileInfo(u.path()); | ||
1692 | 1678 | | |||
1693 | if ( !fileInfo.exists() ) | 1679 | if ( !fileInfo.exists() ) | ||
1694 | { | 1680 | { | ||
1695 | KMessageBox::information(widget(), | 1681 | KMessageBox::information(widget(), | ||
1696 | i18n("<qt>The file <b>%1</b> does not exist.</qt>", fileInfo.fileName()), | 1682 | i18n("<qt>The file <b>%1</b> does not exist.</qt>", fileInfo.fileName()), | ||
1697 | i18n("File Does Not Exist")); | 1683 | i18n("File Does Not Exist")); | ||
1698 | return false; | 1684 | return false; | ||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | 1758 | { | |||
1868 | } | 1854 | } | ||
1869 | } | 1855 | } | ||
1870 | 1856 | | |||
1871 | return dict; | 1857 | return dict; | ||
1872 | 1858 | | |||
1873 | } | 1859 | } | ||
1874 | 1860 | | |||
1875 | 1861 | | |||
1876 | bool KImageMapEditor::openHTMLFile(const KUrl & url) | 1862 | bool KImageMapEditor::openHTMLFile(const QUrl & url) | ||
1877 | { | 1863 | { | ||
1878 | QFile f(url.path()); | 1864 | QFile f(url.path()); | ||
1879 | if ( !f.exists () ) | 1865 | if ( !f.exists () ) | ||
1880 | return false; | 1866 | return false; | ||
1881 | f.open(QIODevice::ReadOnly); | 1867 | f.open(QIODevice::ReadOnly); | ||
1882 | QTextStream s(&f); | 1868 | QTextStream s(&f); | ||
1883 | QString str; | 1869 | QString str; | ||
1884 | QChar w; | 1870 | QChar w; | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
1952 | } | 1938 | } | ||
1953 | 1939 | | |||
1954 | if (!origcode.isEmpty()) { | 1940 | if (!origcode.isEmpty()) { | ||
1955 | _htmlContent.append(new HtmlElement(origcode)); | 1941 | _htmlContent.append(new HtmlElement(origcode)); | ||
1956 | } | 1942 | } | ||
1957 | 1943 | | |||
1958 | f.close(); | 1944 | f.close(); | ||
1959 | 1945 | | |||
1960 | KUrl imageUrl; | 1946 | QUrl imageUrl; | ||
1961 | 1947 | | |||
1962 | map = 0L; | 1948 | map = 0L; | ||
1963 | 1949 | | |||
1964 | // If we have more than on map or more than one image | 1950 | // If we have more than on map or more than one image | ||
1965 | // Let the user choose, otherwise take the only ones | 1951 | // Let the user choose, otherwise take the only ones | ||
1966 | if (maps.count() > 1) { | 1952 | if (maps.count() > 1) { | ||
1967 | map = maps.first(); | 1953 | map = maps.first(); | ||
1968 | } | 1954 | } | ||
1969 | 1955 | | |||
1970 | if (images.count() > 1) { | 1956 | if (images.count() > 1) { | ||
1971 | ImageTag* imgTag = images.first(); | 1957 | ImageTag* imgTag = images.first(); | ||
1972 | if (imgTag) { | 1958 | if (imgTag) { | ||
1973 | if (imgTag->contains("src")) | 1959 | if (imgTag->contains("src")) { | ||
1974 | imageUrl = KUrl(url,imgTag->value("src")); | 1960 | if (url.path().isEmpty() | !url.path().endsWith('/')) { | ||
1961 | imageUrl = QUrl(url.path() + '/').resolved(QUrl(imgTag->value("src"))); | ||||
1962 | } | ||||
1963 | else { | ||||
1964 | imageUrl = url.resolved(QUrl(imgTag->value("src"))); | ||||
1965 | } | ||||
1966 | } | ||||
1975 | } | 1967 | } | ||
1976 | } | 1968 | } | ||
1977 | 1969 | | |||
1978 | // If there is more than one map and more than one image | 1970 | // If there is more than one map and more than one image | ||
1979 | // use the map that has an image with an according usemap tag | 1971 | // use the map that has an image with an according usemap tag | ||
1980 | if (maps.count() > 1 && images.count() > 1) { | 1972 | if (maps.count() > 1 && images.count() > 1) { | ||
1981 | bool found = false; | 1973 | bool found = false; | ||
1982 | MapTag *mapTag; | 1974 | MapTag *mapTag; | ||
1983 | foreach(mapTag, maps) { | 1975 | foreach(mapTag, maps) { | ||
1984 | ImageTag *imageTag; | 1976 | ImageTag *imageTag; | ||
1985 | foreach(imageTag, images) { | 1977 | foreach(imageTag, images) { | ||
1986 | if (imageTag->contains("usemap")) { | 1978 | if (imageTag->contains("usemap")) { | ||
1987 | QString usemap = imageTag->value("usemap"); | 1979 | QString usemap = imageTag->value("usemap"); | ||
1988 | // Remove the # | 1980 | // Remove the # | ||
1989 | QString usemapName = usemap.right(usemap.length()-1); | 1981 | QString usemapName = usemap.right(usemap.length()-1); | ||
1990 | if (usemapName == mapTag->name) { | 1982 | if (usemapName == mapTag->name) { | ||
1991 | if (imageTag->contains("src")) { | 1983 | if (imageTag->contains("src")) { | ||
1992 | imageUrl = KUrl(url,imageTag->value("src")); | 1984 | if (url.path().isEmpty() | !url.path().endsWith('/')) { | ||
1985 | imageUrl = QUrl(url.path() + '/').resolved(QUrl(imageTag->value("src"))); | ||||
1986 | } | ||||
1987 | else { | ||||
1988 | imageUrl = url.resolved(QUrl(imageTag->value("src"))); | ||||
1989 | } | ||||
1993 | found = true; | 1990 | found = true; | ||
1994 | } | 1991 | } | ||
1995 | } | 1992 | } | ||
1996 | } | 1993 | } | ||
1997 | if (found) | 1994 | if (found) | ||
1998 | break; | 1995 | break; | ||
1999 | } | 1996 | } | ||
2000 | if (found) | 1997 | if (found) | ||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Line(s) | |||||
2326 | 2323 | | |||
2327 | Rewritten for Quanta Plus: (C) 2002 Andras Mantia <amantia@freemail.hu> | 2324 | Rewritten for Quanta Plus: (C) 2002 Andras Mantia <amantia@freemail.hu> | ||
2328 | 2325 | | |||
2329 | This program is free software; you can redistribute it and/or modify | 2326 | This program is free software; you can redistribute it and/or modify | ||
2330 | it under the terms of the GNU General Public License as published by | 2327 | it under the terms of the GNU General Public License as published by | ||
2331 | the Free Software Foundation; either version 2 of the License, or | 2328 | the Free Software Foundation; either version 2 of the License, or | ||
2332 | (at your option) any later version. | 2329 | (at your option) any later version. | ||
2333 | */ | 2330 | */ | ||
2334 | static KUrl toRelative(const KUrl& urlToConvert,const KUrl& baseURL) | 2331 | static QUrl toRelative(const QUrl& urlToConvert,const QUrl& baseURL) | ||
2335 | { | 2332 | { | ||
2336 | KUrl resultURL = urlToConvert; | 2333 | QUrl resultURL = urlToConvert; | ||
2337 | if (urlToConvert.protocol() == baseURL.protocol()) | 2334 | if (urlToConvert.scheme() == baseURL.scheme()) | ||
2338 | { | 2335 | { | ||
2339 | QString path = urlToConvert.path(); | 2336 | QString path = urlToConvert.path(); | ||
2340 | QString basePath = baseURL.path(KUrl::AddTrailingSlash); | 2337 | QString basePath = baseURL.path().endsWith('/') ? baseURL.path() : baseURL.path() + '/'; | ||
2341 | if (path.startsWith("/")) | 2338 | if (path.startsWith("/") && basePath != "/") | ||
2342 | { | 2339 | { | ||
2343 | path.remove(0, 1); | 2340 | path.remove(0, 1); | ||
2344 | basePath.remove(0, 1); | 2341 | basePath.remove(0, 1); | ||
2345 | if ( basePath.right(1) != "/" ) basePath.append("/"); | 2342 | if ( basePath.right(1) != "/" ) basePath.append("/"); | ||
2346 | 2343 | | |||
2347 | int pos=0; | 2344 | int pos=0; | ||
2348 | int pos1=0; | 2345 | int pos1=0; | ||
2349 | for (;;) | 2346 | for (;;) | ||
Show All 16 Lines | |||||
2366 | { | 2363 | { | ||
2367 | path="../"+path; | 2364 | path="../"+path; | ||
2368 | }; | 2365 | }; | ||
2369 | } | 2366 | } | ||
2370 | 2367 | | |||
2371 | resultURL.setPath(QDir::cleanPath(path)); | 2368 | resultURL.setPath(QDir::cleanPath(path)); | ||
2372 | } | 2369 | } | ||
2373 | 2370 | | |||
2374 | if (urlToConvert.path().endsWith('/')) resultURL.adjustPath(KUrl::AddTrailingSlash); | 2371 | if (urlToConvert.path().endsWith('/')) resultURL.setPath(resultURL.path() + '/'); | ||
2375 | return resultURL; | 2372 | return resultURL; | ||
2376 | } | 2373 | } | ||
2377 | 2374 | | |||
2378 | 2375 | | |||
2379 | void KImageMapEditor::saveImageMap(const KUrl & url) | 2376 | void KImageMapEditor::saveImageMap(const QUrl & url) | ||
2380 | { | 2377 | { | ||
2381 | QFileInfo fileInfo(url.path()); | 2378 | QFileInfo fileInfo(url.path()); | ||
2382 | 2379 | | |||
2383 | if (!QFileInfo(url.directory()).isWritable()) { | 2380 | if (!QFileInfo(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()).isWritable()) { | ||
2384 | KMessageBox::error(widget(), | 2381 | KMessageBox::error(widget(), | ||
2385 | i18n("<qt>The file <i>%1</i> could not be saved, because you do not have the required write permissions.</qt>", url.path())); | 2382 | i18n("<qt>The file <i>%1</i> could not be saved, because you do not have the required write permissions.</qt>", url.path())); | ||
2386 | return; | 2383 | return; | ||
2387 | } | 2384 | } | ||
2388 | 2385 | | |||
2389 | if (!backupFileCreated) { | 2386 | if (!backupFileCreated) { | ||
2390 | QString backupFile = url.path()+'~'; | 2387 | QString backupFile = url.path()+'~'; | ||
2391 | KIO::file_copy(url, KUrl(backupFile ), -1, KIO::Overwrite | KIO::HideProgressInfo); | 2388 | KIO::file_copy(url, QUrl::fromUserInput(backupFile ), -1, KIO::Overwrite | KIO::HideProgressInfo); | ||
2392 | backupFileCreated = true; | 2389 | backupFileCreated = true; | ||
2393 | } | 2390 | } | ||
2394 | 2391 | | |||
2395 | setModified(false); | 2392 | setModified(false); | ||
2396 | 2393 | | |||
2397 | if (mapName().isEmpty()) { | 2394 | if (mapName().isEmpty()) { | ||
2398 | mapEditName(); | 2395 | mapEditName(); | ||
2399 | } | 2396 | } | ||
2400 | QFile file(url.path()); | 2397 | QFile file(url.path()); | ||
2401 | file.open(QIODevice::WriteOnly); | 2398 | file.open(QIODevice::WriteOnly); | ||
2402 | 2399 | | |||
2403 | QTextStream t(&file); | 2400 | QTextStream t(&file); | ||
2404 | 2401 | | |||
2405 | if (_htmlContent.isEmpty()) { | 2402 | if (_htmlContent.isEmpty()) { | ||
2406 | t << "<html>\n" | 2403 | t << "<html>\n" | ||
2407 | << "<head>\n" | 2404 | << "<head>\n" | ||
2408 | << " <title></title>\n" | 2405 | << " <title></title>\n" | ||
2409 | << "</head>\n" | 2406 | << "</head>\n" | ||
2410 | << "<body>\n" | 2407 | << "<body>\n" | ||
2411 | << " " << getHTMLImageMap() | 2408 | << " " << getHTMLImageMap() | ||
2412 | << "\n" | 2409 | << "\n" | ||
2413 | << " <img src=\"" << toRelative(_imageUrl,KUrl( url.directory() )).path() << "\"" | 2410 | << " <img src=\"" << toRelative(_imageUrl,QUrl( url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path() )).path() << "\"" | ||
2414 | << " usemap=\"#" << _mapName << "\"" | 2411 | << " usemap=\"#" << _mapName << "\"" | ||
2415 | << " width=\"" << drawZone->picture().width() << "\"" | 2412 | << " width=\"" << drawZone->picture().width() << "\"" | ||
2416 | << " height=\"" << drawZone->picture().height() << "\">\n" | 2413 | << " height=\"" << drawZone->picture().height() << "\">\n" | ||
2417 | << "</body>\n" | 2414 | << "</body>\n" | ||
2418 | << "</html>"; | 2415 | << "</html>"; | ||
2419 | } else | 2416 | } else | ||
2420 | { | 2417 | { | ||
2421 | t << getHtmlCode(); | 2418 | t << getHtmlCode(); | ||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Line(s) | 2764 | { | |||
2783 | 2780 | | |||
2784 | init(); | 2781 | init(); | ||
2785 | emit setWindowCaption(""); | 2782 | emit setWindowCaption(""); | ||
2786 | 2783 | | |||
2787 | return true; | 2784 | return true; | ||
2788 | 2785 | | |||
2789 | } | 2786 | } | ||
2790 | 2787 | | |||
2791 | void KImageMapEditor::addImage(const KUrl & imgUrl) { | 2788 | void KImageMapEditor::addImage(const QUrl & imgUrl) { | ||
2792 | if (imgUrl.isEmpty()) | 2789 | if (imgUrl.isEmpty()) | ||
2793 | return; | 2790 | return; | ||
2794 | 2791 | | |||
2795 | QString relativePath ( toRelative(imgUrl, KUrl( url().adjusted(QUrl::RemoveFilename).path() )).path() ); | 2792 | QString relativePath ( toRelative(imgUrl, QUrl( url().adjusted(QUrl::RemoveFilename).path() )).path() ); | ||
2796 | 2793 | | |||
2797 | QString imgHtml = QString("<img src=\"")+relativePath+QString("\">"); | 2794 | QString imgHtml = QString("<img src=\"")+relativePath+QString("\">"); | ||
2798 | ImageTag* imgTag = new ImageTag(); | 2795 | ImageTag* imgTag = new ImageTag(); | ||
2799 | imgTag->insert("tagname","img"); | 2796 | imgTag->insert("tagname","img"); | ||
2800 | imgTag->insert("src", relativePath); | 2797 | imgTag->insert("src", relativePath); | ||
2801 | 2798 | | |||
2802 | HtmlImgElement* imgEl = new HtmlImgElement(imgHtml); | 2799 | HtmlImgElement* imgEl = new HtmlImgElement(imgHtml); | ||
2803 | imgEl->imgTag = imgTag; | 2800 | imgEl->imgTag = imgTag; | ||
Show All 22 Lines | |||||
2826 | */ | 2823 | */ | ||
2827 | void KImageMapEditor::setImageActionsEnabled(bool b) { | 2824 | void KImageMapEditor::setImageActionsEnabled(bool b) { | ||
2828 | imageRemoveAction->setEnabled(b); | 2825 | imageRemoveAction->setEnabled(b); | ||
2829 | imageUsemapAction->setEnabled(b); | 2826 | imageUsemapAction->setEnabled(b); | ||
2830 | } | 2827 | } | ||
2831 | 2828 | | |||
2832 | 2829 | | |||
2833 | void KImageMapEditor::imageAdd() { | 2830 | void KImageMapEditor::imageAdd() { | ||
2834 | KUrl imgUrl = QFileDialog::getOpenFileUrl(widget(), i18n("Select image"), | 2831 | QUrl imgUrl = QFileDialog::getOpenFileUrl(widget(), i18n("Select image"), | ||
2835 | QUrl(), i18n("Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;All Files (*)")); | 2832 | QUrl(), i18n("Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;All Files (*)")); | ||
2836 | addImage(imgUrl); | 2833 | addImage(imgUrl); | ||
2837 | } | 2834 | } | ||
2838 | 2835 | | |||
2839 | void KImageMapEditor::imageRemove() { | 2836 | void KImageMapEditor::imageRemove() { | ||
2840 | ImageTag* imgTag = imagesListView->selectedImage(); | 2837 | ImageTag* imgTag = imagesListView->selectedImage(); | ||
2841 | HtmlImgElement* imgEl = findHtmlImgElement(imgTag); | 2838 | HtmlImgElement* imgEl = findHtmlImgElement(imgTag); | ||
2842 | imagesListView->removeImage(imgTag); | 2839 | imagesListView->removeImage(imgTag); | ||
2843 | _htmlContent.removeAt(_htmlContent.indexOf(imgEl)); | 2840 | _htmlContent.removeAt(_htmlContent.indexOf(imgEl)); | ||
2844 | 2841 | | |||
2845 | if (imagesListView->topLevelItemCount() == 0) { | 2842 | if (imagesListView->topLevelItemCount() == 0) { | ||
2846 | setPicture(getBackgroundImage()); | 2843 | setPicture(getBackgroundImage()); | ||
2847 | setImageActionsEnabled(false); | 2844 | setImageActionsEnabled(false); | ||
2848 | } | 2845 | } | ||
2849 | else { | 2846 | else { | ||
2850 | ImageTag* selected = imagesListView->selectedImage(); | 2847 | ImageTag* selected = imagesListView->selectedImage(); | ||
2851 | if (selected) { | 2848 | if (selected) { | ||
2852 | if (selected->contains("src")) { | 2849 | if (selected->contains("src")) { | ||
2853 | setPicture(KUrl(selected->value("src"))); | 2850 | setPicture(QUrl(selected->value("src"))); | ||
2854 | } | 2851 | } | ||
2855 | } | 2852 | } | ||
2856 | } | 2853 | } | ||
2857 | 2854 | | |||
2858 | setModified(true); | 2855 | setModified(true); | ||
2859 | } | 2856 | } | ||
2860 | 2857 | | |||
2861 | void KImageMapEditor::imageUsemap() { | 2858 | void KImageMapEditor::imageUsemap() { | ||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
While at it can you change this connect to new style syntax to make sure it's not breaking with the KUrl->QUrl change?