Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmark.cpp
Show All 15 Lines | |||||
16 | * GNU General Public License for more details. * | 16 | * GNU General Public License for more details. * | ||
17 | * * | 17 | * * | ||
18 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
20 | *****************************************************************************/ | 20 | *****************************************************************************/ | ||
21 | 21 | | |||
22 | #include "krbookmark.h" | 22 | #include "krbookmark.h" | ||
23 | #include "../krglobal.h" | 23 | #include "../krglobal.h" | ||
24 | #include "../icon.h" | ||||
24 | #include "../Archive/krarchandler.h" | 25 | #include "../Archive/krarchandler.h" | ||
25 | #include "../FileSystem/krtrashhandler.h" | 26 | #include "../FileSystem/krtrashhandler.h" | ||
26 | #include "../Panel/listpanelactions.h" | 27 | #include "../Panel/listpanelactions.h" | ||
27 | 28 | | |||
28 | #include <KI18n/KLocalizedString> | 29 | #include <KI18n/KLocalizedString> | ||
29 | #include <KIconThemes/KIconLoader> | | |||
30 | #include <KXmlGui/KActionCollection> | 30 | #include <KXmlGui/KActionCollection> | ||
31 | 31 | | |||
32 | #define BM_NAME(X) (QString("Bookmark:")+X) | 32 | #define BM_NAME(X) (QString("Bookmark:")+X) | ||
33 | 33 | | |||
34 | static const char* NAME_TRASH = I18N_NOOP("Trash bin"); | 34 | static const char* NAME_TRASH = I18N_NOOP("Trash bin"); | ||
35 | static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem"); | 35 | static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem"); | ||
36 | static const char* NAME_LAN = I18N_NOOP("Local Network"); | 36 | static const char* NAME_LAN = I18N_NOOP("Local Network"); | ||
37 | 37 | | |||
38 | KrBookmark::KrBookmark(QString name, QUrl url, KActionCollection *parent, QString icon, QString actionName) : | 38 | KrBookmark::KrBookmark(QString name, QUrl url, KActionCollection *parent, QString iconName, QString actionName) : | ||
39 | QAction(parent), _url(url), _icon(icon), _folder(false), _separator(false), _autoDelete(true) | 39 | QAction(parent), _url(url), _iconName(iconName), _folder(false), _separator(false), _autoDelete(true) | ||
40 | { | 40 | { | ||
41 | QString actName = actionName.isNull() ? BM_NAME(name) : BM_NAME(actionName); | 41 | QString actName = actionName.isNull() ? BM_NAME(name) : BM_NAME(actionName); | ||
42 | setText(name); | 42 | setText(name); | ||
43 | parent->addAction(actName, this); | 43 | parent->addAction(actName, this); | ||
44 | connect(this, SIGNAL(triggered()), this, SLOT(activatedProxy())); | 44 | connect(this, SIGNAL(triggered()), this, SLOT(activatedProxy())); | ||
45 | 45 | | |||
46 | // do we have an icon? | 46 | // do we have an icon? | ||
47 | if (!icon.isEmpty()) | 47 | if (!iconName.isEmpty()) | ||
48 | setIcon(QIcon::fromTheme(icon)); | 48 | setIcon(Icon(iconName)); | ||
49 | else { | 49 | else { | ||
50 | // what kind of a url is it? | 50 | // what kind of a url is it? | ||
51 | if (_url.isLocalFile()) { | 51 | if (_url.isLocalFile()) { | ||
52 | setIcon(QIcon::fromTheme("folder")); | 52 | setIcon(Icon("folder")); | ||
53 | } else { // is it an archive? | 53 | } else { // is it an archive? | ||
54 | if (KRarcHandler::isArchive(_url)) | 54 | if (KRarcHandler::isArchive(_url)) | ||
55 | setIcon(QIcon::fromTheme("application-x-tar")); | 55 | setIcon(Icon("application-x-tar")); | ||
56 | else setIcon(QIcon::fromTheme("folder-html")); | 56 | else setIcon(Icon("folder-html")); | ||
57 | } | 57 | } | ||
58 | } | 58 | } | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | KrBookmark::KrBookmark(QString name, QString icon) : | 61 | KrBookmark::KrBookmark(QString name, QString iconName) : | ||
62 | QAction(QIcon::fromTheme(icon), name, 0), _icon(icon), _folder(true), _separator(false), _autoDelete(false) | 62 | QAction(Icon(iconName), name, 0), _iconName(iconName), _folder(true), _separator(false), _autoDelete(false) | ||
63 | { | 63 | { | ||
64 | setIcon(QIcon::fromTheme(icon == "" ? "folder" : icon)); | 64 | setIcon(Icon(iconName == "" ? "folder" : iconName)); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | KrBookmark::~KrBookmark() | 67 | KrBookmark::~KrBookmark() | ||
68 | { | 68 | { | ||
69 | if (_autoDelete) { | 69 | if (_autoDelete) { | ||
70 | QListIterator<KrBookmark *> it(_children); | 70 | QListIterator<KrBookmark *> it(_children); | ||
71 | while (it.hasNext()) | 71 | while (it.hasNext()) | ||
72 | delete it.next(); | 72 | delete it.next(); | ||
73 | _children.clear(); | 73 | _children.clear(); | ||
74 | } | 74 | } | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | KrBookmark * KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) | 77 | KrBookmark * KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) | ||
78 | { | 78 | { | ||
79 | return static_cast<KrBookmark*>(collection->action(BM_NAME(actionName))); | 79 | return static_cast<KrBookmark*>(collection->action(BM_NAME(actionName))); | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | KrBookmark * KrBookmark::trash(KActionCollection *collection) | 82 | KrBookmark * KrBookmark::trash(KActionCollection *collection) | ||
83 | { | 83 | { | ||
84 | KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection); | 84 | KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection); | ||
85 | if (!bm) | 85 | if (!bm) | ||
86 | bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection); | 86 | bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection); | ||
87 | 87 | | |||
88 | bm->setIcon(krLoader->loadIcon(KrTrashHandler::trashIcon(), KIconLoader::Small)); | 88 | bm->setIcon(Icon(KrTrashHandler::trashIconName())); | ||
89 | return bm; | 89 | return bm; | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | KrBookmark * KrBookmark::virt(KActionCollection *collection) | 92 | KrBookmark * KrBookmark::virt(KActionCollection *collection) | ||
93 | { | 93 | { | ||
94 | KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); | 94 | KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); | ||
95 | if (!bm) { | 95 | if (!bm) { | ||
96 | bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection); | 96 | bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection); | ||
97 | bm->setIcon(krLoader->loadIcon("document-open-remote", KIconLoader::Small)); | 97 | bm->setIcon(Icon("document-open-remote")); | ||
98 | } | 98 | } | ||
99 | return bm; | 99 | return bm; | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | KrBookmark * KrBookmark::lan(KActionCollection *collection) | 102 | KrBookmark * KrBookmark::lan(KActionCollection *collection) | ||
103 | { | 103 | { | ||
104 | KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); | 104 | KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); | ||
105 | if (!bm) { | 105 | if (!bm) { | ||
106 | bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection); | 106 | bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection); | ||
107 | bm->setIcon(krLoader->loadIcon("network-workgroup", KIconLoader::Small)); | 107 | bm->setIcon(Icon("network-workgroup")); | ||
108 | } | 108 | } | ||
109 | return bm; | 109 | return bm; | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | QAction * KrBookmark::jumpBackAction(KActionCollection *collection, bool isSetter, ListPanelActions *sourceActions) | 112 | QAction * KrBookmark::jumpBackAction(KActionCollection *collection, bool isSetter, ListPanelActions *sourceActions) | ||
113 | { | 113 | { | ||
114 | auto actionName = isSetter ? QString("setJumpBack") : QString("jumpBack"); | 114 | auto actionName = isSetter ? QString("setJumpBack") : QString("jumpBack"); | ||
115 | auto action = collection->action(actionName); | 115 | auto action = collection->action(actionName); | ||
Show All 35 Lines |