[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/konqueror/keditbookmarks
From: Daniel Teske <teske () squorn ! de>
Date: 2005-08-22 1:10:49
Message-ID: 1124673049.874466.11326.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 451867 by teske:
Push these changes into svn:
- Add a missing copyright notice to bookmarkmodel.cpp
- make F3 and F4 work (changing url/comment)
(double clicking doesn't work, still looking into that)
Next on my list is the searchline.
M +2 -0 bookmarklistview.cpp
M +21 -18 bookmarkmodel.cpp
M +3 -8 bookmarkmodel.h
M +22 -19 toplevel.cpp
M +14 -11 treeitem.cpp
M +2 -1 treeitem.h
--- trunk/KDE/kdebase/konqueror/keditbookmarks/bookmarklistview.cpp #451866:451867
@@ -1,4 +1,6 @@
/* This file is part of the KDE project
+ Copyright (C) 2000 David Faure <faure@kde.org>
+ Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
Copyright (C) 2005 Daniel Teske <teske@squorn.de>
This program is free software; you can redistribute it and/or
--- trunk/KDE/kdebase/konqueror/keditbookmarks/bookmarkmodel.cpp #451866:451867
@@ -32,9 +32,29 @@
int BookmarkModel::count = 0;
BookmarkModel* BookmarkModel::s_bookmarkModel = 0L;
+BookmarkModel* BookmarkModel::self()
+{
+ if(!s_bookmarkModel)
+ s_bookmarkModel = new BookmarkModel(CurrentMgr::self()->root());
+ return s_bookmarkModel;
+}
+
+BookmarkModel::BookmarkModel(KBookmark root)
+ :QAbstractItemModel(), mRoot(root)
+{
+ rootItem = new TreeItem(root, 0);
+}
+
+BookmarkModel::~BookmarkModel()
+{
+ delete rootItem;
+}
+
void BookmarkModel::resetModel()
{
+ delete rootItem;
reset();
+ rootItem = new TreeItem(mRoot, 0);
}
QVariant BookmarkModel::data(const QModelIndex &index, int role) const
@@ -163,10 +183,7 @@
int BookmarkModel::rowCount(const QModelIndex &parent) const
{
if(parent.isValid())
- {
- KBookmark bk = static_cast<TreeItem \
*>(parent.internalPointer())->bookmark();
- return childCount(bk);
- }
+ return static_cast<TreeItem *>(parent.internalPointer())->childCount();
else //root case
{
return 1;
@@ -183,20 +200,6 @@
return createIndex( KBookmark::positionInParent(bk.address()), 0, \
rootItem->treeItemForBookmark(bk)); }
-int BookmarkModel::childCount(KBookmark bk)
-{
- if(!bk.isGroup())
- return 0;
- KBookmark child = bk.toGroup().first();
- int i = 0;
- while(child.hasParent())
- {
- ++i;
- child = bk.toGroup().next(child);
- }
- return i;
-}
-
void BookmarkModel::emitDataChanged(KBookmark bk)
{
QModelIndex index = bookmarkToIndex(bk);
--- trunk/KDE/kdebase/konqueror/keditbookmarks/bookmarkmodel.h #451866:451867
@@ -43,9 +43,8 @@
friend class removeSentry;
friend class IKEBCommand;
-
- static BookmarkModel* self() { if(!s_bookmarkModel) s_bookmarkModel = new \
BookmarkModel(CurrentMgr::self()->root()); return s_bookmarkModel; }
- virtual ~BookmarkModel() {}
+ static BookmarkModel* self();
+ virtual ~BookmarkModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
@@ -58,20 +57,16 @@
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QModelIndex bookmarkToIndex(KBookmark bk);
- static int BookmarkModel::childCount(KBookmark bk);
void emitDataChanged(KBookmark bk);
void resetModel();
private:
TreeItem * rootItem;
- BookmarkModel(KBookmark root)
- :QAbstractItemModel(), mRoot(root)
- { rootItem = new TreeItem(root, 0); }
+ BookmarkModel(KBookmark root);
static BookmarkModel *s_bookmarkModel;
static int count;
KBookmark mRoot;
- // mutable QList<KBookmark> mapIdToAddr;
//Sentry
public:
--- trunk/KDE/kdebase/konqueror/keditbookmarks/toplevel.cpp #451866:451867
@@ -211,24 +211,24 @@
s_topLevel = this;
QSplitter *vsplitter = new QSplitter(this);
- KToolBar *quicksearch = new KToolBar(vsplitter, "search toolbar");
- KAction *resetQuickSearch = new KAction( i18n( "Reset Quick Search" ),
- QApplication::reverseLayout() ? "clear_left" : "locationbar_erase",
- 0, actionCollection(), "reset_quicksearch" );
- resetQuickSearch->setWhatsThis( i18n( "<b>Reset Quick Search</b><br>"
- "Resets the quick search so that all bookmarks are shown again." ) );
- resetQuickSearch->plug( quicksearch );
+//FIXME
+// KToolBar *quicksearch = new KToolBar(vsplitter, "search toolbar");
+//
+// KAction *resetQuickSearch = new KAction( i18n( "Reset Quick Search" ),
+// QApplication::reverseLayout() ? "clear_left" : "locationbar_erase",
+// 0, actionCollection(), "reset_quicksearch" );
+// resetQuickSearch->setWhatsThis( i18n( "<b>Reset Quick Search</b><br>"
+// "Resets the quick search so that all bookmarks are shown again." ) );
+// resetQuickSearch->plug( quicksearch );
+//
+// QLabel *lbl = new QLabel(i18n("Se&arch:"), quicksearch, "kde toolbar \
widget");
- QLabel *lbl = new QLabel(i18n("Se&arch:"), quicksearch, "kde toolbar widget");
+ //K4ListViewSearchLine *searchLineEdit = new \
K4ListViewSearchLine(/*quicksearch*/ vsplitter, 0, "KListViewSearchLine"); + \
//quicksearch->setStretchableWidget(searchLineEdit); + \
//lbl->setBuddy(searchLineEdit); + //connect(resetQuickSearch, \
SIGNAL(activated()), searchLineEdit, SLOT(clear()));
- KListViewSearchLine *searchLineEdit = new KEBSearchLine(quicksearch, 0, \
"KListViewSearchLine");
- quicksearch->setStretchableWidget(searchLineEdit);
- lbl->setBuddy(searchLineEdit);
- connect(resetQuickSearch, SIGNAL(activated()), searchLineEdit, SLOT(clear()));
-
- //FIXME searchLineEdit->setListView(static_cast<KListView*>(ListView::self()->widget()));
-
createActions();
if (m_browser)
createGUI();
@@ -249,6 +249,8 @@
//QT 4 new code
mBookmarkListView = new BookmarkListView(vsplitter);
mBookmarkListView->setModel( BookmarkModel::self() );
+
+ //searchLineEdit->setTreeView(mBookmarkListView);
mBookmarkListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
expandAll();
mBookmarkListView->loadColumnSetting();
@@ -310,10 +312,11 @@
void KEBApp::startEdit( Column c )
{
const QModelIndexList & list = \
mBookmarkListView->selectionModel()->selectedIndexes();
- QModelIndexList::const_iterator it;
- it = list.begin();
- if( (*it).column() == int(c) && (BookmarkModel::self()->flags(*it) & \
Qt::ItemIsEditable) )
- return mBookmarkListView->edit( *it );
+ QModelIndexList::const_iterator it, end;
+ end = list.constEnd();
+ for(it = list.constBegin(); it != end; ++it)
+ if( (*it).column() == int(c) && (BookmarkModel::self()->flags(*it) & \
Qt::ItemIsEditable) ) + return mBookmarkListView->edit( *it );
}
KBookmark KEBApp::firstSelected() const
--- trunk/KDE/kdebase/konqueror/keditbookmarks/treeitem.cpp #451866:451867
@@ -19,8 +19,6 @@
#include "treeitem.h"
#include <kdebug.h>
-#define DEBUG_STUPID_QT
-
TreeItem::TreeItem(KBookmark bk, TreeItem * parent)
: mparent(parent), mbk(bk)
{
@@ -32,15 +30,7 @@
TreeItem::~TreeItem()
{
-#ifndef DEBUG_STUPID_QT
qDeleteAll(children);
-#else
- QList<TreeItem *>::iterator it, end;
- for(it = children.begin(); it != end; ++it)
- {
- (*it)->markDelete();
- }
-#endif
children.clear();
}
@@ -55,11 +45,18 @@
return children[row];
}
+int TreeItem::childCount()
+{
+ if(!init)
+ initChildren();
+ return children.count();
+}
+
TreeItem * TreeItem::parent()
{
#ifdef DEBUG_STUPID_QT
if(deleted)
- kdFatal()<<"child for deleted "<<endl;
+ kdFatal()<<"parent for deleted "<<endl;
#endif
return mparent;
}
@@ -68,6 +65,12 @@
void TreeItem::markDelete()
{
deleted = true;
+ QList<TreeItem *>::iterator it, end;
+ end = children.end();
+ for(it = children.begin(); it != end; ++it)
+ {
+ (*it)->markDelete();
+ }
}
#endif
--- trunk/KDE/kdebase/konqueror/keditbookmarks/treeitem.h #451866:451867
@@ -22,7 +22,7 @@
#include <QList>
#include <kbookmark.h>
-#define DEBUG_STUPID_QT
+//#define DEBUG_STUPID_QT
class TreeItem
{
@@ -35,6 +35,7 @@
void insertChildren(int first, int last);
void deleteChildren(int first, int last);
KBookmark bookmark();
+ int childCount();
TreeItem * treeItemForBookmark(KBookmark bk);
private:
#ifdef DEBUG_STUPID_QT
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic