Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 202 → Rev 201

/trunk/DBViewer/fileform.cpp
64,9 → 64,7
QFile file;
QDataStream out(&Data,QIODevice::ReadOnly);
QString fileName;
// QString fileName_tmp;
if (Data.isEmpty()) return;
out.device()->reset();
out >> fileName;
fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
fileName,
98,11 → 96,3
 
 
}
 
void FileForm::setData(QByteArray new_data){
int i;
 
Data = new_data;
 
i++;
}
/trunk/DBViewer/database.cpp
567,7 → 567,7
 
 
 
QMap <int, QString> filesFieldsToModel;
 
for (int i=0; i < fileFieldList.count(); i++){ // äëÿ âñåõ ïîëåé, õðàíÿùèõ ôàéëû
// static FileDelegate flDelegate;
// static TimeEditDelegate dateDelegate("01.10.2010");
575,16 → 575,15
int fileFieldIndex; //
fileFieldName = fileFieldList.at(i); // îïðåäåëÿåì èìÿ ïîëÿ, õðàíÿùåãî ôàéë
fileFieldIndex = sql_mogel->record().indexOf(fileFieldName); // îïðåäåëÿåì íîìåð ñòîëáöà â ìîäåëå
filesFieldsToModel.insert(fileFieldIndex, fileFieldName);
file_colomns_indexes.append(fileFieldIndex);// çàïîìíèì íîìåð ñòîëáöà ñ äåëåãàòîì äëÿ òèïà "file"
file_colomns_indexes.append(fileFieldIndex);// çàïîìíèì íîìåð ñòîëáöà ñ äåëåãàòîì äëÿ òèïà "àøäó"
ui->tableView->setItemDelegateForColumn(fileFieldIndex, fileDelegate);
 
}
sql_mogel->setFilesFields(filesFieldsToModel);// ïåðåäàåì ìîäåëè ñâÿçàííûé ñïèñîê ñ íîìåðàìè è èìåíàìè ñòîëáöîâ, õðàíÿùèõ ôàéëû
 
 
 
 
 
for (int i=0; i < dateFieldList.count(); i++){ // äëÿ âñåõ ïîëåé ñ òèïîì "DATA"
static MyDEDelegate dateDelegate;
// static TimeEditDelegate dateDelegate("01.10.2010");
/trunk/DBViewer/mymodel.cpp
125,12 → 125,8
QVariant value = QSqlTableModel::data(index, role);
QList <int> keys;
QStringList values;
QList <int> files_keys;
QStringList files_values;
keys = pointers_map.keys(); // ñïèñîê ñòîëáöîâ ñ óêàçàòåëÿìè
values = pointers_map.values(); // ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ
files_keys = files_map.keys(); // ñïèñîê íîìåðîâ ñòîëáöîâ, õðàíÿùèõ ôàéëû
files_values = files_map.values(); // ñïèñîê èìåò ñòîëáöîâ, õðàíÿùèõ ôàéëû
 
switch (role) {
case Qt::DisplayRole:
144,19 → 140,7
int index_of_list;
index_of_list = keys.indexOf(index.column());
 
if (index_of_list == -1){ // ñòîëáåö íå ÿâëÿåòñÿ óêàçàòåëåì, ïðîâåðèì, ìîæåò îí õðàíèò ôàéë
index_of_list = files_keys.indexOf(index.column());
if (index_of_list == -1) return value; // íåò, ñòîëáåö íå õðàíèò ôàéë
QString file_name;
QByteArray data_tmp;
data_tmp = value.toByteArray();
if (data_tmp.isEmpty() || data_tmp.isNull()) return value;
else {
QDataStream out (&data_tmp,QIODevice::ReadOnly);
out >> file_name;
return file_name;
}
}
if (index_of_list == -1) return value;
else {
QString parentInctance;
QSqlQuery q;
/trunk/DBViewer/fileform.h
12,7 → 12,7
public:
FileForm(QWidget *parent = 0);
~FileForm();
void setData(QByteArray new_data);
void setData(QByteArray new_data){Data = new_data;}
QByteArray data(){return Data;}
bool dataIsChanged(){return fdataIsChanged;}
 
/trunk/DBViewer/delegate.cpp
610,9 → 610,7
 
const QAbstractItemModel * model = index.model();
FileForm *flFrm = static_cast<FileForm*>(editor);
QVariant currentData = model->data(index,Qt::EditRole);
 
// QVariant currentData = QSqlTableModel::data(index, 0);
QVariant currentData = model->data(index,0);
QByteArray bytes = currentData.toByteArray();
if (currentData.isValid()) flFrm->setData(bytes);
else return;
/trunk/DBViewer/mymodel.h
16,12 → 16,8
bool setData(const QModelIndex &, const QVariant &, int);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
void setPointers(QMap <int, QString> newPointers){pointers_map = newPointers;}
void setFilesFields(QMap <int, QString> newFilesFields){files_map = newFilesFields;}
 
QMap <int, QString> pointers(){return pointers_map;}
QMap <int, QString> filesFields (){return files_map;}
void setBooleansList(QList <int> newBoolList){bolleans_list = newBoolList;}
 
void setIconIndex(int new_index){icon_index = new_index;}
int iconIndex(){return icon_index;}
 
28,12 → 24,8
private:
QMap <int, QString> pointers_map; // â ýòîì ñâÿçàííîì ñïèñêå áóäåõ õðàíèòü â êà÷åñòâå êëþ÷à íîìåðÿ ñòîëáöîâ ñ óêàçàòåëÿìè
// à â êà÷åñòâå çíà÷åíèé - èìåíà òàáëèö - õðàíèëèù îáúåêòîâ ðîäèòåëüñêîãî êëàññà
QMap <int, QString> files_map; // â ýòîì ñâÿçàííîì ñïèñêå áóäåõ õðàíèòü â êà÷åñòâå êëþ÷à íîìåðÿ ñòîëáöîâ, õðàíÿùèõ ôàéëû
// à â êà÷åñòâå çíà÷åíèé - èìåíà ñòîëáöîâ
 
QList <int> bolleans_list; // ñïèñîê ïîëåé ñ òèïîì "bool"
 
 
int icon_index; // íîìåð ñòîëáöà, â êîòîðîì õðàíÿòüñÿ èêîíêè
 
signals: