/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,15 → 575,16 |
int fileFieldIndex; // |
fileFieldName = fileFieldList.at(i); // îïðåäåëÿåì èìÿ ïîëÿ, õðàíÿùåãî ôàéë |
fileFieldIndex = sql_mogel->record().indexOf(fileFieldName); // îïðåäåëÿåì íîìåð ñòîëáöà â ìîäåëå |
file_colomns_indexes.append(fileFieldIndex);// çàïîìíèì íîìåð ñòîëáöà ñ äåëåãàòîì äëÿ òèïà "àøäó" |
filesFieldsToModel.insert(fileFieldIndex, fileFieldName); |
file_colomns_indexes.append(fileFieldIndex);// çàïîìíèì íîìåð ñòîëáöà ñ äåëåãàòîì äëÿ òèïà "file" |
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,8 → 125,12 |
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: |
140,7 → 144,19 |
int index_of_list; |
index_of_list = keys.indexOf(index.column()); |
if (index_of_list == -1) return value; |
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; |
} |
} |
else { |
QString parentInctance; |
QSqlQuery q; |
/trunk/DBViewer/fileform.h |
---|
12,7 → 12,7 |
public: |
FileForm(QWidget *parent = 0); |
~FileForm(); |
void setData(QByteArray new_data){Data = new_data;} |
void setData(QByteArray new_data); |
QByteArray data(){return Data;} |
bool dataIsChanged(){return fdataIsChanged;} |
/trunk/DBViewer/delegate.cpp |
---|
610,7 → 610,9 |
const QAbstractItemModel * model = index.model(); |
FileForm *flFrm = static_cast<FileForm*>(editor); |
QVariant currentData = model->data(index,0); |
QVariant currentData = model->data(index,Qt::EditRole); |
// QVariant currentData = QSqlTableModel::data(index, 0); |
QByteArray bytes = currentData.toByteArray(); |
if (currentData.isValid()) flFrm->setData(bytes); |
else return; |
/trunk/DBViewer/mymodel.h |
---|
16,8 → 16,12 |
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;} |
24,8 → 28,12 |
private: |
QMap <int, QString> pointers_map; // â ýòîì ñâÿçàííîì ñïèñêå áóäåõ õðàíèòü â êà÷åñòâå êëþ÷à íîìåðÿ ñòîëáöîâ ñ óêàçàòåëÿìè |
// à â êà÷åñòâå çíà÷åíèé - èìåíà òàáëèö - õðàíèëèù îáúåêòîâ ðîäèòåëüñêîãî êëàññà |
QMap <int, QString> files_map; // â ýòîì ñâÿçàííîì ñïèñêå áóäåõ õðàíèòü â êà÷åñòâå êëþ÷à íîìåðÿ ñòîëáöîâ, õðàíÿùèõ ôàéëû |
// à â êà÷åñòâå çíà÷åíèé - èìåíà ñòîëáöîâ |
QList <int> bolleans_list; // ñïèñîê ïîëåé ñ òèïîì "bool" |
int icon_index; // íîìåð ñòîëáöà, â êîòîðîì õðàíÿòüñÿ èêîíêè |
signals: |
/trunk/DBViewer/fileform.cpp |
---|
64,7 → 64,9 |
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, |
96,3 → 98,11 |
} |
void FileForm::setData(QByteArray new_data){ |
int i; |
Data = new_data; |
i++; |
} |