Commit e96a0c3c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compiles with QT_NO_CAST_FROM_ASCII

parent aa79abae
......@@ -36,8 +36,6 @@ if(BUILD_TESTING)
find_package(Qt5Test ${QT_REQUIRED_VERSION} CONFIG REQUIRED)
endif()
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050F02
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
......
......@@ -361,7 +361,7 @@ void ActionsImpl::slotPaste()
QString addr;
KBookmark bk = KEBApp::self()->firstSelected();
if (bk.isGroup())
addr = bk.address() + "/0"; // FIXME internal
addr = bk.address() + QStringLiteral("/0"); // FIXME internal
else
addr = bk.address();
......
......@@ -112,9 +112,9 @@ void BookmarkListView::contextMenuEvent(QContextMenuEvent *e)
QMenu *popup;
if (!index.isValid() || (bk.address() == GlobalBookmarkManager::self()->root().address()) || (bk.isGroup())) // FIXME add empty folder padder
{
popup = KEBApp::self()->popupMenuFactory("popup_folder");
popup = KEBApp::self()->popupMenuFactory(QStringLiteral("popup_folder"));
} else {
popup = KEBApp::self()->popupMenuFactory("popup_bookmark");
popup = KEBApp::self()->popupMenuFactory(QStringLiteral("popup_bookmark"));
}
if (popup)
popup->popup(e->globalPos());
......
......@@ -47,15 +47,10 @@ QString HTMLExporter::toString(const KBookmarkGroup &grp, bool showAddress)
{
m_showAddress = showAddress;
traverse(grp);
return "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><title>"+i18n("My Bookmarks")+"</title>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
"</head>\n"
"<body>\n"
"<div>"
+ m_string +
"</div>\n"
"</body>\n</html>\n";
return QStringLiteral("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n")
+ QStringLiteral("<html><head><title>") + i18n("My Bookmarks") + QStringLiteral("</title>\n")
+ QStringLiteral("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">") + QStringLiteral("</head>\n") + QStringLiteral("<body>\n")
+ QStringLiteral("<div>") + m_string + QStringLiteral("</div>\n") + QStringLiteral("</body>\n</html>\n");
}
void HTMLExporter::visit(const KBookmark &bk)
......
......@@ -206,7 +206,10 @@ QString IEImportCommand::requestFilename() const
QString GaleonImportCommand::requestFilename() const
{
return QFileDialog::getOpenFileName(KEBApp::self(), QString(), QString(QDir::homePath() + "/.galeon"), i18n("Galeon Bookmark Files (*.xbel)"));
return QFileDialog::getOpenFileName(KEBApp::self(),
QString(),
QString(QDir::homePath() + QStringLiteral("/.galeon")),
i18n("Galeon Bookmark Files (*.xbel)"));
}
QString KDE2ImportCommand::requestFilename() const
......
......@@ -62,7 +62,7 @@ void CommandHistory::createActions(KActionCollection *actionCollection)
QAction *standardAction = KStandardAction::create(KStandardAction::Undo, nullptr, nullptr, nullptr);
QAction *undoAction = d->m_undoStack.createUndoAction(actionCollection);
undoAction->setIcon(standardAction->icon());
actionCollection->addAction(KStandardAction::name(KStandardAction::Undo), undoAction);
actionCollection->addAction(QLatin1String(KStandardAction::name(KStandardAction::Undo)), undoAction);
actionCollection->setDefaultShortcuts(undoAction, standardAction->shortcuts());
disconnect(undoAction, &QAction::triggered, &d->m_undoStack, nullptr);
connect(undoAction, &QAction::triggered, this, &CommandHistory::undo);
......@@ -71,7 +71,7 @@ void CommandHistory::createActions(KActionCollection *actionCollection)
standardAction = KStandardAction::create(KStandardAction::Redo, nullptr, nullptr, nullptr);
QAction *redoAction = d->m_undoStack.createRedoAction(actionCollection);
redoAction->setIcon(standardAction->icon());
actionCollection->addAction(KStandardAction::name(KStandardAction::Redo), redoAction);
actionCollection->addAction(QLatin1String(KStandardAction::name(KStandardAction::Redo)), redoAction);
actionCollection->setDefaultShortcuts(redoAction, standardAction->shortcuts());
disconnect(redoAction, &QAction::triggered, &d->m_undoStack, nullptr);
connect(redoAction, &QAction::triggered, this, &CommandHistory::redo);
......
......@@ -132,7 +132,7 @@ void CreateCommand::redo()
} else if (m_group) {
Q_ASSERT(!m_text.isEmpty());
bk = parentGroup.createNewFolder(m_text);
bk.internalElement().setAttribute(QStringLiteral("folded"), (m_open ? "no" : "yes"));
bk.internalElement().setAttribute(QStringLiteral("folded"), (m_open ? QLatin1String("no") : QLatin1String("yes")));
if (!m_iconPath.isEmpty()) {
bk.setIcon(m_iconPath);
}
......@@ -151,7 +151,7 @@ void CreateCommand::redo()
// Q_ASSERT(ok);
if (!(text().isEmpty()) && !parentAddress.isEmpty()) {
// open the parent (useful if it was empty) - only for manual commands
Q_ASSERT(parentGroup.internalElement().tagName() != "xbel");
Q_ASSERT(parentGroup.internalElement().tagName() != QLatin1String("xbel"));
parentGroup.internalElement().setAttribute(QStringLiteral("folded"), QStringLiteral("no"));
}
......@@ -443,7 +443,7 @@ class SortByName
public:
static QString key(const SortItem &item)
{
return (item.bookmark().isGroup() ? "a" : "b") + (item.bookmark().fullText().toLower());
return (item.bookmark().isGroup() ? QStringLiteral("a") : QStringLiteral("b")) + (item.bookmark().fullText().toLower());
}
};
......@@ -476,7 +476,7 @@ void SortCommand::moveAfter(const SortItem &moveMe, const SortItem &afterMe)
{
const QString destAddress = afterMe.isNull()
// move as first child
? KBookmark::parentAddress(moveMe.bookmark().address()) + "/0"
? KBookmark::parentAddress(moveMe.bookmark().address()) + QStringLiteral("/0")
// move after "afterMe"
: KBookmark::nextAddress(afterMe.bookmark().address());
......
......@@ -137,7 +137,7 @@ QVariant KBookmarkModel::data(const QModelIndex &index, int role) const
if (text1.isEmpty() || text2.isEmpty())
return QVariant(text1 + text2);
else
return QVariant(text1 + " -- " + text2);
return QVariant(text1 + QLatin1String(" -- ") + text2);
}
default:
return QVariant(); // can't happen
......@@ -318,7 +318,7 @@ QMimeData *KBookmarkModel::mimeData(const QModelIndexList &indexes) const
}
bookmarks.populateMimeData(mimeData);
mimeData->setData(s_mime_bookmark_addresses, addresses);
mimeData->setData(QLatin1String(s_mime_bookmark_addresses), addresses);
return mimeData;
}
......@@ -366,9 +366,9 @@ bool KBookmarkModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
KEBMacroCommand *cmd = CmdGen::insertMimeSource(this, QStringLiteral("Copy"), data, addr);
d->mCommandHistory->addCommand(cmd);
} else if (action == Qt::MoveAction) {
if (data->hasFormat(s_mime_bookmark_addresses)) {
if (data->hasFormat(QLatin1String(s_mime_bookmark_addresses))) {
KBookmark::List bookmarks;
QList<QByteArray> addresses = data->data(s_mime_bookmark_addresses).split(';');
QList<QByteArray> addresses = data->data(QLatin1String(s_mime_bookmark_addresses)).split(';');
std::sort(addresses.begin(), addresses.end());
for (const auto &address : std::as_const(addresses)) {
KBookmark bk = bookmarkManager()->findByAddress(QString::fromLatin1(address));
......
......@@ -62,7 +62,7 @@ public:
}
void visitEnter(const KBookmarkGroup &group) override
{
m_addressList.append(group.address() + '/');
m_addressList.append(group.address() + QLatin1Char('/'));
m_titleList.append(group.text());
}
......@@ -105,8 +105,8 @@ private Q_SLOTS:
CreateCommand *cmd =
new CreateCommand(m_model, QStringLiteral("/0"), QStringLiteral("test_bk"), QStringLiteral("www"), QUrl(QStringLiteral("https://www.kde.org")));
cmd->redo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << "/0");
QCOMPARE(BookmarkLister::urlList(m_bookmarkManager), QStringList() << "https://www.kde.org");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0"));
QCOMPARE(BookmarkLister::urlList(m_bookmarkManager), QStringList() << QStringLiteral("https://www.kde.org"));
QCOMPARE(m_model->rowCount(m_rootIndex), 1);
cmd->undo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList());
......@@ -119,12 +119,12 @@ private Q_SLOTS:
CreateCommand *cmd =
new CreateCommand(m_model, QStringLiteral("/0"), QStringLiteral("test_bk"), QStringLiteral("www"), QUrl(QStringLiteral("https://www.kde.org")));
cmd->redo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << "/0");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0"));
DeleteCommand *deleteCmd = new DeleteCommand(m_model, QStringLiteral("/0"));
deleteCmd->redo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList());
deleteCmd->undo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << "/0");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0"));
deleteCmd->redo();
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList());
......@@ -136,23 +136,18 @@ private Q_SLOTS:
{
CreateCommand *folderCmd = new CreateCommand(m_model, QStringLiteral("/0"), QStringLiteral("folder"), QStringLiteral("folder"), true /*open*/);
m_cmdHistory->addCommand(folderCmd); // calls redo
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << "/0/");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0/"));
QCOMPARE(m_model->rowCount(m_rootIndex), 1);
const QString kde = QStringLiteral("https://www.kde.org");
CreateCommand *cmd = new CreateCommand(m_model, QStringLiteral("/0/0"), QStringLiteral("test_bk"), QStringLiteral("www"), QUrl(kde));
m_cmdHistory->addCommand(cmd); // calls redo
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/0/0");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0/") << QStringLiteral("/0/0"));
// Insert before this bookmark
const QString first = QStringLiteral("https://first.example.com");
m_cmdHistory->addCommand(new CreateCommand(m_model, QStringLiteral("/0/0"), QStringLiteral("first_bk"), QStringLiteral("www"), QUrl(first)));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/0/0"
<< "/0/1");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0/") << QStringLiteral("/0/0") << QStringLiteral("/0/1"));
QCOMPARE(BookmarkLister::urlList(m_bookmarkManager), QStringList() << first << kde);
// Move the kde bookmark before the first bookmark
......@@ -165,10 +160,7 @@ private Q_SLOTS:
QMimeData *mimeData = m_model->mimeData(QModelIndexList() << kdeIndex);
bool ok = m_model->dropMimeData(mimeData, Qt::MoveAction, 0, 0, kdeIndex.parent());
QVERIFY(ok);
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/0/0"
<< "/0/1");
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager), QStringList() << QStringLiteral("/0/") << QStringLiteral("/0/0") << QStringLiteral("/0/1"));
QCOMPARE(BookmarkLister::urlList(m_bookmarkManager), QStringList() << kde << first);
delete mimeData;
......@@ -185,44 +177,29 @@ private Q_SLOTS:
// Create new folder, then move both bookmarks into it (#287038)
m_cmdHistory->addCommand(new CreateCommand(m_model, QStringLiteral("/1"), QStringLiteral("folder2"), QStringLiteral("folder2"), true));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/0/0"
<< "/0/1"
<< "/1/");
QStringList() << QStringLiteral("/0/") << QStringLiteral("/0/0") << QStringLiteral("/0/1") << QStringLiteral("/1/"));
QCOMPARE(m_model->rowCount(m_rootIndex), 2);
moveTwoBookmarks(QStringLiteral("/0/0"), QStringLiteral("/0/1"), QStringLiteral("/1"));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/1/"
<< "/1/0"
<< "/1/1");
QStringList() << QStringLiteral("/0/") << QStringLiteral("/1/") << QStringLiteral("/1/0") << QStringLiteral("/1/1"));
QCOMPARE(BookmarkLister::urlList(m_bookmarkManager), QStringList() << kde << first);
// Move bookmarks from /1 into subfolder /1/2 (which will become /1/0)
m_cmdHistory->addCommand(new CreateCommand(m_model, QStringLiteral("/1/2"), QStringLiteral("subfolder"), QStringLiteral("subfolder"), true));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/1/"
<< "/1/0"
<< "/1/1"
<< "/1/2/");
QStringList() << QStringLiteral("/0/") << QStringLiteral("/1/") << QStringLiteral("/1/0") << QStringLiteral("/1/1")
<< QStringLiteral("/1/2/"));
moveTwoBookmarks(QStringLiteral("/1/0"), QStringLiteral("/1/1"), QStringLiteral("/1/2"));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/1/"
<< "/1/0/"
<< "/1/0/0"
<< "/1/0/1");
QStringList() << QStringLiteral("/0/") << QStringLiteral("/1/") << QStringLiteral("/1/0/") << QStringLiteral("/1/0/0")
<< QStringLiteral("/1/0/1"));
// Move them up again
moveTwoBookmarks(QStringLiteral("/1/0/0"), QStringLiteral("/1/0/1"), QStringLiteral("/1"));
QCOMPARE(BookmarkLister::addressList(m_bookmarkManager),
QStringList() << "/0/"
<< "/1/"
<< "/1/0"
<< "/1/1"
<< "/1/2/");
QStringList() << QStringLiteral("/0/") << QStringLiteral("/1/") << QStringLiteral("/1/0") << QStringLiteral("/1/1")
<< QStringLiteral("/1/2/"));
undoAll();
}
......@@ -236,7 +213,7 @@ private Q_SLOTS:
QStringList bookmarks;
bookmarks << QStringLiteral("Faure") << QStringLiteral("Web") << QStringLiteral("Kde") << QStringLiteral("Avatar") << QStringLiteral("David");
for (int i = 0; i < bookmarks.count(); ++i) {
m_cmdHistory->addCommand(new CreateCommand(m_model, "/0/" + QString::number(i), bookmarks[i], QStringLiteral("www"), QUrl(kde)));
m_cmdHistory->addCommand(new CreateCommand(m_model, QStringLiteral("/0/") + QString::number(i), bookmarks[i], QStringLiteral("www"), QUrl(kde)));
}
const QStringList addresses = BookmarkLister::addressList(m_bookmarkManager);
// qCDebug(KEDITBOOKMARKS_LOG) << addresses;
......@@ -317,7 +294,7 @@ private:
void undoAll()
{
QAction *undoAction = m_collection.action(KStandardAction::name(KStandardAction::Undo));
QAction *undoAction = m_collection.action(QLatin1String(KStandardAction::name(KStandardAction::Undo)));
QVERIFY(undoAction);
while (undoAction->isEnabled()) {
undoAction->trigger();
......
......@@ -46,7 +46,7 @@
static bool askUser(const QString &filename, bool &readonly)
{
QString interfaceName = QStringLiteral("org.kde.keditbookmarks");
QString appId = interfaceName + '-' + QString().setNum(QApplication::applicationPid());
QString appId = interfaceName + QLatin1Char('-') + QString().setNum(QApplication::applicationPid());
QDBusConnection dbus = QDBusConnection::sessionBus();
QDBusReply<QStringList> reply = dbus.interface()->registeredServiceNames();
......@@ -163,64 +163,65 @@ int main(int argc, char **argv)
GlobalBookmarkManager::self()->createManager(filename, QString(), new CommandHistory());
GlobalBookmarkManager::ExportType exportType = GlobalBookmarkManager::MozillaExport; // uumm.. can i just set it to -1 ?
int got = 0;
const char *arg, *arg2 = nullptr, *importType = nullptr;
if (arg = "exportmoz", parser.isSet(arg)) {
QString arg;
QString arg2;
QString importType;
if (arg = QStringLiteral("exportmoz"), parser.isSet(arg)) {
exportType = GlobalBookmarkManager::MozillaExport;
arg2 = arg;
got++;
}
if (arg = "exportns", parser.isSet(arg)) {
if (arg = QStringLiteral("exportns"), parser.isSet(arg)) {
exportType = GlobalBookmarkManager::NetscapeExport;
arg2 = arg;
got++;
}
if (arg = "exporthtml", parser.isSet(arg)) {
if (arg = QStringLiteral("exporthtml"), parser.isSet(arg)) {
exportType = GlobalBookmarkManager::HTMLExport;
arg2 = arg;
got++;
}
if (arg = "exportie", parser.isSet(arg)) {
if (arg = QStringLiteral("exportie"), parser.isSet(arg)) {
exportType = GlobalBookmarkManager::IEExport;
arg2 = arg;
got++;
}
if (arg = "exportopera", parser.isSet(arg)) {
if (arg = QStringLiteral("exportopera"), parser.isSet(arg)) {
exportType = GlobalBookmarkManager::OperaExport;
arg2 = arg;
got++;
}
if (arg = "importmoz", parser.isSet(arg)) {
importType = "Moz";
if (arg = QStringLiteral("importmoz"), parser.isSet(arg)) {
importType = QStringLiteral("Moz");
arg2 = arg;
got++;
}
if (arg = "importns", parser.isSet(arg)) {
importType = "NS";
if (arg = QStringLiteral("importns"), parser.isSet(arg)) {
importType = QStringLiteral("NS");
arg2 = arg;
got++;
}
if (arg = "importie", parser.isSet(arg)) {
importType = "IE";
if (arg = QStringLiteral("importie"), parser.isSet(arg)) {
importType = QStringLiteral("IE");
arg2 = arg;
got++;
}
if (arg = "importopera", parser.isSet(arg)) {
importType = "Opera";
if (arg = QStringLiteral("importopera"), parser.isSet(arg)) {
importType = QStringLiteral("Opera");
arg2 = arg;
got++;
}
if (arg = "importgaleon", parser.isSet(arg)) {
importType = "Galeon";
if (arg = QStringLiteral("importgaleon"), parser.isSet(arg)) {
importType = QStringLiteral("Galeon");
arg2 = arg;
got++;
}
if (arg = "importkde3", parser.isSet(arg)) {
importType = "KDE2";
if (arg = QStringLiteral("importkde3"), parser.isSet(arg)) {
importType = QStringLiteral("KDE2");
arg2 = arg;
got++;
}
if (!importType && arg2) {
Q_ASSERT(arg2);
if (importType.isEmpty() && !arg2.isEmpty()) {
// TODO - maybe an xbel export???
if (got > 1) { // got == 0 isn't possible as !isGui is dependent on "export.*"
qCWarning(KEDITBOOKMARKS_LOG) << i18n("You may only specify a single --export option.");
......@@ -228,7 +229,7 @@ int main(int argc, char **argv)
}
QString path = parser.value(arg2);
GlobalBookmarkManager::self()->doExport(exportType, path);
} else if (importType) {
} else if (!importType.isEmpty()) {
if (got > 1) { // got == 0 isn't possible as !isGui is dependent on "import.*"
qCWarning(KEDITBOOKMARKS_LOG) << i18n("You may only specify a single --import option.");
return 1;
......
......@@ -258,7 +258,6 @@ void KEBApp::setActionsEnabled(SelcAbilities sa)
KBookmark KEBApp::firstSelected() const
{
QModelIndex index;
const QModelIndexList &list = mBookmarkListView->selectionModel()->selectedIndexes();
if (list.count()) // selection in main listview, return bookmark for firstSelected
return mBookmarkListView->bookmarkForIndex(*list.constBegin());
......@@ -271,7 +270,7 @@ KBookmark KEBApp::firstSelected() const
QString KEBApp::insertAddress() const
{
KBookmark current = firstSelected();
return (current.isGroup()) ? (current.address() + "/0") // FIXME internal representation used
return (current.isGroup()) ? (current.address() + QStringLiteral("/0")) // FIXME internal representation used
: KBookmark::nextAddress(current.address());
}
......@@ -289,8 +288,8 @@ static bool lessAddress(const QString &first, const QString &second)
if (b == error)
return true;
a += '/';
b += '/';
a += QLatin1Char('/');
b += QLatin1Char('/');
uint aLast = 0;
uint bLast = 0;
......@@ -399,11 +398,6 @@ KEBApp::~KEBApp()
delete GlobalBookmarkManager::self();
}
KToggleAction *KEBApp::getToggleAction(const char *action) const
{
return static_cast<KToggleAction *>(actionCollection()->action(action));
}
void KEBApp::resetActions()
{
stateChanged(QStringLiteral("disablestuff"));
......
......@@ -62,14 +62,12 @@ public:
SelcAbilities getSelectionAbilities() const;
void setActionsEnabled(SelcAbilities);
QMenu *popupMenuFactory(const char *type)
QMenu *popupMenuFactory(const QString &type)
{
QWidget *menu = factory()->container(type, this);
return dynamic_cast<QMenu *>(menu);
}
KToggleAction *getToggleAction(const char *) const;
QString caption() const
{
return m_caption;
......
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