Пример #1
0
/*! \internal */
QModelIndex KDPropertyModel::parent(const QModelIndex& index) const
{
  //qDebug() << "parent( " <<index<<" )";
  if(!index.isValid() || privateData(index) == d->rootproperty || d->parentOf(privateData(index)) == d->rootproperty )
    return QModelIndex();

  Q_ASSERT(privateData(index));

  /* Only sub-properties can have parents in flat mode */
  if( isFlat() && privateData(index)->isStandalone() ) return QModelIndex();

  return indexOf(d->parentOf(privateData(index)));
}
Пример #2
0
/*! \internal */
Qt::ItemFlags KDPropertyModel::flags(const QModelIndex &index) const
{
  Qt::ItemFlags f = QAbstractItemModel::flags(index);
  if(isEnabled(index)) {
    f |= Qt::ItemIsEnabled;
    if(isEditable(index))
      f |= Qt::ItemIsEditable;
  } else {
    f &= !Qt::ItemIsEnabled;
  }
  if(privateData(index) && privateData(index)->isCategory())
    f |= Qt::ItemIsUserCheckable|Qt::ItemIsEnabled;
  return f;
}
Пример #3
0
void QOfonoModemInterface::objectPathChanged(const QString &path, const QVariantMap *)
{
    // The base implementation would immediately create the D-Bus interface
    // object. However we need to check if our interface is actually available
    // and postpone creation of the D-Bus interface object if our interface
    // isn't there (see onModemInterfacesChanged below)
    bool wasReady = isReady();

    Private *d_ptr = privateData();
    if (!d_ptr->modem.isNull()) {
        disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)),
            this, SLOT(onModemInterfacesChanged(QStringList)));
        d_ptr->modem.reset();
    }

    setDbusInterface(NULL, NULL);

    d_ptr->modem = QOfonoModem::instance(objectPath());
    connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)),
        this, SLOT(onModemInterfacesChanged(QStringList)));

    Q_EMIT modemPathChanged(path);
    onModemInterfacesChanged(d_ptr->modem->interfaces());
    if (wasReady != isReady()) {
        Q_EMIT readyChanged();
    }
}
Пример #4
0
/*! \internal */
bool KDPropertyModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
  if(KDPropertyInterface *property = privateData(index)) {
    if (role == Qt::EditRole /*|| role == ChangedRole*/ ) {
      if( value != property->value() ) {
        property->setValue(value);
        property->setChanged(true);

        KDPropertyInterface* stdalone = property;
        while(stdalone != 0 && !stdalone->isStandalone())
          stdalone = stdalone->parent();
        if (stdalone != 0 && stdalone != property /*&& nonfake->dirty()*/) {
          /*nonfake->setDirty(false);*/ // TODO
          emit propertyChanged(stdalone);
        }
      }
    } else if( role == Qt::CheckStateRole && property->isCategory() ) {
      KDPropertyCategory* cat = static_cast<KDPropertyCategory*>(property);
      cat->setChecked( qVariantValue<int>(value)==Qt::Checked );
      update(cat);
    }
    return true;
  }
  return false;
}
Пример #5
0
void QOfonoModemInterface::onModemInterfacesChanged(const QStringList &interfaces)
{
    if (interfaces.contains(privateData()->interfaceName)) {
        Q_ASSERT(!objectPath().isEmpty());
        if (!dbusInterface()) {
            setDbusInterface(createDbusInterface(objectPath()), NULL);
        }
    } else {
        setDbusInterface(NULL, NULL);
    }
}
Пример #6
0
/*! \internal */
QModelIndex KDPropertyModel::index(int row, int column, const QModelIndex& parent) const
{
  //qDebug() << "index( " << row << ", " << column << ", " <<parent<<" )";
  if ( row < 0 || row >= rowCount( parent ) || column < 0 || column >= columnCount( parent ) )
      return QModelIndex();
  if( isFlat() && (!parent.isValid() || (parent.isValid()
       && static_cast<KDPropertyGroupInterface*>(parent.internalPointer())->isCategory() ) ) ) {
    int c = row;
    KDPropertyInterface* prop = d->dfsCount( d->rootproperty, c );
    if( prop ) return createIndex(row,column,prop);
    else return QModelIndex();
  } else {
    if(!parent.isValid()) {
      Q_ASSERT( d->rootproperty );
      Q_ASSERT( d->childAt(d->rootproperty, row) );
      return createIndex(row, column, d->childAt(d->rootproperty, row));
    }
    Q_ASSERT( privateData(parent) );
    Q_ASSERT( d->childAt(privateData(parent), row) );
    return createIndex(row, column, d->childAt(privateData(parent), row));
  }
}
Пример #7
0
/*! \internal */
int KDPropertyModel::rowCount(const QModelIndex& parent) const
{
  if (!parent.isValid()) {
    if( isFlat() ) return d->countAll(d->rootproperty);
    else return d->rootproperty->propertyCount();
  }

  if (KDPropertyInterface *p = privateData(parent)) {
    return (p->isContainer())
      ? static_cast<KDPropertyGroupInterface*>(p)->propertyCount()
      : 0;
  }

  return (d->rootproperty->isContainer() )
    ? static_cast<KDPropertyGroupInterface*>(d->rootproperty)->propertyCount()
    : 0;
}
Пример #8
0
QString ContentsChatItem::selection() const
{
    if (selectionMode() == FullSelection)
        return data(MessageModel::DisplayRole).toString();
    if (selectionMode() == PartialSelection) {
        int start = qMin(selectionStart(), selectionEnd());
        int end   = start + qAbs(selectionStart() - selectionEnd());
        int offset = 0;

        for (const Smiley &s : privateData()->smileys) {
            if(s.smileyfiedStart() >= start && s.smileyfiedStart()+1 <= end) {
                offset += s.text().count() - ((s.type() == Smiley::Emoji) ? s.graphics().count() : 1);
            }
        }

        return data(MessageModel::DisplayRole).toString().mid(start, end-start+offset);;
    }
    return QString();
}
Пример #9
0
void EyeCalibrator::setPrivateParameters() { 
  
    Datum privateData(M_DICTIONARY, 2);
    
    Datum paramsH = (fitableFunctions->getElement(HfunctionIndex))->getParameters();
    privateData.addElement(R_CALIBRATOR_PARAMS_H,paramsH);   // M_LIST
    
    Datum paramsV = (fitableFunctions->getElement(VfunctionIndex))->getParameters();
    privateData.addElement(R_CALIBRATOR_PARAMS_V,paramsV);   // M_LIST
    
    storePrivateData(privateData);   // base class method 
    
    // updated Feb 2007  -- DDC may suggest a better way, but works for now
    // Two potential problems that are delt with by the PrivateStorable base class:
    // 1) if we load saved data (in a private variable), then this causes us to come in on a notification
    //      in that case, we will NOT update the private variable (because the VARIABLE is locked and we don't need to update it!)
    //      (but, no matter what, we will keep track of the private variable values (in the PrivateStorable class) to deal with the following problem:
    // 2) if we change the value of the eye calibrator data by any other method, we will update the private variable
    //      and that will trigger a notification back to us, but we will IGNORE that notification (because the CALIBRATOR is locked and we don't need it!)
    //

}
Пример #10
0
void ContentsChatItem::initDocument(QTextDocument *doc)
{
    QString text = data(MessageModel::DisplayRole).toString();

    privateData()->smileys = SmileyList::fromText(text);

    doc->setPlainText(text);
    doc->setTextWidth(width());

    // Replace smileys
    QTextCursor c(doc);
    int i=0;
    for(const Smiley &smiley : privateData()->smileys) {

        // Remove textual smiley representation
        c.setPosition(smiley.smileyfiedStart());
        c.setPosition(smiley.smileyfiedStart()+smiley.text().count(), QTextCursor::KeepAnchor);
        c.removeSelectedText();

        if (smiley.type() == Smiley::Pixmap) {

            QObject *smileyInterface = new SmileyTextObject(smiley.graphics());
            doc->documentLayout()->registerHandler(QTextFormat::UserObject + i+1, smileyInterface);

            QTextCharFormat smileyFormat;
            smileyFormat.setObjectType(QTextFormat::UserObject + i+1);
            c.insertText(QString(QChar::ObjectReplacementCharacter), smileyFormat);
            i++;
        }
        else if (smiley.type() == Smiley::Emoji) {

            c.insertText(smiley.graphics());
            c.setPosition(smiley.smileyfiedStart(), QTextCursor::KeepAnchor);
            QTextCharFormat format;
            format.setFont(smiley.emojiFont());
            c.mergeCharFormat(format);
        }
    }

    // Clickables
    QString dummtext = text;
    for(const Smiley &smiley : privateData()->smileys) {
        QString dummy = "#";
        if(smiley.type() == Smiley::Emoji) {
            for(int i=1; i<smiley.graphics().count(); i++)
                dummy += "#";
        }
        dummtext.replace(smiley.smileyfiedStart(), smiley.text().count(), dummy);
    }

    privateData()->clickables = ClickableList::fromString(dummtext);
    foreach(Clickable click, privateData()->clickables) {
        QTextCursor c(doc);
        c.setPosition(click.start());
        c.setPosition(click.start()+click.length(), QTextCursor::KeepAnchor);
        QTextCharFormat f;
        f.setAnchor(true);
        f.setAnchorHref(c.selectedText());
        f.setForeground(QApplication::palette().brush(QPalette::Link));
        c.mergeCharFormat(f);
    }
Пример #11
0
const SmileyList *ContentsChatItem::smileyList() const
{
    return &(privateData()->smileys);
}
Пример #12
0
QOfonoObject::ExtData* QOfonoModemInterface::extData() const
{
    return privateData()->ext;
}
Пример #13
0
/*! \internal */
QModelIndex KDPropertyModel::buddy(const QModelIndex& index) const
{
  if (index.column() == 0 && privateData(index) && !privateData(index)->isCategory() )
    return createIndex(index.row(), 1, index.internalPointer());
  return index;
}
Пример #14
0
/*! \internal */
bool KDPropertyModel::isEnabled(const QModelIndex& index) const
{
  return privateData(index) && privateData(index)->isEnabled();
}
Пример #15
0
/*! \internal */
bool KDPropertyModel::isEditable(const QModelIndex& index) const
{
  return index.column() == 1 && privateData(index) && privateData(index)->isEditable();
}
Пример #16
0
/*! \internal */
QVariant KDPropertyModel::data(const QModelIndex& index, int role) const
{
  if (!privateData(index))
    return QVariant();

  KDPropertyInterface *o = privateData(index);
  Q_ASSERT(o);
  switch (index.column()) {
  case 0:
    switch (role) {
    case Qt::EditRole:
    case Qt::DisplayRole:
      return o->name().isEmpty()
	? QLatin1String("<noname>")
	: o->name();
    case Qt::DecorationRole:
      if( o->isCategory() ) return o->decoration();
      break;
    case Qt::BackgroundColorRole:
      return o->isCategory()
	?QApplication::palette().color(QPalette::AlternateBase)
	:QApplication::palette().color(QPalette::Base);
    case Qt::CheckStateRole:
      return (o->isCategory()&&static_cast<KDPropertyCategory*>(o)->isCheckable())
        ?qVariantFromValue(static_cast<int>(static_cast<KDPropertyCategory*>(o)->isChecked()))
	:QVariant();
	break;
    case ChangedRole:
      return o->isChanged();
    case HelpRole:
      return o->helpText();
    default:
      break;
    }
    break;
  case 1: {
    switch (role) {
    case Qt::EditRole:
      return o->value();
    case Qt::DisplayRole:
      return o->toString();
    case Qt::DecorationRole:
      if( !o->isCategory() ) return o->decoration();
      break;
    case Qt::BackgroundColorRole:
      return o->isCategory()
	?QApplication::palette().color(QPalette::AlternateBase)
	:QApplication::palette().color(QPalette::Base);
    case ChangedRole:
      return o->isChanged();
    case EditorTypeRole:
      return o->editorType();
    case HelpRole:
      return o->helpText();
    default:
      QVariant v = o->editorHint(role);
      if( v.isValid() ) return v;
      break;
    }
    break;
  }
  default:
    break;
  }
  return QVariant();
}