Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 200 → Rev 201

/trunk/DBViewer/fileform.cpp
7,6 → 7,7
ui(new Ui::FileForm)
{
ui->setupUi(this);
FileForm::fdataIsChanged = false;
}
 
FileForm::~FileForm()
46,13 → 47,15
data_tmp = file.readAll();
out << data_tmp;
file.close();
FileForm::fdataIsChanged = true;
 
 
}
 
void FileForm::on_pushButton_2_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ôàéë"
Data.clear();
 
Data.clear();
FileForm::fdataIsChanged = true;
 
}
 
void FileForm::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Ñîõðàíèòü ôàéë"
88,6 → 91,7
int size;
size = file.size();
file.close();
FileForm::fdataIsChanged = true;
 
 
 
/trunk/DBViewer/database.cpp
566,6 → 566,24
 
 
 
 
 
for (int i=0; i < fileFieldList.count(); i++){ // äëÿ âñåõ ïîëåé, õðàíÿùèõ ôàéëû
// static FileDelegate flDelegate;
// static TimeEditDelegate dateDelegate("01.10.2010");
QString fileFieldName; // èìÿ ïîëÿ
int fileFieldIndex; //
fileFieldName = fileFieldList.at(i); // îïðåäåëÿåì èìÿ ïîëÿ, õðàíÿùåãî ôàéë
fileFieldIndex = sql_mogel->record().indexOf(fileFieldName); // îïðåäåëÿåì íîìåð ñòîëáöà â ìîäåëå
file_colomns_indexes.append(fileFieldIndex);// çàïîìíèì íîìåð ñòîëáöà ñ äåëåãàòîì äëÿ òèïà "àøäó"
ui->tableView->setItemDelegateForColumn(fileFieldIndex, fileDelegate);
 
}
 
 
 
 
 
for (int i=0; i < dateFieldList.count(); i++){ // äëÿ âñåõ ïîëåé ñ òèïîì "DATA"
static MyDEDelegate dateDelegate;
// static TimeEditDelegate dateDelegate("01.10.2010");
641,7 → 659,7
pointersToModel.insert(pointerIndex, parentInctancesList.at(i)); // ôîðìèðóåì ñïèñîê ñòîëáöîâ ñ óêàçàòåëÿìè
}
 
sql_mogel->setPointers(pointersToModel); // ïåðåäàåì ñïèñîê ìîäåëè
sql_mogel->setPointers(pointersToModel); // ïåðåäàåì ñïèñîê óêàçàòåëåé ìîäåëå
 
pointer_index = sql_mogel->record().indexOf(pointer_name); // ýòî ãëîáàëüíàÿ ïåðåìåííàÿ, íå òðîãàåì, íóæíà! :-)
 
/trunk/DBViewer/fileform.h
14,6 → 14,7
~FileForm();
void setData(QByteArray new_data){Data = new_data;}
QByteArray data(){return Data;}
bool dataIsChanged(){return fdataIsChanged;}
 
protected:
void changeEvent(QEvent *e);
21,6 → 22,7
private:
Ui::FileForm *ui;
QByteArray Data;
bool fdataIsChanged;
 
private slots:
void on_pushButton_clicked(); // îáðàáîò÷èê íàæàòèÿ êíîïêè "Ïîìåíÿòü ôàéë"
/trunk/DBViewer/delegate.cpp
573,3 → 573,89
void IconDelegate::setTableView(QTableView* table){
tblView = table;
}
 
 
 
 
 
 
 
 
FileDelegate::FileDelegate( QObject * parent ) : QItemDelegate(parent)
{
}
 
 
 
 
 
QWidget *FileDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex & /* index */) const
{
 
FileForm *editor = new FileForm(parent);
 
return editor;
 
}
 
 
 
 
void FileDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
 
 
const QAbstractItemModel * model = index.model();
FileForm *flFrm = static_cast<FileForm*>(editor);
QVariant currentData = model->data(index,0);
QByteArray bytes = currentData.toByteArray();
if (currentData.isValid()) flFrm->setData(bytes);
else return;
 
}
 
 
 
 
void FileDelegate::setModelData(
QWidget *editor,
QAbstractItemModel *model,
const QModelIndex& index) const {
FileForm *flFrm = static_cast<FileForm*>(editor);
if (!(flFrm->dataIsChanged())) return;
 
m_Data = flFrm->data();
if (!m_Data.isEmpty()) { // åñëè ìàññèâ íå ïóñòîé
model->setData(index, QVariant (m_Data), Qt::EditRole);
 
}
else { // åñëè ìàññèâ ïóñòîé (ôàéë óäàëèëè)
QVariant val_null;
model->setData(index, val_null, Qt::EditRole);
 
}
 
 
 
}
 
 
 
void FileDelegate::updateEditorGeometry(
QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex& /* index */) const {
 
 
// QRect r(option.rect.x() + option.rect.width()/2 - 7, option.rect.y() + option.rect.height()/2 - 7, 150, 100);
// editor->setGeometry(r);
 
editor->setGeometry(option.rect);
}
 
 
 
 
/trunk/DBViewer/mainwindow.cpp
91,8 → 91,8
 
picture_delegate = new CPictureDelegate(this);
iconDelegate = new IconDelegate(this);
fileDelegate = new FileDelegate(this);
 
 
// fileForm.show();
 
}
/trunk/DBViewer/delegate.h
13,6 → 13,7
#include <QMessageBox>
 
#include "iconform.h"
#include "fileform.h"
 
//#include <QMainWindow>
//! [0]
128,8 → 129,46
//QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
 
class FileDelegate : public QItemDelegate
{
mutable QByteArray m_Data;
private:
// QTableView *tblView;
 
public:
FileDelegate ( QObject *parent );
 
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
 
void setEditorData(QWidget *editor,
const QModelIndex &index) const;
 
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;
 
 
void updateEditorGeometry(
QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
 
/*
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
*/
 
 
 
// void setTableView(QTableView* table);
 
 
//QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
 
class TimeEditDelegate : public QItemDelegate
{
Q_OBJECT
/trunk/DBViewer/mainwindow.h
155,6 → 155,7
QItemDelegate standart_delegate;
CPictureDelegate * picture_delegate;
IconDelegate * iconDelegate;
FileDelegate * fileDelegate;
bool comboBox_slot_enable; // äëÿ áëîêèðîâêè ñëîòà, êîãäà ìåíÿåì item_index èç ïðîãðàììû, à íå âðó÷íóþ
QList <int> boolFieldsIndexes_global; // ñïèñîê íîìåðîâ ñòîëáöîâ ñ òèïîì "BOOL"