Speed-up the BrowseDialog

This commit is contained in:
Tobias Rundstrom 2006-08-25 11:16:09 -04:00
parent 95ff470248
commit 2756d57390
3 changed files with 11 additions and 6 deletions

View file

@ -11,20 +11,22 @@
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QToolButton> #include <QToolButton>
#include <QTreeView>
BrowseDialog::BrowseDialog (QWidget *parent) : QDialog (parent) BrowseDialog::BrowseDialog (QWidget *parent) : QDialog (parent)
{ {
setSizeGripEnabled(true); setSizeGripEnabled(true);
QGridLayout *grid = new QGridLayout (this); QGridLayout *grid = new QGridLayout (this);
m_list = new QListView (this); m_list = new QTreeView (this);
m_model = new BrowseModel (this); m_model = new BrowseModel (this);
m_list->setModel (m_model); m_list->setModel (m_model);
m_list->setSelectionMode (QAbstractItemView::ExtendedSelection); m_list->setSelectionMode (QAbstractItemView::ExtendedSelection);
m_list->setSelectionBehavior (QAbstractItemView::SelectRows); m_list->setSelectionBehavior (QAbstractItemView::SelectRows);
m_list->setWrapping (true); // m_list->setWrapping (true);
m_list->setResizeMode (QListView::Adjust); m_list->setIndentation (0);
//m_list->setResizeMode (QListView::Adjust);
m_list->setEditTriggers (QAbstractItemView::EditKeyPressed); m_list->setEditTriggers (QAbstractItemView::EditKeyPressed);
m_list->setContextMenuPolicy (Qt::CustomContextMenu); m_list->setContextMenuPolicy (Qt::CustomContextMenu);

View file

@ -4,6 +4,7 @@
#include "BrowseModel.h" #include "BrowseModel.h"
#include <QDialog> #include <QDialog>
#include <QTreeView>
#include <QListView> #include <QListView>
#include <QGridLayout> #include <QGridLayout>
#include <QPushButton> #include <QPushButton>
@ -27,7 +28,7 @@ class BrowseDialog : public QDialog
QStringList getFiles (); QStringList getFiles ();
private: private:
QListView *m_list; QTreeView *m_list;
QComboBox *m_lookInCombo; QComboBox *m_lookInCombo;
QLineEdit *m_lookInEdit; QLineEdit *m_lookInEdit;
QLineEdit *m_fileNameEdit; QLineEdit *m_fileNameEdit;

View file

@ -86,12 +86,12 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
QString name; QString name;
if (d.contains ("name")) { if (d.contains ("name")) {
name = QString::fromStdString ((*res).get<std::string> ("name")); name = QString::fromStdString (d.get<std::string> ("name"));
} else { } else {
name = path.mid (path.lastIndexOf ("/")+1); name = path.mid (path.lastIndexOf ("/")+1);
} }
bool isdir = (*res).get<int32_t> ("isdir"); bool isdir = d.get<int32_t> ("isdir");
if (m_filter_dot && name.startsWith (".")) if (m_filter_dot && name.startsWith ("."))
// skip these files // skip these files
@ -104,6 +104,8 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
emit dirChanged (m_current_dir); emit dirChanged (m_current_dir);
qDebug ("done");
return true; return true;
} }