Re: [SailfishDevel] Build a Model with fixed items + dynamic ones

2015-04-20 Thread Nils Jeisecke
Hi,

On Fri, Apr 17, 2015 at 12:09 PM, François K. daithe...@free.fr wrote:
 1/ The first one is to build a Model that would inherit from 
 QAbstractListModel.
 In the constructor, I would add the first 6 items (hard-code them).

maybe this code can give you some inspiration to solve at least some
part of your problem:

-- prefixmodel.h

#ifndef PREFIXMODEL_h
#define PREFIXMODEL_h

#include QAbstractProxyModel

class RealModel;

class PrefixModel : public QAbstractProxyModel
{
  Q_OBJECT

public:

  explicit PrefixModel(QObject *parent = 0);

  int rowCount(const QModelIndex parent = QModelIndex()) const;
  int columnCount(const QModelIndex parent) const { return 1; }
  QModelIndex parent(const QModelIndex ) const { return QModelIndex(); }
  QModelIndex index(int row, int column, const QModelIndex parent =
QModelIndex()) const;

  QModelIndex mapFromSource(const QModelIndex sourceIndex) const;
  QModelIndex mapToSource(const QModelIndex proxyIndex) const;

  void setRealModel(RealModel *sourceModel)

private slots:

  void sourceRowsInserted(const QModelIndex , int, int);
  void sourceRowsRemoved(const QModelIndex , int, int);
  void sourceRowsAboutToBeInserted(const QModelIndex , int, int);
  void sourceRowsAboutToBeRemoved(const QModelIndex , int, int);
  void sourceReset();
  QVariant data(const QModelIndex proxyIndex, int role) const;
};

#endif // PREFIXMODEL_h

-- prefixmodel.cpp

#include prefixmodel.h
#incldue realmodel.h

#define FIX_ITEMS 6

PrefixModel::PrefixModel(QObject *parent) :
  QAbstractProxyModel(parent)
{
}

QModelIndex PrefixModel::mapFromSource(const QModelIndex sourceIndex) const
{
  return sourceModel()-index(sourceIndex.row() + FIX_ITEMS,
sourceIndex.column());
}

QModelIndex PrefixModel::mapToSource(const QModelIndex proxyIndex) const
{
  if (!sourceModel())
return QModelIndex();

  return sourceModel()-index(proxyIndex.row() - FIX_ITEMS,
proxyIndex.column());
}

QVariant PrefixModel::data(const QModelIndex proxyIndex, int role) const
{
  if (proxyIndex.row()  FIX_ITEMS) {
if (role == Qt::DisplayRole)
  return QString(fix item #%1).arg(proxyIndex.row());

return QVariant();
  }
  return QAbstractProxyModel::data(proxyIndex, role);
}

int PrefixModel::rowCount(const QModelIndex parent) const
{
  if (!sourceModel())
return 0;

  return sourceModel()-rowCount(parent) + FIX_ITEMS;
}

QModelIndex PrefixModel::index(int row, int column, const QModelIndex
parent) const
{
  return createIndex(row, column, 0);
}

void PrefixModel::setRealModel(RealModel *sourceModel)
{
  if (this-sourceModel() == sourceModel)
return;

  if (this-sourceModel())
this-sourceModel()-disconnect(this);

  QAbstractProxyModel::setSourceModel(sourceModel);
  emit sourceModelChanged();

  connect(sourceModel,
SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this,
SLOT(sourceRowsAboutToBeInserted(QModelIndex,int,int)));
  connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(sourceRowsInserted(QModelIndex,int,int)));
  connect(sourceModel,
SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this,
SLOT(sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
  connect(sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this,
SLOT(sourceRowsRemoved(QModelIndex,int,int)));
  connect(sourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset()));
}

RealModel *PrefixModel::sourceModelInternal() const
{
  return qobject_castRealModel*(QAbstractProxyModel::sourceModel());
}

void PrefixModel::sourceRowsInserted(const QModelIndex , int start, int end)
{
  endInsertRows();
}

void PrefixModel::sourceRowsRemoved(const QModelIndex , int start, int end)
{
  endRemoveRows();
}

void PrefixModel::sourceRowsAboutToBeInserted(const QModelIndex , int
start, int end)
{
  beginInsertRows(QModelIndex(), start + FIX_ITEMS, end + FIX_ITEMS);
}

void PrefixModel::sourceRowsAboutToBeRemoved(const QModelIndex , int
start, int end)
{
  beginRemoveRows(QModelIndex(), start + FIX_ITEMS, end + FIX_ITEMS);
}

void PrefixModel::sourceReset()
{
  beginResetModel();
  endResetModel();
}

Nils
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

[SailfishDevel] Android Subsystem

2013-12-18 Thread Nils Jeisecke
Hi list,

Sometimes starting of Android applications does not work. The home
screen shows a panel which says Loading, then the android subsystem
crashes (I guess).
After closing some Sailfish apps, it usually works. A memory problem?

Back Key: When pressing the Back Key and the application does not
handle this the panel on home disappears as if all Android apps were
terminated. On BB10 this simply shows the task switcher.

This plus the general task switching issue renders the whole Android
subsystem currently nearly unusable for me (please read this just as a
bug report - I really want this platform to become successful and
there's already quite a lot which I like about the device).

Nils
___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] A new Jolla phone user - after 2 days of use

2013-12-17 Thread Nils Jeisecke
Oops, sent to early...

- With the white cover and it's ambient active you can hardly read
your network providers's name in the lock screen (not much of an
information loss but it looks rather strange)
- Cannot copy/paste in Mail or in Browser
- Browser can't share links
- Don't like the Browser's look and feel. It is totally out of place
with the rest of the OS.
- Regular disconnects from WLAN
- I had to manually setup the APN for T-Mobile

Don't get me wrong. It's great to have the device but it does wear the
beta tag for a reason. However I love to have double tap to wake-up
back ;-)

Nils
___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] Bluetooth headset/carkit issue (and clock related feedback)

2013-12-17 Thread Nils Jeisecke
On Tue, Dec 17, 2013 at 11:09 AM, Valerio Valerio
valerio.vale...@jollamobile.com wrote:
 you can access that info at anytime by doing a peak gesture:
 http://www.youtube.com/watch?v=p9YGtW274GIfeature=c4-overviewlist=UUgK45xp5j9vJMJ3odffESjA
But where's the date? Currently calendar has to be open on the home
screen to see that.

Nils
___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] A new Jolla phone user - after 2 days of use

2013-12-17 Thread Nils Jeisecke
Hi,

did anybody manage to create all-day events in the calendar? It shows
existing events as all-day but I can't find a UI for setting that.

Nils
___
SailfishOS.org Devel mailing list