Хранилища Subversion OpenInventory

Редакция

Редакция 62 | Редакция 76 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 62 Редакция 75
Строка 22... Строка 22...
22
22
23
23
24
bool ModelForDescriptionTable::setData(const QModelIndex &index, const QVariant &value, int role) {
24
bool ModelForDescriptionTable::setData(const QModelIndex &index, const QVariant &value, int role) {
25
  ////  if (index.column()==3) return false; // â òðåòüåé êîëîíêå íå äàåì ïîìåíÿòü çíà÷åíèå
25
  ////  if (index.column()==3) return false; // â òðåòüåé êîëîíêå íå äàåì ïîìåíÿòü çíà÷åíèå
26
    bool lResult = false;
26
    bool lResult = false;
-
 
27
    QVariant old_value; // ñîõðàíèì ñòàðîå çíà÷åíèå
-
 
28
    old_value = data(index);
-
 
29
27
30
28
    /*
31
    /*
29
    QString str_tmp;
32
    QString str_tmp;
30
    if (index.column()==1) {                // åñëè ìåíÿåì èìÿ êëàññà
33
    if (index.column()==1) {                // åñëè ìåíÿåì èìÿ êëàññà
31
        str_tmp = value.toString();         // òî ïîìåíÿåì è èìÿ òàáëèöû
34
        str_tmp = value.toString();         // òî ïîìåíÿåì è èìÿ òàáëèöû
Строка 45... Строка 48...
45
        QSqlRecord rec = record(index.row());
48
        QSqlRecord rec = record(index.row());
46
49
47
        rec.setValue(index.column(), value);
50
        rec.setValue(index.column(), value);
48
        rec.setGenerated(index.column(), true);
51
        rec.setGenerated(index.column(), true);
49
52
-
 
53
-
 
54
        if (index.column()==1){ // åñëè ïîìåíÿëîñü èìÿ ïîëÿ
-
 
55
            QSqlQuery qu;
-
 
56
            QString old_field_name; // ñòàðîå èìÿ ïîëÿ
-
 
57
            QString new_field_name; // íîâîå èìÿ ïîëÿ
-
 
58
            QString query_str;
-
 
59
            QString type_str; // òèï äàííûõ ïîëÿ
-
 
60
            old_field_name = old_value.toString(); // îïðåäåëèì òåêóùåå (êîòîðîå íóæíî ïîìåíÿòü) èìÿ ïîëÿ
-
 
61
            new_field_name = value.toString();
-
 
62
            type_str = data(ModelForDescriptionTable::index(index.row(), 3)).toString(); // òèï ïîëÿ õðàíèòüñÿ â 3 ñòîëáöå, ñ÷èòûâàåì åãî çíà÷åíèå
-
 
63
            query_str = tr("ALTER TABLE ");
-
 
64
            query_str.append(ModelForDescriptionTable::Inctance);
-
 
65
            query_str.append(tr(" CHANGE COLUMN `"));
-
 
66
            query_str.append(old_field_name);
-
 
67
            query_str.append(tr("` `"));
-
 
68
            query_str.append(new_field_name);
-
 
69
            query_str.append(tr("` "));
-
 
70
            query_str.append(type_str);
-
 
71
            query_str.append(tr(" CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL"));
-
 
72
            qu.prepare(query_str);
-
 
73
            bool ok;
-
 
74
            ok = qu.exec();
-
 
75
            if (!ok) return false;
-
 
76
50
        /*
77
            /*
51
        if (index.column()==1){
78
            if (!ok) {
-
 
79

-
 
80
                            QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
-
 
81
                                                                                        this,                      // Ðîäèòåëüñêèé âèäæåò.
-
 
82
                                                                                        QObject::tr("Database Error"),   // Çàãîëîâîê.
-
 
83
                                                                                        qu.lastError().text() ); // Òåêñò ñîîáùåíèÿ.
-
 
84

-
 
85
                                                                        return ok; // âûõîäèì íå ïðèìåíÿÿ èçìåíåíèé
-
 
86

-
 
87
                                 }
-
 
88

-
 
89
*/
-
 
90
-
 
91
52
            rec.setValue(index.column()+2, QVariant(str_tmp));
92
          //  rec.setValue(index.column()+2, QVariant(str_tmp));
53
            rec.setGenerated(index.column()+2, true);
93
          //  rec.setGenerated(index.column()+2, true);
54
            newindex = MyModel::index(index.row(), index.column()+2);
94
          //  newindex = MyModel::index(index.row(), index.column()+2);
55
            QSqlTableModel::setData(newindex, QVariant(str_tmp), Qt::EditRole);
95
          //  QSqlTableModel::setData(newindex, QVariant(str_tmp), Qt::EditRole);
56
        }
96
        }
-
 
97
57
        */
98
58
/*
99
/*
59

100

60
        if (index.column()==0){
101
        if (index.column()==0){
61
            rec.setValue(index.column()+3, QVariant(str_tmp));
102
            rec.setValue(index.column()+3, QVariant(str_tmp));
62
            rec.setGenerated(index.column()+3, true);
103
            rec.setGenerated(index.column()+3, true);
Строка 111... Строка 152...
111
     case Qt::SizeHintRole:return value;
152
     case Qt::SizeHintRole:return value;
112
153
113
       }
154
       }
114
  return value;
155
  return value;
115
}
156
}
-
 
157
-
 
158
-
 
159
void ModelForDescriptionTable::setInctance(QString currInctatce){ // ïåðåäàåì èìÿ òåêóùåé òàáëèöû-õðàíèëèùà
-
 
160
    ModelForDescriptionTable::Inctance = currInctatce;
-
 
161
}