Krazy/EBN: qMin is better than QMIN
[kphotoalbum.git] / MainWindow / DirtyIndicator.cpp
blobbf439ccc28049d8caf0ecce702ebe43e838224dd
1 /* Copyright (C) 2003-2006 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
18 #include "DirtyIndicator.h"
19 #include <kiconloader.h>
20 #include <QPixmap>
21 #include <QLabel>
23 static MainWindow::DirtyIndicator* _instance = 0;
24 bool MainWindow::DirtyIndicator::_autoSaveDirty = false;
25 bool MainWindow::DirtyIndicator::_saveDirty = false;
27 MainWindow::DirtyIndicator::DirtyIndicator( QWidget* parent )
28 :QLabel( parent )
30 _dirtyPix = QPixmap( SmallIcon( QString::fromLatin1( "media-floppy" ) ) );
31 setFixedWidth( _dirtyPix.width() );
32 _instance = this;
34 // Might have been marked dirty even before the indicator had been created, by the database searching during loading.
35 if ( _saveDirty )
36 markDirty();
39 void MainWindow::DirtyIndicator::markDirty()
41 if ( _instance ) {
42 _instance->markDirtySlot();
43 } else {
44 _saveDirty = true;
45 _autoSaveDirty = true;
49 void MainWindow::DirtyIndicator::markDirtySlot() {
50 _saveDirty = true;
51 _autoSaveDirty = true;
52 setPixmap( _dirtyPix );
53 emit dirty();
56 void MainWindow::DirtyIndicator::autoSaved()
58 _autoSaveDirty= false;
61 void MainWindow::DirtyIndicator::saved()
63 _autoSaveDirty = false;
64 _saveDirty = false;
65 setPixmap( QPixmap() );
68 bool MainWindow::DirtyIndicator::isSaveDirty() const
70 return _saveDirty;
73 bool MainWindow::DirtyIndicator::isAutoSaveDirty() const
75 return _autoSaveDirty;
79 #include "DirtyIndicator.moc"