]>
cloud.milkyroute.net Git - dolphin.git/blob - src/protocolcombo.cpp
729102973e1bfb96030c67e6093bff8de32cf1a6
1 /***************************************************************************
2 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
23 #include <kprotocolinfo.h>
24 #include <kprotocolmanager.h>
26 #include "protocolcombo.h"
28 const static int customProtocolIndex
= 0;
30 ProtocolCombo::ProtocolCombo(const QString
& protocol
, UrlNavigator
* parent
)
31 : UrlNavigatorButton(-1, parent
),
32 m_protocols(KProtocolInfo::protocols())
35 QStringList::iterator it
= m_protocols
.begin();
36 QStringList::iterator itEnd
= m_protocols
.end();
37 QMenu
* menu
= new QMenu(this);
40 //kDebug() << "info for " << *it << " "
41 // << KProtocolInfo::protocolClass(*it) << endl;
42 //TODO: wow this is ugly. or .. is it? ;) we need a way to determine
43 // if a protocol is appropriate for use in a file manager. hum!
44 //if (KProtocolInfo::capabilities(*it).findIndex("filemanager") == -1)
46 // DF: why not just supportsListing?
48 if (KProtocolInfo::protocolClass(*it
) == ":" ||
49 !KProtocolManager::supportsWriting(*it
))
51 //kDebug() << "!!! removing " << *it << endl;
52 QStringList::iterator tempIt
= it
;
54 m_protocols
.erase(it
);
64 // menu->insertItem("", customProtocolIndex);
65 // menu->insertStringList(m_protocols);
67 for (QStringList::const_iterator it
= m_protocols
.constBegin();
68 it
!= m_protocols
.constEnd();
71 menu
->insertItem(*it
, i
);
73 //menu->insertItems(m_protocols);
74 connect(menu
, SIGNAL(activated(int)), this, SLOT(setProtocol(int)));
82 // #include "urlnavigator.h"
83 void ProtocolCombo::setProtocol(const QString
& protocol
)
86 // if (KProtocolInfo::isKnownProtocol(protocol))
87 // int index = m_protocols.findIndex(protocol);
90 // changeItem(protocol, customProtocolIndex);
91 // setCurrentItem(customProtocolIndex);
95 // setCurrentItem(index + 1);
99 void ProtocolCombo::setProtocol(int index
)
101 if (index
< 0 || index
> m_protocols
.count())
106 QString protocol
= m_protocols
[index
];
107 kDebug() << "setProtocol " << index
<< " " << protocol
<< endl
;
109 emit
activated(protocol
);
113 QString
ProtocolCombo::currentProtocol() const
115 return text(); //currentText();
118 #include "protocolcombo.moc"