examples/itemviews/addressbook/tablemodel.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
--- a/examples/itemviews/addressbook/tablemodel.cpp	Tue Jul 06 15:10:48 2010 +0300
+++ b/examples/itemviews/addressbook/tablemodel.cpp	Wed Aug 18 10:37:55 2010 +0300
@@ -72,13 +72,13 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 //! [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 @@
 //! [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 @@
 {
     if (!index.isValid())
         return Qt::ItemIsEnabled;
-    
+
     return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;
 }
 //! [7]