Verified Commit 3f758218 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 5e1b1a57
This diff is collapsed.
......@@ -29,53 +29,60 @@ class KBookmarkModel;
class ActionsImpl : public QObject
{
Q_OBJECT
Q_OBJECT
public:
ActionsImpl(QObject* parent, KBookmarkModel* model);
~ActionsImpl();
bool save();
ActionsImpl(QObject *parent, KBookmarkModel *model);
~ActionsImpl();
bool save();
TestLinkItrHolder* testLinkHolder() { return m_testLinkHolder; }
FavIconsItrHolder* favIconHolder() { return m_favIconHolder; }
TestLinkItrHolder *testLinkHolder()
{
return m_testLinkHolder;
}
FavIconsItrHolder *favIconHolder()
{
return m_favIconHolder;
}
public Q_SLOTS:
void slotLoad();
void slotSaveAs();
void slotCut();
void slotCopy();
void slotPaste();
void slotRename();
void slotChangeURL();
void slotChangeComment();
void slotChangeIcon();
void slotDelete();
void slotNewFolder();
void slotNewBookmark();
void slotInsertSeparator();
void slotSort();
void slotSetAsToolbar();
void slotOpenLink();
void slotTestSelection();
void slotTestAll();
void slotCancelAllTests();
void slotUpdateFavIcon();
void slotRecursiveSort();
void slotUpdateAllFavIcons();
void slotCancelFavIconUpdates();
void slotExpandAll();
void slotCollapseAll();
void slotImport();
void slotExportOpera();
void slotExportHTML();
void slotExportIE();
void slotExportNS();
void slotExportMoz();
void slotLoad();
void slotSaveAs();
void slotCut();
void slotCopy();
void slotPaste();
void slotRename();
void slotChangeURL();
void slotChangeComment();
void slotChangeIcon();
void slotDelete();
void slotNewFolder();
void slotNewBookmark();
void slotInsertSeparator();
void slotSort();
void slotSetAsToolbar();
void slotOpenLink();
void slotTestSelection();
void slotTestAll();
void slotCancelAllTests();
void slotUpdateFavIcon();
void slotRecursiveSort();
void slotUpdateAllFavIcons();
void slotCancelFavIconUpdates();
void slotExpandAll();
void slotCollapseAll();
void slotImport();
void slotExportOpera();
void slotExportHTML();
void slotExportIE();
void slotExportNS();
void slotExportMoz();
private:
CommandHistory* commandHistory();
KBookmarkModel* m_model;
TestLinkItrHolder* m_testLinkHolder;
FavIconsItrHolder* m_favIconHolder;
CommandHistory *commandHistory();
KBookmarkModel *m_model;
TestLinkItrHolder *m_testLinkHolder;
FavIconsItrHolder *m_favIconHolder;
};
#endif
......@@ -18,22 +18,21 @@
#include "bookmarkinfowidget.h"
#include "bookmarklistview.h"
#include "kbookmarkmodel/commands.h"
#include "kbookmarkmodel/commandhistory.h"
#include "globalbookmarkmanager.h"
#include "kbookmarkmodel/commandhistory.h"
#include "kbookmarkmodel/commands.h"
#include "kbookmarkmodel/model.h"
#include <stdlib.h>
#include <QTimer>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QTimer>
#include <KLocalizedString>
#include <KLineEdit>
// SHUFFLE all these functions around, the order is just plain stupid
void BookmarkInfoWidget::showBookmark(const KBookmark &bk)
{
......@@ -69,15 +68,14 @@ void BookmarkInfoWidget::showBookmark(const KBookmark &bk)
}
// read/write fields
m_title_le->setReadOnly( (bk.isSeparator()|| !bk.hasParent() )? true : false);
m_title_le->setReadOnly((bk.isSeparator() || !bk.hasParent()) ? true : false);
if (bk.fullText() != m_title_le->text())
m_title_le->setText(bk.fullText());
m_url_le->setReadOnly(bk.isGroup() || bk.isSeparator());
if (bk.isGroup()) {
m_url_le->setText(QString());
}
else {
m_url_le->setText(QString());
} else {
// Update the text if and only if the text represents a different URL to that
// of the current bookmark - the old method, "m_url_le->text() != bk.url().pathOrUrl()",
// created difficulties due to the ambiguity of converting URLs to text. (#172647)
......@@ -88,7 +86,7 @@ void BookmarkInfoWidget::showBookmark(const KBookmark &bk)
}
}
m_comment_le->setReadOnly((bk.isSeparator()|| !bk.hasParent()) ? true : false );
m_comment_le->setReadOnly((bk.isSeparator() || !bk.hasParent()) ? true : false);
QString commentText = bk.description();
if (m_comment_le->text() != commentText) {
const int cursorPosition = m_comment_le->cursorPosition();
......@@ -98,19 +96,16 @@ void BookmarkInfoWidget::showBookmark(const KBookmark &bk)
// readonly fields
updateStatus();
}
void BookmarkInfoWidget::updateStatus()
{
//FIXME we don't want every metadata element, but only that with owner "https://www.kde.org"
QString visitDate =
GlobalBookmarkManager::makeTimeStr(m_bk.metaDataItem(QStringLiteral("time_visited")));
// FIXME we don't want every metadata element, but only that with owner "https://www.kde.org"
QString visitDate = GlobalBookmarkManager::makeTimeStr(m_bk.metaDataItem(QStringLiteral("time_visited")));
m_visitdate_le->setReadOnly(true);
m_visitdate_le->setText(visitDate);
QString creationDate =
GlobalBookmarkManager::makeTimeStr(m_bk.metaDataItem(QStringLiteral("time_added")));
QString creationDate = GlobalBookmarkManager::makeTimeStr(m_bk.metaDataItem(QStringLiteral("time_added")));
m_credate_le->setReadOnly(true);
m_credate_le->setText(creationDate);
......@@ -139,13 +134,10 @@ void BookmarkInfoWidget::slotTextChangedTitle(const QString &str)
timer->start(1000);
if(titlecmd)
{
if (titlecmd) {
titlecmd->modify(str);
titlecmd->redo();
}
else
{
} else {
titlecmd = new EditCommand(m_model, m_bk.address(), 0, str);
m_model->commandHistory()->addCommand(titlecmd);
}
......@@ -156,19 +148,17 @@ void BookmarkInfoWidget::commitURL()
urlcmd = nullptr;
}
void BookmarkInfoWidget::slotTextChangedURL(const QString &str) {
void BookmarkInfoWidget::slotTextChangedURL(const QString &str)
{
if (m_bk.isNull() || !m_url_le->isModified())
return;
timer->start(1000);
if(urlcmd)
{
if (urlcmd) {
urlcmd->modify(str);
urlcmd->redo();
}
else
{
} else {
urlcmd = new EditCommand(m_model, m_bk.address(), 1, str);
m_model->commandHistory()->addCommand(urlcmd);
}
......@@ -179,19 +169,17 @@ void BookmarkInfoWidget::commitComment()
commentcmd = nullptr;
}
void BookmarkInfoWidget::slotTextChangedComment(const QString &str) {
void BookmarkInfoWidget::slotTextChangedComment(const QString &str)
{
if (m_bk.isNull() || !m_comment_le->isModified())
return;
timer->start(1000);
if(commentcmd)
{
if (commentcmd) {
commentcmd->modify(str);
commentcmd->redo();
}
else
{
} else {
commentcmd = new EditCommand(m_model, m_bk.address(), 2, str);
m_model->commandHistory()->addCommand(commentcmd);
}
......@@ -199,24 +187,22 @@ void BookmarkInfoWidget::slotTextChangedComment(const QString &str) {
void BookmarkInfoWidget::slotUpdate()
{
const QModelIndexList & list = mBookmarkListView->selectionModel()->selectedRows();
if( list.count() == 1)
{
const QModelIndexList &list = mBookmarkListView->selectionModel()->selectedRows();
if (list.count() == 1) {
QModelIndex index = *list.constBegin();
showBookmark( mBookmarkListView->bookmarkModel()->bookmarkForIndex(index) );
}
else
showBookmark( KBookmark() );
showBookmark(mBookmarkListView->bookmarkModel()->bookmarkForIndex(index));
} else
showBookmark(KBookmark());
}
BookmarkInfoWidget::BookmarkInfoWidget(BookmarkListView * lv, KBookmarkModel* model, QWidget *parent)
: QWidget(parent), m_model(model), mBookmarkListView(lv) {
connect(mBookmarkListView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &BookmarkInfoWidget::slotUpdate);
BookmarkInfoWidget::BookmarkInfoWidget(BookmarkListView *lv, KBookmarkModel *model, QWidget *parent)
: QWidget(parent)
, m_model(model)
, mBookmarkListView(lv)
{
connect(mBookmarkListView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &BookmarkInfoWidget::slotUpdate);
connect(mBookmarkListView->model(), &QAbstractItemModel::dataChanged,
this, &BookmarkInfoWidget::slotUpdate);
connect(mBookmarkListView->model(), &QAbstractItemModel::dataChanged, this, &BookmarkInfoWidget::slotUpdate);
timer = new QTimer(this);
timer->setSingleShot(true);
......@@ -264,6 +250,3 @@ BookmarkInfoWidget::BookmarkInfoWidget(BookmarkListView * lv, KBookmarkModel* mo
showBookmark(KBookmark());
}
......@@ -31,12 +31,16 @@ class KLineEdit;
class QTimer;
class BookmarkInfoWidget : public QWidget {
class BookmarkInfoWidget : public QWidget
{
Q_OBJECT
public:
explicit BookmarkInfoWidget(BookmarkListView * lv, KBookmarkModel* model, QWidget * = nullptr);
explicit BookmarkInfoWidget(BookmarkListView *lv, KBookmarkModel *model, QWidget * = nullptr);
KBookmark bookmark() { return m_bk; }
KBookmark bookmark()
{
return m_bk;
}
public Q_SLOTS:
void slotTextChangedURL(const QString &);
......@@ -54,15 +58,13 @@ private:
void updateStatus();
void showBookmark(const KBookmark &bk);
EditCommand * titlecmd, * urlcmd, * commentcmd;
QTimer * timer;
KLineEdit *m_title_le, *m_url_le,
*m_comment_le;
KLineEdit *m_visitdate_le, *m_credate_le,
*m_visitcount_le;
EditCommand *titlecmd, *urlcmd, *commentcmd;
QTimer *timer;
KLineEdit *m_title_le, *m_url_le, *m_comment_le;
KLineEdit *m_visitdate_le, *m_credate_le, *m_visitcount_le;
KBookmark m_bk;
KBookmarkModel* m_model;
BookmarkListView * mBookmarkListView;
KBookmarkModel *m_model;
BookmarkListView *mBookmarkListView;
};
#endif
......@@ -25,8 +25,10 @@
#include "keditbookmarks_debug.h"
#include <QTimer>
BookmarkIterator::BookmarkIterator(BookmarkIteratorHolder* holder, const QList<KBookmark>& bks)
: QObject(holder), m_bookmarkList(bks), m_holder(holder)
BookmarkIterator::BookmarkIterator(BookmarkIteratorHolder *holder, const QList<KBookmark> &bks)
: QObject(holder)
, m_bookmarkList(bks)
, m_holder(holder)
{
delayedEmitNextOne();
}
......@@ -65,15 +67,16 @@ void BookmarkIterator::nextOne()
}
}
KBookmarkModel* BookmarkIterator::model()
KBookmarkModel *BookmarkIterator::model()
{
return m_holder->model();
}
/* --------------------------- */
BookmarkIteratorHolder::BookmarkIteratorHolder(QObject* parent, KBookmarkModel* model)
: QObject(parent), m_model(model)
BookmarkIteratorHolder::BookmarkIteratorHolder(QObject *parent, KBookmarkModel *model)
: QObject(parent)
, m_model(model)
{
Q_ASSERT(m_model);
}
......@@ -94,7 +97,7 @@ void BookmarkIteratorHolder::removeIterator(BookmarkIterator *itr)
void BookmarkIteratorHolder::cancelAllItrs()
{
const auto iterList = m_iterators;
for (BookmarkIterator* iterator : iterList) {
for (BookmarkIterator *iterator : iterList) {
iterator->cancel();
}
qDeleteAll(m_iterators);
......@@ -102,26 +105,24 @@ void BookmarkIteratorHolder::cancelAllItrs()
doIteratorListChanged();
}
void BookmarkIteratorHolder::addAffectedBookmark(const QString & address)
void BookmarkIteratorHolder::addAffectedBookmark(const QString &address)
{
//qCDebug(KEDITBOOKMARKS_LOG) << address;
if(m_affectedBookmark.isNull())
// qCDebug(KEDITBOOKMARKS_LOG) << address;
if (m_affectedBookmark.isNull())
m_affectedBookmark = address;
else
m_affectedBookmark = KBookmark::commonParent(m_affectedBookmark, address);
//qCDebug(KEDITBOOKMARKS_LOG) << "m_affectedBookmark is now" << m_affectedBookmark;
// qCDebug(KEDITBOOKMARKS_LOG) << "m_affectedBookmark is now" << m_affectedBookmark;
}
void BookmarkIteratorHolder::doIteratorListChanged()
{
//qCDebug(KEDITBOOKMARKS_LOG) << count() << "iterators";
// qCDebug(KEDITBOOKMARKS_LOG) << count() << "iterators";
Q_EMIT setCancelEnabled(count() > 0);
if(count() == 0) {
//qCDebug(KEDITBOOKMARKS_LOG) << "Notifying managers" << m_affectedBookmark;
KBookmarkManager* mgr = m_model->bookmarkManager();
if (count() == 0) {
// qCDebug(KEDITBOOKMARKS_LOG) << "Notifying managers" << m_affectedBookmark;
KBookmarkManager *mgr = m_model->bookmarkManager();
model()->notifyManagers(mgr->findByAddress(m_affectedBookmark).toGroup());
m_affectedBookmark.clear();
}
}
......@@ -19,9 +19,9 @@
#ifndef __bookmarkiterator_h
#define __bookmarkiterator_h
#include <QObject>
#include <QList>
#include <KBookmark>
#include <QList>
#include <QObject>
class KBookmarkModel;
class BookmarkIteratorHolder;
......@@ -35,10 +35,13 @@ class BookmarkIterator : public QObject
Q_OBJECT
public:
BookmarkIterator(BookmarkIteratorHolder* holder, const QList<KBookmark>& bks);
BookmarkIterator(BookmarkIteratorHolder *holder, const QList<KBookmark> &bks);
virtual ~BookmarkIterator();
BookmarkIteratorHolder* holder() const { return m_holder; }
KBookmarkModel* model();
BookmarkIteratorHolder *holder() const
{
return m_holder;
}
KBookmarkModel *model();
void delayedEmitNextOne();
virtual void cancel() = 0;
......@@ -53,7 +56,7 @@ protected:
private:
KBookmark m_bk;
QList<KBookmark> m_bookmarkList;
BookmarkIteratorHolder* m_holder;
BookmarkIteratorHolder *m_holder;
};
/**
......@@ -67,20 +70,28 @@ class BookmarkIteratorHolder : public QObject
Q_OBJECT
public:
void cancelAllItrs();
void removeIterator(BookmarkIterator*);
void insertIterator(BookmarkIterator*);
void addAffectedBookmark(const QString & address);
KBookmarkModel* model() { return m_model; }
void removeIterator(BookmarkIterator *);
void insertIterator(BookmarkIterator *);
void addAffectedBookmark(const QString &address);
KBookmarkModel *model()
{
return m_model;
}
Q_SIGNALS:
void setCancelEnabled(bool canCancel);
protected:
BookmarkIteratorHolder(QObject* parent, KBookmarkModel* model);
virtual ~BookmarkIteratorHolder() {}
BookmarkIteratorHolder(QObject *parent, KBookmarkModel *model);
virtual ~BookmarkIteratorHolder()
{
}
void doIteratorListChanged();
int count() const { return m_iterators.count(); }
KBookmarkModel* m_model;
int count() const
{
return m_iterators.count();
}
KBookmarkModel *m_model;
private:
QString m_affectedBookmark;
......
......@@ -19,21 +19,22 @@
#include "bookmarklistview.h"
#include "globalbookmarkmanager.h"
#include "kbookmarkmodel/commands.h"
#include "kbookmarkmodel/model.h"
#include "toplevel.h" // for KEBApp
#include "settings.h"
#include "kbookmarkmodel/commands.h"
#include "toplevel.h" // for KEBApp
#include <QHeaderView>
#include <QBrush>
#include <QContextMenuEvent>
#include <QHeaderView>
#include <QItemSelection>
#include <QMenu>
#include <QBrush>
#include "keditbookmarks_debug.h"
BookmarkFolderView::BookmarkFolderView( BookmarkListView * view, QWidget * parent )
: KBookmarkView(parent), mview(view)
BookmarkFolderView::BookmarkFolderView(BookmarkListView *view, QWidget *parent)
: KBookmarkView(parent)
, mview(view)
{
mmodel = new BookmarkFolderViewFilterModel(parent);
mmodel->setSourceModel(view->model());
......@@ -41,87 +42,78 @@ BookmarkFolderView::BookmarkFolderView( BookmarkListView * view, QWidget * paren
header()->setVisible(false);
setRootIsDecorated(false);
setDropIndicatorShown(true);
setCurrentIndex( mmodel->index(0,0, QModelIndex()));
setCurrentIndex(mmodel->index(0, 0, QModelIndex()));
connect(mmodel, &BookmarkFolderViewFilterModel::modelReset, this, &BookmarkFolderView::slotReset);
}
BookmarkFolderView::~BookmarkFolderView()
{
}
void BookmarkFolderView::selectionChanged ( const QItemSelection & deselected, const QItemSelection & selected)
void BookmarkFolderView::selectionChanged(const QItemSelection &deselected, const QItemSelection &selected)
{
const QModelIndexList & list = selectionModel()->selectedIndexes();
if(list.count())
mview->setRootIndex( mmodel->mapToSource(list.at(0)) );
const QModelIndexList &list = selectionModel()->selectedIndexes();
if (list.count())
mview->setRootIndex(mmodel->mapToSource(list.at(0)));
else
mview->setRootIndex( QModelIndex());
mview->setRootIndex(QModelIndex());
KBookmarkView::selectionChanged(deselected, selected);
}
void BookmarkFolderView::slotReset()
{
setCurrentIndex( mmodel->index(0,0, QModelIndex()));
setCurrentIndex(mmodel->index(0, 0, QModelIndex()));
loadFoldedState();
}
KBookmark BookmarkFolderView::bookmarkForIndex(const QModelIndex & idx) const
KBookmark BookmarkFolderView::bookmarkForIndex(const QModelIndex &idx) const
{
qCDebug(KEDITBOOKMARKS_LOG)<<"BookmarkFolderView::bookmarkForIndex"<<idx;
const QModelIndex & index = mmodel->mapToSource(idx);
qCDebug(KEDITBOOKMARKS_LOG) << "BookmarkFolderView::bookmarkForIndex" << idx;
const QModelIndex &index = mmodel->mapToSource(idx);
return static_cast<KBookmarkModel *>(mmodel->sourceModel())->bookmarkForIndex(index);
}
/********/
BookmarkListView::BookmarkListView( QWidget * parent )
BookmarkListView::BookmarkListView(QWidget *parent)
: KBookmarkView(parent)
{
setDragEnabled(true);
}
void BookmarkListView::setModel(QAbstractItemModel * model)
void BookmarkListView::setModel(QAbstractItemModel *model)
{
KBookmarkView::setModel(model);
}
KBookmarkModel* BookmarkListView::bookmarkModel() const
KBookmarkModel *BookmarkListView::bookmarkModel() const
{
return dynamic_cast<KBookmarkModel*>(QTreeView::model());
return dynamic_cast<KBookmarkModel *>(QTreeView::model());
}
KBookmark BookmarkListView::bookmarkForIndex(const QModelIndex & idx) const
KBookmark BookmarkListView::bookmarkForIndex(const QModelIndex &idx) const
{
return bookmarkModel()->bookmarkForIndex(idx);
}
BookmarkListView::~BookmarkListView()
{
saveColumnSetting();
}
void BookmarkListView::contextMenuEvent ( QContextMenuEvent * e )
void BookmarkListView::contextMenuEvent(QContextMenuEvent *e)
{
QModelIndex index = indexAt(e->pos());
KBookmark bk;
if(index.isValid())
if (index.isValid())
bk = bookmarkForIndex(index);
QMenu* popup;
if( !index.isValid()
|| (bk.address() == GlobalBookmarkManager::self()->root().address())
|| (bk.isGroup())) //FIXME add empty folder padder
QMenu *popup;
if (!index.isValid() || (bk.address() == GlobalBookmarkManager::self()->root().address()) || (bk.isGroup())) // FIXME add empty folder padder
{
popup = KEBApp::self()->popupMenuFactory("popup_folder");
}
else
{
} else {
popup = KEBApp::self()->popupMenuFactory("popup_bookmark");
}
if (popup)
......@@ -138,16 +130,16 @@ void BookmarkListView::loadColumnSetting()
void BookmarkListView::saveColumnSetting()
{
KEBSettings::setName( header()->sectionSize(