mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
Port keditbookmarks to Qt4's model/view framework.
Editing, creating and selecting bookmarks works. For deleting you have to run apply-patches in your qt-copy directory. All other things are broken. (E.g. drag'n'drop, the edit fields at the bottom, the searchline...) I wrote down some of my learned lessons while working with Qt4's model/view framework at http://www.squorn.de/kde/qtmodelview.html svn path=/trunk/KDE/kdebase/konqueror/keditbookmarks/; revision=448977
This commit is contained in:
parent
a24e20fbb3
commit
fddf326d4e
|
@ -12,7 +12,9 @@ kbookmarkmerger_LDADD = $(LIB_KIO)
|
|||
|
||||
dcop_DCOPIDLNG = true
|
||||
keditbookmarks_la_SOURCES = main.cpp listview.cpp toplevel.cpp actionsimpl.cpp commands.cpp importers.cpp dcop.skel dcop.cpp bookmarkiterator.cpp \
|
||||
testlink.cpp favicons.cpp updater.cpp exporters.cpp kbookmarknotifier.stub bookmarkinfo.cpp kebsearchline.cpp settings.kcfgc
|
||||
testlink.cpp favicons.cpp updater.cpp exporters.cpp kbookmarknotifier.stub bookmarkinfo.cpp kebsearchline.cpp settings.kcfgc \
|
||||
bookmarkmodel.cpp bookmarklistview.cpp treeitem.cpp
|
||||
|
||||
kbookmarknotifier_DIR = $(includedir)
|
||||
keditbookmarks_la_LIBADD = $(top_builddir)/libkonq/libkonq.la
|
||||
keditbookmarks_la_LDFLAGS = $(all_libraries) -module -avoid-version
|
||||
|
|
|
@ -141,9 +141,6 @@ void KEBApp::createActions() {
|
|||
(void) new KAction(
|
||||
i18n("Set as T&oolbar Folder"), "bookmark_toolbar", 0,
|
||||
actn, SLOT( slotSetAsToolbar() ), actionCollection(), "setastoolbar");
|
||||
(void) new KAction(
|
||||
i18n("Show in T&oolbar"), "bookmark_toolbar", 0,
|
||||
actn, SLOT( slotShowInToolbar() ), actionCollection(), "showintoolbar");
|
||||
(void) new KAction(
|
||||
i18n("&Expand All Folders"), 0,
|
||||
actn, SLOT( slotExpandAll() ), actionCollection(), "expandall");
|
||||
|
@ -209,14 +206,13 @@ void KEBApp::createActions() {
|
|||
actn, SLOT( slotExportMoz() ), actionCollection(), "exportMoz");
|
||||
}
|
||||
|
||||
void ActionsImpl::slotLoad() {
|
||||
void ActionsImpl::slotLoad()
|
||||
{
|
||||
QString bookmarksFile
|
||||
= KFileDialog::getOpenFileName(QString::null, "*.xml", KEBApp::self());
|
||||
if (bookmarksFile.isNull())
|
||||
return;
|
||||
KEBApp::self()->m_caption = QString::null;
|
||||
KEBApp::self()->m_bookmarksFilename = bookmarksFile;
|
||||
KEBApp::self()->construct();
|
||||
KEBApp::self()->reset(QString::null, bookmarksFile);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotSaveAs() {
|
||||
|
@ -292,9 +288,6 @@ void KEBApp::setActionsEnabled(SelcAbilities sa) {
|
|||
if( sa.multiSelect || (sa.singleSelect && !sa.root && !sa.urlIsEmpty && !sa.group && !sa.separator))
|
||||
toEnable << "testlink" << "updatefavicon";
|
||||
|
||||
if( sa.itemSelected)
|
||||
toEnable << "showintoolbar";
|
||||
|
||||
if (sa.singleSelect && !sa.root && !sa.separator) {
|
||||
toEnable << "rename" << "changeicon" << "changecomment";
|
||||
if (!sa.group)
|
||||
|
@ -308,14 +301,11 @@ void KEBApp::setActionsEnabled(SelcAbilities sa) {
|
|||
}
|
||||
}
|
||||
|
||||
QString stbString = sa.tbShowState ? i18n("Hide in T&oolbar") : i18n("Show in T&oolbar");
|
||||
coll->action("showintoolbar")->setText(stbString);
|
||||
|
||||
for ( QStringList::Iterator it = toEnable.begin();
|
||||
it != toEnable.end(); ++it )
|
||||
{
|
||||
//kdDebug() <<" enabling action "<<(*it) << endl;
|
||||
coll->action((*it).ascii())->setEnabled(true);
|
||||
// kdDebug() << (*it) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,18 +320,29 @@ void KEBApp::setCancelTestsEnabled(bool enabled) {
|
|||
void ActionsImpl::slotCut() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
slotCopy();
|
||||
DeleteManyCommand *mcmd = new DeleteManyCommand( i18n("Cut Items"), ListView::self()->selectedAddresses() );
|
||||
DeleteManyCommand *mcmd = new DeleteManyCommand( i18n("Cut Items"), KEBApp::self()->selectedBookmarks() );
|
||||
CmdHistory::self()->addCommand(mcmd);
|
||||
|
||||
}
|
||||
|
||||
void ActionsImpl::slotCopy() {
|
||||
//FIXME remove after kdelibs gets a suitable constructor
|
||||
Q3ValueList<KBookmark> convert(QVector<KBookmark> vec)
|
||||
{
|
||||
Q3ValueList<KBookmark> list;
|
||||
QVector<KBookmark>::const_iterator it, end;
|
||||
end = vec.constEnd();
|
||||
for(it = vec.constBegin(); it != end; ++it)
|
||||
list.append( *it );
|
||||
return list;
|
||||
}
|
||||
//FIXME end remove
|
||||
|
||||
void ActionsImpl::slotCopy()
|
||||
{
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
// this is not a command, because it can't be undone
|
||||
Q_ASSERT(ListView::self()->selectedItemsMap().count() != 0);
|
||||
Q3ValueList<KBookmark> bookmarks
|
||||
= ListView::self()->itemsToBookmarks(ListView::self()->selectedItemsMap());
|
||||
KBookmarkDrag* data = KBookmarkDrag::newDrag(bookmarks, 0 /* not this ! */);
|
||||
QVector<KBookmark> bookmarks = KEBApp::self()->selectedBookmarksExpanded();
|
||||
KBookmarkDrag* data = KBookmarkDrag::newDrag(convert(bookmarks), 0 /* not this ! */);
|
||||
kapp->clipboard()->setData(data, QClipboard::Selection);
|
||||
kapp->clipboard()->setData(data, QClipboard::Clipboard);
|
||||
}
|
||||
|
@ -352,13 +353,14 @@ void ActionsImpl::slotPaste() {
|
|||
CmdGen::insertMimeSource(
|
||||
i18n("Paste"),
|
||||
kapp->clipboard()->data(QClipboard::Clipboard),
|
||||
ListView::self()->userAddress());
|
||||
KEBApp::self()->firstSelected().address());
|
||||
CmdHistory::self()->didCommand(mcmd);
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
void ActionsImpl::slotNewFolder() {
|
||||
void ActionsImpl::slotNewFolder()
|
||||
{
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
bool ok;
|
||||
QString str = KInputDialog::getText( i18n( "Create New Bookmark Folder" ),
|
||||
|
@ -367,23 +369,25 @@ void ActionsImpl::slotNewFolder() {
|
|||
return;
|
||||
|
||||
CreateCommand *cmd = new CreateCommand(
|
||||
ListView::self()->userAddress(),
|
||||
KEBApp::self()->insertAddress(),
|
||||
str, "bookmark_folder", /*open*/ true);
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotNewBookmark() {
|
||||
void ActionsImpl::slotNewBookmark()
|
||||
{
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
// TODO - make a setCurrentItem(Command *) which uses finaladdress interface
|
||||
CreateCommand * cmd = new CreateCommand(
|
||||
ListView::self()->userAddress(),
|
||||
KEBApp::self()->insertAddress(),
|
||||
QString::null, "www", KURL("http://"));
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotInsertSeparator() {
|
||||
void ActionsImpl::slotInsertSeparator()
|
||||
{
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
CreateCommand * cmd = new CreateCommand(ListView::self()->userAddress());
|
||||
CreateCommand * cmd = new CreateCommand(KEBApp::self()->insertAddress());
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
}
|
||||
|
||||
|
@ -396,7 +400,7 @@ void ActionsImpl::slotImport() {
|
|||
if (!import)
|
||||
return;
|
||||
CmdHistory::self()->addCommand(import);
|
||||
ListView::self()->setCurrent( ListView::self()->getItemAtAddress(import->groupAddress()), true);
|
||||
//FIXME select import->groupAddress
|
||||
}
|
||||
|
||||
// TODO - this is getting ugly and repetitive. cleanup!
|
||||
|
@ -439,7 +443,7 @@ void ActionsImpl::slotPrint() {
|
|||
KTempFile tmpf(locateLocal("tmp", "print_bookmarks"), ".html");
|
||||
QTextStream *tstream = tmpf.textStream();
|
||||
tstream->setEncoding(QTextStream::Unicode);
|
||||
(*tstream) << exporter.toString(CurrentMgr::self()->mgr()->root(), true);
|
||||
(*tstream) << exporter.toString(CurrentMgr::self()->root(), true);
|
||||
tmpf.close();
|
||||
|
||||
s_appId = kapp->dcopClient()->appId();
|
||||
|
@ -476,12 +480,12 @@ void ActionsImpl::slotCancelAllTests() {
|
|||
|
||||
void ActionsImpl::slotTestAll() {
|
||||
TestLinkItrHolder::self()->insertItr(
|
||||
new TestLinkItr(ListView::self()->allBookmarks()));
|
||||
new TestLinkItr(KEBApp::self()->allBookmarks()));
|
||||
}
|
||||
|
||||
void ActionsImpl::slotUpdateAllFavIcons() {
|
||||
FavIconsItrHolder::self()->insertItr(
|
||||
new FavIconsItr(ListView::self()->allBookmarks()));
|
||||
new FavIconsItr(KEBApp::self()->allBookmarks()));
|
||||
}
|
||||
|
||||
ActionsImpl::~ActionsImpl() {
|
||||
|
@ -493,12 +497,12 @@ ActionsImpl::~ActionsImpl() {
|
|||
|
||||
void ActionsImpl::slotTestSelection() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
TestLinkItrHolder::self()->insertItr(new TestLinkItr(ListView::self()->selectedBookmarksExpanded()));
|
||||
TestLinkItrHolder::self()->insertItr(new TestLinkItr(KEBApp::self()->selectedBookmarksExpanded()));
|
||||
}
|
||||
|
||||
void ActionsImpl::slotUpdateFavIcon() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
FavIconsItrHolder::self()->insertItr(new FavIconsItr(ListView::self()->selectedBookmarksExpanded()));
|
||||
FavIconsItrHolder::self()->insertItr(new FavIconsItr(KEBApp::self()->selectedBookmarksExpanded()));
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
@ -531,7 +535,7 @@ void KBookmarkGroupList::visitEnter(const KBookmarkGroup &grp) {
|
|||
|
||||
void ActionsImpl::slotRecursiveSort() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
KBookmark bk = ListView::self()->firstSelected()->bookmark();
|
||||
KBookmark bk = KEBApp::self()->firstSelected();
|
||||
Q_ASSERT(bk.isGroup());
|
||||
KEBMacroCommand *mcmd = new KEBMacroCommand(i18n("Recursive Sort"));
|
||||
KBookmarkGroupList lister(CurrentMgr::self()->mgr());
|
||||
|
@ -547,7 +551,7 @@ void ActionsImpl::slotRecursiveSort() {
|
|||
|
||||
void ActionsImpl::slotSort() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
KBookmark bk = ListView::self()->firstSelected()->bookmark();
|
||||
KBookmark bk = KEBApp::self()->firstSelected();
|
||||
Q_ASSERT(bk.isGroup());
|
||||
SortCommand *cmd = new SortCommand(i18n("Sort Alphabetically"), bk.address());
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
|
@ -557,16 +561,17 @@ void ActionsImpl::slotSort() {
|
|||
|
||||
void ActionsImpl::slotDelete() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
DeleteManyCommand *mcmd = new DeleteManyCommand(i18n("Delete Items"), ListView::self()->selectedAddresses());
|
||||
DeleteManyCommand *mcmd = new DeleteManyCommand(i18n("Delete Items"), KEBApp::self()->selectedBookmarks());
|
||||
CmdHistory::self()->addCommand(mcmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotOpenLink() {
|
||||
void ActionsImpl::slotOpenLink()
|
||||
{
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
//Q3ValueList<KBookmark> bks = ListView::self()->itemsToBookmarks(ListView::self()->selectedItemsMap());
|
||||
Q3ValueList<KBookmark> bks = ListView::self()->itemsToBookmarks(ListView::self()->selectedItemsMap());
|
||||
Q3ValueListIterator<KBookmark> it;
|
||||
for (it = bks.begin(); it != bks.end(); ++it) {
|
||||
QVector<KBookmark> bookmarks = KEBApp::self()->selectedBookmarksExpanded();
|
||||
QVector<KBookmark>::const_iterator it, end;
|
||||
end = bookmarks.constEnd();
|
||||
for (it = bookmarks.constBegin(); it != end; ++it) {
|
||||
if ((*it).isGroup() || (*it).isSeparator())
|
||||
continue;
|
||||
(void)new KRun((*it).url());
|
||||
|
@ -577,55 +582,47 @@ void ActionsImpl::slotOpenLink() {
|
|||
|
||||
void ActionsImpl::slotRename() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
ListView::self()->rename(KEBListView::NameColumn);
|
||||
KEBApp::self()->startEdit( KEBApp::NameColumn );
|
||||
}
|
||||
|
||||
void ActionsImpl::slotChangeURL() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
ListView::self()->rename(KEBListView::UrlColumn);
|
||||
KEBApp::self()->startEdit( KEBApp::UrlColumn );
|
||||
}
|
||||
|
||||
void ActionsImpl::slotChangeComment() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
ListView::self()->rename(KEBListView::CommentColumn);
|
||||
KEBApp::self()->startEdit( KEBApp::CommentColumn );
|
||||
}
|
||||
|
||||
void ActionsImpl::slotSetAsToolbar() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
KBookmark bk = ListView::self()->firstSelected()->bookmark();
|
||||
KBookmark bk = KEBApp::self()->firstSelected();
|
||||
Q_ASSERT(bk.isGroup());
|
||||
KEBMacroCommand *mcmd = CmdGen::setAsToolbar(bk);
|
||||
CmdHistory::self()->addCommand(mcmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotShowInToolbar() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
KBookmark bk = ListView::self()->firstSelected()->bookmark();
|
||||
bool shown = CmdGen::shownInToolbar(bk);
|
||||
KEBMacroCommand *mcmd = CmdGen::setShownInToolbar(bk, !shown);
|
||||
CmdHistory::self()->addCommand(mcmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotChangeIcon() {
|
||||
KEBApp::self()->bkInfo()->commitChanges();
|
||||
KBookmark bk = ListView::self()->firstSelected()->bookmark();
|
||||
KBookmark bk = KEBApp::self()->firstSelected();
|
||||
KIconDialog dlg(KEBApp::self());
|
||||
QString newIcon = dlg.selectIcon(KIcon::Small, KIcon::FileSystem);
|
||||
if (newIcon.isEmpty())
|
||||
return;
|
||||
EditCommand *cmd = new EditCommand(
|
||||
bk.address(),
|
||||
EditCommand::Edition("icon", newIcon),
|
||||
i18n("Icon"));
|
||||
EditCommand *cmd = new EditCommand(bk.address(), -1, newIcon);
|
||||
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
}
|
||||
|
||||
void ActionsImpl::slotExpandAll() {
|
||||
ListView::self()->setOpen(true);
|
||||
void ActionsImpl::slotExpandAll()
|
||||
{
|
||||
KEBApp::self()->expandAll();
|
||||
}
|
||||
|
||||
void ActionsImpl::slotCollapseAll() {
|
||||
ListView::self()->setOpen(false);
|
||||
void ActionsImpl::slotCollapseAll()
|
||||
{
|
||||
KEBApp::self()->collapseAll();
|
||||
}
|
||||
|
||||
#include "actionsimpl.moc"
|
||||
|
|
|
@ -47,7 +47,6 @@ public slots:
|
|||
void slotInsertSeparator();
|
||||
void slotSort();
|
||||
void slotSetAsToolbar();
|
||||
void slotShowInToolbar();
|
||||
void slotOpenLink();
|
||||
void slotShowNS();
|
||||
void slotTestSelection();
|
||||
|
|
|
@ -107,7 +107,7 @@ void BookmarkInfoWidget::showBookmark(const KBookmark &bk) {
|
|||
|
||||
m_comment_le->setReadOnly((bk.isSeparator()|| !bk.hasParent()) ? true : false );
|
||||
m_comment_le->setText(
|
||||
NodeEditCommand::getNodeText(bk, QStringList() << "desc"));
|
||||
EditCommand::getNodeText(bk, QStringList() << "desc"));
|
||||
|
||||
// readonly fields
|
||||
updateStatus();
|
||||
|
@ -117,13 +117,13 @@ void BookmarkInfoWidget::showBookmark(const KBookmark &bk) {
|
|||
void BookmarkInfoWidget::updateStatus()
|
||||
{
|
||||
QString visitDate =
|
||||
CurrentMgr::makeTimeStr( NodeEditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
CurrentMgr::makeTimeStr( EditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
<< "time_visited" ));
|
||||
m_visitdate_le->setReadOnly(true);
|
||||
m_visitdate_le->setText(visitDate);
|
||||
|
||||
QString creationDate =
|
||||
CurrentMgr::makeTimeStr( NodeEditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
CurrentMgr::makeTimeStr( EditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
<< "time_added" ));
|
||||
m_credate_le->setReadOnly(true);
|
||||
m_credate_le->setText(creationDate);
|
||||
|
@ -131,7 +131,7 @@ void BookmarkInfoWidget::updateStatus()
|
|||
// TODO - get the actual field name from the spec if it exists, else copy galeon
|
||||
m_visitcount_le->setReadOnly(true);
|
||||
m_visitcount_le->setText(
|
||||
NodeEditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
EditCommand::getNodeText(m_bk, QStringList() << "info" << "metadata"
|
||||
<< "visit_count" ));
|
||||
}
|
||||
|
||||
|
@ -144,12 +144,12 @@ void BookmarkInfoWidget::commitChanges()
|
|||
|
||||
void BookmarkInfoWidget::commitTitle()
|
||||
{
|
||||
if(titlecmd)
|
||||
{
|
||||
emit updateListViewItem();
|
||||
CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(titlecmd->affectedBookmarks()).toGroup());
|
||||
titlecmd = 0;
|
||||
}
|
||||
// if(titlecmd)
|
||||
// {
|
||||
// emit updateListViewItem();
|
||||
// CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(titlecmd->affectedBookmarks()).toGroup());
|
||||
// titlecmd = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
void BookmarkInfoWidget::slotTextChangedTitle(const QString &str)
|
||||
|
@ -157,79 +157,79 @@ void BookmarkInfoWidget::slotTextChangedTitle(const QString &str)
|
|||
if (m_bk.isNull() || !m_title_le->isModified())
|
||||
return;
|
||||
|
||||
timer->start(1000, true);
|
||||
// timer->start(1000, true);
|
||||
|
||||
if(titlecmd)
|
||||
{
|
||||
NodeEditCommand::setNodeText(m_bk, QStringList() << "title", str);
|
||||
titlecmd->modify(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
titlecmd = new NodeEditCommand(m_bk.address(), str, "title");
|
||||
titlecmd->execute();
|
||||
CmdHistory::self()->addInFlightCommand(titlecmd);
|
||||
}
|
||||
// if(titlecmd)
|
||||
// {
|
||||
// EditCommand::setNodeText(m_bk, QStringList() << "title", str);
|
||||
// //titlecmd->modify(str);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //titlecmd = new NodeEditCommand(m_bk.address(), str, "title");
|
||||
// //titlecmd->execute();
|
||||
// //CmdHistory::self()->addInFlightCommand(titlecmd);
|
||||
// }
|
||||
}
|
||||
|
||||
void BookmarkInfoWidget::commitURL()
|
||||
{
|
||||
if(urlcmd)
|
||||
{
|
||||
emit updateListViewItem();
|
||||
CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(urlcmd->affectedBookmarks()).toGroup());
|
||||
urlcmd = 0;
|
||||
}
|
||||
// if(urlcmd)
|
||||
// {
|
||||
// emit updateListViewItem();
|
||||
// CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(urlcmd->affectedBookmarks()).toGroup());
|
||||
// urlcmd = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
void BookmarkInfoWidget::slotTextChangedURL(const QString &str) {
|
||||
if (m_bk.isNull() || !m_url_le->isModified())
|
||||
return;
|
||||
|
||||
timer->start(1000, true);
|
||||
// timer->start(1000, true);
|
||||
|
||||
if(urlcmd)
|
||||
{
|
||||
KURL u = KURL::fromPathOrURL(str);
|
||||
m_bk.internalElement().setAttribute("href", u.url(0, 106));
|
||||
urlcmd->modify("href", u.url(0, 106));
|
||||
}
|
||||
else
|
||||
{
|
||||
KURL u = KURL::fromPathOrURL(str);
|
||||
urlcmd = new EditCommand(m_bk.address(), EditCommand::Edition("href", u.url(0, 106)), i18n("URL"));
|
||||
urlcmd->execute();
|
||||
CmdHistory::self()->addInFlightCommand(urlcmd);
|
||||
}
|
||||
// if(urlcmd)
|
||||
// {
|
||||
// KURL u = KURL::fromPathOrURL(str);
|
||||
// m_bk.internalElement().setAttribute("href", u.url(0, 106));
|
||||
// //urlcmd->modify("href", u.url(0, 106));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// KURL u = KURL::fromPathOrURL(str);
|
||||
// //urlcmd = new EditCommand(m_bk.address(), EditCommand::Edition("href", u.url(0, 106)), i18n("URL"));
|
||||
// //urlcmd->execute();
|
||||
// //CmdHistory::self()->addInFlightCommand(urlcmd);
|
||||
// }
|
||||
}
|
||||
|
||||
void BookmarkInfoWidget::commitComment()
|
||||
{
|
||||
if(commentcmd)
|
||||
{
|
||||
emit updateListViewItem();
|
||||
CurrentMgr::self()->notifyManagers( CurrentMgr::bookmarkAt( commentcmd->affectedBookmarks() ).toGroup());
|
||||
commentcmd = 0;
|
||||
}
|
||||
// if(commentcmd)
|
||||
// {
|
||||
// emit updateListViewItem();
|
||||
// CurrentMgr::self()->notifyManagers( CurrentMgr::bookmarkAt( commentcmd->affectedBookmarks() ).toGroup());
|
||||
// commentcmd = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
void BookmarkInfoWidget::slotTextChangedComment(const QString &str) {
|
||||
if (m_bk.isNull() || !m_comment_le->isModified())
|
||||
return;
|
||||
|
||||
timer->start(1000, true);
|
||||
// timer->start(1000, true);
|
||||
|
||||
if(commentcmd)
|
||||
{
|
||||
NodeEditCommand::setNodeText(m_bk, QStringList() << "desc", str);
|
||||
commentcmd->modify(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
commentcmd = new NodeEditCommand(m_bk.address(), str, "desc");
|
||||
commentcmd->execute();
|
||||
CmdHistory::self()->addInFlightCommand(commentcmd);
|
||||
}
|
||||
// if(commentcmd)
|
||||
// {
|
||||
// EditCommand::setNodeText(m_bk, QStringList() << "desc", str);
|
||||
// //commentcmd->modify(str);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //commentcmd = new NodeEditCommand(m_bk.address(), str, "desc");
|
||||
// //commentcmd->execute();
|
||||
// //CmdHistory::self()->addInFlightCommand(commentcmd);
|
||||
// }
|
||||
}
|
||||
|
||||
BookmarkInfoWidget::BookmarkInfoWidget(QWidget *parent, const char *name)
|
||||
|
@ -238,9 +238,9 @@ BookmarkInfoWidget::BookmarkInfoWidget(QWidget *parent, const char *name)
|
|||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL( timeout() ), SLOT( commitChanges()));
|
||||
|
||||
titlecmd = 0;
|
||||
urlcmd = 0;
|
||||
commentcmd = 0;
|
||||
// titlecmd = 0;
|
||||
// urlcmd = 0;
|
||||
// commentcmd = 0;
|
||||
|
||||
QBoxLayout *vbox = new QVBoxLayout(this);
|
||||
QGridLayout *grid = new QGridLayout(vbox, 3, 4, 4);
|
||||
|
|
|
@ -54,40 +54,6 @@ public slots:
|
|||
void slotTextChangedTitle(const QString &);
|
||||
void slotTextChangedComment(const QString &);
|
||||
|
||||
// _The deal with all those commitChanges() calls_
|
||||
// First a short example how all the components
|
||||
// normally fit together:
|
||||
// Note: not all details are included
|
||||
// For example: The user clicks on "New Bookmark"
|
||||
// This constructs a cmd = new CreateCommand( .. )
|
||||
// CmdHistory::self()->addCommand( cmd ) is called
|
||||
// CmdHistory executes the command
|
||||
// and enables the undo button
|
||||
// and emits slotCommandExecuted
|
||||
// We catch the signal and call
|
||||
// CurrentMgr::self()->notifyManagers( .. );
|
||||
|
||||
// The bookmarkinfo widget is special, because
|
||||
// we don't want to send a notification
|
||||
// for every change, but want to enable the undo
|
||||
// button and need to send the notification
|
||||
// if the user has stopped typing
|
||||
|
||||
// So as soon as the user starts typing
|
||||
// we create a command
|
||||
// and call CmdHistory::self()->addInFlightCommand( cmd );
|
||||
// addInFlightCommand() doesn't execute the command, it just
|
||||
// adds it to the command history (To enable the undo button)
|
||||
// For every keystroke after that the command is modified
|
||||
// and we change our internal state to reflect the change
|
||||
// (Basically changing it in the same way, executing would have.)
|
||||
|
||||
// At this point we have a modified state, but haven't send it
|
||||
// to the other bookmarkmanagers
|
||||
// That is done in commitChanges()
|
||||
// commitChanges() should be called everywhere, where we are
|
||||
// sure that the user has stopped typing.
|
||||
// And a few other cleanups are done in commitChanges()
|
||||
void commitChanges();
|
||||
void commitTitle();
|
||||
void commitURL();
|
||||
|
@ -96,9 +62,10 @@ public slots:
|
|||
signals:
|
||||
void updateListViewItem();
|
||||
private:
|
||||
NodeEditCommand *titlecmd;
|
||||
EditCommand *urlcmd;
|
||||
NodeEditCommand *commentcmd;
|
||||
//FIXME bookmarkinfowidget and commands
|
||||
//NodeEditCommand *titlecmd;
|
||||
//EditCommand *urlcmd;
|
||||
//NodeEditCommand *commentcmd;
|
||||
QTimer * timer;
|
||||
BookmarkLineEdit *m_title_le, *m_url_le,
|
||||
*m_comment_le;
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include "listview.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <qtimer.h>
|
||||
#include <assert.h>
|
||||
|
||||
BookmarkIterator::BookmarkIterator(Q3ValueList<KBookmark> bks) : m_bklist(bks) {
|
||||
BookmarkIterator::BookmarkIterator(QVector<KBookmark> bks) : m_bklist(bks) {
|
||||
connect(this, SIGNAL( deleteSelf(BookmarkIterator *) ),
|
||||
SLOT( slotCancelTest(BookmarkIterator *) ));
|
||||
delayedEmitNextOne();
|
||||
|
@ -46,12 +46,6 @@ void BookmarkIterator::slotCancelTest(BookmarkIterator *test) {
|
|||
holder()->removeItr(test);
|
||||
}
|
||||
|
||||
KEBListViewItem* BookmarkIterator::curItem() const {
|
||||
if (!m_bk.hasParent())
|
||||
return 0;
|
||||
return ListView::self()->getItemAtAddress(m_bk.address());
|
||||
}
|
||||
|
||||
const KBookmark BookmarkIterator::curBk() const {
|
||||
assert(m_bk.hasParent());
|
||||
return m_bk;
|
||||
|
@ -65,7 +59,7 @@ void BookmarkIterator::nextOne() {
|
|||
return;
|
||||
}
|
||||
|
||||
Q3ValueListIterator<KBookmark> head = m_bklist.begin();
|
||||
QVector<KBookmark>::iterator head = m_bklist.begin(); //FIXME using vector is bad here
|
||||
KBookmark bk = (*head);
|
||||
|
||||
bool viable = bk.hasParent() && isApplicable(bk);
|
||||
|
@ -75,7 +69,7 @@ void BookmarkIterator::nextOne() {
|
|||
doAction();
|
||||
}
|
||||
|
||||
m_bklist.remove(head);
|
||||
m_bklist.erase(head);
|
||||
|
||||
if (!viable)
|
||||
delayedEmitNextOne();
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
#include <qobject.h>
|
||||
#include <q3ptrlist.h>
|
||||
//Added by qt3to4:
|
||||
#include <Q3ValueList>
|
||||
#include <QVector>
|
||||
#include <kbookmark.h>
|
||||
|
||||
class KEBListViewItem;
|
||||
|
@ -35,7 +34,7 @@ class BookmarkIterator : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BookmarkIterator(Q3ValueList<KBookmark> bks);
|
||||
BookmarkIterator(QVector<KBookmark> bks);
|
||||
virtual ~BookmarkIterator();
|
||||
virtual BookmarkIteratorHolder* holder() const = 0;
|
||||
|
||||
|
@ -50,12 +49,11 @@ signals:
|
|||
protected:
|
||||
virtual void doAction() = 0;
|
||||
virtual bool isApplicable(const KBookmark &bk) const = 0;
|
||||
KEBListViewItem* curItem() const;
|
||||
const KBookmark curBk() const;
|
||||
|
||||
private:
|
||||
KBookmark m_bk;
|
||||
Q3ValueList<KBookmark> m_bklist;
|
||||
QVector<KBookmark> m_bklist;
|
||||
};
|
||||
|
||||
class BookmarkIteratorHolder
|
||||
|
|
279
keditbookmarks/bookmarklistview.cpp
Normal file
279
keditbookmarks/bookmarklistview.cpp
Normal file
|
@ -0,0 +1,279 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2005 Daniel Teske <teske@squorn.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "bookmarklistview.h"
|
||||
#include "bookmarkmodel.h"
|
||||
#include "toplevel.h"
|
||||
#include "settings.h"
|
||||
#include <QHeaderView>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QBrush>
|
||||
#include <QPalette>
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
BookmarkListView::BookmarkListView( QWidget * parent )
|
||||
:QTreeView( parent )
|
||||
{
|
||||
dirtyGetSelectionAbilies = true;
|
||||
}
|
||||
|
||||
BookmarkListView::~BookmarkListView()
|
||||
{
|
||||
saveColumnSetting();
|
||||
}
|
||||
|
||||
int BookmarkListView::min(int a, int b)
|
||||
{
|
||||
return a < b? a : b;
|
||||
}
|
||||
|
||||
int BookmarkListView::max(int a, int b)
|
||||
{
|
||||
return a > b? a : b;
|
||||
}
|
||||
|
||||
QRect BookmarkListView::merge(QRect a, QRect b)
|
||||
{
|
||||
if(a.isNull())
|
||||
return b;
|
||||
if(b.isNull())
|
||||
return a;
|
||||
a.normalized();
|
||||
b.normalized();
|
||||
int left = min(a.left(), b.left());
|
||||
int top = min(a.top(), b.top());
|
||||
int width = max(a.right(), b.right()) - left + 1;
|
||||
int height = max(a.bottom(), b.bottom()) - top + 1;
|
||||
return QRect(left, top, width, height);
|
||||
}
|
||||
|
||||
QRect BookmarkListView::rectForRow(QModelIndex index)
|
||||
{
|
||||
QModelIndex parent = index.parent();
|
||||
int row = index.row();
|
||||
int columnCount = model()->columnCount(parent);
|
||||
|
||||
QRect result;
|
||||
for(int i = 0; i<columnCount; ++i)
|
||||
result = merge( visualRect( parent.child(row, i) ), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QRect BookmarkListView::rectForRowWithChildren(QModelIndex index)
|
||||
{
|
||||
QRect rect = rectForRow(index);
|
||||
int rowCount = model()->rowCount(index);
|
||||
for(int i=0; i<rowCount; ++i)
|
||||
rect = merge(rect, rectForRowWithChildren( index.child(i, 0) ));
|
||||
return rect;
|
||||
}
|
||||
|
||||
void BookmarkListView::deselectChildren( const QModelIndex & parent)
|
||||
{
|
||||
int rowCount = model()->rowCount(parent);
|
||||
if(rowCount)
|
||||
{
|
||||
QItemSelection deselect;
|
||||
deselect.select( parent.child(0,0), parent.child(rowCount-1, model()->columnCount(parent)-1));
|
||||
selectionModel()->select(deselect, QItemSelectionModel::Deselect);
|
||||
|
||||
for(int i=0; i<rowCount; ++i)
|
||||
deselectChildren(parent.child(i, 0));
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME check scalability of this code
|
||||
void BookmarkListView::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )
|
||||
{
|
||||
kdDebug()<<"Selection changed "<<endl;
|
||||
dirtyGetSelectionAbilies = true;
|
||||
QTreeView::selectionChanged( selected, deselected );
|
||||
|
||||
// deselect indexes which shouldn't have been selected
|
||||
QItemSelection deselectAgain; // selections which need to be undone
|
||||
const QModelIndexList & list = selected.indexes();
|
||||
QModelIndexList::const_iterator it, end;
|
||||
end = list.constEnd();
|
||||
for(it = list.constBegin(); it != end; ++it)
|
||||
{
|
||||
if( (*it).column() != 0)
|
||||
continue;
|
||||
if(parentSelected( *it ))
|
||||
deselectAgain.select( (*it), (*it).parent().child( (*it).row(), model()->columnCount() -1) );
|
||||
}
|
||||
selectionModel()->select( deselectAgain, QItemSelectionModel::Deselect);
|
||||
|
||||
//deselect children of selected items
|
||||
for(it = list.constBegin(); it != end; ++it)
|
||||
{
|
||||
if( (*it).column() !=0)
|
||||
continue;
|
||||
deselectChildren(*it);
|
||||
}
|
||||
|
||||
// ensure that drawRow is called for all children
|
||||
const QModelIndexList & sellist = selected.indexes();
|
||||
end = sellist.constEnd();
|
||||
QRect rect;
|
||||
for(it = sellist.constBegin(); it != end; ++it)
|
||||
{
|
||||
if((*it).column() != 0)
|
||||
continue;
|
||||
if( static_cast<TreeItem *>((*it).internalPointer())->bookmark().address() == "") //FIXME
|
||||
continue;
|
||||
rect = merge(rect, rectForRowWithChildren(*it));
|
||||
}
|
||||
const QModelIndexList & desellist = deselected.indexes();
|
||||
end = desellist.constEnd();
|
||||
for(it = desellist.constBegin(); it != end; ++it)
|
||||
{
|
||||
if((*it).column() != 0)
|
||||
continue;
|
||||
if( static_cast<TreeItem *>((*it).internalPointer())->bookmark().address() == "") //FIXME
|
||||
continue;
|
||||
rect = merge(rect, rectForRowWithChildren(*it));
|
||||
}
|
||||
rect.setLeft(0);
|
||||
viewport()->update(rect);
|
||||
}
|
||||
|
||||
QItemSelectionModel::SelectionFlags BookmarkListView::selectionCommand ( const QModelIndex & index, const QEvent * event ) const
|
||||
{
|
||||
const QMouseEvent * qme = dynamic_cast<const QMouseEvent *>(event);
|
||||
if(qme && (qme->button() == Qt::RightButton ) && parentSelected(index)) //right click on a parentSelected index
|
||||
return QItemSelectionModel::NoUpdate; // don't modify selection, only show a context menu
|
||||
else
|
||||
return QTreeView::selectionCommand( index, event );
|
||||
}
|
||||
|
||||
void BookmarkListView::contextMenuEvent ( QContextMenuEvent * e )
|
||||
{
|
||||
QModelIndex index = indexAt(e->pos());
|
||||
KBookmark bk;
|
||||
if(index.isValid())
|
||||
bk = static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
|
||||
QMenu* popup;
|
||||
if( !index.isValid()
|
||||
|| (bk.address() == CurrentMgr::self()->root().address())
|
||||
|| (bk.isGroup())) //FIXME add empty folder padder
|
||||
{
|
||||
popup = KEBApp::self()->popupMenuFactory("popup_folder");
|
||||
}
|
||||
else
|
||||
{
|
||||
popup = KEBApp::self()->popupMenuFactory("popup_bookmark");
|
||||
}
|
||||
if (popup)
|
||||
popup->popup(e->globalPos());
|
||||
}
|
||||
|
||||
void BookmarkListView::drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
||||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
if(parentSelected(index))
|
||||
{
|
||||
|
||||
int base_h, base_s, base_v;
|
||||
opt.palette.base().color().getHsv(&base_h, &base_s, &base_v);
|
||||
|
||||
int hilite_h, hilite_s, hilite_v;
|
||||
opt.palette.highlight().color().getHsv(&hilite_h, &hilite_s, &hilite_v);
|
||||
|
||||
QColor col;
|
||||
col.setHsv(hilite_h,
|
||||
(hilite_s + base_s + base_s ) / 3,
|
||||
(hilite_v + base_v + base_v ) / 3);
|
||||
opt.palette.setBrush(QPalette::Base, QBrush( col ) );
|
||||
}
|
||||
QTreeView::drawRow( painter, opt, index );
|
||||
}
|
||||
|
||||
bool BookmarkListView::parentSelected(const QModelIndex & idx ) const
|
||||
{
|
||||
QModelIndex index = idx.parent();
|
||||
while(index.isValid())
|
||||
{
|
||||
QModelIndex parent = index.parent();
|
||||
if(selectionModel()->isRowSelected(index.row(), parent) && parent.isValid() )
|
||||
return true;
|
||||
else
|
||||
index = index.parent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//FIXME clean up and remove unneeded things
|
||||
SelcAbilities BookmarkListView::getSelectionAbilities() const
|
||||
{
|
||||
if(dirtyGetSelectionAbilies)
|
||||
{
|
||||
const QModelIndexList & sel = selectionModel()->selectedIndexes();
|
||||
selctionAbilities.itemSelected = false;
|
||||
selctionAbilities.group = false;
|
||||
selctionAbilities.separator = false;
|
||||
selctionAbilities.urlIsEmpty = false;
|
||||
selctionAbilities.root = false;
|
||||
selctionAbilities.multiSelect = false;
|
||||
selctionAbilities.singleSelect = false;
|
||||
selctionAbilities.notEmpty = false;
|
||||
|
||||
if ( sel .count() > 0)
|
||||
{
|
||||
KBookmark nbk = static_cast<TreeItem *>((*sel.constBegin()).internalPointer())->bookmark();
|
||||
selctionAbilities.itemSelected = true;
|
||||
selctionAbilities.group = nbk.isGroup();
|
||||
selctionAbilities.separator = nbk.isSeparator();
|
||||
selctionAbilities.urlIsEmpty = nbk.url().isEmpty();
|
||||
selctionAbilities.root = nbk.address() == CurrentMgr::self()->root().address();
|
||||
selctionAbilities.multiSelect = (sel.count() > BookmarkModel::self()->columnCount());
|
||||
selctionAbilities.singleSelect = (!selctionAbilities.multiSelect && selctionAbilities.itemSelected);
|
||||
}
|
||||
//FIXME check next line, if it actually works
|
||||
selctionAbilities.notEmpty = CurrentMgr::self()->root().first().hasParent(); //FIXME that's insane, checks wheter there exists at least one bookmark
|
||||
|
||||
// kdDebug()<<"sa.itemSelected "<<selctionAbilities.itemSelected<<"\nsa.group "<<selctionAbilities.group<<
|
||||
// "\nsa.separator "<<selctionAbilities.separator<<"\nsa.urlIsEmpty "<<selctionAbilities.urlIsEmpty<<
|
||||
// "\nsa.root "<<selctionAbilities.root<<"\nsa.multiSelect "<<selctionAbilities.multiSelect<<
|
||||
// "\nsa.singleSelect "<<selctionAbilities.singleSelect<<endl;
|
||||
dirtyGetSelectionAbilies = false;
|
||||
return selctionAbilities;
|
||||
}
|
||||
return selctionAbilities;
|
||||
}
|
||||
|
||||
void BookmarkListView::loadColumnSetting()
|
||||
{
|
||||
header()->resizeSection(KEBApp::NameColumn, KEBSettings::name());
|
||||
header()->resizeSection(KEBApp::UrlColumn, KEBSettings::uRL());
|
||||
header()->resizeSection(KEBApp::CommentColumn, KEBSettings::comment());
|
||||
header()->resizeSection(KEBApp::StatusColumn, KEBSettings::status());
|
||||
}
|
||||
|
||||
void BookmarkListView::saveColumnSetting()
|
||||
{
|
||||
KEBSettings::setName( header()->sectionSize(KEBApp::NameColumn));
|
||||
KEBSettings::setURL( header()->sectionSize(KEBApp::UrlColumn));
|
||||
KEBSettings::setComment( header()->sectionSize(KEBApp::CommentColumn));
|
||||
KEBSettings::setStatus( header()->sectionSize(KEBApp::StatusColumn));
|
||||
KEBSettings::writeConfig();
|
||||
}
|
62
keditbookmarks/bookmarklistview.h
Normal file
62
keditbookmarks/bookmarklistview.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2005 Daniel Teske <teske@squorn.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __bookmarklistview_h
|
||||
#define __bookmarklistview_h
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QVector>
|
||||
#include <kbookmark.h>
|
||||
|
||||
struct SelcAbilities {
|
||||
bool itemSelected:1;
|
||||
bool group:1;
|
||||
bool root:1;
|
||||
bool separator:1;
|
||||
bool urlIsEmpty:1;
|
||||
bool multiSelect:1;
|
||||
bool singleSelect:1;
|
||||
bool notEmpty:1;
|
||||
};
|
||||
|
||||
class BookmarkListView : public QTreeView
|
||||
{
|
||||
public:
|
||||
BookmarkListView( QWidget * parent = 0 );
|
||||
virtual ~BookmarkListView();
|
||||
virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
virtual void drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
|
||||
virtual QItemSelectionModel::SelectionFlags selectionCommand ( const QModelIndex & index, const QEvent * event = 0 ) const;
|
||||
SelcAbilities getSelectionAbilities() const;
|
||||
void loadColumnSetting();
|
||||
void saveColumnSetting ();
|
||||
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QContextMenuEvent * e );
|
||||
private:
|
||||
int min(int a, int b);
|
||||
int max(int a, int b);
|
||||
QRect merge(QRect a, QRect b);
|
||||
void deselectChildren(const QModelIndex & parent);
|
||||
QRect BookmarkListView::rectForRow(QModelIndex index);
|
||||
QRect BookmarkListView::rectForRowWithChildren(QModelIndex index);
|
||||
bool parentSelected(const QModelIndex & index ) const;
|
||||
mutable SelcAbilities selctionAbilities;
|
||||
mutable bool dirtyGetSelectionAbilies;
|
||||
};
|
||||
#endif
|
206
keditbookmarks/bookmarkmodel.cpp
Normal file
206
keditbookmarks/bookmarkmodel.cpp
Normal file
|
@ -0,0 +1,206 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2005 Daniel Teske <teske@squorn.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "bookmarkmodel.h"
|
||||
#include "toplevel.h"
|
||||
#include "commands.h"
|
||||
|
||||
#include <kcommand.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QStringList>
|
||||
#include <kdebug.h>
|
||||
|
||||
int BookmarkModel::count = 0;
|
||||
BookmarkModel* BookmarkModel::s_bookmarkModel = 0L;
|
||||
|
||||
void BookmarkModel::resetModel()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
QVariant BookmarkModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
//Text
|
||||
if(index.isValid() && (role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
KBookmark bk = static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
if(bk.address() == "")
|
||||
if(index.column() == 0)
|
||||
return QVariant( i18n("Bookmarks") );
|
||||
else
|
||||
return QVariant();
|
||||
|
||||
switch( index.column() )
|
||||
{
|
||||
case 0:
|
||||
return QVariant( bk.fullText() );
|
||||
case 1:
|
||||
return QVariant( bk.url().pathOrURL() );
|
||||
case 2:
|
||||
return QVariant( EditCommand::getNodeText(bk, QStringList() << QString("desc")) );
|
||||
case 3:
|
||||
return QVariant( QString() ); //FIXME status column
|
||||
default:
|
||||
return QVariant( QString() ); //can't happen
|
||||
}
|
||||
}
|
||||
|
||||
//Icon
|
||||
if(index.isValid() && role == Qt::DecorationRole && index.column() == 0)
|
||||
{
|
||||
KBookmark bk = static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
if(bk.address() == "")
|
||||
return QVariant( QIcon(SmallIcon("bookmark")));
|
||||
return QVariant( QIcon(SmallIcon(bk.icon())));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
//FIXME QModelIndex BookmarkModel::buddy(const QModelIndex & index) //return parent for empty folder padders
|
||||
|
||||
|
||||
Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::ItemIsEnabled;
|
||||
|
||||
KBookmark bk = static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
if( bk.address() != "" )
|
||||
{
|
||||
if( bk.isGroup())
|
||||
{
|
||||
if(index.column() == 0 || index.column() == 2)
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||
}
|
||||
else
|
||||
if(index.column() < 3)
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
bool BookmarkModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if(index.isValid() && role == Qt::EditRole)
|
||||
{
|
||||
//FIXME don't create a commmand if still the same
|
||||
// and ignore if name column and empty
|
||||
QString addr = static_cast<TreeItem *>(index.internalPointer())->bookmark().address();
|
||||
CmdHistory::self()->addCommand(new EditCommand( addr, index.column(), value.toString()) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant BookmarkModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
return i18n("Bookmark");
|
||||
case 1:
|
||||
return i18n("URL");
|
||||
case 2:
|
||||
return i18n("Comment");
|
||||
case 3:
|
||||
return i18n("Status");
|
||||
default:
|
||||
return QString(); // Can't happpen
|
||||
}
|
||||
}
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex BookmarkModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if( ! parent.isValid())
|
||||
return createIndex(row, column, rootItem);
|
||||
|
||||
TreeItem * item = static_cast<TreeItem *>(parent.internalPointer());
|
||||
return createIndex(row, column, item->child(row));
|
||||
}
|
||||
|
||||
|
||||
|
||||
QModelIndex BookmarkModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
KBookmark bk = static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
|
||||
if(bk.address() == mRoot.address())
|
||||
return QModelIndex();
|
||||
|
||||
KBookmarkGroup parent = bk.parentGroup();
|
||||
TreeItem * item = static_cast<TreeItem *>(index.internalPointer());
|
||||
if(parent.address() != mRoot.address())
|
||||
return createIndex( KBookmark::positionInParent(parent.address()) , 0, item->parent());
|
||||
else //parent is root
|
||||
return createIndex( 0, 0, item->parent());
|
||||
}
|
||||
|
||||
int BookmarkModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if(parent.isValid())
|
||||
{
|
||||
KBookmark bk = static_cast<TreeItem *>(parent.internalPointer())->bookmark();
|
||||
return childCount(bk);
|
||||
}
|
||||
else //root case
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int BookmarkModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
QModelIndex BookmarkModel::bookmarkToIndex(KBookmark bk)
|
||||
{
|
||||
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);
|
||||
emit dataChanged(index, index );
|
||||
}
|
||||
|
||||
#include "bookmarkmodel.moc"
|
126
keditbookmarks/bookmarkmodel.h
Normal file
126
keditbookmarks/bookmarkmodel.h
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2005 Daniel Teske <teske@squorn.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __bookmarkmodel_h
|
||||
#define __bookmarkmodel_h
|
||||
|
||||
#include <q3valuevector.h>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <kbookmark.h>
|
||||
#include "toplevel.h"
|
||||
#include "treeitem.h"
|
||||
#include "commands.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
class BookmarkModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class insertSentry;
|
||||
friend class insertSentry;
|
||||
class removeSentry;
|
||||
friend class removeSentry;
|
||||
friend class IKEBCommand;
|
||||
|
||||
static BookmarkModel* self() { if(!s_bookmarkModel) s_bookmarkModel = new BookmarkModel(CurrentMgr::self()->root()); return s_bookmarkModel; }
|
||||
virtual ~BookmarkModel() {}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const;
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QModelIndex parent(const QModelIndex &index) const;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
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); }
|
||||
static BookmarkModel *s_bookmarkModel;
|
||||
static int count;
|
||||
KBookmark mRoot;
|
||||
// mutable QList<KBookmark> mapIdToAddr;
|
||||
|
||||
//Sentry
|
||||
protected:
|
||||
class insertSentry
|
||||
{
|
||||
public:
|
||||
insertSentry(KBookmark parent, int first, int last)
|
||||
{
|
||||
QModelIndex mParent = BookmarkModel::self()->bookmarkToIndex(parent);
|
||||
BookmarkModel::self()->beginInsertRows( mParent, first, last);
|
||||
|
||||
mt = static_cast<TreeItem *>(mParent.internalPointer());
|
||||
mf = first;
|
||||
ml = last;
|
||||
}
|
||||
~insertSentry()
|
||||
{
|
||||
mt->insertChildren(mf, ml);
|
||||
BookmarkModel::self()->endInsertRows();
|
||||
}
|
||||
private:
|
||||
TreeItem * mt;
|
||||
int mf, ml;
|
||||
};
|
||||
class removeSentry
|
||||
{
|
||||
public:
|
||||
removeSentry(KBookmark parent, int first, int last)
|
||||
{
|
||||
QModelIndex mParent = BookmarkModel::self()->bookmarkToIndex(parent);
|
||||
//FIXME remove this once Qt fixes their really stupid bugs
|
||||
for(int i = first; i <= last; ++i)
|
||||
{
|
||||
KEBApp::self()->mBookmarkListView->selectionModel()->select(mParent.child(i, 0), QItemSelectionModel::Deselect);
|
||||
}
|
||||
|
||||
BookmarkModel::self()->beginRemoveRows( mParent, first, last);
|
||||
|
||||
mt = static_cast<TreeItem *>(mParent.internalPointer());
|
||||
mf = first;
|
||||
ml = last;
|
||||
}
|
||||
~removeSentry()
|
||||
{
|
||||
mt->deleteChildren(mf, ml);
|
||||
BookmarkModel::self()->endRemoveRows();
|
||||
}
|
||||
private:
|
||||
TreeItem * mt;
|
||||
int mf, ml;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "commands.h"
|
||||
#include "bookmarkmodel.h"
|
||||
|
||||
#include "kinsertionsort.h"
|
||||
|
||||
|
@ -53,100 +54,18 @@ QString KEBMacroCommand::affectedBookmarks() const
|
|||
return affectBook;
|
||||
}
|
||||
|
||||
QString DeleteManyCommand::prevOrParentAddress(QString addr)
|
||||
{
|
||||
QString prev = KBookmark::previousAddress( addr );
|
||||
if( CurrentMgr::bookmarkAt(prev).hasParent())
|
||||
return prev;
|
||||
else
|
||||
return KBookmark::parentAddress( addr );
|
||||
}
|
||||
|
||||
QString DeleteManyCommand::preOrderNextAddress(QString addr)
|
||||
{
|
||||
QString rootAdr = CurrentMgr::self()->mgr()->root().address();
|
||||
while(addr != rootAdr)
|
||||
{
|
||||
QString next = KBookmark::nextAddress(addr);
|
||||
if(CurrentMgr::bookmarkAt( next ).hasParent() )
|
||||
return next;
|
||||
addr = KBookmark::parentAddress( addr );
|
||||
}
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
bool DeleteManyCommand::isConsecutive(const Q3ValueList<QString> & addresses)
|
||||
{
|
||||
Q3ValueList<QString>::const_iterator it, end;
|
||||
it = addresses.begin();
|
||||
end = addresses.end();
|
||||
QString addr = *(addresses.begin());
|
||||
for( ; it != end; ++it)
|
||||
{
|
||||
if( *it != addr )
|
||||
return false;
|
||||
addr = KBookmark::nextAddress(addr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DeleteManyCommand::DeleteManyCommand(const QString &name, const Q3ValueList<QString> & addresses)
|
||||
DeleteManyCommand::DeleteManyCommand(const QString &name, const QVector<KBookmark> & bookmarks)
|
||||
: KEBMacroCommand(name)
|
||||
{
|
||||
Q3ValueList<QString>::const_iterator it, begin;
|
||||
begin = addresses.begin();
|
||||
it = addresses.end();
|
||||
QVector<KBookmark>::const_iterator it, begin;
|
||||
begin = bookmarks.constBegin();
|
||||
it = bookmarks.constEnd();
|
||||
while(begin != it)
|
||||
{
|
||||
--it;
|
||||
DeleteCommand * dcmd = new DeleteCommand(*it);
|
||||
DeleteCommand * dcmd = new DeleteCommand( (*it).address() );
|
||||
addCommand(dcmd);
|
||||
}
|
||||
|
||||
// Set m_currentAddress
|
||||
if( addresses.count() == 1)
|
||||
{
|
||||
// First try next bookmark
|
||||
if( CurrentMgr::bookmarkAt( KBookmark::nextAddress( *begin ) ).hasParent() )
|
||||
m_currentAddress = *begin;
|
||||
else
|
||||
{
|
||||
m_currentAddress = preOrderNextAddress( KBookmark::parentAddress( *begin ) );
|
||||
if(m_currentAddress == QString::null)
|
||||
m_currentAddress = prevOrParentAddress( *begin );
|
||||
}
|
||||
}
|
||||
else // multi selection
|
||||
{
|
||||
// Check if all bookmarks are consecutive
|
||||
if(isConsecutive(addresses)) // Mark next bookmark after all selected
|
||||
{ // That's a little work...
|
||||
Q3ValueList<QString>::const_iterator last = addresses.end();
|
||||
--last;
|
||||
if( CurrentMgr::bookmarkAt( KBookmark::nextAddress(*last) ).hasParent() )
|
||||
m_currentAddress = *begin;
|
||||
else
|
||||
{
|
||||
m_currentAddress = preOrderNextAddress( KBookmark::parentAddress( *begin ) );
|
||||
if( m_currentAddress == QString::null)
|
||||
m_currentAddress = prevOrParentAddress( *begin );
|
||||
}
|
||||
}
|
||||
else // not consecutive, select the common parent (This could be more clever)
|
||||
{
|
||||
Q3ValueList<QString>::const_iterator jt, end;
|
||||
end = addresses.end();
|
||||
m_currentAddress = *begin;
|
||||
for( jt = addresses.begin(); jt != end; ++jt)
|
||||
m_currentAddress = KBookmark::commonParent(m_currentAddress, *jt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString DeleteManyCommand::currentAddress() const
|
||||
{
|
||||
return m_currentAddress;
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,7 +81,8 @@ QString CreateCommand::name() const {
|
|||
}
|
||||
}
|
||||
|
||||
void CreateCommand::execute() {
|
||||
void CreateCommand::execute()
|
||||
{
|
||||
QString parentAddress = KBookmark::parentAddress(m_to);
|
||||
KBookmarkGroup parentGroup =
|
||||
CurrentMgr::bookmarkAt(parentAddress).toGroup();
|
||||
|
@ -176,7 +96,7 @@ void CreateCommand::execute() {
|
|||
: CurrentMgr::bookmarkAt(previousSibling);
|
||||
|
||||
KBookmark bk = KBookmark(QDomElement());
|
||||
|
||||
BookmarkModel::insertSentry guard(parentGroup, KBookmark::positionInParent(m_to), KBookmark::positionInParent(m_to));
|
||||
if (m_separator) {
|
||||
bk = parentGroup.createNewSeparator();
|
||||
|
||||
|
@ -220,8 +140,7 @@ void CreateCommand::unexecute() {
|
|||
KBookmark bk = CurrentMgr::bookmarkAt(m_to);
|
||||
Q_ASSERT(!bk.isNull() && !bk.parentGroup().isNull());
|
||||
|
||||
ListView::self()->invalidate(bk.address());
|
||||
|
||||
BookmarkModel::removeSentry(bk.parentGroup(), KBookmark::positionInParent(bk.address()), KBookmark::positionInParent(bk.address()));
|
||||
bk.parentGroup().deleteBookmark(bk);
|
||||
}
|
||||
|
||||
|
@ -230,72 +149,94 @@ QString CreateCommand::affectedBookmarks() const
|
|||
return KBookmark::parentAddress(m_to);
|
||||
}
|
||||
|
||||
QString CreateCommand::currentAddress() const
|
||||
{
|
||||
QString bk = KBookmark::previousAddress( m_to );
|
||||
if(CurrentMgr::bookmarkAt( bk).hasParent())
|
||||
return bk;
|
||||
else
|
||||
return KBookmark::parentAddress( m_to );
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
QString EditCommand::name() const {
|
||||
return i18n("%1 Change").arg(m_mytext);
|
||||
}
|
||||
|
||||
void EditCommand::execute() {
|
||||
KBookmark bk = CurrentMgr::bookmarkAt(m_address);
|
||||
Q_ASSERT(!bk.isNull());
|
||||
|
||||
m_reverseEditions.clear();
|
||||
|
||||
Q3ValueList<Edition>::Iterator it = m_editions.begin();
|
||||
|
||||
for ( ; it != m_editions.end() ; ++it) {
|
||||
// backup current value
|
||||
m_reverseEditions.append( Edition((*it).attr,
|
||||
bk.internalElement().attribute((*it).attr)));
|
||||
// set new value
|
||||
bk.internalElement().setAttribute((*it).attr, (*it).value);
|
||||
}
|
||||
}
|
||||
|
||||
void EditCommand::unexecute() {
|
||||
// code reuse
|
||||
EditCommand cmd(m_address, m_reverseEditions);
|
||||
cmd.execute();
|
||||
// get the editions back from it,
|
||||
// in case they changed
|
||||
// (hmm, shouldn't happen - TODO CHECK!)
|
||||
m_editions = cmd.m_reverseEditions;
|
||||
}
|
||||
|
||||
QString EditCommand::affectedBookmarks() const
|
||||
EditCommand::EditCommand(const QString & address, int col, const QString & newValue)
|
||||
: KCommand(), mAddress(address), mCol(col)
|
||||
{
|
||||
return KBookmark::parentAddress(m_address);
|
||||
}
|
||||
|
||||
void EditCommand::modify(const QString & a, const QString & v)
|
||||
{
|
||||
Q3ValueList<Edition>::Iterator it = m_editions.begin();
|
||||
Q3ValueList<Edition>::Iterator end = m_editions.end();
|
||||
for ( ; it != end; ++it)
|
||||
if(mCol == 1)
|
||||
{
|
||||
if( (*it).attr == a)
|
||||
(*it).value = v;
|
||||
KURL u = KURL::fromPathOrURL(newValue);
|
||||
mNewValue = u.url(0, 106);
|
||||
}
|
||||
else
|
||||
mNewValue = newValue;
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
QString NodeEditCommand::name() const {
|
||||
// TODO - make dynamic
|
||||
return i18n("Renaming");
|
||||
QString EditCommand::name() const
|
||||
{
|
||||
if(mCol==-1)
|
||||
return i18n("%1 Change").arg(i18n("Icon"));
|
||||
else if(mCol==0)
|
||||
return i18n("%1 Change").arg(i18n("Title") );
|
||||
else if(mCol==1)
|
||||
return i18n("%1 Change").arg(i18n("URL"));
|
||||
else if(mCol==2)
|
||||
return i18n("%1 Change").arg(i18n("Comment"));
|
||||
//Never reached
|
||||
return QString("");
|
||||
}
|
||||
|
||||
QString NodeEditCommand::getNodeText(KBookmark bk, const QStringList &nodehier) {
|
||||
void EditCommand::execute()
|
||||
{
|
||||
KBookmark bk = CurrentMgr::bookmarkAt(mAddress);
|
||||
if(mCol==-2)
|
||||
{
|
||||
mOldValue = bk.internalElement().attribute("toolbar");
|
||||
bk.internalElement().setAttribute("toolbar", mNewValue);
|
||||
}
|
||||
else if(mCol==-1)
|
||||
{
|
||||
mOldValue = bk.internalElement().attribute("icon");
|
||||
bk.internalElement().setAttribute("icon", mNewValue);
|
||||
}
|
||||
else if(mCol==0)
|
||||
{
|
||||
mOldValue = bk.fullText();
|
||||
setNodeText(bk, QStringList()<< "title", mNewValue);
|
||||
}
|
||||
else if(mCol==1)
|
||||
{
|
||||
mOldValue = bk.internalElement().attribute("href");
|
||||
bk.internalElement().setAttribute("href", mNewValue);
|
||||
}
|
||||
else if(mCol==2)
|
||||
{
|
||||
mOldValue = getNodeText(bk, QStringList()<<"desc");
|
||||
setNodeText(bk, QStringList()<<"desc", mNewValue);
|
||||
}
|
||||
BookmarkModel::self()->emitDataChanged(bk);
|
||||
}
|
||||
|
||||
void EditCommand::unexecute()
|
||||
{
|
||||
|
||||
KBookmark bk = CurrentMgr::bookmarkAt(mAddress);
|
||||
if(mCol==-2)
|
||||
{
|
||||
bk.internalElement().setAttribute("toolbar", mOldValue);
|
||||
}
|
||||
else if(mCol==-1)
|
||||
{
|
||||
bk.internalElement().setAttribute("icon", mOldValue);
|
||||
}
|
||||
else if(mCol==0)
|
||||
{
|
||||
setNodeText(bk, QStringList()<<"title", mOldValue);
|
||||
}
|
||||
else if(mCol==1)
|
||||
{
|
||||
bk.internalElement().setAttribute("href", mOldValue );
|
||||
}
|
||||
else if(mCol==2)
|
||||
{
|
||||
setNodeText(bk, QStringList()<<"desc", mOldValue);
|
||||
}
|
||||
BookmarkModel::self()->emitDataChanged(bk);
|
||||
}
|
||||
|
||||
QString EditCommand::getNodeText(KBookmark bk, const QStringList &nodehier)
|
||||
{
|
||||
QDomNode subnode = bk.internalElement();
|
||||
for (QStringList::ConstIterator it = nodehier.begin();
|
||||
it != nodehier.end(); ++it)
|
||||
|
@ -309,8 +250,9 @@ QString NodeEditCommand::getNodeText(KBookmark bk, const QStringList &nodehier)
|
|||
: subnode.firstChild().toText().data();
|
||||
}
|
||||
|
||||
QString NodeEditCommand::setNodeText(KBookmark bk, const QStringList &nodehier,
|
||||
const QString newValue) {
|
||||
QString EditCommand::setNodeText(KBookmark bk, const QStringList &nodehier,
|
||||
const QString newValue)
|
||||
{
|
||||
QDomNode subnode = bk.internalElement();
|
||||
for (QStringList::ConstIterator it = nodehier.begin();
|
||||
it != nodehier.end(); ++it)
|
||||
|
@ -334,37 +276,10 @@ QString NodeEditCommand::setNodeText(KBookmark bk, const QStringList &nodehier,
|
|||
return oldText;
|
||||
}
|
||||
|
||||
void NodeEditCommand::execute() {
|
||||
// DUPLICATED HEAVILY FROM KIO/BOOKMARKS
|
||||
KBookmark bk = CurrentMgr::bookmarkAt(m_address);
|
||||
Q_ASSERT(!bk.isNull());
|
||||
m_oldText = setNodeText(bk, QStringList() << m_nodename, m_newText);
|
||||
}
|
||||
|
||||
void NodeEditCommand::unexecute() {
|
||||
// reuse code
|
||||
NodeEditCommand cmd(m_address, m_oldText, m_nodename);
|
||||
cmd.execute();
|
||||
// get the old text back from it, in case they changed
|
||||
// (hmm, shouldn't happen)
|
||||
// AK - DUP'ed from above???
|
||||
m_newText = cmd.m_oldText;
|
||||
}
|
||||
|
||||
void NodeEditCommand::modify(const QString & newText)
|
||||
{
|
||||
m_newText = newText;
|
||||
}
|
||||
|
||||
QString NodeEditCommand::affectedBookmarks() const
|
||||
{
|
||||
return KBookmark::parentAddress(m_address);
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
void DeleteCommand::execute() {
|
||||
// kdDebug() << "DeleteCommand::execute " << m_from << endl;
|
||||
kdDebug() << "DeleteCommand::execute " << m_from << endl;
|
||||
|
||||
KBookmark bk = CurrentMgr::bookmarkAt(m_from);
|
||||
Q_ASSERT(!bk.isNull());
|
||||
|
@ -402,7 +317,6 @@ void DeleteCommand::execute() {
|
|||
bk.icon(), bk.url());
|
||||
}
|
||||
}
|
||||
|
||||
m_cmd->unexecute();
|
||||
}
|
||||
|
||||
|
@ -595,41 +509,19 @@ QString SortCommand::affectedBookmarks() const
|
|||
|
||||
/* -------------------------------------- */
|
||||
|
||||
KEBMacroCommand* CmdGen::setAsToolbar(const KBookmark &bk) {
|
||||
KEBMacroCommand* CmdGen::setAsToolbar(const KBookmark &bk)
|
||||
{
|
||||
KEBMacroCommand *mcmd = new KEBMacroCommand(i18n("Set as Bookmark Toolbar"));
|
||||
|
||||
KBookmarkGroup oldToolbar = CurrentMgr::self()->mgr()->toolbar();
|
||||
if (!oldToolbar.isNull()) {
|
||||
Q3ValueList<EditCommand::Edition> lst;
|
||||
lst.append(EditCommand::Edition("toolbar", "no"));
|
||||
lst.append(EditCommand::Edition("icon", ""));
|
||||
EditCommand *cmd1 = new EditCommand(oldToolbar.address(), lst);
|
||||
mcmd->addCommand(cmd1);
|
||||
if (!oldToolbar.isNull())
|
||||
{
|
||||
mcmd->addCommand( new EditCommand(oldToolbar.address(), -2, "no")); //toolbar
|
||||
mcmd->addCommand( new EditCommand(oldToolbar.address(), -1, "")); //icon
|
||||
}
|
||||
|
||||
Q3ValueList<EditCommand::Edition> lst;
|
||||
lst.append(EditCommand::Edition("toolbar", "yes"));
|
||||
lst.append(EditCommand::Edition("icon", "bookmark_toolbar"));
|
||||
// TODO - see below
|
||||
EditCommand *cmd2 = new EditCommand(bk.address(), lst);
|
||||
mcmd->addCommand(cmd2);
|
||||
|
||||
return mcmd;
|
||||
}
|
||||
|
||||
bool CmdGen::shownInToolbar(const KBookmark &bk) {
|
||||
return (bk.internalElement().attribute("showintoolbar") == "yes");
|
||||
}
|
||||
|
||||
KEBMacroCommand* CmdGen::setShownInToolbar(const KBookmark &bk, bool show) {
|
||||
QString i18n_name = i18n("%1 in Bookmark Toolbar").arg(show ? i18n("Show")
|
||||
: i18n("Hide"));
|
||||
KEBMacroCommand *mcmd = new KEBMacroCommand(i18n_name);
|
||||
|
||||
Q3ValueList<EditCommand::Edition> lst;
|
||||
lst.append(EditCommand::Edition("showintoolbar", show ? "yes" : "no"));
|
||||
EditCommand *cmd2 = new EditCommand(bk.address(), lst);
|
||||
mcmd->addCommand(cmd2);
|
||||
mcmd->addCommand( new EditCommand(bk.address(), -2, "yes"));
|
||||
mcmd->addCommand( new EditCommand(bk.address(), -1, "bookmark_toolbar"));
|
||||
|
||||
return mcmd;
|
||||
}
|
||||
|
@ -702,42 +594,42 @@ KEBMacroCommand* CmdGen::itemsMoved(const QMap<KEBListViewItem *, bool> & items,
|
|||
const QString &newAddress, bool copy) {
|
||||
KEBMacroCommand *mcmd = new KEBMacroCommand(copy ? i18n("Copy Items")
|
||||
: i18n("Move Items"));
|
||||
|
||||
Q3ValueList<KBookmark> list = ListView::self()->itemsToBookmarks( items );
|
||||
Q3ValueList<KBookmark>::const_iterator it, end;
|
||||
it = list.begin();
|
||||
end = list.end();
|
||||
|
||||
QString bkInsertAddr = newAddress;
|
||||
for (; it != end; ++it) {
|
||||
if (copy) {
|
||||
CreateCommand *cmd;
|
||||
cmd = new CreateCommand(
|
||||
bkInsertAddr,
|
||||
(*it).internalElement()
|
||||
.cloneNode(true).toElement(),
|
||||
(*it).text());
|
||||
|
||||
cmd->execute();
|
||||
mcmd->addCommand(cmd);
|
||||
|
||||
bkInsertAddr = cmd->finalAddress();
|
||||
|
||||
} else /* if (move) */ {
|
||||
QString oldAddress = (*it).address();
|
||||
if (bkInsertAddr.startsWith(oldAddress)) //FIXME uses internal representation of address
|
||||
continue;
|
||||
|
||||
MoveCommand *cmd = new MoveCommand(oldAddress, bkInsertAddr,
|
||||
(*it).text());
|
||||
cmd->execute();
|
||||
mcmd->addCommand(cmd);
|
||||
|
||||
bkInsertAddr = cmd->finalAddress();
|
||||
}
|
||||
|
||||
bkInsertAddr = KBookmark::nextAddress(bkInsertAddr);
|
||||
}
|
||||
//FIXME rewrite CmdGen::itemsMoved
|
||||
// Q3ValueList<KBookmark> list = ListView::self()->itemsToBookmarks( items );
|
||||
// Q3ValueList<KBookmark>::const_iterator it, end;
|
||||
// it = list.begin();
|
||||
// end = list.end();
|
||||
//
|
||||
// QString bkInsertAddr = newAddress;
|
||||
// for (; it != end; ++it) {
|
||||
// if (copy) {
|
||||
// CreateCommand *cmd;
|
||||
// cmd = new CreateCommand(
|
||||
// bkInsertAddr,
|
||||
// (*it).internalElement()
|
||||
// .cloneNode(true).toElement(),
|
||||
// (*it).text());
|
||||
//
|
||||
// cmd->execute();
|
||||
// mcmd->addCommand(cmd);
|
||||
//
|
||||
// bkInsertAddr = cmd->finalAddress();
|
||||
//
|
||||
// } else /* if (move) */ {
|
||||
// QString oldAddress = (*it).address();
|
||||
// if (bkInsertAddr.startsWith(oldAddress)) //FIXME uses internal representation of address
|
||||
// continue;
|
||||
//
|
||||
// MoveCommand *cmd = new MoveCommand(oldAddress, bkInsertAddr,
|
||||
// (*it).text());
|
||||
// cmd->execute();
|
||||
// mcmd->addCommand(cmd);
|
||||
//
|
||||
// bkInsertAddr = cmd->finalAddress();
|
||||
// }
|
||||
//
|
||||
// bkInsertAddr = KBookmark::nextAddress(bkInsertAddr);
|
||||
// }
|
||||
|
||||
return mcmd;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Q3PtrList>
|
||||
#include <Q3MimeSourceFactory>
|
||||
|
||||
|
||||
// Interface adds the affectedBookmarks method
|
||||
// Any class should on call add those bookmarks which are
|
||||
// affected by executing or unexecuting the command
|
||||
|
@ -40,7 +41,6 @@ public:
|
|||
IKEBCommand() {};
|
||||
virtual ~IKEBCommand() {};
|
||||
virtual QString affectedBookmarks() const = 0;
|
||||
virtual QString currentAddress() const { return QString::null; }
|
||||
};
|
||||
|
||||
class KEBMacroCommand : public KMacroCommand, public IKEBCommand
|
||||
|
@ -55,14 +55,8 @@ public:
|
|||
class DeleteManyCommand : public KEBMacroCommand
|
||||
{
|
||||
public:
|
||||
DeleteManyCommand(const QString &name, const Q3ValueList<QString> & addresses);
|
||||
DeleteManyCommand(const QString &name, const QVector<KBookmark> & bookmarks);
|
||||
virtual ~DeleteManyCommand() {};
|
||||
virtual QString currentAddress() const;
|
||||
private:
|
||||
QString prevOrParentAddress(QString addr);
|
||||
QString preOrderNextAddress(QString addr);
|
||||
bool isConsecutive(const Q3ValueList<QString> & addresses);
|
||||
QString m_currentAddress;
|
||||
};
|
||||
|
||||
class CreateCommand : public KCommand, public IKEBCommand
|
||||
|
@ -104,7 +98,6 @@ public:
|
|||
virtual void unexecute();
|
||||
virtual QString name() const;
|
||||
virtual QString affectedBookmarks() const;
|
||||
virtual QString currentAddress() const;
|
||||
private:
|
||||
QString m_to;
|
||||
QString m_text;
|
||||
|
@ -120,66 +113,20 @@ private:
|
|||
class EditCommand : public KCommand, public IKEBCommand
|
||||
{
|
||||
public:
|
||||
|
||||
struct Edition {
|
||||
Edition() { ; } // needed for QValueList
|
||||
Edition(const QString &a, const QString &v) : attr(a), value(v) {}
|
||||
QString attr;
|
||||
QString value;
|
||||
};
|
||||
|
||||
// change one attribute
|
||||
EditCommand(const QString &address, Edition edition, const QString &name = QString::null)
|
||||
: KCommand(), m_address(address), m_mytext(name)
|
||||
{
|
||||
m_editions.append(edition);
|
||||
}
|
||||
|
||||
// change multiple attributes
|
||||
EditCommand(const QString &address,
|
||||
const Q3ValueList<Edition> &editions,
|
||||
const QString &name = QString::null)
|
||||
: KCommand(), m_address(address), m_editions(editions), m_mytext(name)
|
||||
{ ; }
|
||||
|
||||
void modify(const QString & a, const QString & v);
|
||||
|
||||
virtual ~EditCommand() { ; }
|
||||
EditCommand(const QString & address, int col, const QString & newValue);
|
||||
virtual ~EditCommand() {};
|
||||
virtual void execute();
|
||||
virtual void unexecute();
|
||||
virtual QString name() const;
|
||||
virtual QString affectedBookmarks() const;
|
||||
virtual QString affectedBookmarks() const { return KBookmark::parentAddress(mAddress); }
|
||||
static QString EditCommand::getNodeText(KBookmark bk, const QStringList &nodehier);
|
||||
static QString EditCommand::setNodeText(KBookmark bk, const QStringList &nodehier,
|
||||
const QString newValue);
|
||||
private:
|
||||
QString m_address;
|
||||
Q3ValueList<Edition> m_editions;
|
||||
Q3ValueList<Edition> m_reverseEditions;
|
||||
QString m_mytext;
|
||||
};
|
||||
|
||||
class NodeEditCommand : public KCommand, public IKEBCommand
|
||||
{
|
||||
public:
|
||||
NodeEditCommand(const QString &address,
|
||||
const QString &newText,
|
||||
const QString &nodeName)
|
||||
: KCommand(), m_address(address), m_newText(newText), m_nodename(nodeName)
|
||||
{ ; }
|
||||
|
||||
void modify(const QString & newText);
|
||||
|
||||
virtual ~NodeEditCommand() { ; }
|
||||
virtual void execute();
|
||||
virtual void unexecute();
|
||||
virtual QString affectedBookmarks() const;
|
||||
virtual QString name() const;
|
||||
static QString getNodeText(KBookmark bk, const QStringList &nodehier);
|
||||
static QString setNodeText(KBookmark bk, const QStringList &nodehier,
|
||||
QString newValue);
|
||||
private:
|
||||
QString m_address;
|
||||
QString m_newText;
|
||||
QString m_oldText;
|
||||
QString m_nodename;
|
||||
QString mAddress;
|
||||
int mCol;
|
||||
QString mNewValue;
|
||||
QString mOldValue;
|
||||
};
|
||||
|
||||
class DeleteCommand : public KCommand, public IKEBCommand
|
||||
|
@ -248,8 +195,6 @@ class KEBListViewItem;
|
|||
class CmdGen {
|
||||
public:
|
||||
static KEBMacroCommand* setAsToolbar(const KBookmark &bk);
|
||||
static KEBMacroCommand* setShownInToolbar(const KBookmark &bk, bool show);
|
||||
static bool shownInToolbar(const KBookmark &bk);
|
||||
static KEBMacroCommand* deleteItems(const QString &commandName, const QMap<KEBListViewItem *, bool> & items);
|
||||
static KEBMacroCommand* insertMimeSource(const QString &cmdName, QMimeSource *data, const QString &addr);
|
||||
static KEBMacroCommand* itemsMoved(const QMap<KEBListViewItem *, bool> & items, const QString &newAddress, bool copy);
|
||||
|
|
|
@ -59,7 +59,7 @@ void KBookmarkEditorIface::slotDcopUpdatedAccessMetadata(QString filename, QStri
|
|||
kdDebug() << "slotDcopUpdatedAccessMetadata(" << url << ")" << endl;
|
||||
// no undo
|
||||
CurrentMgr::self()->mgr()->updateAccessMetadata(url, false);
|
||||
ListView::self()->updateStatus(url);
|
||||
//FIXME ListView::self()->updateStatus(url);
|
||||
KEBApp::self()->updateStatus(url);
|
||||
// notice - no save here! see! :)
|
||||
}
|
||||
|
|
|
@ -59,20 +59,20 @@ void FavIconsItrHolder::addAffectedBookmark( const QString & address )
|
|||
|
||||
/* -------------------------- */
|
||||
|
||||
FavIconsItr::FavIconsItr(Q3ValueList<KBookmark> bks)
|
||||
FavIconsItr::FavIconsItr(QVector<KBookmark> bks)
|
||||
: BookmarkIterator(bks) {
|
||||
m_updater = 0;
|
||||
}
|
||||
|
||||
FavIconsItr::~FavIconsItr() {
|
||||
if (curItem())
|
||||
curItem()->restoreStatus();
|
||||
//FIXME if (curItem())
|
||||
// curItem()->restoreStatus();
|
||||
delete m_updater;
|
||||
}
|
||||
|
||||
void FavIconsItr::slotDone(bool succeeded) {
|
||||
// kdDebug() << "FavIconsItr::slotDone()" << endl;
|
||||
curItem()->setTmpStatus(succeeded ? i18n("OK") : i18n("No favicon found"));
|
||||
//FIXME curItem()->setTmpStatus(succeeded ? i18n("OK") : i18n("No favicon found"));
|
||||
holder()->addAffectedBookmark(KBookmark::parentAddress(curBk().address()));
|
||||
delayedEmitNextOne();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ bool FavIconsItr::isApplicable(const KBookmark &bk) const {
|
|||
|
||||
void FavIconsItr::doAction() {
|
||||
// kdDebug() << "FavIconsItr::doAction()" << endl;
|
||||
curItem()->setTmpStatus(i18n("Updating favicon..."));
|
||||
//FIXME curItem()->setTmpStatus(i18n("Updating favicon..."));
|
||||
if (!m_updater) {
|
||||
m_updater = new FavIconUpdater(kapp, "FavIconUpdater");
|
||||
connect(m_updater, SIGNAL( done(bool) ),
|
||||
|
@ -92,7 +92,7 @@ void FavIconsItr::doAction() {
|
|||
if (curBk().url().protocol().startsWith("http")) {
|
||||
m_updater->downloadIcon(curBk());
|
||||
} else {
|
||||
curItem()->setTmpStatus(i18n("Local file"));
|
||||
//FIXME curItem()->setTmpStatus(i18n("Local file"));
|
||||
delayedEmitNextOne();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class FavIconsItr : public BookmarkIterator
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FavIconsItr(Q3ValueList<KBookmark> bks);
|
||||
FavIconsItr(QVector<KBookmark> bks);
|
||||
~FavIconsItr();
|
||||
virtual FavIconsItrHolder* holder() const { return FavIconsItrHolder::self(); }
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void ImportCommand::execute() {
|
|||
|
||||
} else {
|
||||
// import into the root, after cleaning it up
|
||||
bkGroup = CurrentMgr::self()->mgr()->root();
|
||||
bkGroup = CurrentMgr::self()->root();
|
||||
delete m_cleanUpCmd;
|
||||
m_cleanUpCmd = DeleteCommand::deleteAll(bkGroup);
|
||||
|
||||
|
@ -128,7 +128,7 @@ void ImportCommand::unexecute() {
|
|||
|
||||
} else {
|
||||
// we imported at the root -> delete everything
|
||||
KBookmarkGroup root = CurrentMgr::self()->mgr()->root();
|
||||
KBookmarkGroup root = CurrentMgr::self()->root();
|
||||
KCommand *cmd = DeleteCommand::deleteAll(root);
|
||||
|
||||
cmd->execute();
|
||||
|
@ -141,7 +141,7 @@ void ImportCommand::unexecute() {
|
|||
|
||||
QString ImportCommand::affectedBookmarks() const
|
||||
{
|
||||
QString rootAdr = CurrentMgr::self()->mgr()->root().address();
|
||||
QString rootAdr = CurrentMgr::self()->root().address();
|
||||
if(m_group == rootAdr)
|
||||
return m_group;
|
||||
else
|
||||
|
@ -270,11 +270,11 @@ void XBELImportCommand::doExecute(const KBookmarkGroup &/*bkGroup*/) {
|
|||
QDomNode node = doc.importNode(subDoc, true);
|
||||
|
||||
if (!folder().isEmpty()) {
|
||||
CurrentMgr::self()->mgr()->root().internalElement().appendChild(node);
|
||||
CurrentMgr::self()->root().internalElement().appendChild(node);
|
||||
m_group = KBookmarkGroup(node.toElement()).address();
|
||||
|
||||
} else {
|
||||
QDomElement root = CurrentMgr::self()->mgr()->root().internalElement();
|
||||
QDomElement root = CurrentMgr::self()->root().internalElement();
|
||||
|
||||
Q3ValueList<QDomElement> childList;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="keditbookmarks" version="29">
|
||||
<kpartgui name="keditbookmarks" version="30">
|
||||
|
||||
<MenuBar>
|
||||
|
||||
|
@ -41,8 +41,6 @@
|
|||
<Action name="changeurl"/>
|
||||
<Action name="changecomment"/>
|
||||
<Action name="changeicon"/>
|
||||
<Separator/>
|
||||
<Action name="showintoolbar"/>
|
||||
</Menu>
|
||||
|
||||
<Menu name="view"><text>&View</text>
|
||||
|
@ -96,7 +94,6 @@
|
|||
<Menu name="popup_folder">
|
||||
<!-- Stuff for folders -->
|
||||
<Action name="setastoolbar"/>
|
||||
<Action name="showintoolbar"/>
|
||||
<Action name="sort"/>
|
||||
<Action name="recursivesort"/>
|
||||
<Separator/>
|
||||
|
@ -121,7 +118,6 @@
|
|||
|
||||
<Menu name="popup_bookmark">
|
||||
<!-- Stuff for bookmarks -->
|
||||
<Action name="showintoolbar"/>
|
||||
<Action name="openlink"/>
|
||||
<Action name="testlink"/>
|
||||
<Action name="updatefavicon"/>
|
||||
|
@ -198,7 +194,6 @@
|
|||
<Action name="openlink"/>
|
||||
<Action name="rename"/>
|
||||
<Action name="setastoolbar"/>
|
||||
<Action name="showintoolbar"/>
|
||||
<Action name="sort"/>
|
||||
<Action name="recursivesort"/>
|
||||
<Action name="testall"/>
|
||||
|
|
|
@ -19,370 +19,8 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "listview.h"
|
||||
/*void ListView::handleDropped(KEBListView *, QDropEvent *e, Q3ListViewItem *newParent, Q3ListViewItem *itemAfterQLVI) {
|
||||
|
||||
#include "toplevel.h"
|
||||
#include "bookmarkinfo.h"
|
||||
#include "commands.h"
|
||||
#include "testlink.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qclipboard.h>
|
||||
#include <q3popupmenu.h>
|
||||
#include <qpainter.h>
|
||||
#include <q3header.h>
|
||||
//Added by qt3to4:
|
||||
#include <Q3PtrList>
|
||||
#include <QKeyEvent>
|
||||
#include <QEvent>
|
||||
#include <QDropEvent>
|
||||
#include <Q3ValueList>
|
||||
#include <Q3ValueVector>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <dcopclient.h>
|
||||
#include <kdebug.h>
|
||||
#include <kapplication.h>
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kstdaction.h>
|
||||
#include <kedittoolbar.h>
|
||||
#include <kfiledialog.h>
|
||||
#include <kkeydialog.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <klineedit.h>
|
||||
#include <krun.h>
|
||||
#include <klistviewsearchline.h>
|
||||
|
||||
#include <kbookmarkdrag.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <q3tl.h>
|
||||
|
||||
// #define DEBUG_ADDRESSES
|
||||
|
||||
ListView* ListView::s_self = 0;
|
||||
|
||||
int ListView::s_myrenamecolumn = -1;
|
||||
KEBListViewItem *ListView::s_myrenameitem = 0;
|
||||
|
||||
QStringList ListView::s_selected_addresses;
|
||||
QString ListView::s_current_address;
|
||||
|
||||
ListView::ListView()
|
||||
: m_needToFixUp(false)
|
||||
{
|
||||
}
|
||||
|
||||
ListView::~ListView() {
|
||||
self()->m_listView->saveColumnSetting();
|
||||
}
|
||||
|
||||
void ListView::createListViews(QSplitter *splitter) {
|
||||
s_self = new ListView();
|
||||
self()->m_listView = new KEBListView(splitter, false);
|
||||
splitter->setSizes(Q3ValueList<int>() << 100 << 300);
|
||||
}
|
||||
|
||||
void ListView::initListViews() {
|
||||
self()->m_listView->init();
|
||||
}
|
||||
|
||||
void ListView::updateListViewSetup(bool readonly) {
|
||||
self()->m_listView->readonlyFlagInit(readonly);
|
||||
}
|
||||
|
||||
void ListView::connectSignals() {
|
||||
m_listView->makeConnections();
|
||||
}
|
||||
|
||||
bool lessAddress(QString a, QString b)
|
||||
{
|
||||
if(a == b)
|
||||
return false;
|
||||
|
||||
QString error("ERROR");
|
||||
if(a == error)
|
||||
return false;
|
||||
if(b == error)
|
||||
return true;
|
||||
|
||||
a += "/";
|
||||
b += "/";
|
||||
|
||||
uint aLast = 0;
|
||||
uint bLast = 0;
|
||||
uint aEnd = a.length();
|
||||
uint bEnd = b.length();
|
||||
// Each iteration checks one "/"-delimeted part of the address
|
||||
// "" is treated correctly
|
||||
while(true)
|
||||
{
|
||||
// Invariant: a[0 ... aLast] == b[0 ... bLast]
|
||||
if(aLast + 1 == aEnd) //The last position was the last slash
|
||||
return true; // That means a is shorter than b
|
||||
if(bLast +1 == bEnd)
|
||||
return false;
|
||||
|
||||
uint aNext = a.find("/", aLast + 1);
|
||||
uint bNext = b.find("/", bLast + 1);
|
||||
|
||||
bool okay;
|
||||
uint aNum = a.mid(aLast + 1, aNext - aLast - 1).toUInt(&okay);
|
||||
if(!okay)
|
||||
return false;
|
||||
uint bNum = b.mid(bLast + 1, bNext - bLast - 1).toUInt(&okay);
|
||||
if(!okay)
|
||||
return true;
|
||||
|
||||
if(aNum != bNum)
|
||||
return aNum < bNum;
|
||||
|
||||
aLast = aNext;
|
||||
bLast = bNext;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator<(const KBookmark & first, const KBookmark & second) //FIXME Using internal represantation
|
||||
{
|
||||
return lessAddress(first.address(), second.address());
|
||||
}
|
||||
|
||||
|
||||
Q3ValueList<KBookmark> ListView::itemsToBookmarks(const QMap<KEBListViewItem *, bool> & items) const
|
||||
{
|
||||
Q3ValueList<KBookmark> bookmarks; //TODO optimize by using a Q3ValueVector
|
||||
QMap<KEBListViewItem *, bool>::const_iterator it = items.begin();
|
||||
QMap<KEBListViewItem *, bool>::const_iterator end = items.end();
|
||||
for( ; it!=end; ++it)
|
||||
{
|
||||
if(it.key() != m_listView->rootItem() )
|
||||
bookmarks.push_back( it.key()->bookmark() );
|
||||
}
|
||||
qHeapSort(bookmarks);
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
void ListView::invalidate(const QString & address)
|
||||
{
|
||||
invalidate(getItemAtAddress(address));
|
||||
}
|
||||
|
||||
void ListView::invalidate(Q3ListViewItem * item)
|
||||
{
|
||||
if(item->isSelected())
|
||||
{
|
||||
m_listView->setSelected(item, false);
|
||||
m_needToFixUp = true;
|
||||
}
|
||||
|
||||
if(m_listView->currentItem() == item)
|
||||
{
|
||||
// later overiden by fixUpCurrent
|
||||
m_listView->setCurrentItem(m_listView->rootItem());
|
||||
m_needToFixUp = true;
|
||||
}
|
||||
|
||||
Q3ListViewItem * child = item->firstChild();
|
||||
while(child)
|
||||
{
|
||||
//invalidate(child);
|
||||
child = child->nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void ListView::fixUpCurrent(const QString & address)
|
||||
{
|
||||
if(!m_needToFixUp)
|
||||
return;
|
||||
m_needToFixUp = false;
|
||||
|
||||
Q3ListViewItem * item;
|
||||
if(mSelectedItems.count() != 0)
|
||||
{
|
||||
QString least = mSelectedItems.begin().key()->bookmark().address();
|
||||
QMap<KEBListViewItem *, bool>::iterator it, end;
|
||||
end = mSelectedItems.end();
|
||||
for(it = mSelectedItems.begin(); it != end; ++it)
|
||||
if( lessAddress(it.key()->bookmark().address(), least))
|
||||
least = it.key()->bookmark().address();
|
||||
item = getItemAtAddress(least);
|
||||
}
|
||||
else
|
||||
item = getItemAtAddress(address);
|
||||
m_listView->setSelected( item, true );
|
||||
m_listView->setCurrentItem( item );
|
||||
}
|
||||
|
||||
|
||||
void ListView::selected(KEBListViewItem * item, bool s)
|
||||
{
|
||||
Q_ASSERT(item->bookmark().hasParent() || item == m_listView->rootItem());
|
||||
QMap<KEBListViewItem *, bool>::iterator it;
|
||||
|
||||
if(s)
|
||||
mSelectedItems[item] = item;
|
||||
else
|
||||
if((it = mSelectedItems.find(item)) != mSelectedItems.end())
|
||||
mSelectedItems.remove(it);
|
||||
|
||||
KEBApp::self()->updateActions();
|
||||
|
||||
if (mSelectedItems.count() != 1)
|
||||
{
|
||||
KEBApp::self()->bkInfo()->showBookmark(KBookmark());
|
||||
return;
|
||||
}
|
||||
//FIXME do it once somewhere
|
||||
if (!KEBApp::self()->bkInfo()->connected()) {
|
||||
connect(KEBApp::self()->bkInfo(), SIGNAL( updateListViewItem() ),
|
||||
SLOT( slotBkInfoUpdateListViewItem() ));
|
||||
KEBApp::self()->bkInfo()->setConnected(true);
|
||||
}
|
||||
|
||||
KEBApp::self()->bkInfo()->showBookmark(firstSelected()->bookmark());
|
||||
firstSelected()->modUpdate();
|
||||
}
|
||||
|
||||
KEBListViewItem * ListView::firstSelected() const
|
||||
{
|
||||
if(mSelectedItems.isEmpty())
|
||||
return 0L;
|
||||
else
|
||||
return mSelectedItems.begin().key();
|
||||
}
|
||||
|
||||
void ListView::deselectAllChildren(KEBListViewItem *item)
|
||||
{
|
||||
KEBListViewItem* child = static_cast<KEBListViewItem *>(item->firstChild());
|
||||
while(child)
|
||||
{
|
||||
if (child)
|
||||
{
|
||||
if(child->isSelected())
|
||||
child->listView()->setSelected(child, false); //calls deselectAllChildren
|
||||
else
|
||||
deselectAllChildren(child);
|
||||
}
|
||||
child->repaint();
|
||||
child = static_cast<KEBListViewItem *>(child->nextSibling());
|
||||
}
|
||||
}
|
||||
|
||||
Q3ValueList<QString> ListView::selectedAddresses()
|
||||
{
|
||||
Q3ValueList<QString> addresses;
|
||||
Q3ValueList<KBookmark> bookmarks = itemsToBookmarks( selectedItemsMap() );
|
||||
Q3ValueList<KBookmark>::const_iterator it, end;
|
||||
end = bookmarks.end();
|
||||
for( it = bookmarks.begin(); it != end; ++it)
|
||||
addresses.append( (*it).address() );
|
||||
return addresses;
|
||||
}
|
||||
|
||||
|
||||
Q3ValueList<KBookmark> ListView::selectedBookmarksExpanded() const {
|
||||
Q3ValueList<KBookmark> bookmarks;
|
||||
for (Q3ListViewItemIterator it(m_listView); it.current() != 0; ++it) {
|
||||
if (!it.current()->isSelected())
|
||||
continue;
|
||||
if(it.current() == m_listView->firstChild()) // root case
|
||||
continue;
|
||||
if (it.current()->childCount() == 0) // non folder case
|
||||
bookmarks.append(static_cast<KEBListViewItem *>(it.current())->bookmark());
|
||||
else
|
||||
selectedBookmarksExpandedHelper(static_cast<KEBListViewItem *>(it.current()), bookmarks);
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
void ListView::selectedBookmarksExpandedHelper(KEBListViewItem * item, Q3ValueList<KBookmark> & bookmarks) const
|
||||
{
|
||||
KEBListViewItem* child = static_cast<KEBListViewItem *>(item->firstChild());
|
||||
while( child )
|
||||
{
|
||||
if (!child->isEmptyFolderPadder() && (child->childCount() == 0))
|
||||
bookmarks.append(child->bookmark());
|
||||
if(child->childCount())
|
||||
selectedBookmarksExpandedHelper(child, bookmarks);
|
||||
child = static_cast<KEBListViewItem *>(child->nextSibling());
|
||||
}
|
||||
}
|
||||
|
||||
Q3ValueList<KBookmark> ListView::allBookmarks() const {
|
||||
Q3ValueList<KBookmark> bookmarks;
|
||||
for (Q3ListViewItemIterator it(m_listView); it.current() != 0; ++it)
|
||||
{
|
||||
KEBListViewItem * item = static_cast<KEBListViewItem *>(it.current());
|
||||
if (!item->isEmptyFolderPadder() && (item->childCount() == 0))
|
||||
bookmarks.append(static_cast<KEBListViewItem *>(it.current())->bookmark());
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
// DESIGN - make + "/0" a kbookmark:: thing?
|
||||
|
||||
QString ListView::userAddress() const
|
||||
{
|
||||
KBookmark current = firstSelected()->bookmark();
|
||||
return (current.isGroup())
|
||||
? (current.address() + "/0") //FIXME internal represantation used
|
||||
: KBookmark::nextAddress(current.address());
|
||||
}
|
||||
|
||||
void ListView::setCurrent(KEBListViewItem *item, bool select) {
|
||||
m_listView->setCurrentItem(item);
|
||||
if(select)
|
||||
{
|
||||
m_listView->clearSelection();
|
||||
m_listView->setSelected(item, true);
|
||||
}
|
||||
}
|
||||
|
||||
KEBListViewItem* ListView::getItemAtAddress(const QString &address) const {
|
||||
//FIXME uses internal represantation of bookmark address
|
||||
Q3ListViewItem *item = m_listView->rootItem();
|
||||
|
||||
QStringList addresses = QStringList::split('/',address); // e.g /5/10/2
|
||||
|
||||
for (QStringList::Iterator it = addresses.begin(); it != addresses.end(); ++it) {
|
||||
if (item = item->firstChild(), !item)
|
||||
return 0;
|
||||
for (unsigned int i = 0; i < (*it).toUInt(); ++i)
|
||||
if (item = item->nextSibling(), !item)
|
||||
return 0;
|
||||
}
|
||||
return static_cast<KEBListViewItem *>(item);
|
||||
}
|
||||
|
||||
void ListView::setOpen(bool open) {
|
||||
for (Q3ListViewItemIterator it(m_listView); it.current() != 0; ++it)
|
||||
if (it.current()->parent())
|
||||
it.current()->setOpen(open);
|
||||
}
|
||||
|
||||
SelcAbilities ListView::getSelectionAbilities() const {
|
||||
SelcAbilities sa = { false, false, false, false, false, false, false, false, false };
|
||||
|
||||
if (mSelectedItems.count() > 0) {
|
||||
KBookmark nbk = firstSelected()->bookmark();
|
||||
sa.itemSelected = true;
|
||||
sa.group = nbk.isGroup();
|
||||
sa.separator = nbk.isSeparator();
|
||||
sa.urlIsEmpty = nbk.url().isEmpty();
|
||||
sa.root = (firstSelected() == m_listView->rootItem());
|
||||
sa.multiSelect = (mSelectedItems.count() > 1);
|
||||
sa.singleSelect = (!sa.multiSelect && sa.itemSelected);
|
||||
sa.tbShowState = CmdGen::shownInToolbar(nbk);
|
||||
}
|
||||
|
||||
sa.notEmpty = (m_listView->rootItem()->childCount() > 0);
|
||||
|
||||
return sa;
|
||||
}
|
||||
|
||||
void ListView::handleDropped(KEBListView *, QDropEvent *e, Q3ListViewItem *newParent, Q3ListViewItem *itemAfterQLVI) {
|
||||
bool inApp = (e->source() == m_listView->viewport());
|
||||
|
||||
// drop before root item
|
||||
|
@ -409,348 +47,12 @@ void ListView::handleDropped(KEBListView *, QDropEvent *e, Q3ListViewItem *newPa
|
|||
}
|
||||
|
||||
CmdHistory::self()->didCommand(mcmd);
|
||||
|
||||
}
|
||||
|
||||
void ListView::updateStatus(QString url) {
|
||||
m_listView->updateByURL(url);
|
||||
}
|
||||
|
||||
void ListView::updateListView()
|
||||
{
|
||||
// this is upper border of the visible are
|
||||
int lastCurrentY = m_listView->contentsY();
|
||||
|
||||
//Save selected items (restored in fillWithGroup)
|
||||
s_selected_addresses.clear();
|
||||
QMap<KEBListViewItem *, bool>::const_iterator it, end;
|
||||
it = mSelectedItems.begin();
|
||||
end = mSelectedItems.end();
|
||||
for ( ; it != end; ++it)
|
||||
s_selected_addresses << it.key()->bookmark().address();
|
||||
if(m_listView->currentItem())
|
||||
{
|
||||
KEBListViewItem * item = static_cast<KEBListViewItem*>(m_listView->currentItem());
|
||||
if(item->isEmptyFolderPadder())
|
||||
s_current_address = static_cast<KEBListViewItem*>(item->parent())->bookmark().address();
|
||||
else
|
||||
s_current_address = item->bookmark().address();
|
||||
}
|
||||
else
|
||||
s_current_address = QString::null;
|
||||
|
||||
updateTree();
|
||||
m_searchline->updateSearch();
|
||||
|
||||
// ensureVisible wants to have the midpoint of the new visible area
|
||||
m_listView->ensureVisible(0, lastCurrentY + m_listView->visibleHeight() / 2, 0, m_listView->visibleHeight() / 2 );
|
||||
}
|
||||
|
||||
void ListView::updateTree() {
|
||||
KBookmarkGroup root = CurrentMgr::self()->mgr()->root();
|
||||
fillWithGroup(m_listView, root);
|
||||
}
|
||||
|
||||
void ListView::fillWithGroup(KEBListView *lv, KBookmarkGroup group, KEBListViewItem *parentItem) {
|
||||
KEBListViewItem *lastItem = 0;
|
||||
if (!parentItem)
|
||||
{
|
||||
lv->clear();
|
||||
KEBListViewItem *tree = new KEBListViewItem(lv, group);
|
||||
fillWithGroup(lv, group, tree);
|
||||
tree->Q3ListViewItem::setOpen(true);
|
||||
if (s_selected_addresses.contains(tree->bookmark().address()))
|
||||
lv->setSelected(tree, true);
|
||||
if(!s_current_address.isNull() && s_current_address == tree->bookmark().address())
|
||||
lv->setCurrentItem(tree);
|
||||
return;
|
||||
}
|
||||
for (KBookmark bk = group.first(); !bk.isNull(); bk = group.next(bk)) {
|
||||
KEBListViewItem *item = 0;
|
||||
if (bk.isGroup()) {
|
||||
KBookmarkGroup grp = bk.toGroup();
|
||||
item = (parentItem)
|
||||
? new KEBListViewItem(parentItem, lastItem, grp)
|
||||
: new KEBListViewItem(lv, lastItem, grp);
|
||||
fillWithGroup(lv, grp, item);
|
||||
if (grp.isOpen())
|
||||
item->Q3ListViewItem::setOpen(true);
|
||||
if (grp.first().isNull())
|
||||
new KEBListViewItem(item, item); // empty folder
|
||||
lastItem = item;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
item = (parentItem)
|
||||
? ( (lastItem)
|
||||
? new KEBListViewItem(parentItem, lastItem, bk)
|
||||
: new KEBListViewItem(parentItem, bk))
|
||||
: ( (lastItem)
|
||||
? new KEBListViewItem(lv, lastItem, bk)
|
||||
: new KEBListViewItem(lv, bk));
|
||||
lastItem = item;
|
||||
}
|
||||
if (s_selected_addresses.contains(bk.address()))
|
||||
lv->setSelected(item, true);
|
||||
if(!s_current_address.isNull() && s_current_address == bk.address())
|
||||
lv->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ListView::handleMoved(KEBListView *) {
|
||||
// kdDebug() << "ListView::handleMoved()" << endl;
|
||||
/* TODO - neil's wishlist item - unfortunately handleMoved is not called sometimes...
|
||||
* KMacroCommand *mcmd = CmdGen::self()->deleteItems( i18n("Moved Items"),
|
||||
* ListView::self()->selectedItems());
|
||||
* CmdHistory::self()->didCommand(mcmd);
|
||||
*/
|
||||
}
|
||||
|
||||
void ListView::slotBkInfoUpdateListViewItem() {
|
||||
// its not possible that the selection changed inbetween as
|
||||
// handleSelectionChanged is the one that sets up bkInfo()
|
||||
// to emit this signal, otoh. maybe this can cause various
|
||||
// differing responses.
|
||||
// kdDebug() << "slotBkInfoUpdateListViewItem()" << endl;
|
||||
KEBListViewItem *i = firstSelected();
|
||||
Q_ASSERT(i);
|
||||
KBookmark bk = i->bookmark();
|
||||
i->setText(KEBListView::NameColumn, bk.fullText());
|
||||
i->setText(KEBListView::UrlColumn, bk.url().pathOrURL());
|
||||
QString commentStr = NodeEditCommand::getNodeText(bk, QStringList() << "desc");
|
||||
i->setText(KEBListView::CommentColumn, commentStr);
|
||||
}
|
||||
|
||||
void ListView::handleContextMenu(KEBListView *, KListView *, Q3ListViewItem *qitem, const QPoint &p) {
|
||||
KEBListViewItem *item = static_cast<KEBListViewItem *>(qitem);
|
||||
const char *type = ( !item
|
||||
|| (item == m_listView->rootItem())
|
||||
|| (item->bookmark().isGroup())
|
||||
|| (item->isEmptyFolderPadder()))
|
||||
? "popup_folder" : "popup_bookmark";
|
||||
QWidget* popup = KEBApp::self()->popupMenuFactory(type);
|
||||
if (popup)
|
||||
static_cast<Q3PopupMenu*>(popup)->popup(p);
|
||||
}
|
||||
|
||||
void ListView::handleDoubleClicked(KEBListView *lv, Q3ListViewItem *item, const QPoint &, int column) {
|
||||
lv->rename(item, column);
|
||||
}
|
||||
|
||||
void ListView::handleItemRenamed(KEBListView *lv, Q3ListViewItem *item, const QString &newText, int column) {
|
||||
Q_ASSERT(item);
|
||||
KBookmark bk = static_cast<KEBListViewItem *>(item)->bookmark();
|
||||
KCommand *cmd = 0;
|
||||
if (column == KEBListView::NameColumn) {
|
||||
if (newText.isEmpty()) {
|
||||
// can't have an empty name, therefore undo the user action
|
||||
item->setText(KEBListView::NameColumn, bk.fullText());
|
||||
} else if (bk.fullText() != newText) {
|
||||
cmd = new NodeEditCommand(bk.address(), newText, "title");
|
||||
}
|
||||
|
||||
} else if (column == KEBListView::UrlColumn && !lv->isFolderList()) {
|
||||
if (bk.url().pathOrURL() != newText)
|
||||
{
|
||||
KURL u = KURL::fromPathOrURL(newText);
|
||||
cmd = new EditCommand(bk.address(), EditCommand::Edition("href", u.url(0, 106)), i18n("URL"));
|
||||
}
|
||||
|
||||
} else if (column == KEBListView::CommentColumn && !lv->isFolderList()) {
|
||||
if (NodeEditCommand::getNodeText(bk, QStringList() << "desc") != newText)
|
||||
cmd = new NodeEditCommand(bk.address(), newText, "desc");
|
||||
}
|
||||
CmdHistory::self()->addCommand(cmd);
|
||||
}
|
||||
|
||||
// used by f2 and f3 shortcut slots - see actionsimpl
|
||||
void ListView::rename(int column) {
|
||||
m_listView->rename(firstSelected(), column);
|
||||
}
|
||||
|
||||
void ListView::clearSelection() {
|
||||
m_listView->clearSelection();
|
||||
}
|
||||
|
||||
void ListView::startRename(int column, KEBListViewItem *item) {
|
||||
s_myrenamecolumn = column;
|
||||
s_myrenameitem = item;
|
||||
}
|
||||
|
||||
void ListView::renameNextCell(bool fwd) {
|
||||
KEBListView *lv = m_listView;
|
||||
while (1) {
|
||||
if (fwd && s_myrenamecolumn < KEBListView::CommentColumn) {
|
||||
s_myrenamecolumn++;
|
||||
} else if (!fwd && s_myrenamecolumn > KEBListView::NameColumn) {
|
||||
s_myrenamecolumn--;
|
||||
} else {
|
||||
s_myrenameitem =
|
||||
static_cast<KEBListViewItem *>(
|
||||
fwd ? ( s_myrenameitem->itemBelow()
|
||||
? s_myrenameitem->itemBelow() : lv->firstChild() )
|
||||
: ( s_myrenameitem->itemAbove()
|
||||
? s_myrenameitem->itemAbove() : lv->lastItem() ) );
|
||||
s_myrenamecolumn
|
||||
= fwd ? KEBListView::NameColumn
|
||||
: KEBListView::CommentColumn;
|
||||
}
|
||||
if (s_myrenameitem
|
||||
&& s_myrenameitem != m_listView->rootItem()
|
||||
&& !s_myrenameitem->isEmptyFolderPadder()
|
||||
&& !s_myrenameitem->bookmark().isSeparator()
|
||||
&& !(s_myrenamecolumn == KEBListView::UrlColumn && s_myrenameitem->bookmark().isGroup())
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
lv->rename(s_myrenameitem, s_myrenamecolumn);
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
class KeyPressEater : public QObject {
|
||||
public:
|
||||
KeyPressEater( QWidget *parent = 0, const char *name = 0 )
|
||||
: QObject(parent, name) {
|
||||
m_allowedToTab = true;
|
||||
}
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
bool m_allowedToTab;
|
||||
};
|
||||
|
||||
bool KeyPressEater::eventFilter(QObject *, QEvent *pe) {
|
||||
if (pe->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *k = (QKeyEvent *) pe;
|
||||
if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab)
|
||||
&& !(k->state() & Qt::ControlModifier || k->state() & Qt::AltModifier)
|
||||
) {
|
||||
if (m_allowedToTab) {
|
||||
bool fwd = (k->key() == Qt::Key_Tab && !(k->state() & Qt::ShiftModifier));
|
||||
ListView::self()->renameNextCell(fwd);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
m_allowedToTab = (k->key() == Qt::Key_Escape || k->key() == Qt::Key_Enter);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
void KEBListView::loadColumnSetting()
|
||||
{
|
||||
header()->resizeSection(KEBListView::NameColumn, KEBSettings::name());
|
||||
header()->resizeSection(KEBListView::UrlColumn, KEBSettings::uRL());
|
||||
header()->resizeSection(KEBListView::CommentColumn, KEBSettings::comment());
|
||||
header()->resizeSection(KEBListView::StatusColumn, KEBSettings::status());
|
||||
#ifdef DEBUG_ADDRESSES
|
||||
header()->resizeSection(KEBListView::AddressColumn, KEBSettings::address());
|
||||
#endif
|
||||
m_widthsDirty = false;
|
||||
}
|
||||
|
||||
void KEBListView::saveColumnSetting ()
|
||||
{
|
||||
if (m_widthsDirty) {
|
||||
KEBSettings::setName( header()->sectionSize(KEBListView::NameColumn));
|
||||
KEBSettings::setURL( header()->sectionSize(KEBListView::UrlColumn));
|
||||
KEBSettings::setComment( header()->sectionSize(KEBListView::CommentColumn));
|
||||
KEBSettings::setStatus( header()->sectionSize(KEBListView::StatusColumn));
|
||||
#ifdef DEBUG_ADDRESSES
|
||||
KEBSettings::setAddress( header()->sectionSize(KEBListView::AddressColumn));
|
||||
#endif
|
||||
KEBSettings::writeConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void KEBListView::slotColumnSizeChanged(int, int, int)
|
||||
{
|
||||
m_widthsDirty = true;
|
||||
}
|
||||
|
||||
void KEBListView::init() {
|
||||
setRootIsDecorated(false);
|
||||
if (!m_folderList) {
|
||||
addColumn(i18n("Bookmark"), 0); // KEBListView::NameColumn
|
||||
addColumn(i18n("URL"), 0);
|
||||
addColumn(i18n("Comment"), 0);
|
||||
addColumn(i18n("Status"), 0);
|
||||
#ifdef DEBUG_ADDRESSES
|
||||
addColumn(i18n("Address"), 0);
|
||||
#endif
|
||||
} else {
|
||||
addColumn(i18n("Folder"), 0);
|
||||
}
|
||||
loadColumnSetting();
|
||||
setRenameable(KEBListView::NameColumn);
|
||||
setRenameable(KEBListView::UrlColumn);
|
||||
setRenameable(KEBListView::CommentColumn);
|
||||
setTabOrderedRenaming(false);
|
||||
setSorting(-1, false);
|
||||
setDragEnabled(true);
|
||||
setSelectionModeExt((!m_folderList) ? KListView::Extended: KListView::Single);
|
||||
setAllColumnsShowFocus(true);
|
||||
connect(header(), SIGNAL(sizeChange(int, int, int)),
|
||||
this, SLOT(slotColumnSizeChanged(int, int, int)));
|
||||
}
|
||||
|
||||
void KEBListView::makeConnections() {
|
||||
connect(this, SIGNAL( moved() ),
|
||||
SLOT( slotMoved() ));
|
||||
connect(this, SIGNAL( contextMenu(KListView *, Q3ListViewItem*, const QPoint &) ),
|
||||
SLOT( slotContextMenu(KListView *, Q3ListViewItem *, const QPoint &) ));
|
||||
connect(this, SIGNAL( itemRenamed(Q3ListViewItem *, const QString &, int) ),
|
||||
SLOT( slotItemRenamed(Q3ListViewItem *, const QString &, int) ));
|
||||
connect(this, SIGNAL( doubleClicked(Q3ListViewItem *, const QPoint &, int) ),
|
||||
SLOT( slotDoubleClicked(Q3ListViewItem *, const QPoint &, int) ));
|
||||
connect(this, SIGNAL( dropped(QDropEvent*, Q3ListViewItem*, Q3ListViewItem*) ),
|
||||
SLOT( slotDropped(QDropEvent*, Q3ListViewItem*, Q3ListViewItem*) ));
|
||||
}
|
||||
|
||||
void KEBListView::readonlyFlagInit(bool readonly) {
|
||||
setItemsMovable(readonly); // we move items ourselves (for undo)
|
||||
setItemsRenameable(!readonly);
|
||||
setAcceptDrops(!readonly);
|
||||
setDropVisualizer(!readonly);
|
||||
}
|
||||
|
||||
void KEBListView::slotMoved()
|
||||
{ ListView::self()->handleMoved(this); }
|
||||
void KEBListView::slotContextMenu(KListView *a, Q3ListViewItem *b, const QPoint &c)
|
||||
{ ListView::self()->handleContextMenu(this, a,b,c); }
|
||||
void KEBListView::slotItemRenamed(Q3ListViewItem *a, const QString &b, int c)
|
||||
{ ListView::self()->handleItemRenamed(this, a,b,c); }
|
||||
void KEBListView::slotDoubleClicked(Q3ListViewItem *a, const QPoint &b, int c)
|
||||
{ ListView::self()->handleDoubleClicked(this, a,b,c); }
|
||||
void KEBListView::slotDropped(QDropEvent *a, Q3ListViewItem *b, Q3ListViewItem *c)
|
||||
{ ListView::self()->handleDropped(this, a,b,c); }
|
||||
|
||||
void KEBListView::rename(Q3ListViewItem *qitem, int column) {
|
||||
KEBListViewItem *item = static_cast<KEBListViewItem *>(qitem);
|
||||
if ( !(column == NameColumn || column == UrlColumn || column == CommentColumn)
|
||||
|| KEBApp::self()->readonly()
|
||||
|| !item
|
||||
|| item == firstChild()
|
||||
|| item->isEmptyFolderPadder()
|
||||
|| item->bookmark().isSeparator()
|
||||
|| (column == UrlColumn && item->bookmark().isGroup())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
ListView::startRename(column, item);
|
||||
KeyPressEater *keyPressEater = new KeyPressEater(this);
|
||||
renameLineEdit()->installEventFilter(keyPressEater);
|
||||
KListView::rename(item, column);
|
||||
}
|
||||
|
||||
KEBListViewItem* KEBListView::rootItem() const {
|
||||
return static_cast<KEBListViewItem *>(firstChild());
|
||||
}
|
||||
*/
|
||||
|
||||
// Update display of bookmarks containing URL
|
||||
/*
|
||||
void KEBListView::updateByURL(QString url) {
|
||||
for (Q3ListViewItemIterator it(this); it.current(); it++) {
|
||||
KEBListViewItem *p = static_cast<KEBListViewItem *>(it.current());
|
||||
|
@ -759,11 +61,14 @@ void KEBListView::updateByURL(QString url) {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
bool KEBListView::acceptDrag(QDropEvent * e) const {
|
||||
/*bool KEBListView::acceptDrag(QDropEvent * e) const {
|
||||
return (e->source() == viewport() || KBookmarkDrag::canDecode(e));
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
Q3DragObject *KEBListView::dragObject() {
|
||||
Q3ValueList<KBookmark> bookmarks =
|
||||
ListView::self()->itemsToBookmarks(ListView::self()->selectedItemsMap());
|
||||
|
@ -772,172 +77,6 @@ Q3DragObject *KEBListView::dragObject() {
|
|||
(bookmarks.size() == 1) ? bookmarks.first().icon() : QString("bookmark");
|
||||
drag->setPixmap(SmallIcon(iconname)) ;
|
||||
return drag;
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
||||
bool KEBListViewItem::parentSelected(Q3ListViewItem * item)
|
||||
{
|
||||
Q3ListViewItem *root = item->listView()->firstChild();
|
||||
for( Q3ListViewItem *parent = item->parent(); parent ; parent = parent->parent())
|
||||
if (parent->isSelected() && parent != root)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void KEBListViewItem::setSelected(bool s)
|
||||
{
|
||||
if( isEmptyFolderPadder())
|
||||
{
|
||||
parent()->setSelected(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(listView()->firstChild() == this)
|
||||
{
|
||||
ListView::self()->selected(this, s);
|
||||
Q3ListViewItem::setSelected( s );
|
||||
return;
|
||||
}
|
||||
|
||||
if(s == false)
|
||||
{
|
||||
ListView::self()->selected(this, false);
|
||||
Q3ListViewItem::setSelected( false );
|
||||
ListView::deselectAllChildren( this ); //repaints
|
||||
}
|
||||
else if(parentSelected(this))
|
||||
return;
|
||||
else
|
||||
{
|
||||
ListView::self()->selected(this, true);
|
||||
Q3ListViewItem::setSelected( true );
|
||||
ListView::deselectAllChildren(this);
|
||||
}
|
||||
}
|
||||
|
||||
void KEBListViewItem::normalConstruct(const KBookmark &bk) {
|
||||
#ifdef DEBUG_ADDRESSES
|
||||
setText(KEBListView::AddressColumn, bk.address());
|
||||
#endif
|
||||
setText(KEBListView::CommentColumn, NodeEditCommand::getNodeText(bk, QStringList() << "desc"));
|
||||
bool shown = CmdGen::shownInToolbar(bk);
|
||||
setPixmap(0, SmallIcon(shown ? QString("bookmark_toolbar") : bk.icon()));
|
||||
// DESIGN - modUpdate badly needs a redesign
|
||||
modUpdate();
|
||||
}
|
||||
|
||||
// DESIGN - following constructors should be names classes or else just explicit
|
||||
|
||||
// toplevel item (there should be only one!)
|
||||
KEBListViewItem::KEBListViewItem(Q3ListView *parent, const KBookmarkGroup &gp)
|
||||
: Q3ListViewItem(parent, KEBApp::self()->caption().isNull()
|
||||
? i18n("Bookmarks")
|
||||
: i18n("%1 Bookmarks").arg(KEBApp::self()->caption())),
|
||||
m_bookmark(gp), m_emptyFolderPadder(false) {
|
||||
|
||||
setPixmap(0, SmallIcon("bookmark"));
|
||||
setExpandable(true);
|
||||
}
|
||||
|
||||
// empty folder item
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, Q3ListViewItem *after)
|
||||
: Q3ListViewItem(parent, after, i18n("Empty Folder") ), m_emptyFolderPadder(true) {
|
||||
setPixmap(0, SmallIcon("bookmark"));
|
||||
}
|
||||
|
||||
// group
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, Q3ListViewItem *after, const KBookmarkGroup &gp)
|
||||
: Q3ListViewItem(parent, after, gp.fullText()), m_bookmark(gp), m_emptyFolderPadder(false) {
|
||||
setExpandable(true);
|
||||
normalConstruct(gp);
|
||||
}
|
||||
|
||||
// bookmark (first of its group)
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, const KBookmark & bk)
|
||||
: Q3ListViewItem(parent, bk.fullText(), bk.url().pathOrURL()), m_bookmark(bk), m_emptyFolderPadder(false) {
|
||||
normalConstruct(bk);
|
||||
}
|
||||
|
||||
// bookmark (after another)
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, Q3ListViewItem *after, const KBookmark &bk)
|
||||
: Q3ListViewItem(parent, after, bk.fullText(), bk.url().pathOrURL()), m_bookmark(bk), m_emptyFolderPadder(false) {
|
||||
normalConstruct(bk);
|
||||
}
|
||||
|
||||
// root bookmark (first of its group)
|
||||
KEBListViewItem::KEBListViewItem(Q3ListView *parent, const KBookmark & bk)
|
||||
: Q3ListViewItem(parent, bk.fullText(), bk.url().pathOrURL()), m_bookmark(bk), m_emptyFolderPadder(false) {
|
||||
normalConstruct(bk);
|
||||
}
|
||||
|
||||
// root bookmark (after another)
|
||||
KEBListViewItem::KEBListViewItem(Q3ListView *parent, Q3ListViewItem *after, const KBookmark &bk)
|
||||
: Q3ListViewItem(parent, after, bk.fullText(), bk.url().pathOrURL()), m_bookmark(bk), m_emptyFolderPadder(false) {
|
||||
normalConstruct(bk);
|
||||
}
|
||||
|
||||
// DESIGN - move this into kbookmark or into a helper
|
||||
void KEBListViewItem::setOpen(bool open) {
|
||||
if (!parent())
|
||||
return;
|
||||
m_bookmark.internalElement().setAttribute("folded", open ? "no" : "yes");
|
||||
Q3ListViewItem::setOpen(open);
|
||||
}
|
||||
|
||||
void KEBListViewItem::greyStyle(QColorGroup &cg) {
|
||||
int h, s, v;
|
||||
cg.background().hsv(&h, &s, &v);
|
||||
QColor color = (v > 180 && v < 220) ? (Qt::darkGray) : (Qt::gray);
|
||||
cg.setColor(QColorGroup::Text, color);
|
||||
}
|
||||
|
||||
void KEBListViewItem::boldStyle(QPainter *p) {
|
||||
QFont font = p->font();
|
||||
font.setBold(true);
|
||||
p->setFont(font);
|
||||
}
|
||||
|
||||
void KEBListViewItem::paintCell(QPainter *p, const QColorGroup &ocg, int col, int w, int a) {
|
||||
QColorGroup cg(ocg);
|
||||
if (parentSelected(this)) {
|
||||
int base_h, base_s, base_v;
|
||||
cg.background().hsv(&base_h, &base_s, &base_v);
|
||||
|
||||
int hilite_h, hilite_s, hilite_v;
|
||||
cg.highlight().hsv(&hilite_h, &hilite_s, &hilite_v);
|
||||
|
||||
QColor col(hilite_h,
|
||||
(hilite_s + base_s + base_s ) / 3,
|
||||
(hilite_v + base_v + base_v ) / 3,
|
||||
QColor::Hsv);
|
||||
cg.setColor(QColorGroup::Base, col);
|
||||
}
|
||||
|
||||
if (col == KEBListView::StatusColumn) {
|
||||
switch (m_paintStyle) {
|
||||
case KEBListViewItem::GreyStyle:
|
||||
{
|
||||
greyStyle(cg);
|
||||
break;
|
||||
}
|
||||
case KEBListViewItem::BoldStyle:
|
||||
{
|
||||
boldStyle(p);
|
||||
break;
|
||||
}
|
||||
case KEBListViewItem::GreyBoldStyle:
|
||||
{
|
||||
greyStyle(cg);
|
||||
boldStyle(p);
|
||||
break;
|
||||
}
|
||||
case KEBListViewItem::DefaultStyle:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Q3ListViewItem::paintCell(p, cg, col, w,a);
|
||||
}
|
||||
|
||||
#include "listview.moc"
|
||||
*/
|
||||
|
|
|
@ -19,202 +19,4 @@
|
|||
|
||||
#ifndef __listview_h
|
||||
#define __listview_h
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <q3listview.h>
|
||||
//Added by qt3to4:
|
||||
#include <Q3ValueList>
|
||||
#include <QDropEvent>
|
||||
#include <Q3PtrList>
|
||||
#include <QMap>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kbookmark.h>
|
||||
#include <klistview.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include "toplevel.h"
|
||||
|
||||
class QSplitter;
|
||||
class KListViewSearchLine;
|
||||
|
||||
class KEBListViewItem : public Q3ListViewItem
|
||||
{
|
||||
public:
|
||||
KEBListViewItem(Q3ListView *, const KBookmarkGroup &);
|
||||
KEBListViewItem(KEBListViewItem *, Q3ListViewItem *);
|
||||
KEBListViewItem(KEBListViewItem *, Q3ListViewItem *, const KBookmarkGroup &);
|
||||
KEBListViewItem(KEBListViewItem *, const KBookmark &);
|
||||
KEBListViewItem(KEBListViewItem *, Q3ListViewItem *, const KBookmark &);
|
||||
|
||||
KEBListViewItem(Q3ListView *, const KBookmark &);
|
||||
KEBListViewItem(Q3ListView *, Q3ListViewItem *, const KBookmark &);
|
||||
|
||||
void nsPut(const QString &nm);
|
||||
|
||||
void modUpdate();
|
||||
|
||||
void setOldStatus(const QString &);
|
||||
void setTmpStatus(const QString &);
|
||||
void restoreStatus();
|
||||
|
||||
void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment);
|
||||
void setSelected ( bool s );
|
||||
|
||||
virtual void setOpen(bool);
|
||||
|
||||
bool isEmptyFolderPadder() const { return m_emptyFolderPadder; }
|
||||
const KBookmark bookmark() const { return m_bookmark; }
|
||||
|
||||
typedef enum { GreyStyle, BoldStyle, GreyBoldStyle, DefaultStyle } PaintStyle;
|
||||
|
||||
static bool parentSelected(Q3ListViewItem * item);
|
||||
|
||||
private:
|
||||
const QString nsGet() const;
|
||||
void normalConstruct(const KBookmark &);
|
||||
|
||||
KBookmark m_bookmark;
|
||||
PaintStyle m_paintStyle;
|
||||
bool m_emptyFolderPadder;
|
||||
QString m_oldStatus;
|
||||
void greyStyle(QColorGroup &);
|
||||
void boldStyle(QPainter *);
|
||||
};
|
||||
|
||||
class KEBListView : public KListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {
|
||||
NameColumn = 0,
|
||||
UrlColumn = 1,
|
||||
CommentColumn = 2,
|
||||
StatusColumn = 3,
|
||||
AddressColumn = 4
|
||||
};
|
||||
KEBListView(QWidget *parent, bool folderList)
|
||||
: KListView(parent), m_folderList(folderList) {}
|
||||
virtual ~KEBListView() {}
|
||||
|
||||
void init();
|
||||
void makeConnections();
|
||||
void readonlyFlagInit(bool);
|
||||
|
||||
void loadColumnSetting();
|
||||
void saveColumnSetting();
|
||||
|
||||
void updateByURL(QString url);
|
||||
|
||||
bool isFolderList() const { return m_folderList; }
|
||||
|
||||
KEBListViewItem* rootItem() const;
|
||||
|
||||
public slots:
|
||||
virtual void rename(Q3ListViewItem *item, int c);
|
||||
void slotMoved();
|
||||
void slotContextMenu(KListView *, Q3ListViewItem *, const QPoint &);
|
||||
void slotItemRenamed(Q3ListViewItem *, const QString &, int);
|
||||
void slotDoubleClicked(Q3ListViewItem *, const QPoint &, int);
|
||||
void slotDropped(QDropEvent*, Q3ListViewItem*, Q3ListViewItem*);
|
||||
void slotColumnSizeChanged(int, int, int);
|
||||
|
||||
protected:
|
||||
virtual bool acceptDrag(QDropEvent *e) const;
|
||||
virtual Q3DragObject* dragObject();
|
||||
|
||||
private:
|
||||
bool m_folderList;
|
||||
bool m_widthsDirty;
|
||||
};
|
||||
|
||||
// DESIGN - make some stuff private if possible
|
||||
class ListView : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// init stuff
|
||||
void initListViews();
|
||||
void updateListViewSetup(bool readOnly);
|
||||
void connectSignals();
|
||||
void setSearchLine(KListViewSearchLine * searchline) { m_searchline = searchline; };
|
||||
|
||||
// selected item stuff
|
||||
void selected(KEBListViewItem * item, bool s);
|
||||
|
||||
void invalidate(const QString & address);
|
||||
void invalidate(Q3ListViewItem * item);
|
||||
void fixUpCurrent(const QString & address);
|
||||
|
||||
KEBListViewItem * firstSelected() const;
|
||||
QMap<KEBListViewItem *, bool> selectedItemsMap() const
|
||||
{ return mSelectedItems; }
|
||||
Q3ValueList<QString> selectedAddresses();
|
||||
|
||||
// bookmark helpers
|
||||
Q3ValueList<KBookmark> itemsToBookmarks(const QMap<KEBListViewItem *, bool> & items) const;
|
||||
|
||||
// bookmark stuff
|
||||
Q3ValueList<KBookmark> allBookmarks() const;
|
||||
Q3ValueList<KBookmark> selectedBookmarksExpanded() const;
|
||||
|
||||
// address stuff
|
||||
KEBListViewItem* getItemAtAddress(const QString &address) const;
|
||||
QString userAddress() const;
|
||||
|
||||
// gui stuff - DESIGN - all of it???
|
||||
SelcAbilities getSelectionAbilities() const;
|
||||
|
||||
void updateListView();
|
||||
void setOpen(bool open); // DESIGN -rename to setAllOpenFlag
|
||||
void setCurrent(KEBListViewItem *item, bool select);
|
||||
void renameNextCell(bool dir);
|
||||
|
||||
QWidget *widget() const { return m_listView; }
|
||||
void rename(int);
|
||||
void clearSelection();
|
||||
|
||||
void updateStatus(QString url);
|
||||
|
||||
static ListView* self() { return s_self; }
|
||||
static void createListViews(QSplitter *parent);
|
||||
|
||||
void handleMoved(KEBListView *);
|
||||
void handleDropped(KEBListView *, QDropEvent *, Q3ListViewItem *, Q3ListViewItem *);
|
||||
void handleContextMenu(KEBListView *, KListView *, Q3ListViewItem *, const QPoint &);
|
||||
void handleDoubleClicked(KEBListView *, Q3ListViewItem *, const QPoint &, int);
|
||||
void handleItemRenamed(KEBListView *, Q3ListViewItem *, const QString &, int);
|
||||
|
||||
static void startRename(int column, KEBListViewItem *item);
|
||||
|
||||
static void deselectAllChildren(KEBListViewItem *item);
|
||||
|
||||
~ListView();
|
||||
|
||||
public slots:
|
||||
void slotBkInfoUpdateListViewItem();
|
||||
|
||||
private:
|
||||
void updateTree();
|
||||
void selectedBookmarksExpandedHelper(KEBListViewItem * item, Q3ValueList<KBookmark> & bookmarks) const;
|
||||
void fillWithGroup(KEBListView *, KBookmarkGroup, KEBListViewItem * = 0);
|
||||
|
||||
ListView();
|
||||
|
||||
KEBListView *m_listView;
|
||||
KListViewSearchLine * m_searchline;
|
||||
|
||||
// Actually this is a std:set, the bool is ignored
|
||||
QMap<KEBListViewItem *, bool> mSelectedItems;
|
||||
bool m_needToFixUp;
|
||||
|
||||
// statics
|
||||
static ListView *s_self;
|
||||
static int s_myrenamecolumn;
|
||||
static KEBListViewItem *s_myrenameitem;
|
||||
static QStringList s_selected_addresses;
|
||||
static QString s_current_address;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <kbookmarkmanager.h>
|
||||
|
||||
#include <kaction.h>
|
||||
#include <klocale.h>
|
||||
|
||||
TestLinkItrHolder *TestLinkItrHolder::s_self = 0;
|
||||
|
||||
|
@ -65,15 +66,15 @@ void TestLinkItrHolder::addAffectedBookmark( const QString & address )
|
|||
|
||||
/* -------------------------- */
|
||||
|
||||
TestLinkItr::TestLinkItr(Q3ValueList<KBookmark> bks)
|
||||
TestLinkItr::TestLinkItr(QVector<KBookmark> bks)
|
||||
: BookmarkIterator(bks) {
|
||||
m_job = 0;
|
||||
}
|
||||
|
||||
TestLinkItr::~TestLinkItr() {
|
||||
//FIXME set status
|
||||
if (m_job) {
|
||||
// kdDebug() << "JOB kill\n";
|
||||
curItem()->restoreStatus();
|
||||
m_job->disconnect();
|
||||
m_job->kill(false);
|
||||
}
|
||||
|
@ -95,9 +96,9 @@ void TestLinkItr::doAction() {
|
|||
connect(m_job, SIGNAL( data( KIO::Job *, const QByteArray &)),
|
||||
this, SLOT( slotJobData(KIO::Job *, const QByteArray &)));
|
||||
|
||||
curItem()->setTmpStatus(i18n("Checking..."));
|
||||
//FIXME curItem()->setTmpStatus(i18n("Checking..."));
|
||||
QString oldModDate = TestLinkItrHolder::self()->getMod(curBk().url().url());
|
||||
curItem()->setOldStatus(oldModDate);
|
||||
//FIXME curItem()->setOldStatus(oldModDate);
|
||||
TestLinkItrHolder::self()->setMod(curBk().url().url(), i18n("Checking..."));
|
||||
}
|
||||
|
||||
|
@ -116,7 +117,7 @@ void TestLinkItr::slotJobData(KIO::Job *job, const QByteArray &data) {
|
|||
// print the first line of the <title>
|
||||
leftover = leftover.left(close_pos);
|
||||
}
|
||||
curItem()->nsPut(KCharsets::resolveEntities(leftover));
|
||||
//FIXME curItem()->nsPut(KCharsets::resolveEntities(leftover));
|
||||
m_errSet = true;
|
||||
break;
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ void TestLinkItr::slotJobData(KIO::Job *job, const QByteArray &data) {
|
|||
} else {
|
||||
QString modDate = transfer->queryMetaData("modified");
|
||||
if (!modDate.isEmpty()) {
|
||||
curItem()->nsPut(QString::number(KRFCDate::parseDate(modDate)));
|
||||
//FIXME curItem()->nsPut(QString::number(KRFCDate::parseDate(modDate)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,7 @@ void TestLinkItr::slotJobData(KIO::Job *job, const QByteArray &data) {
|
|||
|
||||
void TestLinkItr::slotJobResult(KIO::Job *job) {
|
||||
m_job = 0;
|
||||
if ( !curItem() ) return;
|
||||
//FIXME if ( !curItem() ) return;
|
||||
|
||||
KIO::TransferJob *transfer = (KIO::TransferJob *)job;
|
||||
QString modDate = transfer->queryMetaData("modified");
|
||||
|
@ -145,20 +146,20 @@ void TestLinkItr::slotJobResult(KIO::Job *job) {
|
|||
QString jerr = job->errorString();
|
||||
if (!jerr.isEmpty()) {
|
||||
jerr.replace("\n", " ");
|
||||
curItem()->nsPut(jerr);
|
||||
//FIXME curItem()->nsPut(jerr);
|
||||
chkErr = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (chkErr) {
|
||||
if (!modDate.isEmpty()) {
|
||||
curItem()->nsPut(QString::number(KRFCDate::parseDate(modDate)));
|
||||
//FIXME curItem()->nsPut(QString::number(KRFCDate::parseDate(modDate)));
|
||||
} else if (!m_errSet) {
|
||||
curItem()->nsPut(QString::number(KRFCDate::parseDate("0")));
|
||||
//FIXME curItem()->nsPut(QString::number(KRFCDate::parseDate("0")));
|
||||
}
|
||||
}
|
||||
|
||||
curItem()->modUpdate();
|
||||
//FIXME curItem()->modUpdate();
|
||||
holder()->addAffectedBookmark(KBookmark::parentAddress(curBk().address()));
|
||||
delayedEmitNextOne();
|
||||
}
|
||||
|
@ -195,6 +196,7 @@ void TestLinkItrHolder::resetToValue(const QString &url, const QString &oldValue
|
|||
|
||||
/* -------------------------- */
|
||||
|
||||
/*
|
||||
QString TestLinkItrHolder::calcPaintStyle(const QString &url, KEBListViewItem::PaintStyle &_style,
|
||||
const QString &nVisit, const QString &Modify) {
|
||||
bool newModValid = false;
|
||||
|
@ -298,7 +300,8 @@ QString TestLinkItrHolder::calcPaintStyle(const QString &url, KEBListViewItem::P
|
|||
_style = style;
|
||||
return statusStr;
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
static void parseInfo (KBookmark &bk, QString &nVisited) {
|
||||
nVisited =
|
||||
NodeEditCommand::getNodeText(bk, QStringList() << "info" << "metadata"
|
||||
|
@ -306,6 +309,7 @@ static void parseInfo (KBookmark &bk, QString &nVisited) {
|
|||
|
||||
// kdDebug() << " Visited=" << nVisited << "\n";
|
||||
}
|
||||
*/
|
||||
|
||||
static void parseNsInfo(const QString &nsinfo, QString &nCreate, QString &nAccess, QString &nModify) {
|
||||
QStringList sl = QStringList::split(' ', nsinfo);
|
||||
|
@ -341,6 +345,8 @@ static const QString updateNsInfoMod(const QString &_nsinfo, const QString &nm)
|
|||
}
|
||||
|
||||
// KEBListViewItem !!!!!!!!!!!
|
||||
//FIXME nsPut
|
||||
/*
|
||||
void KEBListViewItem::nsPut(const QString &newModDate) {
|
||||
static const QString NetscapeInfoAttribute = "netscapeinfo";
|
||||
const QString info = m_bookmark.internalElement().attribute(NetscapeInfoAttribute);
|
||||
|
@ -349,8 +355,10 @@ void KEBListViewItem::nsPut(const QString &newModDate) {
|
|||
TestLinkItrHolder::self()->setMod(m_bookmark.url().url(), newModDate);
|
||||
setText(KEBListView::StatusColumn, newModDate);
|
||||
}
|
||||
*/
|
||||
|
||||
// KEBListViewItem !!!!!!!!!!!
|
||||
/*
|
||||
void KEBListViewItem::modUpdate() {
|
||||
QString nCreate, nAccess, oldModify;
|
||||
QString iVisit;
|
||||
|
@ -367,10 +375,11 @@ void KEBListViewItem::modUpdate() {
|
|||
if (statusLine != "Error")
|
||||
setText(KEBListView::StatusColumn, statusLine);
|
||||
}
|
||||
|
||||
*/
|
||||
/* -------------------------- */
|
||||
|
||||
// KEBListViewItem !!!!!!!!!!!
|
||||
/*
|
||||
void KEBListViewItem::setOldStatus(const QString &oldStatus) {
|
||||
// kdDebug() << "KEBListViewItem::setOldStatus" << endl;
|
||||
m_oldStatus = oldStatus;
|
||||
|
@ -391,5 +400,5 @@ void KEBListViewItem::restoreStatus() {
|
|||
modUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
#include "testlink.moc"
|
||||
|
|
|
@ -41,8 +41,6 @@ public:
|
|||
const QString getOldVisit(const QString &url) const;
|
||||
void setMod(const QString &url, const QString &val);
|
||||
void setOldVisit(const QString &url, const QString &val);
|
||||
static QString calcPaintStyle(const QString &, KEBListViewItem::PaintStyle&,
|
||||
const QString &, const QString &);
|
||||
protected:
|
||||
virtual void doItrListChanged();
|
||||
private:
|
||||
|
@ -58,7 +56,7 @@ class TestLinkItr : public BookmarkIterator
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TestLinkItr(Q3ValueList<KBookmark> bks);
|
||||
TestLinkItr(QVector<KBookmark> bks);
|
||||
~TestLinkItr();
|
||||
virtual TestLinkItrHolder* holder() const { return TestLinkItrHolder::self(); }
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "toplevel.h"
|
||||
|
||||
#include "bookmarkmodel.h"
|
||||
|
||||
#include "bookmarkinfo.h"
|
||||
#include "listview.h"
|
||||
#include "actionsimpl.h"
|
||||
|
@ -29,6 +31,7 @@
|
|||
#include "settings.h"
|
||||
#include "commands.h"
|
||||
#include "kebsearchline.h"
|
||||
#include "bookmarklistview.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -57,6 +60,10 @@
|
|||
|
||||
#include <kbookmarkdrag.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <assert.h>
|
||||
#include <qglobal.h>
|
||||
|
||||
|
||||
|
||||
CmdHistory* CmdHistory::s_self = 0;
|
||||
|
||||
|
@ -82,13 +89,6 @@ void CmdHistory::slotCommandExecuted(KCommand *k) {
|
|||
KBookmark bk = CurrentMgr::bookmarkAt(cmd->affectedBookmarks());
|
||||
Q_ASSERT(bk.isGroup());
|
||||
CurrentMgr::self()->notifyManagers(bk.toGroup());
|
||||
|
||||
// sets currentItem to something sensible
|
||||
// if the currentItem was invalidated by executing
|
||||
// CreateCommand or DeleteManyCommand
|
||||
// otherwise does nothing
|
||||
// sensible is either a already selected item or cmd->currentAddress()
|
||||
ListView::self()->fixUpCurrent( cmd->currentAddress() );
|
||||
}
|
||||
|
||||
void CmdHistory::notifyDocSaved() {
|
||||
|
@ -123,7 +123,13 @@ void CmdHistory::clearHistory() {
|
|||
|
||||
CurrentMgr *CurrentMgr::s_mgr = 0;
|
||||
|
||||
KBookmark CurrentMgr::bookmarkAt(const QString &a) {
|
||||
KBookmarkGroup CurrentMgr::root()
|
||||
{
|
||||
return mgr()->root();
|
||||
}
|
||||
|
||||
KBookmark CurrentMgr::bookmarkAt(const QString &a)
|
||||
{
|
||||
return self()->mgr()->findByAddress(a);
|
||||
}
|
||||
|
||||
|
@ -154,7 +160,6 @@ void CurrentMgr::slotBookmarksChanged(const QString &, const QString &) {
|
|||
}
|
||||
|
||||
CmdHistory::self()->clearHistory();
|
||||
ListView::self()->updateListView();
|
||||
KEBApp::self()->updateActions();
|
||||
}
|
||||
|
||||
|
@ -165,7 +170,7 @@ void CurrentMgr::notifyManagers(KBookmarkGroup grp)
|
|||
}
|
||||
|
||||
void CurrentMgr::notifyManagers() {
|
||||
notifyManagers( mgr()->root() );
|
||||
notifyManagers( root() );
|
||||
}
|
||||
|
||||
void CurrentMgr::reloadConfig() {
|
||||
|
@ -205,10 +210,7 @@ KEBApp::KEBApp(
|
|||
|
||||
s_topLevel = this;
|
||||
|
||||
int h = 20;
|
||||
|
||||
QSplitter *vsplitter = new QSplitter(this);
|
||||
|
||||
KToolBar *quicksearch = new KToolBar(vsplitter, "search toolbar");
|
||||
|
||||
KAction *resetQuickSearch = new KAction( i18n( "Reset Quick Search" ),
|
||||
|
@ -225,20 +227,7 @@ KEBApp::KEBApp(
|
|||
lbl->setBuddy(searchLineEdit);
|
||||
connect(resetQuickSearch, SIGNAL(activated()), searchLineEdit, SLOT(clear()));
|
||||
|
||||
ListView::createListViews(vsplitter);
|
||||
ListView::self()->initListViews();
|
||||
searchLineEdit->setListView(static_cast<KListView*>(ListView::self()->widget()));
|
||||
ListView::self()->setSearchLine(searchLineEdit);
|
||||
|
||||
m_bkinfo = new BookmarkInfoWidget(vsplitter);
|
||||
|
||||
vsplitter->setOrientation(Qt::Vertical);
|
||||
vsplitter->setSizes(Q3ValueList<int>() << h << 380
|
||||
<< m_bkinfo->sizeHint().height() );
|
||||
|
||||
setCentralWidget(vsplitter);
|
||||
resize(ListView::self()->widget()->sizeHint().width(),
|
||||
vsplitter->sizeHint().height());
|
||||
//FIXME searchLineEdit->setListView(static_cast<KListView*>(ListView::self()->widget()));
|
||||
|
||||
createActions();
|
||||
if (m_browser)
|
||||
|
@ -251,30 +240,195 @@ KEBApp::KEBApp(
|
|||
connect(kapp->clipboard(), SIGNAL( dataChanged() ),
|
||||
SLOT( slotClipboardDataChanged() ));
|
||||
|
||||
ListView::self()->connectSignals();
|
||||
|
||||
KGlobal::locale()->insertCatalogue("libkonq");
|
||||
|
||||
m_canPaste = false;
|
||||
|
||||
construct();
|
||||
CurrentMgr::self()->createManager(m_bookmarksFilename);
|
||||
|
||||
ListView::self()->setCurrent(ListView::self()->getItemAtAddress(address), true);
|
||||
//QT 4 new code
|
||||
mBookmarkListView = new BookmarkListView(vsplitter);
|
||||
mBookmarkListView->setModel( BookmarkModel::self() );
|
||||
mBookmarkListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
expandAll();
|
||||
mBookmarkListView->loadColumnSetting();
|
||||
|
||||
m_bkinfo = new BookmarkInfoWidget(vsplitter);
|
||||
|
||||
vsplitter->setOrientation(Qt::Vertical);
|
||||
//FIXME set sensible sizes for vsplitter?
|
||||
|
||||
setCentralWidget(vsplitter);
|
||||
|
||||
slotClipboardDataChanged();
|
||||
setAutoSaveSettings();
|
||||
|
||||
connect(mBookmarkListView->selectionModel(), SIGNAL(selectionChanged( const QItemSelection &, const QItemSelection & )),
|
||||
this, SLOT(selectionChanged()));
|
||||
|
||||
setCancelFavIconUpdatesEnabled(false);
|
||||
setCancelTestsEnabled(false);
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void KEBApp::construct() {
|
||||
CurrentMgr::self()->createManager(m_bookmarksFilename);
|
||||
void KEBApp::reset(const QString & caption, const QString & bookmarksFileName)
|
||||
{
|
||||
m_caption = caption;
|
||||
m_bookmarksFilename = bookmarksFileName;
|
||||
CurrentMgr::self()->createManager(m_bookmarksFilename); //FIXME this is still a memory leak (iff called by slotLoad)
|
||||
BookmarkModel::self()->resetModel();
|
||||
expandAll();
|
||||
updateActions();
|
||||
}
|
||||
|
||||
ListView::self()->updateListViewSetup(m_readOnly);
|
||||
ListView::self()->updateListView();
|
||||
ListView::self()->widget()->setFocus();
|
||||
void KEBApp::collapseAll()
|
||||
{
|
||||
collapseAllHelper( BookmarkModel::self()->index(0, 0, QModelIndex()));
|
||||
}
|
||||
|
||||
slotClipboardDataChanged();
|
||||
setAutoSaveSettings();
|
||||
void KEBApp::collapseAllHelper( QModelIndex index )
|
||||
{
|
||||
mBookmarkListView->collapse(index);
|
||||
int rowCount = index.model()->rowCount(index);
|
||||
for(int i=0; i<rowCount; ++i)
|
||||
collapseAllHelper(index.child(i, 0));
|
||||
}
|
||||
|
||||
void KEBApp::expandAll()
|
||||
{
|
||||
expandAllHelper( BookmarkModel::self()->index(0, 0, QModelIndex()));
|
||||
}
|
||||
|
||||
void KEBApp::expandAllHelper(QModelIndex index)
|
||||
{
|
||||
mBookmarkListView->expand(index);
|
||||
int rowCount = index.model()->rowCount(index);
|
||||
for(int i=0; i<rowCount; ++i)
|
||||
expandAllHelper(index.child(i, 0));
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
KBookmark KEBApp::firstSelected() const
|
||||
{
|
||||
const QModelIndexList & list = mBookmarkListView->selectionModel()->selectedIndexes();
|
||||
QModelIndex index = *list.constBegin();
|
||||
return static_cast<TreeItem *>(index.internalPointer())->bookmark();
|
||||
}
|
||||
|
||||
QString KEBApp::insertAddress() const
|
||||
{
|
||||
KBookmark current = firstSelected();
|
||||
return (current.isGroup())
|
||||
? (current.address() + "/0") //FIXME internal represantation used
|
||||
: KBookmark::nextAddress(current.address());
|
||||
}
|
||||
|
||||
bool lessAddress(QString a, QString b)
|
||||
{
|
||||
if(a == b)
|
||||
return false;
|
||||
|
||||
QString error("ERROR");
|
||||
if(a == error)
|
||||
return false;
|
||||
if(b == error)
|
||||
return true;
|
||||
|
||||
a += "/";
|
||||
b += "/";
|
||||
|
||||
uint aLast = 0;
|
||||
uint bLast = 0;
|
||||
uint aEnd = a.length();
|
||||
uint bEnd = b.length();
|
||||
// Each iteration checks one "/"-delimeted part of the address
|
||||
// "" is treated correctly
|
||||
while(true)
|
||||
{
|
||||
// Invariant: a[0 ... aLast] == b[0 ... bLast]
|
||||
if(aLast + 1 == aEnd) //The last position was the last slash
|
||||
return true; // That means a is shorter than b
|
||||
if(bLast +1 == bEnd)
|
||||
return false;
|
||||
|
||||
uint aNext = a.find("/", aLast + 1);
|
||||
uint bNext = b.find("/", bLast + 1);
|
||||
|
||||
bool okay;
|
||||
uint aNum = a.mid(aLast + 1, aNext - aLast - 1).toUInt(&okay);
|
||||
if(!okay)
|
||||
return false;
|
||||
uint bNum = b.mid(bLast + 1, bNext - bLast - 1).toUInt(&okay);
|
||||
if(!okay)
|
||||
return true;
|
||||
|
||||
if(aNum != bNum)
|
||||
return aNum < bNum;
|
||||
|
||||
aLast = aNext;
|
||||
bLast = bNext;
|
||||
}
|
||||
}
|
||||
|
||||
bool lessBookmark(const KBookmark & first, const KBookmark & second) //FIXME Using internal represantation
|
||||
{
|
||||
return lessAddress(first.address(), second.address());
|
||||
}
|
||||
|
||||
QVector<KBookmark> KEBApp::selectedBookmarks() const
|
||||
{
|
||||
QVector<KBookmark> bookmarks;
|
||||
const QModelIndexList & list = mBookmarkListView->selectionModel()->selectedIndexes();
|
||||
bookmarks.reserve(list.count());
|
||||
QModelIndexList::const_iterator it, end;
|
||||
end = list.constEnd();
|
||||
for( it = list.constBegin(); it != end; ++it)
|
||||
{
|
||||
if((*it).column() != 0)
|
||||
continue;
|
||||
KBookmark bk = static_cast<TreeItem *>((*it).internalPointer())->bookmark();;
|
||||
if(bk.address() != CurrentMgr::self()->root().address())
|
||||
bookmarks.push_back( bk );
|
||||
}
|
||||
qSort(bookmarks.begin(), bookmarks.end(), lessBookmark);
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
QVector<KBookmark> KEBApp::selectedBookmarksExpanded() const
|
||||
{
|
||||
QVector<KBookmark> bookmarks = selectedBookmarks();
|
||||
QVector<KBookmark> result;
|
||||
result.reserve(bookmarks.size()); // at least
|
||||
QVector<KBookmark>::const_iterator it, end;
|
||||
end = bookmarks.constEnd();
|
||||
for(it = bookmarks.constBegin(); it != end; ++it)
|
||||
{
|
||||
selectedBookmarksExpandedHelper( *it, result );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void KEBApp::selectedBookmarksExpandedHelper(KBookmark bk, QVector<KBookmark> & bookmarks) const
|
||||
{
|
||||
bookmarks.push_back( bk );
|
||||
if(bk.isGroup())
|
||||
{
|
||||
KBookmarkGroup parent = bk.toGroup();
|
||||
KBookmark child = parent.first();
|
||||
while(child.hasParent())
|
||||
{
|
||||
selectedBookmarksExpandedHelper(child, bookmarks);
|
||||
child = parent.next(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KEBApp::updateStatus(QString url)
|
||||
|
@ -288,7 +442,8 @@ KEBApp::~KEBApp() {
|
|||
delete m_cmdHistory;
|
||||
delete m_dcopIface;
|
||||
delete ActionsImpl::self();
|
||||
delete ListView::self();
|
||||
delete mBookmarkListView;
|
||||
delete BookmarkModel::self();
|
||||
}
|
||||
|
||||
KToggleAction* KEBApp::getToggleAction(const char *action) const {
|
||||
|
@ -310,10 +465,14 @@ bool KEBApp::nsShown() const {
|
|||
return getToggleAction("settings_showNS")->isChecked();
|
||||
}
|
||||
|
||||
// this should be pushed from listview, not pulled
|
||||
void KEBApp::selectionChanged()
|
||||
{
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void KEBApp::updateActions() {
|
||||
resetActions();
|
||||
setActionsEnabled(ListView::self()->getSelectionAbilities());
|
||||
setActionsEnabled(mBookmarkListView->getSelectionAbilities());
|
||||
}
|
||||
|
||||
void KEBApp::slotClipboardDataChanged() {
|
||||
|
@ -329,10 +488,7 @@ void KEBApp::slotClipboardDataChanged() {
|
|||
|
||||
void KEBApp::notifyCommandExecuted() {
|
||||
// kdDebug() << "KEBApp::notifyCommandExecuted()" << endl;
|
||||
if (!m_readOnly) {
|
||||
ListView::self()->updateListView();
|
||||
updateActions();
|
||||
}
|
||||
updateActions();
|
||||
}
|
||||
|
||||
/* -------------------------- */
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <kmainwindow.h>
|
||||
#include <kcommand.h>
|
||||
#include <kbookmark.h>
|
||||
#include <QMenu>
|
||||
#include <QVector>
|
||||
#include "bookmarklistview.h"
|
||||
|
||||
class KBookmarkManager;
|
||||
class KToggleAction;
|
||||
|
@ -32,18 +35,8 @@ class KBookmarkEditorIface;
|
|||
class ImportCommand;
|
||||
class BookmarkInfoWidget;
|
||||
class IKEBCommand;
|
||||
|
||||
struct SelcAbilities {
|
||||
bool itemSelected:1;
|
||||
bool group:1;
|
||||
bool root:1;
|
||||
bool separator:1;
|
||||
bool urlIsEmpty:1;
|
||||
bool multiSelect:1;
|
||||
bool singleSelect:1;
|
||||
bool notEmpty:1;
|
||||
bool tbShowState:1;
|
||||
};
|
||||
class BookmarkModel;
|
||||
class BookmarkListView;
|
||||
|
||||
class CmdHistory : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -79,6 +72,7 @@ public:
|
|||
typedef enum {HTMLExport, OperaExport, IEExport, MozillaExport, NetscapeExport} ExportType;
|
||||
|
||||
static CurrentMgr* self() { if (!s_mgr) { s_mgr = new CurrentMgr(); } return s_mgr; }
|
||||
KBookmarkGroup CurrentMgr::root();
|
||||
static KBookmark bookmarkAt(const QString & a);
|
||||
|
||||
KBookmarkManager* mgr() const { return m_mgr; }
|
||||
|
@ -116,6 +110,8 @@ public:
|
|||
KEBApp(const QString & bookmarksFile, bool readonly, const QString &address, bool browser, const QString &caption);
|
||||
virtual ~KEBApp();
|
||||
|
||||
void reset(const QString & caption, const QString & bookmarksFileName);
|
||||
|
||||
void updateActions();
|
||||
void updateStatus(QString url);
|
||||
void setActionsEnabled(SelcAbilities);
|
||||
|
@ -126,8 +122,10 @@ public:
|
|||
void notifyCommandExecuted();
|
||||
void findURL(QString url);
|
||||
|
||||
QWidget* popupMenuFactory(const char *type) {
|
||||
return factory()->container(type, this);
|
||||
QMenu* popupMenuFactory(const char *type)
|
||||
{
|
||||
QWidget * menu = factory()->container(type, this);
|
||||
return dynamic_cast<QMenu *>(menu);
|
||||
}
|
||||
|
||||
KToggleAction* getToggleAction(const char *) const;
|
||||
|
@ -139,15 +137,38 @@ public:
|
|||
|
||||
BookmarkInfoWidget *bkInfo() { return m_bkinfo; }
|
||||
|
||||
void collapseAll();
|
||||
void expandAll();
|
||||
|
||||
enum Column {
|
||||
NameColumn = 0,
|
||||
UrlColumn = 1,
|
||||
CommentColumn = 2,
|
||||
StatusColumn = 3
|
||||
};
|
||||
void startEdit( Column c );
|
||||
KBookmark firstSelected() const;
|
||||
QString insertAddress() const;
|
||||
QVector<KBookmark> selectedBookmarks() const;
|
||||
QVector<KBookmark> selectedBookmarksExpanded() const;
|
||||
QVector<KBookmark> allBookmarks() const
|
||||
{ return QVector<KBookmark>();} //FIXME look up what it is suppposed to do, seems like only bookmarks but not folder are returned
|
||||
public slots:
|
||||
void slotConfigureToolbars();
|
||||
|
||||
protected slots:
|
||||
void slotClipboardDataChanged();
|
||||
void slotNewToolbarConfig();
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
static KBookmarkManager* bookmarkManager();
|
||||
void selectedBookmarksExpandedHelper(KBookmark bk, QVector<KBookmark> & bookmarks) const;
|
||||
void collapseAllHelper( QModelIndex index );
|
||||
void expandAllHelper(QModelIndex index);
|
||||
|
||||
public: //FIXME
|
||||
BookmarkListView * mBookmarkListView;
|
||||
private:
|
||||
|
||||
void resetActions();
|
||||
void createActions();
|
||||
|
@ -157,13 +178,10 @@ private:
|
|||
static KEBApp *s_topLevel;
|
||||
KBookmarkEditorIface *m_dcopIface;
|
||||
|
||||
public: // only temporary
|
||||
CmdHistory *m_cmdHistory;
|
||||
QString m_bookmarksFilename;
|
||||
QString m_caption;
|
||||
|
||||
void construct();
|
||||
|
||||
private:
|
||||
BookmarkInfoWidget *m_bkinfo;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <kparts/part.h>
|
||||
#include <kparts/componentfactory.h>
|
||||
#include <kparts/browserextension.h>
|
||||
#include <assert.h>
|
||||
|
||||
FavIconUpdater::FavIconUpdater(QObject *parent, const char *name)
|
||||
: KonqFavIconMgr(parent, name) {
|
||||
|
|
Loading…
Reference in a new issue