bool
MedialibDialog::compl_reply (const Xmms::List <Xmms::Dict> &list)
{
	QStringList compl_list;

	Xmms::List <Xmms::Dict>::const_iterator it_end = list.end();
	for (Xmms::List <Xmms::Dict>::const_iterator it = list.begin();
	     it != it_end; ++ it) {
		/* This seems to happen if a album is "" */
		if (it->contains (m_currentsel)) {
			QString qs = XClient::stdToQ (it->get<std::string> (m_currentsel));
			if (! qs.isEmpty())
				compl_list.append (qs);
		}
	}

	if (m_completer) {
		delete m_completer;
	}

	m_completer = new QCompleter (compl_list, this);
	m_completer->setCaseSensitivity (Qt::CaseInsensitive);
	m_le->setCompleter (m_completer);

	m_le->setEnabled (true);
	m_indicator->setStatus (false);
	m_le->setFocus (Qt::OtherFocusReason);
	m_cb->setEnabled (true);

	return true;
}
bool
PlaylistModel::handle_list (const Xmms::List< int > &list)
{
	beginRemoveRows (QModelIndex (), 0, m_plist.size ());
	m_plist.clear ();
	endRemoveRows ();

	Xmms::List< int >::const_iterator it_end = list.end();
	int i = std::distance(list.begin(), it_end);
	beginInsertRows (QModelIndex (), 0, i);
	for (Xmms::List< int >::const_iterator it = list.begin();
	     it != it_end; ++it) {
		m_plist.append (*it);
	}

	endInsertRows ();

	return true;
}
Пример #3
0
bool
PlaylistModel::handle_list (const Xmms::List< unsigned int > &list)
#endif
{
	beginRemoveRows (QModelIndex (), 0, m_plist.size ());
	m_plist.clear ();
	endRemoveRows ();

	int i = 0;
#if HAVE_XMMSV
	for (Xmms::List< int >::const_iterator iter = list.begin();
	     iter != list.end(); ++iter) {
		i++;
	}
#else
	for (list.first (); list.isValid (); ++list) {
		i ++;
	}
#endif
	beginInsertRows (QModelIndex (), 0, i);
#if HAVE_XMMSV
	for (Xmms::List< int >::const_iterator iter = list.begin();
	     iter != list.end(); ++iter) {
		m_plist.append (*iter);
	}
#else
	for (list.first (); list.isValid (); ++list) {
		m_plist.append (*list);
	}
#endif

	endInsertRows ();

	emitTotalPlaytime  ();

	return true;
}
bool
CollectionInfoModel::info_callback (const Xmms::List<Xmms::Dict> &list)
{
    /* convert the first entry in the list to get the headers */
	QList < QHash < QString, QVariant > > l;
	Xmms::List<Xmms::Dict>::const_iterator it_end = list.end();
	for (Xmms::List<Xmms::Dict>::const_iterator it = list.begin();
	     it != it_end; ++it) {
		QHash<QString, QVariant> h = XClient::convert_dict (*it);
		l.append (h);
	}
	set_data (l);

	return true;
}
Пример #5
0
bool
BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
{
	while (!m_list.isEmpty ()) {
		delete m_list.takeFirst ();
	}

#if HAVE_XMMSV
	for (Xmms::List< Xmms::Dict >::const_iterator iter = res.begin();
	     iter != res.end(); ++iter) {
		Xmms::Dict d = *iter;
#else
	for (res.first (); res.isValid (); ++res) {
		Xmms::Dict d = *res;
#endif

		if (!d.contains ("path"))
			continue;

		QString path = QString::fromStdString (d.get<std::string> ("path"));

		QString name;
		if (d.contains ("name")) {
			name = QString::fromStdString (d.get<std::string> ("name"));
		} else {
			if (d.contains ("title")) {
				if (d.contains ("artist")) {
					name += QString::fromStdString (d.get<std::string> ("artist"));
					name += " - ";
				}
				if (d.contains ("album")) {
					name += QString::fromStdString (d.get<std::string> ("album"));
					name += " - ";
				}
				if (d.contains ("tracknr")) {
					name += QString::number (d.get<int32_t>
											 ("tracknr")).rightJustified(2, '0');
					name += " - ";
				}
				name += QString::fromStdString (d.get<std::string> ("title"));
			} else {
				QString tmp2 = path.mid (path.lastIndexOf ("/")+1);
				name = decodeXmmsUrl (tmp2);
			}
		}

		bool isdir = d.get<int32_t> ("isdir");

		if (m_filter_dot && name.startsWith ("."))
			// skip these files 
			continue;

		m_list.append (new BrowseModelItem (path, name, isdir));
	}

	qSort (m_list.begin (), m_list.end (), BrowseModelItem::itemCompare);

	//qDebug ("%s", m_list.size() > 0 ? qPrintable(m_list.at(0)->data("name")) : "none");

	reset ();

	emit dirChanged (m_current_dir);

	return true;
}

/* QModel overrides */
int
BrowseModel::rowCount (const QModelIndex &parent) const
{
	if (parent.isValid())
		return 0;

	return m_list.size ();
}

int
BrowseModel::columnCount (const QModelIndex &parent) const
{
	return m_columns.size ();
}

QVariant
BrowseModel::data (const QModelIndex &index,
						 int role) const
{
	if (!index.isValid ())
		return QVariant ();

	if (index.column () == 0 && role == Qt::DecorationRole)
		return fileIcon(index);

	if (role != Qt::DisplayRole)
		return QVariant ();

	QString h = m_columns[index.column ()].toLower ();

	return QVariant (m_list.at (index.row ())->data (h));
}

QVariant
BrowseModel::headerData (int section,
						 Qt::Orientation orientation,
						 int role) const
{
	if (role == Qt::DisplayRole)
		return QVariant (m_columns[section]);
	return QVariant ();
}

QIcon
BrowseModel::fileIcon (const QModelIndex &index) const
{
    if (!index.isValid())
		return QIcon ();

	BrowseModelItem *item = m_list.at (index.row ());
	if (item && item->isDir ())
    	return QIcon (m_style->standardPixmap (QStyle::SP_DirClosedIcon));

	return QIcon (m_style->standardPixmap (QStyle::SP_FileIcon));
}