Changeset View
Changeset View
Standalone View
Standalone View
src/k3bdiroperator.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 35 | { | |||
---|---|---|---|---|---|
56 | m_bmMenu = new KBookmarkMenu( bmMan, this, m_bmPopup->menu(), actionCollection() ); | 56 | m_bmMenu = new KBookmarkMenu( bmMan, this, m_bmPopup->menu(), actionCollection() ); | ||
57 | 57 | | |||
58 | (void)K3b::createAction( this,i18n("&Add to Project"), 0, Qt::SHIFT+Qt::Key_Return, | 58 | (void)K3b::createAction( this,i18n("&Add to Project"), 0, Qt::SHIFT+Qt::Key_Return, | ||
59 | this, SLOT(slotAddFilesToProject()), | 59 | this, SLOT(slotAddFilesToProject()), | ||
60 | actionCollection(), "add_file_to_project"); | 60 | actionCollection(), "add_file_to_project"); | ||
61 | 61 | | |||
62 | connect( this, SIGNAL(fileSelected(KFileItem)), | 62 | connect( this, SIGNAL(fileSelected(KFileItem)), | ||
63 | this, SLOT(slotAddFilesToProject()) ); | 63 | this, SLOT(slotAddFilesToProject()) ); | ||
64 | connect( this, &KDirOperator::contextMenuAboutToShow, | ||||
65 | this, &DirOperator::extendContextMenu ); | ||||
64 | } | 66 | } | ||
65 | 67 | | |||
66 | 68 | | |||
67 | K3b::DirOperator::~DirOperator() | 69 | K3b::DirOperator::~DirOperator() | ||
68 | { | 70 | { | ||
69 | delete m_bmMenu; | 71 | delete m_bmMenu; | ||
70 | } | 72 | } | ||
71 | 73 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
118 | 120 | | |||
119 | 121 | | |||
120 | QUrl K3b::DirOperator::currentUrl() const | 122 | QUrl K3b::DirOperator::currentUrl() const | ||
121 | { | 123 | { | ||
122 | return url(); | 124 | return url(); | ||
123 | } | 125 | } | ||
124 | 126 | | |||
125 | 127 | | |||
126 | void K3b::DirOperator::activatedMenu( const KFileItem&, const QPoint& pos ) | 128 | void K3b::DirOperator::extendContextMenu( const KFileItem&, QMenu* menu ) | ||
127 | { | 129 | { | ||
128 | // both from KDirOperator | 130 | QAction* firstAction = menu->actions().first(); | ||
129 | setupMenu(); | 131 | menu->insertAction( firstAction, actionCollection()->action("add_file_to_project") ); | ||
130 | updateSelectionDependentActions(); | 132 | menu->insertSeparator( firstAction ); | ||
131 | 133 | menu->addSeparator(); | |||
132 | // insert our own actions | 134 | menu->addAction( m_bmPopup ); | ||
133 | KActionMenu* dirOpMenu = qobject_cast<KActionMenu*>( actionCollection()->action("popupMenu") ); | | |||
134 | if (!dirOpMenu) { | | |||
135 | return; | | |||
136 | } | | |||
137 | QAction* firstAction = dirOpMenu->menu()->actions().first(); | | |||
138 | dirOpMenu->insertAction( firstAction, actionCollection()->action("add_file_to_project") ); | | |||
139 | dirOpMenu->insertSeparator( firstAction ); | | |||
140 | dirOpMenu->addSeparator(); | | |||
141 | dirOpMenu->addAction( m_bmPopup ); | | |||
142 | 135 | | |||
143 | bool hasSelection = !selectedItems().isEmpty(); | 136 | bool hasSelection = !selectedItems().isEmpty(); | ||
144 | /* | 137 | /* | ||
145 | view() && view()->selectedItems() && | 138 | view() && view()->selectedItems() && | ||
146 | !view()->selectedItems()->isEmpty(); | 139 | !view()->selectedItems()->isEmpty(); | ||
147 | */ | 140 | */ | ||
148 | actionCollection()->action("add_file_to_project")->setEnabled( hasSelection && k3bappcore->k3bMainWindow()->activeView() != 0 ); | 141 | actionCollection()->action("add_file_to_project")->setEnabled( hasSelection && k3bappcore->k3bMainWindow()->activeView() != 0 ); | ||
149 | | ||||
150 | dirOpMenu->menu()->popup( pos ); | | |||
151 | } | 142 | } | ||
152 | 143 | | |||
153 | 144 | | |||
154 | void K3b::DirOperator::slotAddFilesToProject() | 145 | void K3b::DirOperator::slotAddFilesToProject() | ||
155 | { | 146 | { | ||
156 | QList<QUrl> files; | 147 | QList<QUrl> files; | ||
157 | QList<KFileItem> items(selectedItems()); | 148 | QList<KFileItem> items(selectedItems()); | ||
158 | Q_FOREACH( const KFileItem& fileItem, items ) { | 149 | Q_FOREACH( const KFileItem& fileItem, items ) { | ||
Show All 9 Lines |