| Summary: | KURLComboBox should update item text to be the URL in ALL modes (not just KURLComboBox::Directories)! | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | Calin Culianu <cculianu> |
| Component: | general | Assignee: | David Faure <faure> |
| Status: | RESOLVED UNMAINTAINED | ||
| Severity: | normal | CC: | a.samirh78, kdelibs-bugs-null, nate |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Gentoo Packages | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Small KDE app to show the broken/unexpected behavior | ||
Here is a more correct code snippet.. you can call this testapp.cpp and compile it with:
# g++ -L${QTDIR}/lib -I ${QTDIR}/include -L`kde-config --expandvars --install lib` -lkio -lkdecore -I`kde-config --expandvars --prefix`/include -o testapp testapp.cpp
run it with:
# ./testapp
----------------- CODE SAMPLE TO REPRODUCE BUG... ----------------------
#include <kglobal.h>
#include <kiconloader.h>
#include <kurlcombobox.h>
#include <kurl.h>
#include <qstring.h>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <qvbox.h>
#include <qlabel.h>
int main(int argc, char **argv)
{
KAboutData about("testapp", "Test App", "1.0");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
QWidget *w = new QVBox(0);
app.setMainWidget(w);
KURLComboBox *box_broken, *box_works;
(void)new QLabel("Works:", w);
box_works = new KURLComboBox(KURLComboBox::Directories, true, w);
(void)new QLabel("Broken:", w);
box_broken = new KURLComboBox(KURLComboBox::Both, true, w);
QPixmap folder_red = KGlobal::iconLoader()->loadIcon("folder_red", KIcon::Small, 0, KIcon::DefaultState, 0L, true),
folder = KGlobal::iconLoader()->loadIcon("folder", KIcon::Small, 0, KIcon::DefaultState, 0L, true);
box_broken->addDefaultURL((QString)"/", folder_red, "Root directory");
box_broken->addDefaultURL((QString)"/home", folder, "Home directories");
box_works->addDefaultURL((QString)"/", folder_red, "Root directory");
box_works->addDefaultURL((QString)"/home", folder, "Home directories");
box_works->setDefaults();
box_broken->setDefaults();
w->show();
return app.exec();
}
#include <kglobal.h>
#include <kiconloader.h>
#include <kurlcombobox.h>
#include <kurl.h>
#include <qstring.h>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <qvbox.h>
#include <qlabel.h>
int main(int argc, char **argv)
{
KAboutData about("testapp", "Test App", "1.0");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
QWidget *w = new QVBox(0);
app.setMainWidget(w);
KURLComboBox *box_broken, *box_works;
(void)new QLabel("Works:", w);
box_works = new KURLComboBox(KURLComboBox::Directories, true, w);
(void)new QLabel("Broken:", w);
box_broken = new KURLComboBox(KURLComboBox::Both, true, w);
QPixmap folder_red = KGlobal::iconLoader()->loadIcon("folder_red", KIcon::Small, 0, KIcon::DefaultState, 0L, true),
folder = KGlobal::iconLoader()->loadIcon("folder", KIcon::Small, 0, KIcon::DefaultState, 0L, true);
box_broken->addDefaultURL((QString)"/", folder_red, "Root directory");
box_broken->addDefaultURL((QString)"/home", folder, "Home directories");
box_works->addDefaultURL((QString)"/", folder_red, "Root directory");
box_works->addDefaultURL((QString)"/home", folder, "Home directories");
box_works->setDefaults();
box_broken->setDefaults();
w->show();
return app.exec();
}
Oops above code sample is bad.. use attachement instead.. Created attachment 9679 [details]
Small KDE app to show the broken/unexpected behavior
how to compile (on my system at least):
g++ -Wall -L${QTDIR}/lib -I${QTDIR}/include -L`kde-config --expandvars
--install lib` -lkio -lkdecore -I`kde-config --expandvars --prefix`/include -o
testapp testapp.cpp
How to run:
./testapp
Anyone? :( The code has changed in such a long time; feel free to reopen if you still see this issue. |
Version: (using KDE KDE 3.3.2) Installed from: Gentoo Packages Compiler: gcc version 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1) OS: Linux This is a bug in the KIO library's KURLComboBox class.. I was not sure where to file it.. This problem occurs in any KURLComboBox::Mode other than KURLComboBox::Directories: Basically, the problem is that if you load this combo box with a bunch of KURLComboItems that have .text which differs from .url (.text is used for display purposes and .url is the actual URL), AND you are in any mode OTHER than KURLComboBox::Directories, selecting the URL from the combo box *doesn't* correctly update the combo box item text to be "item->url". Instead it remains "item->text" which causes problems since there is no way to find out the actual URL from client code. How to reproduce: KURLComboBox *box_broken = new KURLComboBox(KURLComboBox::Both, true, 0), *box_works = new KURLComboBox(KURLComboBox::Directories, true, 0); box_broken->addDefaultURL((QString)"/", folder_red, "Root directory"); box_broken->addDefaultURL((QString)"/home", folder_red, "Homes directories"); box_broken->show(); box_works->addDefaultURL((QString)"/", folder_red, "Root directory"); box_works->addDefaultURL((QString)"/home", folder_red, "Homes directories"); box_works->show(); Notice how box_broken and box_works behave differently. If you click on a URL in box_works, it switches from the display text to the actual url. Client code can then figure out what the actual URL was. If you do the same on box_broken this change doesn't happen...