28 #include <qlistview.h>
29 #include <qpushbutton.h>
32 #include <qwhatsthis.h>
35 : QDialog( parent, name, modal, fl ),unsavedDocs()
38 setName(
"SaveDialog" );
52 void SaveDialog::initDialog()
54 setSizeGripEnabled( FALSE );
55 SaveDialogLayout =
new QVBoxLayout(
this, 11, 6,
"SaveDialogLayout");
57 label =
new QLabel(
this,
"label" );
58 SaveDialogLayout->addWidget( label );
60 filesView =
new QListView(
this,
"filesView" );
61 filesView->addColumn( tr(
"Modified Files" ) );
62 filesView->header()->setResizeEnabled( FALSE, filesView->header()->count() - 1 );
63 filesView->setItemMargin( 1 );
64 filesView->setResizeMode( QListView::AllColumns );
65 SaveDialogLayout->addWidget( filesView );
67 buttonsLayout =
new QHBoxLayout( 0, 0, 6,
"buttonsLayout");
69 abortClosingButton =
new QPushButton(
this,
"abortClosingButton" );
70 buttonsLayout->addWidget( abortClosingButton );
71 spacer =
new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
72 buttonsLayout->addItem( spacer );
74 dontSaveButton =
new QPushButton(
this,
"dontSaveButton" );
75 buttonsLayout->addWidget( dontSaveButton );
77 saveSelectedButton =
new QPushButton(
this,
"saveSelectedButton" );
78 saveSelectedButton->setDefault(
true);
79 buttonsLayout->addWidget( saveSelectedButton );
80 SaveDialogLayout->addLayout( buttonsLayout );
82 resize( QSize(500, 300).expandedTo(minimumSizeHint()) );
83 clearWState( WState_Polished );
85 connect(abortClosingButton,SIGNAL(clicked()),
this,SLOT(
reject()));
93 QCheckListItem *item =
new QCheckListItem(filesView,
95 QCheckListItem::CheckBox );
97 unsavedDocs.insert( doc, item );
102 setCaption( tr(
"Save the modified files" ) );
103 label->setText( tr(
"Select files to be saved" ) );
104 filesView->header()->setLabel( 0, tr(
"Modified Files" ) );
105 abortClosingButton->setText( tr(
"Abort Closing" ) );
106 dontSaveButton->setText( tr(
"Don't Save" ) );
107 saveSelectedButton->setText( tr(
"Save Selected" ) );
117 QPtrList<QucsDoc> unsavables;
118 QMap<QucsDoc*,QCheckListItem*>::iterator it(unsavedDocs.begin());
119 for ( ; it != unsavedDocs.end(); ++it)
121 if ( it.data()->isOn() )
124 if(app->saveFile(doc) ==
false)
125 unsavables.append(doc);
127 unsavedDocs.remove(it);
130 if(unsavables.isEmpty())
141 return unsavedDocs.isEmpty();