2000-10-26 03:52:56 +00:00
/* This file is part of the KDE project
Copyright ( C ) 2000 David Faure < faure @ kde . org >
2003-01-21 16:16:53 +00:00
Copyright ( C ) 2002 - 2003 Alexander Kellett < lypanov @ kde . org >
2000-10-26 03:52:56 +00:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
2007-12-20 22:23:07 +00:00
License version 2 or at your option version 3 as published by
the Free Software Foundation .
2000-10-26 03:52:56 +00:00
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
2003-10-11 13:45:28 +00:00
General Public License for more details .
2000-10-26 03:52:56 +00:00
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
2005-10-05 08:44:32 +00:00
the Free Software Foundation , Inc . , 51 Franklin Street , Fifth Floor ,
2005-07-04 19:02:09 +00:00
Boston , MA 02110 - 1301 , USA .
2000-10-26 03:52:56 +00:00
*/
2003-09-14 18:07:31 +00:00
# include "toplevel.h"
2010-03-10 14:37:11 +00:00
# include <QVBoxLayout>
# include "globalbookmarkmanager.h"
2003-09-14 18:07:31 +00:00
2010-04-24 09:06:17 +00:00
# include "kbookmarkmodel/model.h"
2005-08-13 20:13:21 +00:00
2010-03-16 20:23:47 +00:00
# include "bookmarkinfowidget.h"
2003-09-14 18:07:31 +00:00
# include "actionsimpl.h"
# include "exporters.h"
2005-02-26 17:10:50 +00:00
# include "settings.h"
2010-04-24 09:06:17 +00:00
# include "kbookmarkmodel/commands.h"
# include "kbookmarkmodel/commandhistory.h"
2005-06-30 23:24:09 +00:00
# include "kebsearchline.h"
2005-08-13 20:13:21 +00:00
# include "bookmarklistview.h"
2003-09-14 18:07:31 +00:00
2003-01-21 16:16:53 +00:00
# include <stdlib.h>
2002-09-17 17:16:23 +00:00
2012-04-09 22:20:00 +00:00
# include <QClipboard>
# include <QSplitter>
# include <QApplication>
2003-06-07 19:52:21 +00:00
2006-05-08 13:46:00 +00:00
# include <kaction.h>
# include <kactioncollection.h>
# include <ktoggleaction.h>
# include <kbookmark.h>
# include <kbookmarkmanager.h>
# include <kdebug.h>
2010-12-26 22:55:45 +00:00
# include <kdialog.h>
2006-05-08 13:46:00 +00:00
# include <kedittoolbar.h>
# include <kfiledialog.h>
# include <klineedit.h>
# include <klocale.h>
# include <kmessagebox.h>
2006-12-18 22:24:28 +00:00
# include <kstandardaction.h>
2003-01-21 16:16:53 +00:00
2003-03-22 19:50:23 +00:00
2007-05-09 22:23:52 +00:00
# include <QtDBus/QDBusConnection>
2003-09-14 17:28:52 +00:00
KEBApp * KEBApp : : s_topLevel = 0 ;
2003-06-13 19:17:25 +00:00
2003-06-20 00:13:10 +00:00
KEBApp : : KEBApp (
2004-07-31 10:22:14 +00:00
const QString & bookmarksFile , bool readonly ,
2006-10-16 13:43:54 +00:00
const QString & address , bool browser , const QString & caption ,
const QString & dbusObjectName
2007-12-15 12:29:41 +00:00
) : KXmlGuiWindow ( ) , m_bookmarksFilename ( bookmarksFile ) ,
2007-02-20 07:00:30 +00:00
m_caption ( caption ) ,
2006-11-06 21:11:32 +00:00
m_dbusObjectName ( dbusObjectName ) , m_readOnly ( readonly ) , m_browser ( browser )
2006-10-16 13:43:54 +00:00
{
2007-01-16 15:10:06 +00:00
QDBusConnection : : sessionBus ( ) . registerObject ( " /keditbookmarks " , this , QDBusConnection : : ExportScriptableSlots ) ;
2005-09-11 22:50:56 +00:00
Q_UNUSED ( address ) ; //FIXME sets the current item
2010-04-07 11:34:26 +00:00
m_cmdHistory = new CommandHistory ( this ) ;
m_cmdHistory - > createActions ( actionCollection ( ) ) ;
2010-04-07 23:04:18 +00:00
connect ( m_cmdHistory , SIGNAL ( notifyCommandExecuted ( KBookmarkGroup ) ) , this , SLOT ( notifyCommandExecuted ( ) ) ) ;
2002-10-16 17:29:51 +00:00
2010-04-08 12:16:33 +00:00
GlobalBookmarkManager : : self ( ) - > createManager ( m_bookmarksFilename , m_dbusObjectName , m_cmdHistory ) ;
2003-10-06 18:29:56 +00:00
s_topLevel = this ;
2000-10-26 03:52:56 +00:00
2003-10-06 18:29:56 +00:00
createActions ( ) ;
if ( m_browser )
createGUI ( ) ;
else
createGUI ( " keditbookmarks-genui.rc " ) ;
2002-06-03 18:58:18 +00:00
2011-07-31 11:33:56 +00:00
connect ( qApp - > clipboard ( ) , SIGNAL ( dataChanged ( ) ) ,
SLOT ( slotClipboardDataChanged ( ) ) ) ;
2003-02-15 00:18:41 +00:00
2005-10-03 15:54:58 +00:00
KGlobal : : locale ( ) - > insertCatalog ( " libkonq " ) ;
2002-04-27 10:47:22 +00:00
2003-10-19 16:23:37 +00:00
m_canPaste = false ;
2005-09-11 22:50:56 +00:00
mBookmarkListView = new BookmarkListView ( ) ;
2010-03-10 14:37:11 +00:00
mBookmarkListView - > setModel ( GlobalBookmarkManager : : self ( ) - > model ( ) ) ;
2005-08-13 20:13:21 +00:00
mBookmarkListView - > setSelectionMode ( QAbstractItemView : : ExtendedSelection ) ;
mBookmarkListView - > loadColumnSetting ( ) ;
2009-11-17 23:55:40 +00:00
mBookmarkListView - > loadFoldedState ( ) ;
2005-08-13 20:13:21 +00:00
2007-04-15 22:37:01 +00:00
KViewSearchLineWidget * searchline = new KViewSearchLineWidget ( mBookmarkListView ) ;
2005-09-11 22:50:56 +00:00
2005-09-20 23:30:16 +00:00
mBookmarkFolderView = new BookmarkFolderView ( mBookmarkListView ) ;
2009-11-17 23:55:40 +00:00
mBookmarkFolderView - > expandAll ( ) ;
2007-04-15 22:37:01 +00:00
2007-12-27 01:43:18 +00:00
QWidget * rightSide = new QWidget ;
2008-02-19 21:57:03 +00:00
QVBoxLayout * listLayout = new QVBoxLayout ( rightSide ) ;
2010-12-26 22:55:45 +00:00
listLayout - > setMargin ( 0 ) ;
2007-12-27 01:43:18 +00:00
rightSide - > setLayout ( listLayout ) ;
2007-04-15 22:37:01 +00:00
listLayout - > addWidget ( searchline ) ;
listLayout - > addWidget ( mBookmarkListView ) ;
2010-04-07 11:34:26 +00:00
m_bkinfo = new BookmarkInfoWidget ( mBookmarkListView , GlobalBookmarkManager : : self ( ) - > model ( ) ) ;
2010-12-26 22:55:45 +00:00
m_bkinfo - > layout ( ) - > setContentsMargins ( 0 , 0 , KDialog : : spacingHint ( ) , KDialog : : spacingHint ( ) ) ;
2005-08-13 20:13:21 +00:00
2007-12-27 01:43:18 +00:00
listLayout - > addWidget ( m_bkinfo ) ;
2005-08-13 20:13:21 +00:00
2005-09-20 23:30:16 +00:00
QSplitter * hsplitter = new QSplitter ( this ) ;
hsplitter - > setOrientation ( Qt : : Horizontal ) ;
hsplitter - > addWidget ( mBookmarkFolderView ) ;
2007-12-27 01:43:18 +00:00
hsplitter - > addWidget ( rightSide ) ;
2008-10-21 22:59:51 +00:00
hsplitter - > setStretchFactor ( 1 , 1 ) ;
2006-06-19 10:42:32 +00:00
2005-09-20 23:30:16 +00:00
setCentralWidget ( hsplitter ) ;
2005-08-13 20:13:21 +00:00
slotClipboardDataChanged ( ) ;
setAutoSaveSettings ( ) ;
2011-07-31 11:33:56 +00:00
connect ( mBookmarkListView - > selectionModel ( ) , SIGNAL ( selectionChanged ( QItemSelection , QItemSelection ) ) ,
2005-08-13 20:13:21 +00:00
this , SLOT ( selectionChanged ( ) ) ) ;
2005-07-05 22:31:08 +00:00
2011-07-31 11:33:56 +00:00
connect ( mBookmarkFolderView - > selectionModel ( ) , SIGNAL ( selectionChanged ( QItemSelection , QItemSelection ) ) ,
2007-12-27 14:26:50 +00:00
this , SLOT ( selectionChanged ( ) ) ) ;
2005-06-10 01:03:05 +00:00
setCancelFavIconUpdatesEnabled ( false ) ;
setCancelTestsEnabled ( false ) ;
2003-10-06 18:29:56 +00:00
updateActions ( ) ;
2003-03-01 11:36:20 +00:00
}
2007-12-16 01:47:07 +00:00
void KEBApp : : expandAll ( )
{
2007-12-28 01:04:09 +00:00
mBookmarkListView - > expandAll ( ) ;
2007-12-16 01:47:07 +00:00
}
void KEBApp : : collapseAll ( )
{
mBookmarkListView - > collapseAll ( ) ;
}
2007-01-16 15:10:06 +00:00
QString KEBApp : : bookmarkFilename ( )
{
return m_bookmarksFilename ;
}
2006-06-19 10:42:32 +00:00
void KEBApp : : reset ( const QString & caption , const QString & bookmarksFileName )
2005-08-13 20:13:21 +00:00
{
2007-12-28 01:04:09 +00:00
//FIXME check this code, probably should be model()->setRoot instead of resetModel()
2005-08-13 20:13:21 +00:00
m_caption = caption ;
m_bookmarksFilename = bookmarksFileName ;
2010-04-07 11:34:26 +00:00
GlobalBookmarkManager : : self ( ) - > createManager ( m_bookmarksFilename , m_dbusObjectName , m_cmdHistory ) ; //FIXME this is still a memory leak (iff called by slotLoad)
2010-03-10 14:37:11 +00:00
GlobalBookmarkManager : : self ( ) - > model ( ) - > resetModel ( ) ;
2005-08-13 20:13:21 +00:00
updateActions ( ) ;
}
2002-04-27 10:47:22 +00:00
2005-08-13 20:13:21 +00:00
void KEBApp : : startEdit ( Column c )
{
const QModelIndexList & list = mBookmarkListView - > selectionModel ( ) - > selectedIndexes ( ) ;
2005-08-22 01:10:43 +00:00
QModelIndexList : : const_iterator it , end ;
end = list . constEnd ( ) ;
for ( it = list . constBegin ( ) ; it ! = end ; + + it )
2007-12-16 01:47:07 +00:00
if ( ( * it ) . column ( ) = = int ( c ) & & ( mBookmarkListView - > model ( ) - > flags ( * it ) & Qt : : ItemIsEditable ) )
2005-08-22 01:10:43 +00:00
return mBookmarkListView - > edit ( * it ) ;
2005-08-13 20:13:21 +00:00
}
2007-12-27 14:26:50 +00:00
//FIXME clean up and remove unneeded things
SelcAbilities KEBApp : : getSelectionAbilities ( ) const
{
SelcAbilities selctionAbilities ;
selctionAbilities . itemSelected = false ;
selctionAbilities . group = false ;
selctionAbilities . separator = false ;
selctionAbilities . urlIsEmpty = false ;
selctionAbilities . root = false ;
selctionAbilities . multiSelect = false ;
selctionAbilities . singleSelect = false ;
selctionAbilities . notEmpty = false ;
selctionAbilities . deleteEnabled = false ;
KBookmark nbk ;
QModelIndexList sel = mBookmarkListView - > selectionModel ( ) - > selectedIndexes ( ) ;
int columnCount ;
if ( sel . count ( ) )
{
nbk = mBookmarkListView - > bookmarkForIndex ( sel . first ( ) ) ;
columnCount = mBookmarkListView - > model ( ) - > columnCount ( ) ;
}
else
{
sel = mBookmarkFolderView - > selectionModel ( ) - > selectedIndexes ( ) ;
2007-12-28 01:04:09 +00:00
if ( sel . count ( ) )
nbk = mBookmarkFolderView - > bookmarkForIndex ( sel . first ( ) ) ;
2007-12-27 14:26:50 +00:00
columnCount = mBookmarkFolderView - > model ( ) - > columnCount ( ) ;
}
if ( sel . count ( ) > 0 )
{
2009-11-17 15:35:05 +00:00
selctionAbilities . deleteEnabled = true ;
2007-12-27 14:26:50 +00:00
selctionAbilities . itemSelected = true ;
selctionAbilities . group = nbk . isGroup ( ) ;
selctionAbilities . separator = nbk . isSeparator ( ) ;
selctionAbilities . urlIsEmpty = nbk . url ( ) . isEmpty ( ) ;
2010-03-10 14:37:11 +00:00
selctionAbilities . root = nbk . address ( ) = = GlobalBookmarkManager : : self ( ) - > root ( ) . address ( ) ;
2007-12-27 14:26:50 +00:00
selctionAbilities . multiSelect = ( sel . count ( ) > columnCount ) ;
selctionAbilities . singleSelect = ( ! selctionAbilities . multiSelect & & selctionAbilities . itemSelected ) ;
}
//FIXME check next line, if it actually works
2010-03-10 14:37:11 +00:00
selctionAbilities . notEmpty = GlobalBookmarkManager : : self ( ) - > root ( ) . first ( ) . hasParent ( ) ;
2007-12-27 14:26:50 +00:00
/* kDebug()
< < " \n sa.itemSelected " < < selctionAbilities . itemSelected
< < " \n sa.group " < < selctionAbilities . group
< < " \n sa.separator " < < selctionAbilities . separator
< < " \n sa.urlIsEmpty " < < selctionAbilities . urlIsEmpty
< < " \n sa.root " < < selctionAbilities . root
< < " \n sa.multiSelect " < < selctionAbilities . multiSelect
< < " \n sa.singleSelect " < < selctionAbilities . singleSelect
< < " \n sa.deleteEnabled " < < selctionAbilities . deleteEnabled
< < endl ;
*/
return selctionAbilities ;
}
void KEBApp : : setActionsEnabled ( SelcAbilities sa ) {
KActionCollection * coll = actionCollection ( ) ;
QStringList toEnable ;
if ( sa . multiSelect | | ( sa . singleSelect & & ! sa . root ) )
toEnable < < " edit_copy " ;
if ( sa . multiSelect | | ( sa . singleSelect & & ! sa . root & & ! sa . urlIsEmpty & & ! sa . group & & ! sa . separator ) )
toEnable < < " openlink " ;
if ( ! m_readOnly ) {
if ( sa . notEmpty )
toEnable < < " testall " < < " updateallfavicons " ;
if ( sa . deleteEnabled & & ( sa . multiSelect | | ( sa . singleSelect & & ! sa . root ) ) )
toEnable < < " delete " < < " edit_cut " ;
if ( sa . singleSelect )
if ( m_canPaste )
toEnable < < " edit_paste " ;
if ( sa . multiSelect | | ( sa . singleSelect & & ! sa . root & & ! sa . urlIsEmpty & & ! sa . group & & ! sa . separator ) )
toEnable < < " testlink " < < " updatefavicon " ;
if ( sa . singleSelect & & ! sa . root & & ! sa . separator ) {
toEnable < < " rename " < < " changeicon " < < " changecomment " ;
if ( ! sa . group )
toEnable < < " changeurl " ;
}
if ( sa . singleSelect ) {
toEnable < < " newfolder " < < " newbookmark " < < " insertseparator " ;
if ( sa . group )
toEnable < < " sort " < < " recursivesort " < < " setastoolbar " ;
}
}
2008-11-11 21:46:50 +00:00
for ( QStringList : : const_iterator it = toEnable . constBegin ( ) ;
it ! = toEnable . constEnd ( ) ; + + it )
2007-12-27 14:26:50 +00:00
{
//kDebug() <<" enabling action "<<(*it);
2010-03-16 20:33:07 +00:00
coll - > action ( * it ) - > setEnabled ( true ) ;
2007-12-27 14:26:50 +00:00
}
}
2005-08-13 20:13:21 +00:00
KBookmark KEBApp : : firstSelected ( ) const
{
2007-12-27 14:26:50 +00:00
QModelIndex index ;
2005-08-13 20:13:21 +00:00
const QModelIndexList & list = mBookmarkListView - > selectionModel ( ) - > selectedIndexes ( ) ;
2007-12-27 14:26:50 +00:00
if ( list . count ( ) ) // selection in main listview, return bookmark for firstSelected
return mBookmarkListView - > bookmarkForIndex ( * list . constBegin ( ) ) ;
2008-07-01 21:59:38 +00:00
// no selection in main listview, fall back to selection in left tree
2007-12-27 14:26:50 +00:00
const QModelIndexList & list2 = mBookmarkFolderView - > selectionModel ( ) - > selectedIndexes ( ) ;
return mBookmarkFolderView - > bookmarkForIndex ( * list2 . constBegin ( ) ) ;
2005-08-13 20:13:21 +00:00
}
QString KEBApp : : insertAddress ( ) const
{
KBookmark current = firstSelected ( ) ;
2006-06-19 10:42:32 +00:00
return ( current . isGroup ( ) )
2005-08-13 20:13:21 +00:00
? ( current . address ( ) + " /0 " ) //FIXME internal represantation used
: KBookmark : : nextAddress ( current . address ( ) ) ;
}
2007-05-26 01:57:37 +00:00
bool lessAddress ( const QString & first , const QString & second )
2005-08-13 20:13:21 +00:00
{
2007-05-26 01:57:37 +00:00
QString a = first ;
QString b = second ;
2005-08-13 20:13:21 +00:00
if ( a = = b )
return false ;
QString error ( " ERROR " ) ;
if ( a = = error )
return false ;
if ( b = = error )
return true ;
2006-05-31 16:23:36 +00:00
a + = ' / ' ;
b + = ' / ' ;
2005-08-13 20:13:21 +00:00
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 ;
2006-04-04 17:57:05 +00:00
uint aNext = a . indexOf ( " / " , aLast + 1 ) ;
uint bNext = b . indexOf ( " / " , bLast + 1 ) ;
2005-08-13 20:13:21 +00:00
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 ( ) ) ;
}
2007-12-16 01:47:07 +00:00
KBookmark : : List KEBApp : : allBookmarks ( ) const
{
KBookmark : : List bookmarks ;
2010-03-10 14:37:11 +00:00
selectedBookmarksExpandedHelper ( GlobalBookmarkManager : : self ( ) - > root ( ) , bookmarks ) ;
2007-12-16 01:47:07 +00:00
return bookmarks ;
}
2005-10-13 19:26:56 +00:00
KBookmark : : List KEBApp : : selectedBookmarks ( ) const
2005-08-13 20:13:21 +00:00
{
2005-10-13 19:26:56 +00:00
KBookmark : : List bookmarks ;
2005-08-13 20:13:21 +00:00
const QModelIndexList & list = mBookmarkListView - > selectionModel ( ) - > selectedIndexes ( ) ;
2008-07-01 21:59:38 +00:00
if ( ! list . isEmpty ( ) ) {
QModelIndexList : : const_iterator it , end ;
end = list . constEnd ( ) ;
for ( it = list . constBegin ( ) ; it ! = end ; + + it ) {
if ( ( * it ) . column ( ) ! = 0 )
continue ;
KBookmark bk = mBookmarkListView - > bookmarkModel ( ) - > bookmarkForIndex ( * it ) ; ;
2010-03-10 14:37:11 +00:00
if ( bk . address ( ) ! = GlobalBookmarkManager : : self ( ) - > root ( ) . address ( ) )
2008-07-01 21:59:38 +00:00
bookmarks . push_back ( bk ) ;
}
qSort ( bookmarks . begin ( ) , bookmarks . end ( ) , lessBookmark ) ;
} else {
bookmarks . push_back ( firstSelected ( ) ) ;
2005-08-13 20:13:21 +00:00
}
2007-12-16 01:47:07 +00:00
2005-08-13 20:13:21 +00:00
return bookmarks ;
}
2005-10-13 19:26:56 +00:00
KBookmark : : List KEBApp : : selectedBookmarksExpanded ( ) const
2005-08-13 20:13:21 +00:00
{
2005-10-13 19:26:56 +00:00
KBookmark : : List bookmarks = selectedBookmarks ( ) ;
KBookmark : : List result ;
KBookmark : : List : : const_iterator it , end ;
2005-08-13 20:13:21 +00:00
end = bookmarks . constEnd ( ) ;
for ( it = bookmarks . constBegin ( ) ; it ! = end ; + + it )
{
selectedBookmarksExpandedHelper ( * it , result ) ;
}
return result ;
}
2007-05-26 01:57:37 +00:00
void KEBApp : : selectedBookmarksExpandedHelper ( const KBookmark & bk , KBookmark : : List & bookmarks ) const
2005-08-13 20:13:21 +00:00
{
2007-12-16 01:47:07 +00:00
//FIXME in which order parents should ideally be: parent then child
// or child and then parents
2005-08-13 20:13:21 +00:00
if ( bk . isGroup ( ) )
{
KBookmarkGroup parent = bk . toGroup ( ) ;
KBookmark child = parent . first ( ) ;
2007-09-03 07:53:52 +00:00
while ( ! child . isNull ( ) )
2005-08-13 20:13:21 +00:00
{
selectedBookmarksExpandedHelper ( child , bookmarks ) ;
child = parent . next ( child ) ;
}
}
2007-12-16 01:47:07 +00:00
else
{
bookmarks . push_back ( bk ) ;
}
2005-07-05 22:31:08 +00:00
}
2007-05-16 18:52:56 +00:00
void KEBApp : : updateStatus ( const QString & url )
2005-07-05 22:31:08 +00:00
{
if ( m_bkinfo - > bookmark ( ) . url ( ) = = url )
m_bkinfo - > updateStatus ( ) ;
2000-10-26 03:52:56 +00:00
}
2003-02-15 19:00:14 +00:00
KEBApp : : ~ KEBApp ( ) {
2009-11-18 00:12:05 +00:00
// Save again, just in case the user expanded/collapsed folders (#131127)
2010-03-10 14:37:11 +00:00
GlobalBookmarkManager : : self ( ) - > notifyManagers ( ) ;
2009-11-18 00:12:05 +00:00
2003-10-06 18:29:56 +00:00
s_topLevel = 0 ;
2005-06-18 13:59:22 +00:00
delete m_cmdHistory ;
2010-04-07 11:34:26 +00:00
delete m_actionsImpl ;
2005-08-13 20:13:21 +00:00
delete mBookmarkListView ;
2010-03-10 14:37:11 +00:00
delete GlobalBookmarkManager : : self ( ) ;
2003-01-21 16:16:53 +00:00
}
2003-06-15 22:46:00 +00:00
KToggleAction * KEBApp : : getToggleAction ( const char * action ) const {
2003-10-06 18:29:56 +00:00
return static_cast < KToggleAction * > ( actionCollection ( ) - > action ( action ) ) ;
2003-02-11 09:57:10 +00:00
}
2003-02-15 19:00:14 +00:00
void KEBApp : : resetActions ( ) {
2003-10-06 18:29:56 +00:00
stateChanged ( " disablestuff " ) ;
stateChanged ( " normal " ) ;
2002-10-16 16:39:37 +00:00
2003-10-06 18:29:56 +00:00
if ( ! m_readOnly )
stateChanged ( " notreadonly " ) ;
2003-02-06 13:16:40 +00:00
}
2003-02-10 13:52:45 +00:00
2005-08-13 20:13:21 +00:00
void KEBApp : : selectionChanged ( )
{
updateActions ( ) ;
}
2003-02-15 19:00:14 +00:00
void KEBApp : : updateActions ( ) {
2003-10-19 10:38:10 +00:00
resetActions ( ) ;
2007-12-27 14:26:50 +00:00
setActionsEnabled ( getSelectionAbilities ( ) ) ;
2002-03-26 23:28:26 +00:00
}
2003-02-15 19:00:14 +00:00
void KEBApp : : slotClipboardDataChanged ( ) {
2007-08-03 06:40:12 +00:00
// kDebug() << "KEBApp::slotClipboardDataChanged";
2003-10-06 18:29:56 +00:00
if ( ! m_readOnly ) {
2005-10-04 20:42:32 +00:00
m_canPaste = KBookmark : : List : : canDecode (
QApplication : : clipboard ( ) - > mimeData ( ) ) ;
2005-07-05 22:31:08 +00:00
updateActions ( ) ;
2003-10-06 18:29:56 +00:00
}
2002-04-28 22:01:11 +00:00
}
2003-02-16 00:05:39 +00:00
/* -------------------------- */
2002-04-28 22:01:11 +00:00
2003-03-22 20:27:55 +00:00
void KEBApp : : notifyCommandExecuted ( ) {
2007-08-03 06:40:12 +00:00
// kDebug() << "KEBApp::notifyCommandExecuted()";
2005-08-13 20:13:21 +00:00
updateActions ( ) ;
2000-11-22 01:46:49 +00:00
}
2003-03-22 16:52:02 +00:00
/* -------------------------- */
2000-10-26 03:52:56 +00:00
2003-02-15 19:00:14 +00:00
void KEBApp : : slotConfigureToolbars ( ) {
2007-02-20 07:00:30 +00:00
saveMainWindowSettings ( KConfigGroup ( KGlobal : : config ( ) , " MainWindow " ) ) ;
2008-06-06 11:50:55 +00:00
KEditToolBar dlg ( actionCollection ( ) , this ) ;
2011-07-31 11:33:56 +00:00
connect ( & dlg , SIGNAL ( newToolBarConfig ( ) ) ,
SLOT ( slotNewToolbarConfig ( ) ) ) ;
2003-10-06 18:29:56 +00:00
dlg . exec ( ) ;
2000-10-26 03:52:56 +00:00
}
2003-02-15 19:00:14 +00:00
void KEBApp : : slotNewToolbarConfig ( ) {
2003-10-06 18:29:56 +00:00
// called when OK or Apply is clicked
createGUI ( ) ;
2007-02-20 07:00:30 +00:00
applyMainWindowSettings ( KConfigGroup ( KGlobal : : config ( ) , " MainWindow " ) ) ;
2002-04-19 23:09:16 +00:00
}
2003-02-16 00:05:39 +00:00
/* -------------------------- */
2002-04-26 22:21:50 +00:00
2000-10-26 03:52:56 +00:00
# include "toplevel.moc"
2003-10-06 18:29:56 +00:00