Qt 4.8
Public Functions | Public Variables | Friends | List of all members
QPPDOptionsModel Class Reference
Inheritance diagram for QPPDOptionsModel:
QAbstractItemModel QObject

Public Functions

int columnCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of columns for the children of the given parent. More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Returns the data stored under the given role for the item referred to by the index. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for the given index. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation. More...
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Returns the index of the item in the model specified by the given row, column and parent index. More...
 
QModelIndex parent (const QModelIndex &index) const
 Returns the parent of the model item with the given index. More...
 
void parseChoices (QOptionTreeItem *parent)
 
void parseGroups (QOptionTreeItem *parent)
 
void parseItems ()
 
void parseOptions (QOptionTreeItem *parent)
 
 QPPDOptionsModel (QCUPSSupport *cups, QObject *parent=0)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of rows under the given parent. More...
 
 ~QPPDOptionsModel ()
 
- Public Functions inherited from QAbstractItemModel
virtual QModelIndex buddy (const QModelIndex &index) const
 Returns a model index for the buddy of the item represented by index. More...
 
virtual bool canFetchMore (const QModelIndex &parent) const
 Returns true if there is more data available for parent; otherwise returns false. More...
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Handles the data supplied by a drag and drop operation that ended with the given action. More...
 
virtual void fetchMore (const QModelIndex &parent)
 Fetches any available data for the items with the parent specified by the parent index. More...
 
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 Returns true if parent has any children; otherwise returns false. More...
 
bool hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More...
 
bool insertColumn (int column, const QModelIndex &parent=QModelIndex())
 Inserts a single column before the given column in the child items of the parent specified. More...
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count new columns into the model before the given column. More...
 
bool insertRow (int row, const QModelIndex &parent=QModelIndex())
 Inserts a single row before the given row in the child items of the parent specified. More...
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count rows into the model before the given row. More...
 
virtual QMap< int, QVariantitemData (const QModelIndex &index) const
 Returns a map with values for all predefined roles in the model for the item at the given index. More...
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
 Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More...
 
virtual QMimeDatamimeData (const QModelIndexList &indexes) const
 Returns an object that contains serialized items of data corresponding to the list of indexes specified. More...
 
virtual QStringList mimeTypes () const
 Returns a list of MIME types that can be used to describe a list of model indexes. More...
 
 QAbstractItemModel (QObject *parent=0)
 Constructs an abstract item model with the given parent. More...
 
bool removeColumn (int column, const QModelIndex &parent=QModelIndex())
 Removes the given column from the child items of the parent specified. More...
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count columns starting with the given column under parent parent from the model. More...
 
bool removeRow (int row, const QModelIndex &parent=QModelIndex())
 Removes the given row from the child items of the parent specified. More...
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count rows starting with the given row under parent parent from the model. More...
 
const QHash< int, QByteArray > & roleNames () const
 Returns the model's role names. More...
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the role data for the item at index to value. More...
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 Sets the data for the given role and section in the header with the specified orientation to the value supplied. More...
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More...
 
void setSupportedDragActions (Qt::DropActions)
 Sets the supported drag actions for the items in the model. More...
 
QModelIndex sibling (int row, int column, const QModelIndex &idx) const
 Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More...
 
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the model by column in the given order. More...
 
virtual QSize span (const QModelIndex &index) const
 Returns the row and column span of the item represented by index. More...
 
Qt::DropActions supportedDragActions () const
 Returns the actions supported by the data in this model. More...
 
virtual Qt::DropActions supportedDropActions () const
 Returns the drop actions supported by this model. More...
 
virtual ~QAbstractItemModel ()
 Destroys the abstract item model. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Public Variables

QCUPSSupportcups
 
const ppd_file_t * ppd
 
QOptionTreeItemrootItem
 

Friends

class QPPDOptionsEditor
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemModel
virtual void revert ()
 Lets the model know that it should discard cached information. More...
 
virtual bool submit ()
 Lets the model know that it should submit cached information to permanent storage. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QAbstractItemModel
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are inserted into the model. More...
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 This signal is emitted just before columns are moved within the model. More...
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are removed from the model. More...
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been inserted into the model. More...
 
void columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
 This signal is emitted after columns have been moved within the model. More...
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been removed from the model. More...
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 This signal is emitted whenever the data in an existing item changes. More...
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 This signal is emitted whenever a header is changed. More...
 
void layoutAboutToBeChanged ()
 This signal is emitted just before the layout of a model is changed. More...
 
void layoutChanged ()
 This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More...
 
void modelAboutToBeReset ()
 This signal is emitted when reset() is called, before the model's internal state (e. More...
 
void modelReset ()
 This signal is emitted when reset() is called, after the model's internal state (e. More...
 
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are inserted into the model. More...
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 This signal is emitted just before rows are moved within the model. More...
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are removed from the model. More...
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been inserted into the model. More...
 
void rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 This signal is emitted after rows have been moved within the model. More...
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been removed from the model. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QAbstractItemModel
void resetInternalData ()
 This slot is called just after the internal data of a model is cleared while it is being reset. More...
 
- Protected Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 Begins a column insertion operation. More...
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 Begins a row insertion operation. More...
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
 Begins a column move operation. More...
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
 Begins a row move operation. More...
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 Begins a column removal operation. More...
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 Begins a row removal operation. More...
 
void beginResetModel ()
 Begins a model reset operation. More...
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More...
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More...
 
QModelIndex createIndex (int row, int column, void *data=0) const
 Creates a model index for the given row and column with the internal pointer ptr. More...
 
QModelIndex createIndex (int row, int column, int id) const
 Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More...
 
QModelIndex createIndex (int row, int column, quint32 id) const
 Creates a model index for the given row and column with the internal identifier, id. More...
 
bool decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream)
 
void encodeData (const QModelIndexList &indexes, QDataStream &stream) const
 
void endInsertColumns ()
 Ends a column insertion operation. More...
 
void endInsertRows ()
 Ends a row insertion operation. More...
 
void endMoveColumns ()
 Ends a column move operation. More...
 
void endMoveRows ()
 Ends a row move operation. More...
 
void endRemoveColumns ()
 Ends a column removal operation. More...
 
void endRemoveRows ()
 Ends a row removal operation. More...
 
void endResetModel ()
 Completes a model reset operation. More...
 
QModelIndexList persistentIndexList () const
 Returns the list of indexes stored as persistent indexes in the model. More...
 
 QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0)
 
void reset ()
 Resets the model to its original state in any attached views. More...
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 Sets the model's role names to roleNames. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 214 of file qprintdialog_unix.cpp.

Constructors and Destructors

◆ QPPDOptionsModel()

QPPDOptionsModel::QPPDOptionsModel ( QCUPSSupport cups,
QObject parent = 0 
)

Definition at line 1065 of file qprintdialog_unix.cpp.

1066  : QAbstractItemModel(parent), rootItem(0), cups(c), ppd(c->currentPPD())
1067 {
1068  parseItems();
1069 }
unsigned char c[8]
Definition: qnumeric_p.h:62
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.
const ppd_file_t * ppd
QOptionTreeItem * rootItem

◆ ~QPPDOptionsModel()

QPPDOptionsModel::~QPPDOptionsModel ( )

Definition at line 1071 of file qprintdialog_unix.cpp.

1072 {
1073 }

Functions

◆ columnCount()

int QPPDOptionsModel::columnCount ( const QModelIndex parent = QModelIndex()) const
virtual

Returns the number of columns for the children of the given parent.

In most subclasses, the number of columns is independent of the parent.

For example:

int DomModel::columnCount(const QModelIndex &/*parent*/) const
{
return 3;
}
Note
When implementing a table based model, columnCount() should return 0 when the parent is valid.
See also
rowCount()

Implements QAbstractItemModel.

Definition at line 1075 of file qprintdialog_unix.cpp.

1076 {
1077  return 2;
1078 }

◆ data()

QVariant QPPDOptionsModel::data ( const QModelIndex index,
int  role = Qt::DisplayRole 
) const
virtual

Returns the data stored under the given role for the item referred to by the index.

Note
If you do not have a value to return, return an invalid QVariant instead of returning 0.
See also
Qt::ItemDataRole, setData(), headerData()

Implements QAbstractItemModel.

Definition at line 1094 of file qprintdialog_unix.cpp.

1095 {
1096  switch(role) {
1097  case Qt::FontRole: {
1098  QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
1099  if (itm && itm->type == QOptionTreeItem::Group){
1100  QFont font = QApplication::font();
1101  font.setBold(true);
1102  return QVariant(font);
1103  }
1104  return QVariant();
1105  }
1106  break;
1107 
1108  case Qt::DisplayRole: {
1109  QOptionTreeItem* itm;
1110  if (!index.isValid())
1111  itm = rootItem;
1112  else
1113  itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
1114 
1115  if (index.column() == 0)
1116  return cups->unicodeString(itm->description);
1117  else if (itm->type == QOptionTreeItem::Option && itm->selected > -1)
1118  return cups->unicodeString(itm->selDescription);
1119  else
1120  return QVariant();
1121  }
1122  break;
1123 
1124  default:
1125  return QVariant();
1126  }
1127  if (role != Qt::DisplayRole)
1128  return QVariant();
1129 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
const char * description
static QFont font()
Returns the default application font.
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString unicodeString(const char *s)
Definition: qcups.cpp:352
QOptionTreeItem * rootItem
const char * selDescription
int column() const
Returns the column this model index refers to.

◆ flags()

Qt::ItemFlags QPPDOptionsModel::flags ( const QModelIndex index) const
virtual

Returns the item flags for the given index.

The base class implementation returns a combination of flags that enables the item (ItemIsEnabled) and allows it to be selected (ItemIsSelectable).

See also
Qt::ItemFlags

Reimplemented from QAbstractItemModel.

Definition at line 1156 of file qprintdialog_unix.cpp.

1157 {
1158  if (!index.isValid() || reinterpret_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Group)
1159  return Qt::ItemIsEnabled;
1160 
1161  if (index.column() == 1)
1163 
1165 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
int type
Definition: qmetatype.cpp:239
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
int column() const
Returns the column this model index refers to.

◆ headerData()

QVariant QPPDOptionsModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Returns the data for the given role and section in the header with the specified orientation.

For horizontal headers, the section number corresponds to the column number. Similarly, for vertical headers, the section number corresponds to the row number.

See also
Qt::ItemDataRole, setHeaderData(), QHeaderView

Reimplemented from QAbstractItemModel.

Definition at line 1234 of file qprintdialog_unix.cpp.

1235 {
1236  if (role != Qt::DisplayRole)
1237  return QVariant();
1238 
1239  switch(section){
1240  case 0:
1241  return QVariant(QApplication::translate("QPPDOptionsModel", "Name"));
1242  case 1:
1243  return QVariant(QApplication::translate("QPPDOptionsModel", "Value"));
1244  default:
1245  return QVariant();
1246  }
1247 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)

◆ index()

QModelIndex QPPDOptionsModel::index ( int  row,
int  column,
const QModelIndex parent = QModelIndex() 
) const
virtual

Returns the index of the item in the model specified by the given row, column and parent index.

When reimplementing this function in a subclass, call createIndex() to generate model indexes that other components can use to refer to items in your model.

See also
createIndex()

Implements QAbstractItemModel.

Definition at line 1131 of file qprintdialog_unix.cpp.

Referenced by QPrintPropertiesDialog::selectPrinter().

1132 {
1133  QOptionTreeItem* itm;
1134  if (!parent.isValid())
1135  itm = rootItem;
1136  else
1137  itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
1138 
1139  return createIndex(row, column, itm->childItems.at(row));
1140 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
QList< QOptionTreeItem * > childItems
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QOptionTreeItem * rootItem

◆ parent()

QModelIndex QPPDOptionsModel::parent ( const QModelIndex index) const
virtual

Returns the parent of the model item with the given index.

Warning
This function is not part of the public interface.

If the item has no parent, an invalid QModelIndex is returned.

A common convention used in models that expose tree data structures is that only items in the first column have children. For that case, when reimplementing this function in a subclass the column of the returned QModelIndex would be 0.

When reimplementing this function in a subclass, be careful to avoid calling QModelIndex member functions, such as QModelIndex::parent(), since indexes belonging to your model will simply call your implementation, leading to infinite recursion.

See also
createIndex()

Implements QAbstractItemModel.

Definition at line 1143 of file qprintdialog_unix.cpp.

1144 {
1145  if (!index.isValid())
1146  return QModelIndex();
1147 
1148  QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
1149 
1150  if (itm->parentItem && itm->parentItem != rootItem)
1151  return createIndex(itm->parentItem->index, 0, itm->parentItem);
1152  else
1153  return QModelIndex();
1154 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
QOptionTreeItem * parentItem
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QModelIndex class is used to locate data in a data model.
QOptionTreeItem * rootItem

◆ parseChoices()

void QPPDOptionsModel::parseChoices ( QOptionTreeItem parent)

Definition at line 1216 of file qprintdialog_unix.cpp.

Referenced by parseOptions().

1217 {
1218  const ppd_option_t* option = reinterpret_cast<const ppd_option_t*>(parent->ptr);
1219  bool marked = false;
1220  for (int i = 0; i < option->num_choices; ++i) {
1221  QOptionTreeItem* choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], option->choices[i].text, parent);
1222  if (static_cast<int>(option->choices[i].marked) == 1) {
1223  parent->selected = i;
1224  parent->selDescription = option->choices[i].text;
1225  marked = true;
1226  } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
1227  parent->selected = i;
1228  parent->selDescription = option->choices[i].text;
1229  }
1230  parent->childItems.append(choice);
1231  }
1232 }
QList< QOptionTreeItem * > childItems
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
const char * selDescription

◆ parseGroups()

void QPPDOptionsModel::parseGroups ( QOptionTreeItem parent)

Definition at line 1177 of file qprintdialog_unix.cpp.

Referenced by parseItems().

1178 {
1179  if (parent->type == QOptionTreeItem::Root) {
1180 
1181  const ppd_file_t* ppdFile = reinterpret_cast<const ppd_file_t*>(parent->ptr);
1182 
1183  if (ppdFile) {
1184  for (int i = 0; i < ppdFile->num_groups; ++i) {
1185  QOptionTreeItem* group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppdFile->groups[i], ppdFile->groups[i].text, parent);
1186  parent->childItems.append(group);
1187  parseGroups(group); // parse possible subgroups
1188  parseOptions(group); // parse options
1189  }
1190  }
1191  } else if (parent->type == QOptionTreeItem::Group) {
1192 
1193  const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
1194 
1195  if (group) {
1196  for (int i = 0; i < group->num_subgroups; ++i) {
1197  QOptionTreeItem* subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], group->subgroups[i].text, parent);
1198  parent->childItems.append(subgroup);
1199  parseGroups(subgroup); // parse possible subgroups
1200  parseOptions(subgroup); // parse options
1201  }
1202  }
1203  }
1204 }
void parseOptions(QOptionTreeItem *parent)
QList< QOptionTreeItem * > childItems
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void parseGroups(QOptionTreeItem *parent)

◆ parseItems()

void QPPDOptionsModel::parseItems ( )

Definition at line 1167 of file qprintdialog_unix.cpp.

Referenced by QPPDOptionsModel(), and QPrintPropertiesDialog::selectPrinter().

1168 {
1170  ppd = cups->currentPPD();
1171  delete rootItem;
1172  rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
1174  emit layoutChanged();
1175 }
const ppd_file_t * currentPPD() const
Definition: qcups.cpp:173
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
#define emit
Definition: qobjectdefs.h:76
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
void parseGroups(QOptionTreeItem *parent)
const ppd_file_t * ppd
QOptionTreeItem * rootItem

◆ parseOptions()

void QPPDOptionsModel::parseOptions ( QOptionTreeItem parent)

Definition at line 1206 of file qprintdialog_unix.cpp.

Referenced by parseGroups().

1207 {
1208  const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
1209  for (int i = 0; i < group->num_options; ++i) {
1210  QOptionTreeItem* opt = new QOptionTreeItem(QOptionTreeItem::Option, i, &group->options[i], group->options[i].text, parent);
1211  parent->childItems.append(opt);
1212  parseChoices(opt);
1213  }
1214 }
QList< QOptionTreeItem * > childItems
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void parseChoices(QOptionTreeItem *parent)

◆ rowCount()

int QPPDOptionsModel::rowCount ( const QModelIndex parent = QModelIndex()) const
virtual

Returns the number of rows under the given parent.

When the parent is valid it means that rowCount is returning the number of children of parent.

Note
When implementing a table based model, rowCount() should return 0 when the parent is valid.
See also
columnCount()

Implements QAbstractItemModel.

Definition at line 1080 of file qprintdialog_unix.cpp.

Referenced by QPrintPropertiesDialog::selectPrinter().

1081 {
1082  QOptionTreeItem* itm;
1083  if (!parent.isValid())
1084  itm = rootItem;
1085  else
1086  itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
1087 
1088  if (itm->type == QOptionTreeItem::Option)
1089  return 0;
1090 
1091  return itm->childItems.count();
1092 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QList< QOptionTreeItem * > childItems
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QOptionTreeItem * rootItem

Friends and Related Functions

◆ QPPDOptionsEditor

friend class QPPDOptionsEditor
friend

Definition at line 216 of file qprintdialog_unix.cpp.

Properties

◆ cups

QCUPSSupport* QPPDOptionsModel::cups

◆ ppd

const ppd_file_t* QPPDOptionsModel::ppd

Definition at line 231 of file qprintdialog_unix.cpp.

Referenced by parseItems().

◆ rootItem

QOptionTreeItem* QPPDOptionsModel::rootItem

The documentation for this class was generated from the following file: