diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 22:53:54 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 22:53:54 (GMT) |
commit | 6e3062e3c361b1d570a55e3c9af8ece295ab5d37 (patch) | |
tree | a8cf7d7a47699a9f63b3b4ddaa9b35746ae14682 /examples/itemviews/addressbook | |
parent | 636698a5f97401a9aeb18cd690d7f08b05dcd5e6 (diff) | |
parent | bba06aacb84b5ae9fc286345e721cab639db35c8 (diff) | |
download | Qt-6e3062e3c361b1d570a55e3c9af8ece295ab5d37.zip Qt-6e3062e3c361b1d570a55e3c9af8ece295ab5d37.tar.gz Qt-6e3062e3c361b1d570a55e3c9af8ece295ab5d37.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (27 commits)
Doc: Added license documentation for 3rd party code and data.
Do not crash if addrinfo signal does not contain ip address information.
Link to the unsinstalled libraries first.
Doc: Excluded the QML documentation from the Qt-only set.
Doc: Whitespace fixes.
Doc: Fixed whitespace issues.
Revert the change in applicationShouldTerminate().
Added LatinAmericaAndTheCaribbean country to the doc.
Network Proxy Query: Fix memleak on OS X
Doc: Reviewed Michael's model/view tutorial and overview document.
Doc: Removed accidentally committed file.
Doc: Fixed incorrect QML property type.
new image for tutorial.qdoc
replaced image, license headers, more links in modelview.qdoc file
Doc: Added the standard three clause BSD license header.
I've cleaned up the qdoc file a bit.
correction of snippet tags
integrating modelview tutorial in the build system, first attempt
new version of modelview.qdoc with snippets
Rolands ModelView Source
...
Diffstat (limited to 'examples/itemviews/addressbook')
-rw-r--r-- | examples/itemviews/addressbook/addresswidget.cpp | 2 | ||||
-rw-r--r-- | examples/itemviews/addressbook/tablemodel.cpp | 48 |
2 files changed, 25 insertions, 25 deletions
diff --git a/examples/itemviews/addressbook/addresswidget.cpp b/examples/itemviews/addressbook/addresswidget.cpp index e226643..22dfae3 100644 --- a/examples/itemviews/addressbook/addresswidget.cpp +++ b/examples/itemviews/addressbook/addresswidget.cpp @@ -230,7 +230,7 @@ void AddressWidget::writeToFile(QString fileName) return; } - QList< QPair<QString, QString> > pairs = table->getList(); + QList< QPair<QString, QString> > pairs = table->getList(); QDataStream out(&file); out << pairs; } diff --git a/examples/itemviews/addressbook/tablemodel.cpp b/examples/itemviews/addressbook/tablemodel.cpp index 603c926..e9a08f0 100644 --- a/examples/itemviews/addressbook/tablemodel.cpp +++ b/examples/itemviews/addressbook/tablemodel.cpp @@ -72,13 +72,13 @@ QVariant TableModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); - + if (index.row() >= listOfPairs.size() || index.row() < 0) return QVariant(); - + if (role == Qt::DisplayRole) { QPair<QString, QString> pair = listOfPairs.at(index.row()); - + if (index.column() == 0) return pair.first; else if (index.column() == 1) @@ -93,15 +93,15 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, int ro { if (role != Qt::DisplayRole) return QVariant(); - + if (orientation == Qt::Horizontal) { switch (section) { case 0: return tr("Name"); - + case 1: return tr("Address"); - + default: return QVariant(); } @@ -115,7 +115,7 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &index) { Q_UNUSED(index); beginInsertRows(QModelIndex(), position, position+rows-1); - + for (int row=0; row < rows; row++) { QPair<QString, QString> pair(" ", " "); listOfPairs.insert(position, pair); @@ -129,9 +129,9 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &index) //! [5] bool TableModel::removeRows(int position, int rows, const QModelIndex &index) { - Q_UNUSED(index); + Q_UNUSED(index); beginRemoveRows(QModelIndex(), position, position+rows-1); - + for (int row=0; row < rows; ++row) { listOfPairs.removeAt(position); } @@ -144,25 +144,25 @@ bool TableModel::removeRows(int position, int rows, const QModelIndex &index) //! [6] bool TableModel::setData(const QModelIndex &index, const QVariant &value, int role) { - if (index.isValid() && role == Qt::EditRole) { - int row = index.row(); - - QPair<QString, QString> p = listOfPairs.value(row); - - if (index.column() == 0) - p.first = value.toString(); - else if (index.column() == 1) - p.second = value.toString(); + if (index.isValid() && role == Qt::EditRole) { + int row = index.row(); + + QPair<QString, QString> p = listOfPairs.value(row); + + if (index.column() == 0) + p.first = value.toString(); + else if (index.column() == 1) + p.second = value.toString(); else return false; - + listOfPairs.replace(row, p); - emit(dataChanged(index, index)); - + emit(dataChanged(index, index)); + return true; - } + } - return false; + return false; } //! [6] @@ -171,7 +171,7 @@ Qt::ItemFlags TableModel::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::ItemIsEnabled; - + return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; } //! [7] |