mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kio: bookmark classes review
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
43c73d1093
commit
af33cfc7d0
4 changed files with 179 additions and 186 deletions
|
@ -526,7 +526,7 @@ QString KBookmark::commonParent(const QString &first, const QString &second)
|
||||||
|
|
||||||
void KBookmark::updateAccessMetadata()
|
void KBookmark::updateAccessMetadata()
|
||||||
{
|
{
|
||||||
kDebug(7043) << "KBookmark::updateAccessMetadata" << address() << url().prettyUrl();
|
kDebug(7043) << "updateAccessMetadata" << address() << url().prettyUrl();
|
||||||
|
|
||||||
const uint timet = QDateTime::currentDateTime().toTime_t();
|
const uint timet = QDateTime::currentDateTime().toTime_t();
|
||||||
setMetaDataItem("time_added", QString::number(timet), DontOverwriteMetaData);
|
setMetaDataItem("time_added", QString::number(timet), DontOverwriteMetaData);
|
||||||
|
|
|
@ -49,11 +49,11 @@
|
||||||
|
|
||||||
#define BOOKMARK_CHANGE_NOTIFY_INTERFACE "org.kde.KIO.KBookmarkManager"
|
#define BOOKMARK_CHANGE_NOTIFY_INTERFACE "org.kde.KIO.KBookmarkManager"
|
||||||
|
|
||||||
class KBookmarkManagerList : public QList<KBookmarkManager *>
|
class KBookmarkManagerList : public QList<KBookmarkManager*>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~KBookmarkManagerList() {
|
~KBookmarkManagerList() {
|
||||||
qDeleteAll( begin() , end() ); // auto-delete functionality
|
qDeleteAll(begin() , end()); // auto-delete functionality
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
@ -61,7 +61,8 @@ public:
|
||||||
|
|
||||||
K_GLOBAL_STATIC(KBookmarkManagerList, s_pSelf)
|
K_GLOBAL_STATIC(KBookmarkManagerList, s_pSelf)
|
||||||
|
|
||||||
class KBookmarkMap : private KBookmarkGroupTraverser {
|
class KBookmarkMap : private KBookmarkGroupTraverser
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
KBookmarkMap() : m_mapNeedsUpdate(true) {}
|
KBookmarkMap() : m_mapNeedsUpdate(true) {}
|
||||||
void setNeedsUpdate() { m_mapNeedsUpdate = true; }
|
void setNeedsUpdate() { m_mapNeedsUpdate = true; }
|
||||||
|
@ -140,7 +141,7 @@ public:
|
||||||
QString m_editorCaption;
|
QString m_editorCaption;
|
||||||
|
|
||||||
bool m_typeExternal;
|
bool m_typeExternal;
|
||||||
KDirWatch * m_kDirWatch; // for external bookmark files
|
KDirWatch* m_kDirWatch; // for external bookmark files
|
||||||
|
|
||||||
KBookmarkMap m_map;
|
KBookmarkMap m_map;
|
||||||
};
|
};
|
||||||
|
@ -148,18 +149,19 @@ public:
|
||||||
// ################
|
// ################
|
||||||
// KBookmarkManager
|
// KBookmarkManager
|
||||||
|
|
||||||
static KBookmarkManager* lookupExisting(const QString& bookmarksFile)
|
static KBookmarkManager* lookupExisting(const QString &bookmarksFile)
|
||||||
{
|
{
|
||||||
for ( KBookmarkManagerList::ConstIterator bmit = s_pSelf->constBegin(), bmend = s_pSelf->constEnd();
|
for (KBookmarkManagerList::ConstIterator bmit = s_pSelf->constBegin(), bmend = s_pSelf->constEnd();
|
||||||
bmit != bmend; ++bmit ) {
|
bmit != bmend; ++bmit)
|
||||||
if ( (*bmit)->path() == bookmarksFile )
|
{
|
||||||
|
if ((*bmit)->path() == bookmarksFile) {
|
||||||
return *bmit;
|
return *bmit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KBookmarkManager* KBookmarkManager::managerForFile(const QString &bookmarksFile, const QString &dbusObjectName)
|
||||||
KBookmarkManager* KBookmarkManager::managerForFile( const QString& bookmarksFile, const QString& dbusObjectName )
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&s_pSelf->mutex);
|
QMutexLocker lock(&s_pSelf->mutex);
|
||||||
KBookmarkManager* mgr = lookupExisting(bookmarksFile);
|
KBookmarkManager* mgr = lookupExisting(bookmarksFile);
|
||||||
|
@ -167,12 +169,12 @@ KBookmarkManager* KBookmarkManager::managerForFile( const QString& bookmarksFile
|
||||||
return mgr;
|
return mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr = new KBookmarkManager( bookmarksFile, dbusObjectName );
|
mgr = new KBookmarkManager(bookmarksFile, dbusObjectName);
|
||||||
s_pSelf->append( mgr );
|
s_pSelf->append(mgr);
|
||||||
return mgr;
|
return mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkManager* KBookmarkManager::managerForExternalFile( const QString& bookmarksFile )
|
KBookmarkManager* KBookmarkManager::managerForExternalFile(const QString &bookmarksFile)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&s_pSelf->mutex);
|
QMutexLocker lock(&s_pSelf->mutex);
|
||||||
KBookmarkManager* mgr = lookupExisting(bookmarksFile);
|
KBookmarkManager* mgr = lookupExisting(bookmarksFile);
|
||||||
|
@ -180,71 +182,71 @@ KBookmarkManager* KBookmarkManager::managerForExternalFile( const QString& bookm
|
||||||
return mgr;
|
return mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr = new KBookmarkManager( bookmarksFile );
|
mgr = new KBookmarkManager(bookmarksFile);
|
||||||
s_pSelf->append( mgr );
|
s_pSelf->append(mgr);
|
||||||
return mgr;
|
return mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PI_DATA "version=\"1.0\" encoding=\"UTF-8\""
|
#define PI_DATA "version=\"1.0\" encoding=\"UTF-8\""
|
||||||
|
|
||||||
static QDomElement createXbelTopLevelElement(QDomDocument & doc)
|
static QDomElement createXbelTopLevelElement(QDomDocument &doc)
|
||||||
{
|
{
|
||||||
QDomElement topLevel = doc.createElement("xbel");
|
QDomElement topLevel = doc.createElement("xbel");
|
||||||
topLevel.setAttribute("xmlns:mime", "http://www.freedesktop.org/standards/shared-mime-info");
|
topLevel.setAttribute("xmlns:mime", "http://www.freedesktop.org/standards/shared-mime-info");
|
||||||
topLevel.setAttribute("xmlns:bookmark", "http://www.freedesktop.org/standards/desktop-bookmarks");
|
topLevel.setAttribute("xmlns:bookmark", "http://www.freedesktop.org/standards/desktop-bookmarks");
|
||||||
topLevel.setAttribute("xmlns:kdepriv", "http://www.kde.org/kdepriv");
|
topLevel.setAttribute("xmlns:kdepriv", "http://www.kde.org/kdepriv");
|
||||||
doc.appendChild( topLevel );
|
doc.appendChild( topLevel );
|
||||||
doc.insertBefore( doc.createProcessingInstruction( "xml", PI_DATA), topLevel );
|
doc.insertBefore( doc.createProcessingInstruction("xml", PI_DATA), topLevel);
|
||||||
return topLevel;
|
return topLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkManager::KBookmarkManager( const QString & bookmarksFile, const QString & dbusObjectName)
|
KBookmarkManager::KBookmarkManager(const QString &bookmarksFile, const QString &dbusObjectName)
|
||||||
: d(new KBookmarkManagerPrivate(false, dbusObjectName))
|
: d(new KBookmarkManagerPrivate(false, dbusObjectName))
|
||||||
{
|
{
|
||||||
if(dbusObjectName.isNull()) {
|
if (dbusObjectName.isNull()) {
|
||||||
// get dbusObjectName from file
|
// get dbusObjectName from file
|
||||||
if ( QFile::exists(d->m_bookmarksFile) ) {
|
if (QFile::exists(d->m_bookmarksFile) ) {
|
||||||
// sets d->m_dbusObjectName
|
// sets d->m_dbusObjectName
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new KBookmarkManagerAdaptor(this);
|
new KBookmarkManagerAdaptor(this);
|
||||||
QDBusConnection::sessionBus().registerObject( d->m_dbusObjectName, this );
|
QDBusConnection::sessionBus().registerObject(d->m_dbusObjectName, this);
|
||||||
QDBusConnection::sessionBus().connect(QString(), d->m_dbusObjectName, BOOKMARK_CHANGE_NOTIFY_INTERFACE,
|
QDBusConnection::sessionBus().connect(
|
||||||
"bookmarksChanged", this, SLOT(notifyChanged(QString,QDBusMessage)));
|
QString(), d->m_dbusObjectName, BOOKMARK_CHANGE_NOTIFY_INTERFACE, "bookmarksChanged",
|
||||||
QDBusConnection::sessionBus().connect(QString(), d->m_dbusObjectName, BOOKMARK_CHANGE_NOTIFY_INTERFACE,
|
this, SLOT(notifyChanged(QString,QDBusMessage))
|
||||||
"bookmarkConfigChanged", this, SLOT(notifyConfigChanged()));
|
);
|
||||||
|
QDBusConnection::sessionBus().connect(
|
||||||
|
QString(), d->m_dbusObjectName, BOOKMARK_CHANGE_NOTIFY_INTERFACE, "bookmarkConfigChanged",
|
||||||
|
this, SLOT(notifyConfigChanged())
|
||||||
|
);
|
||||||
|
|
||||||
d->m_update = true;
|
d->m_update = true;
|
||||||
|
|
||||||
Q_ASSERT( !bookmarksFile.isEmpty() );
|
Q_ASSERT(!bookmarksFile.isEmpty());
|
||||||
d->m_bookmarksFile = bookmarksFile;
|
d->m_bookmarksFile = bookmarksFile;
|
||||||
|
|
||||||
if ( !QFile::exists(d->m_bookmarksFile) )
|
if (!QFile::exists(d->m_bookmarksFile)) {
|
||||||
{
|
|
||||||
QDomElement topLevel = createXbelTopLevelElement(d->m_doc);
|
QDomElement topLevel = createXbelTopLevelElement(d->m_doc);
|
||||||
topLevel.setAttribute("dbusName", dbusObjectName);
|
topLevel.setAttribute("dbusName", dbusObjectName);
|
||||||
d->m_docIsLoaded = true;
|
d->m_docIsLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkManager::KBookmarkManager(const QString & bookmarksFile)
|
KBookmarkManager::KBookmarkManager(const QString &bookmarksFile)
|
||||||
: d(new KBookmarkManagerPrivate(false))
|
: d(new KBookmarkManagerPrivate(false))
|
||||||
{
|
{
|
||||||
// use KDirWatch to monitor this bookmarks file
|
// use KDirWatch to monitor this bookmarks file
|
||||||
d->m_typeExternal = true;
|
d->m_typeExternal = true;
|
||||||
d->m_update = true;
|
d->m_update = true;
|
||||||
|
|
||||||
Q_ASSERT( !bookmarksFile.isEmpty() );
|
Q_ASSERT(!bookmarksFile.isEmpty());
|
||||||
d->m_bookmarksFile = bookmarksFile;
|
d->m_bookmarksFile = bookmarksFile;
|
||||||
|
|
||||||
if ( !QFile::exists(d->m_bookmarksFile) )
|
if (!QFile::exists(d->m_bookmarksFile)) {
|
||||||
{
|
|
||||||
createXbelTopLevelElement(d->m_doc);
|
createXbelTopLevelElement(d->m_doc);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
d->m_docIsLoaded = true;
|
d->m_docIsLoaded = true;
|
||||||
|
@ -252,21 +254,23 @@ KBookmarkManager::KBookmarkManager(const QString & bookmarksFile)
|
||||||
// start KDirWatch
|
// start KDirWatch
|
||||||
d->m_kDirWatch = new KDirWatch();
|
d->m_kDirWatch = new KDirWatch();
|
||||||
d->m_kDirWatch->addFile(d->m_bookmarksFile);
|
d->m_kDirWatch->addFile(d->m_bookmarksFile);
|
||||||
QObject::connect(d->m_kDirWatch, SIGNAL(dirty(const QString&)),
|
QObject::connect(
|
||||||
this, SLOT(slotFileChanged(const QString&)));
|
d->m_kDirWatch, SIGNAL(dirty(QString)),
|
||||||
|
this, SLOT(slotFileChanged(QString))
|
||||||
|
);
|
||||||
kDebug(7043) << "starting KDirWatch for " << d->m_bookmarksFile;
|
kDebug(7043) << "starting KDirWatch for " << d->m_bookmarksFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::slotFileChanged(const QString& path)
|
void KBookmarkManager::slotFileChanged(const QString &path)
|
||||||
{
|
{
|
||||||
if (path == d->m_bookmarksFile)
|
if (path == d->m_bookmarksFile)
|
||||||
{
|
{
|
||||||
kDebug(7043) << "file changed (KDirWatch) " << path ;
|
kDebug(7043) << "file changed (KDirWatch)" << path;
|
||||||
// Reparse
|
// Reparse
|
||||||
parse();
|
parse();
|
||||||
// Tell our GUI
|
// Tell our GUI
|
||||||
// (emit where group is "" to directly mark the root menu as dirty)
|
// (emit where group is "" to directly mark the root menu as dirty)
|
||||||
emit changed( "", QString() );
|
emit changed("", QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,44 +288,40 @@ bool KBookmarkManager::autoErrorHandlingEnabled() const
|
||||||
return d->m_dialogAllowed;
|
return d->m_dialogAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::setAutoErrorHandlingEnabled( bool enable, QWidget *parent )
|
void KBookmarkManager::setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
|
||||||
{
|
{
|
||||||
d->m_dialogAllowed = enable;
|
d->m_dialogAllowed = enable;
|
||||||
d->m_dialogParent = parent;
|
d->m_dialogParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::setUpdate( bool update )
|
void KBookmarkManager::setUpdate(bool update)
|
||||||
{
|
{
|
||||||
d->m_update = update;
|
d->m_update = update;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument KBookmarkManager::internalDocument() const
|
QDomDocument KBookmarkManager::internalDocument() const
|
||||||
{
|
{
|
||||||
if(!d->m_docIsLoaded)
|
if (!d->m_docIsLoaded) {
|
||||||
{
|
|
||||||
parse();
|
parse();
|
||||||
d->m_toolbarDoc.clear();
|
d->m_toolbarDoc.clear();
|
||||||
}
|
}
|
||||||
return d->m_doc;
|
return d->m_doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KBookmarkManager::parse() const
|
void KBookmarkManager::parse() const
|
||||||
{
|
{
|
||||||
d->m_docIsLoaded = true;
|
d->m_docIsLoaded = true;
|
||||||
//kDebug(7043) << "KBookmarkManager::parse " << d->m_bookmarksFile;
|
// kDebug(7043) << "parsing" << d->m_bookmarksFile;
|
||||||
QFile file( d->m_bookmarksFile );
|
QFile file(d->m_bookmarksFile);
|
||||||
if ( !file.open( QIODevice::ReadOnly ) )
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
{
|
kWarning() << "Can't open" << d->m_bookmarksFile;
|
||||||
kWarning() << "Can't open " << d->m_bookmarksFile;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->m_doc = QDomDocument("xbel");
|
d->m_doc = QDomDocument("xbel");
|
||||||
d->m_doc.setContent( &file );
|
d->m_doc.setContent(&file);
|
||||||
|
|
||||||
if ( d->m_doc.documentElement().isNull() )
|
if (d->m_doc.documentElement().isNull()) {
|
||||||
{
|
kWarning() << "main tag is missing, creating default" << d->m_bookmarksFile;
|
||||||
kWarning() << "KBookmarkManager::parse : main tag is missing, creating default " << d->m_bookmarksFile;
|
|
||||||
QDomElement element = d->m_doc.createElement("xbel");
|
QDomElement element = d->m_doc.createElement("xbel");
|
||||||
d->m_doc.appendChild(element);
|
d->m_doc.appendChild(element);
|
||||||
}
|
}
|
||||||
|
@ -329,89 +329,82 @@ void KBookmarkManager::parse() const
|
||||||
QDomElement docElem = d->m_doc.documentElement();
|
QDomElement docElem = d->m_doc.documentElement();
|
||||||
|
|
||||||
QString mainTag = docElem.tagName();
|
QString mainTag = docElem.tagName();
|
||||||
if ( mainTag != "xbel" )
|
if (mainTag != "xbel" ) {
|
||||||
kWarning() << "KBookmarkManager::parse : unknown main tag " << mainTag;
|
kWarning() << "unknown main tag" << mainTag;
|
||||||
|
|
||||||
if(d->m_dbusObjectName.isNull())
|
|
||||||
{
|
|
||||||
d->m_dbusObjectName = docElem.attribute("dbusName");
|
|
||||||
}
|
}
|
||||||
else if(docElem.attribute("dbusName") != d->m_dbusObjectName)
|
|
||||||
{
|
if (d->m_dbusObjectName.isNull()) {
|
||||||
|
d->m_dbusObjectName = docElem.attribute("dbusName");
|
||||||
|
} else if(docElem.attribute("dbusName") != d->m_dbusObjectName) {
|
||||||
docElem.setAttribute("dbusName", d->m_dbusObjectName);
|
docElem.setAttribute("dbusName", d->m_dbusObjectName);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomNode n = d->m_doc.documentElement().previousSibling();
|
QDomNode n = d->m_doc.documentElement().previousSibling();
|
||||||
if ( n.isProcessingInstruction() )
|
if (n.isProcessingInstruction()) {
|
||||||
{
|
|
||||||
QDomProcessingInstruction pi = n.toProcessingInstruction();
|
QDomProcessingInstruction pi = n.toProcessingInstruction();
|
||||||
pi.parentNode().removeChild(pi);
|
pi.parentNode().removeChild(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomProcessingInstruction pi;
|
QDomProcessingInstruction pi;
|
||||||
pi = d->m_doc.createProcessingInstruction( "xml", PI_DATA );
|
pi = d->m_doc.createProcessingInstruction("xml", PI_DATA);
|
||||||
d->m_doc.insertBefore( pi, docElem );
|
d->m_doc.insertBefore(pi, docElem);
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
d->m_map.setNeedsUpdate();
|
d->m_map.setNeedsUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KBookmarkManager::save( bool toolbarCache ) const
|
bool KBookmarkManager::save(bool toolbarCache) const
|
||||||
{
|
{
|
||||||
return saveAs( d->m_bookmarksFile, toolbarCache );
|
return saveAs(d->m_bookmarksFile, toolbarCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KBookmarkManager::saveAs( const QString & filename, bool toolbarCache ) const
|
bool KBookmarkManager::saveAs(const QString &filename, bool toolbarCache) const
|
||||||
{
|
{
|
||||||
kDebug(7043) << "KBookmarkManager::save " << filename;
|
kDebug(7043) << "save as" << filename << toolbarCache;
|
||||||
|
|
||||||
// Save the bookmark toolbar folder for quick loading
|
// Save the bookmark toolbar folder for quick loading
|
||||||
// but only when it will actually make things quicker
|
// but only when it will actually make things quicker
|
||||||
const QString cacheFilename = filename + QLatin1String(".tbcache");
|
const QString cacheFilename = filename + QLatin1String(".tbcache");
|
||||||
if(toolbarCache && !root().isToolbarGroup())
|
if(toolbarCache && !root().isToolbarGroup()) {
|
||||||
{
|
KSaveFile cacheFile(cacheFilename);
|
||||||
KSaveFile cacheFile( cacheFilename );
|
if (cacheFile.open()) {
|
||||||
if ( cacheFile.open() )
|
|
||||||
{
|
|
||||||
QString str;
|
QString str;
|
||||||
QTextStream stream(&str, QIODevice::WriteOnly);
|
QTextStream stream(&str, QIODevice::WriteOnly);
|
||||||
stream << root().findToolbar();
|
stream << root().findToolbar();
|
||||||
const QByteArray cstr = str.toUtf8();
|
const QByteArray cstr = str.toUtf8();
|
||||||
cacheFile.write( cstr.data(), cstr.length() );
|
cacheFile.write(cstr.data(), cstr.length());
|
||||||
cacheFile.finalize();
|
cacheFile.finalize();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else // remove any (now) stale cache
|
// remove any (now) stale cache
|
||||||
{
|
QFile::remove(cacheFilename);
|
||||||
QFile::remove( cacheFilename );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KSaveFile file( filename );
|
KSaveFile file(filename);
|
||||||
if ( file.open() )
|
if (file.open()) {
|
||||||
{
|
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
stream.setCodec( QTextCodec::codecForName( "UTF-8" ) );
|
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
stream << internalDocument().toString();
|
stream << internalDocument().toString();
|
||||||
stream.flush();
|
stream.flush();
|
||||||
if ( file.finalize() )
|
if (file.finalize()) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hadSaveError = false;
|
static int hadSaveError = false;
|
||||||
file.abort();
|
file.abort();
|
||||||
if ( !hadSaveError ) {
|
if (!hadSaveError) {
|
||||||
QString err = i18n("Unable to save bookmarks in %1. Reported error was: %2. "
|
QString err = i18n("Unable to save bookmarks in %1. Reported error was: %2. "
|
||||||
"This error message will only be shown once. The cause "
|
"This error message will only be shown once. The cause "
|
||||||
"of the error needs to be fixed as quickly as possible, "
|
"of the error needs to be fixed as quickly as possible, "
|
||||||
"which is most likely a full hard drive.",
|
"which is most likely a full hard drive.",
|
||||||
filename, file.errorString());
|
filename, file.errorString());
|
||||||
|
|
||||||
if (d->m_dialogAllowed && qApp->type() != QApplication::Tty && QThread::currentThread() == qApp->thread())
|
if (d->m_dialogAllowed && qApp->type() != QApplication::Tty && QThread::currentThread() == qApp->thread()) {
|
||||||
KMessageBox::error( QApplication::activeWindow(), err );
|
KMessageBox::error(QApplication::activeWindow(), err);
|
||||||
|
}
|
||||||
|
|
||||||
kError() << QString("Unable to save bookmarks in %1. File reported the following error-code: %2.").arg(filename).arg(file.error());
|
kError() << QString("Unable to save bookmarks in %1. File reported the following error-code: %2.").arg(filename).arg(file.error());
|
||||||
emit const_cast<KBookmarkManager*>(this)->error(err);
|
emit const_cast<KBookmarkManager*>(this)->error(err);
|
||||||
|
@ -432,11 +425,10 @@ KBookmarkGroup KBookmarkManager::root() const
|
||||||
|
|
||||||
KBookmarkGroup KBookmarkManager::toolbar()
|
KBookmarkGroup KBookmarkManager::toolbar()
|
||||||
{
|
{
|
||||||
kDebug(7043) << "KBookmarkManager::toolbar begin";
|
// kDebug(7043) << "toolbar begin";
|
||||||
// Only try to read from a toolbar cache if the full document isn't loaded
|
// Only try to read from a toolbar cache if the full document isn't loaded
|
||||||
if(!d->m_docIsLoaded)
|
if (!d->m_docIsLoaded) {
|
||||||
{
|
kDebug(7043) << "trying toolbar cache";
|
||||||
kDebug(7043) << "KBookmarkManager::toolbar trying cache";
|
|
||||||
const QString cacheFilename = d->m_bookmarksFile + QLatin1String(".tbcache");
|
const QString cacheFilename = d->m_bookmarksFile + QLatin1String(".tbcache");
|
||||||
QFileInfo bmInfo(d->m_bookmarksFile);
|
QFileInfo bmInfo(d->m_bookmarksFile);
|
||||||
QFileInfo cacheInfo(cacheFilename);
|
QFileInfo cacheInfo(cacheFilename);
|
||||||
|
@ -444,19 +436,16 @@ KBookmarkGroup KBookmarkManager::toolbar()
|
||||||
QFile::exists(cacheFilename) &&
|
QFile::exists(cacheFilename) &&
|
||||||
bmInfo.lastModified() < cacheInfo.lastModified())
|
bmInfo.lastModified() < cacheInfo.lastModified())
|
||||||
{
|
{
|
||||||
kDebug(7043) << "KBookmarkManager::toolbar reading file";
|
kDebug(7043) << "reading file toolbar cache";
|
||||||
QFile file( cacheFilename );
|
QFile file(cacheFilename);
|
||||||
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
if ( file.open( QIODevice::ReadOnly ) )
|
|
||||||
{
|
|
||||||
d->m_toolbarDoc = QDomDocument("cache");
|
d->m_toolbarDoc = QDomDocument("cache");
|
||||||
d->m_toolbarDoc.setContent( &file );
|
d->m_toolbarDoc.setContent(&file);
|
||||||
kDebug(7043) << "KBookmarkManager::toolbar opened";
|
kDebug(7043) << "toolbar cache opened";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!d->m_toolbarDoc.isNull())
|
if (!d->m_toolbarDoc.isNull()) {
|
||||||
{
|
kDebug(7043) << "returning toolbar element";
|
||||||
kDebug(7043) << "KBookmarkManager::toolbar returning element";
|
|
||||||
QDomElement elem = d->m_toolbarDoc.firstChild().toElement();
|
QDomElement elem = d->m_toolbarDoc.firstChild().toElement();
|
||||||
return KBookmarkGroup(elem);
|
return KBookmarkGroup(elem);
|
||||||
}
|
}
|
||||||
|
@ -465,46 +454,43 @@ KBookmarkGroup KBookmarkManager::toolbar()
|
||||||
// Fallback to the normal way if there is no cache or if the bookmark file
|
// Fallback to the normal way if there is no cache or if the bookmark file
|
||||||
// is already loaded
|
// is already loaded
|
||||||
QDomElement elem = root().findToolbar();
|
QDomElement elem = root().findToolbar();
|
||||||
if (elem.isNull())
|
if (elem.isNull()) {
|
||||||
{
|
|
||||||
// Root is the bookmark toolbar if none has been set.
|
// Root is the bookmark toolbar if none has been set.
|
||||||
// Make it explicit to speed up invocations of findToolbar()
|
// Make it explicit to speed up invocations of findToolbar()
|
||||||
root().internalElement().setAttribute("toolbar", "yes");
|
root().internalElement().setAttribute("toolbar", "yes");
|
||||||
return root();
|
return root();
|
||||||
}
|
}
|
||||||
else
|
return KBookmarkGroup(elem);
|
||||||
return KBookmarkGroup(elem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmark KBookmarkManager::findByAddress( const QString & address )
|
KBookmark KBookmarkManager::findByAddress(const QString &address)
|
||||||
{
|
{
|
||||||
//kDebug(7043) << "KBookmarkManager::findByAddress " << address;
|
// kDebug(7043) << "findByAddress" << address;
|
||||||
KBookmark result = root();
|
KBookmark result = root();
|
||||||
// The address is something like /5/10/2+
|
// The address is something like /5/10/2+
|
||||||
const QStringList addresses = address.split(QRegExp("[/+]"),QString::SkipEmptyParts);
|
const QStringList addresses = address.split(QRegExp("[/+]"),QString::SkipEmptyParts);
|
||||||
// kWarning() << addresses.join(",");
|
// kWarning() << addresses.join(",");
|
||||||
foreach (const QString it, addresses)
|
foreach (const QString &it, addresses) {
|
||||||
{
|
|
||||||
bool append = (it == "+");
|
bool append = (it == "+");
|
||||||
uint number = it.toUInt();
|
uint number = it.toUInt();
|
||||||
Q_ASSERT(result.isGroup());
|
Q_ASSERT(result.isGroup());
|
||||||
KBookmarkGroup group = result.toGroup();
|
KBookmarkGroup group = result.toGroup();
|
||||||
KBookmark bk = group.first(), lbk = bk; // last non-null bookmark
|
KBookmark bk = group.first(), lbk = bk; // last non-null bookmark
|
||||||
for ( uint i = 0 ; ( (i<number) || append ) && !bk.isNull() ; ++i ) {
|
for (uint i = 0 ; (i < number || append) && !bk.isNull() ; ++i) {
|
||||||
lbk = bk;
|
lbk = bk;
|
||||||
bk = group.next(bk);
|
bk = group.next(bk);
|
||||||
//kWarning() << i;
|
// kWarning() << i;
|
||||||
}
|
}
|
||||||
//kWarning() << "found section";
|
// kWarning() << "found section";
|
||||||
result = bk;
|
result = bk;
|
||||||
}
|
}
|
||||||
if (result.isNull()) {
|
if (result.isNull()) {
|
||||||
kWarning() << "KBookmarkManager::findByAddress: couldn't find item " << address;
|
kWarning() << "couldn't find item" << address;
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "updating favicon for" << result.url();
|
kDebug() << "updating favicon for" << result.url();
|
||||||
result.setIcon(KMimeType::favIconForUrl(result.url()));
|
result.setIcon(KMimeType::favIconForUrl(result.url()));
|
||||||
}
|
}
|
||||||
//kWarning() << "found " << result.address();
|
// kDebug() << "found " << result.address();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,18 +499,17 @@ void KBookmarkManager::emitChanged()
|
||||||
emitChanged(root());
|
emitChanged(root());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KBookmarkManager::emitChanged(const KBookmarkGroup &group)
|
||||||
void KBookmarkManager::emitChanged( const KBookmarkGroup & group )
|
|
||||||
{
|
{
|
||||||
(void) save(); // KDE5 TODO: emitChanged should return a bool? Maybe rename it to saveAndEmitChanged?
|
(void) save(); // KDE5 TODO: emitChanged should return a bool? Maybe rename it to saveAndEmitChanged?
|
||||||
|
|
||||||
// Tell the other processes too
|
// Tell the other processes too
|
||||||
// kDebug(7043) << "KBookmarkManager::emitChanged : broadcasting change " << group.address();
|
// kDebug(7043) << "broadcasting change " << group.address();
|
||||||
|
|
||||||
emit bookmarksChanged(group.address());
|
emit bookmarksChanged(group.address());
|
||||||
|
|
||||||
// We do get our own broadcast, so no need for this anymore
|
// We do get our own broadcast, so no need for this anymore
|
||||||
//emit changed( group );
|
// emit changed(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::emitConfigChanged()
|
void KBookmarkManager::emitConfigChanged()
|
||||||
|
@ -532,21 +517,24 @@ void KBookmarkManager::emitConfigChanged()
|
||||||
emit bookmarkConfigChanged();
|
emit bookmarkConfigChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::notifyCompleteChange( const QString &caller ) // DBUS call
|
// DBUS call
|
||||||
|
void KBookmarkManager::notifyCompleteChange(const QString &caller)
|
||||||
{
|
{
|
||||||
if (!d->m_update)
|
if (!d->m_update) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
kDebug(7043) << "KBookmarkManager::notifyCompleteChange";
|
kDebug(7043) << "notifyCompleteChange";
|
||||||
// The bk editor tells us we should reload everything
|
// The bk editor tells us we should reload everything
|
||||||
// Reparse
|
// Reparse
|
||||||
parse();
|
parse();
|
||||||
// Tell our GUI
|
// Tell our GUI
|
||||||
// (emit where group is "" to directly mark the root menu as dirty)
|
// (emit where group is "" to directly mark the root menu as dirty)
|
||||||
emit changed( "", caller );
|
emit changed("", caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::notifyConfigChanged() // DBUS call
|
// DBUS call
|
||||||
|
void KBookmarkManager::notifyConfigChanged()
|
||||||
{
|
{
|
||||||
kDebug() << "reloaded bookmark config!";
|
kDebug() << "reloaded bookmark config!";
|
||||||
KBookmarkSettings::self()->readSettings();
|
KBookmarkSettings::self()->readSettings();
|
||||||
|
@ -554,24 +542,26 @@ void KBookmarkManager::notifyConfigChanged() // DBUS call
|
||||||
emit configChanged();
|
emit configChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::notifyChanged( const QString &groupAddress, const QDBusMessage &msg ) // DBUS call
|
// DBUS call
|
||||||
|
void KBookmarkManager::notifyChanged(const QString &groupAddress, const QDBusMessage &msg)
|
||||||
{
|
{
|
||||||
kDebug() << "KBookmarkManager::notifyChanged ( "<<groupAddress<<")";
|
kDebug() << "bookmark group changed" << groupAddress;
|
||||||
if (!d->m_update)
|
if (!d->m_update) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Reparse (the whole file, no other choice)
|
// Reparse (the whole file, no other choice)
|
||||||
// if someone else notified us
|
// if someone else notified us
|
||||||
if (msg.service() != QDBusConnection::sessionBus().baseService())
|
if (msg.service() != QDBusConnection::sessionBus().baseService()) {
|
||||||
parse();
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
//kDebug(7043) << "KBookmarkManager::notifyChanged " << groupAddress;
|
// KBookmarkGroup group = findByAddress( groupAddress ).toGroup();
|
||||||
//KBookmarkGroup group = findByAddress( groupAddress ).toGroup();
|
// Q_ASSERT(!group.isNull());
|
||||||
//Q_ASSERT(!group.isNull());
|
emit changed(groupAddress, QString());
|
||||||
emit changed( groupAddress, QString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::setEditorOptions( const QString& caption, bool browser )
|
void KBookmarkManager::setEditorOptions(const QString &caption, bool browser)
|
||||||
{
|
{
|
||||||
d->m_editorCaption = caption;
|
d->m_editorCaption = caption;
|
||||||
d->m_browserEditor = browser;
|
d->m_browserEditor = browser;
|
||||||
|
@ -580,48 +570,51 @@ void KBookmarkManager::setEditorOptions( const QString& caption, bool browser )
|
||||||
void KBookmarkManager::slotEditBookmarks()
|
void KBookmarkManager::slotEditBookmarks()
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if ( !d->m_editorCaption.isEmpty() )
|
if (!d->m_editorCaption.isEmpty()) {
|
||||||
args << QLatin1String("--customcaption") << d->m_editorCaption;
|
args << QLatin1String("--customcaption") << d->m_editorCaption;
|
||||||
if ( !d->m_browserEditor )
|
}
|
||||||
args << QLatin1String("--nobrowser");
|
if (!d->m_browserEditor) {
|
||||||
if( !d->m_dbusObjectName.isEmpty() )
|
args << QLatin1String("--nobrowser");
|
||||||
args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
|
}
|
||||||
|
if (!d->m_dbusObjectName.isEmpty()) {
|
||||||
|
args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
|
||||||
|
}
|
||||||
args << d->m_bookmarksFile;
|
args << d->m_bookmarksFile;
|
||||||
QProcess::startDetached("keditbookmarks", args);
|
QProcess::startDetached("keditbookmarks", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::slotEditBookmarksAtAddress( const QString& address )
|
void KBookmarkManager::slotEditBookmarksAtAddress(const QString &address)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if ( !d->m_editorCaption.isEmpty() )
|
if (!d->m_editorCaption.isEmpty()) {
|
||||||
args << QLatin1String("--customcaption") << d->m_editorCaption;
|
args << QLatin1String("--customcaption") << d->m_editorCaption;
|
||||||
if ( !d->m_browserEditor )
|
}
|
||||||
args << QLatin1String("--nobrowser");
|
if (!d->m_browserEditor) {
|
||||||
if( !d->m_dbusObjectName.isEmpty() )
|
args << QLatin1String("--nobrowser");
|
||||||
args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
|
}
|
||||||
args << QLatin1String("--address") << address
|
if (!d->m_dbusObjectName.isEmpty()) {
|
||||||
<< d->m_bookmarksFile;
|
args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
|
||||||
|
}
|
||||||
|
args << QLatin1String("--address") << address << d->m_bookmarksFile;
|
||||||
QProcess::startDetached("keditbookmarks", args);
|
QProcess::startDetached("keditbookmarks", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////
|
///////
|
||||||
bool KBookmarkManager::updateAccessMetadata( const QString & url )
|
bool KBookmarkManager::updateAccessMetadata(const QString &url)
|
||||||
{
|
{
|
||||||
d->m_map.update(this);
|
d->m_map.update(this);
|
||||||
QList<KBookmark> list = d->m_map.find(url);
|
QList<KBookmark> list = d->m_map.find(url);
|
||||||
foreach ( KBookmark it, list ) {
|
foreach (KBookmark it, list) {
|
||||||
it.updateAccessMetadata();
|
it.updateAccessMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkManager::updateFavicon( const QString &url, const QString &faviconurl )
|
void KBookmarkManager::updateFavicon(const QString &url, const QString &faviconurl)
|
||||||
{
|
{
|
||||||
d->m_map.update(this);
|
d->m_map.update(this);
|
||||||
QList<KBookmark> list = d->m_map.find(url);
|
QList<KBookmark> list = d->m_map.find(url);
|
||||||
foreach ( KBookmark it, list )
|
foreach (KBookmark it, list) {
|
||||||
{
|
|
||||||
KUrl iconurl(faviconurl);
|
KUrl iconurl(faviconurl);
|
||||||
it.setIcon(KMimeType::favIconForUrl(iconurl));
|
it.setIcon(KMimeType::favIconForUrl(iconurl));
|
||||||
}
|
}
|
||||||
|
@ -635,7 +628,7 @@ KBookmarkManager* KBookmarkManager::userBookmarksManager()
|
||||||
return bookmarkManager;
|
return bookmarkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkSettings* KBookmarkSettings::s_self = 0;
|
KBookmarkSettings* KBookmarkSettings::s_self = nullptr;
|
||||||
|
|
||||||
void KBookmarkSettings::readSettings()
|
void KBookmarkSettings::readSettings()
|
||||||
{
|
{
|
||||||
|
@ -651,9 +644,8 @@ void KBookmarkSettings::readSettings()
|
||||||
|
|
||||||
KBookmarkSettings *KBookmarkSettings::self()
|
KBookmarkSettings *KBookmarkSettings::self()
|
||||||
{
|
{
|
||||||
if (!s_self)
|
if (!s_self) {
|
||||||
{
|
s_self = new KBookmarkSettings();
|
||||||
s_self = new KBookmarkSettings;
|
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
return s_self;
|
return s_self;
|
||||||
|
@ -663,10 +655,12 @@ KBookmarkSettings *KBookmarkSettings::self()
|
||||||
|
|
||||||
bool KBookmarkOwner::enableOption(BookmarkOption action) const
|
bool KBookmarkOwner::enableOption(BookmarkOption action) const
|
||||||
{
|
{
|
||||||
if(action == ShowAddBookmark)
|
if (action == ShowAddBookmark) {
|
||||||
return true;
|
return true;
|
||||||
if(action == ShowEditBookmark)
|
}
|
||||||
|
if (action == ShowEditBookmark) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,7 +671,6 @@ KBookmarkDialog * KBookmarkOwner::bookmarkDialog(KBookmarkManager * mgr, QWidget
|
||||||
|
|
||||||
void KBookmarkOwner::openFolderinTabs(const KBookmarkGroup &)
|
void KBookmarkOwner::openFolderinTabs(const KBookmarkGroup &)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_kbookmarkmanager.cpp"
|
#include "moc_kbookmarkmanager.cpp"
|
||||||
|
|
|
@ -213,7 +213,7 @@ QString KBookmarkMenu::parentAddress() const
|
||||||
return d->m_parentAddress;
|
return d->m_parentAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkManager * KBookmarkMenu::manager() const
|
KBookmarkManager* KBookmarkMenu::manager() const
|
||||||
{
|
{
|
||||||
return d->m_pManager;
|
return d->m_pManager;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ void KBookmarkContextMenu::slotProperties()
|
||||||
{
|
{
|
||||||
// kDebug(7043) << m_highlightedAddress;
|
// kDebug(7043) << m_highlightedAddress;
|
||||||
|
|
||||||
KBookmarkDialog * dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
|
KBookmarkDialog* dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
|
||||||
dlg->editBookmark(bm);
|
dlg->editBookmark(bm);
|
||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ void KBookmarkContextMenu::slotInsert()
|
||||||
|
|
||||||
QString url = m_pOwner->currentUrl();
|
QString url = m_pOwner->currentUrl();
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
KMessageBox::error( QApplication::activeWindow(), i18n("Cannot add bookmark with empty URL."));
|
KMessageBox::error(QApplication::activeWindow(), i18n("Cannot add bookmark with empty URL."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString title = m_pOwner->currentTitle();
|
QString title = m_pOwner->currentTitle();
|
||||||
|
@ -346,24 +346,24 @@ void KBookmarkContextMenu::slotInsert()
|
||||||
if (bm.isGroup()) {
|
if (bm.isGroup()) {
|
||||||
KBookmarkGroup parentBookmark = bm.toGroup();
|
KBookmarkGroup parentBookmark = bm.toGroup();
|
||||||
Q_ASSERT(!parentBookmark.isNull());
|
Q_ASSERT(!parentBookmark.isNull());
|
||||||
parentBookmark.addBookmark( title, KUrl(url) );
|
parentBookmark.addBookmark(title, KUrl(url));
|
||||||
m_pManager->emitChanged( parentBookmark );
|
m_pManager->emitChanged(parentBookmark);
|
||||||
} else {
|
} else {
|
||||||
KBookmarkGroup parentBookmark = bm.parentGroup();
|
KBookmarkGroup parentBookmark = bm.parentGroup();
|
||||||
Q_ASSERT(!parentBookmark.isNull());
|
Q_ASSERT(!parentBookmark.isNull());
|
||||||
KBookmark newBookmark = parentBookmark.addBookmark( title, KUrl(m_pOwner->currentUrl()) );
|
KBookmark newBookmark = parentBookmark.addBookmark(title, KUrl(m_pOwner->currentUrl()));
|
||||||
parentBookmark.moveBookmark( newBookmark, parentBookmark.previous(bm) );
|
parentBookmark.moveBookmark(newBookmark, parentBookmark.previous(bm));
|
||||||
m_pManager->emitChanged( parentBookmark );
|
m_pManager->emitChanged(parentBookmark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkContextMenu::slotRemove()
|
void KBookmarkContextMenu::slotRemove()
|
||||||
{
|
{
|
||||||
//kDebug(7043) << "KBookmarkMenu::slotRemove" << m_highlightedAddress;
|
// kDebug(7043) << "slotRemove" << m_highlightedAddress;
|
||||||
|
|
||||||
bool folder = bm.isGroup();
|
bool folder = bm.isGroup();
|
||||||
|
|
||||||
if(KMessageBox::warningContinueCancel(
|
if (KMessageBox::warningContinueCancel(
|
||||||
QApplication::activeWindow(),
|
QApplication::activeWindow(),
|
||||||
folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text())
|
folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text())
|
||||||
: i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()),
|
: i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()),
|
||||||
|
@ -371,18 +371,19 @@ void KBookmarkContextMenu::slotRemove()
|
||||||
: i18n("Bookmark Deletion"),
|
: i18n("Bookmark Deletion"),
|
||||||
KStandardGuiItem::del())
|
KStandardGuiItem::del())
|
||||||
!= KMessageBox::Continue
|
!= KMessageBox::Continue
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KBookmarkGroup parentBookmark = bm.parentGroup();
|
KBookmarkGroup parentBookmark = bm.parentGroup();
|
||||||
parentBookmark.deleteBookmark( bm );
|
parentBookmark.deleteBookmark(bm);
|
||||||
m_pManager->emitChanged( parentBookmark );
|
m_pManager->emitChanged(parentBookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KBookmarkContextMenu::slotCopyLocation()
|
void KBookmarkContextMenu::slotCopyLocation()
|
||||||
{
|
{
|
||||||
// kDebug(7043) << m_highlightedAddress;
|
// kDebug(7043) << "slotCopyLocation" << m_highlightedAddress;
|
||||||
|
|
||||||
if (!bm.isGroup()) {
|
if (!bm.isGroup()) {
|
||||||
QMimeData* mimeData = new QMimeData();
|
QMimeData* mimeData = new QMimeData();
|
||||||
|
@ -420,7 +421,7 @@ KBookmark KBookmarkContextMenu::bookmark() const
|
||||||
|
|
||||||
void KBookmarkMenu::slotBookmarksChanged(const QString &groupAddress)
|
void KBookmarkMenu::slotBookmarksChanged(const QString &groupAddress)
|
||||||
{
|
{
|
||||||
kDebug(7043) << groupAddress;
|
kDebug(7043) << "slotBookmarksChanged" << groupAddress;
|
||||||
if (groupAddress == d->m_parentAddress) {
|
if (groupAddress == d->m_parentAddress) {
|
||||||
// kDebug(7043) << "setting m_bDirty on" << groupAddress;
|
// kDebug(7043) << "setting m_bDirty on" << groupAddress;
|
||||||
d->m_bDirty = true;
|
d->m_bDirty = true;
|
||||||
|
@ -535,7 +536,7 @@ void KBookmarkMenu::addNewFolder()
|
||||||
if (!d->newBookmarkFolder) {
|
if (!d->newBookmarkFolder) {
|
||||||
d->newBookmarkFolder = new KAction(i18n("New Bookmark Folder..."), this);
|
d->newBookmarkFolder = new KAction(i18n("New Bookmark Folder..."), this);
|
||||||
d->newBookmarkFolder->setIcon(KIcon("folder-new"));
|
d->newBookmarkFolder->setIcon(KIcon("folder-new"));
|
||||||
d->newBookmarkFolder->setHelpText( i18n( "Create a new bookmark folder in this menu"));
|
d->newBookmarkFolder->setHelpText(i18n("Create a new bookmark folder in this menu"));
|
||||||
connect(d->newBookmarkFolder, SIGNAL(triggered(bool)), this, SLOT(slotNewFolder()));
|
connect(d->newBookmarkFolder, SIGNAL(triggered(bool)), this, SLOT(slotNewFolder()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +545,7 @@ void KBookmarkMenu::addNewFolder()
|
||||||
|
|
||||||
void KBookmarkMenu::fillBookmarks()
|
void KBookmarkMenu::fillBookmarks()
|
||||||
{
|
{
|
||||||
KBookmarkGroup parentBookmark = d->m_pManager->findByAddress(d->m_parentAddress ).toGroup();
|
KBookmarkGroup parentBookmark = d->m_pManager->findByAddress(d->m_parentAddress).toGroup();
|
||||||
Q_ASSERT(!parentBookmark.isNull());
|
Q_ASSERT(!parentBookmark.isNull());
|
||||||
|
|
||||||
if (d->m_bIsRoot && !parentBookmark.first().isNull()) { // at least one bookmark
|
if (d->m_bIsRoot && !parentBookmark.first().isNull()) { // at least one bookmark
|
||||||
|
|
|
@ -151,7 +151,6 @@ private:
|
||||||
class KIO_EXPORT KBookmarkContextMenu : public KMenu
|
class KIO_EXPORT KBookmarkContextMenu : public KMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KBookmarkContextMenu(const KBookmark &bm, KBookmarkManager *manager, KBookmarkOwner *owner, QWidget *parent = 0);
|
KBookmarkContextMenu(const KBookmark &bm, KBookmarkManager *manager, KBookmarkOwner *owner, QWidget *parent = 0);
|
||||||
virtual ~KBookmarkContextMenu();
|
virtual ~KBookmarkContextMenu();
|
||||||
|
@ -181,8 +180,8 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KBookmark bm;
|
KBookmark bm;
|
||||||
KBookmarkManager * m_pManager;
|
KBookmarkManager* m_pManager;
|
||||||
KBookmarkOwner * m_pOwner;
|
KBookmarkOwner* m_pOwner;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KIO_EXPORT KBookmarkActionInterface
|
class KIO_EXPORT KBookmarkActionInterface
|
||||||
|
|
Loading…
Add table
Reference in a new issue