00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qwidget.h>
00013
#include <qlayout.h>
00014
#include <qlabel.h>
00015
#include <qiconview.h>
00016
#include <qtabwidget.h>
00017
00018
00019
#include "layoutWidget.h"
00020
#include "titleWidget.h"
00021
#include "window.h"
00022
#include "subalbumsWidget.h"
00023
#include "subalbumWidget.h"
00024
#include "editing/editingInterface.h"
00025
#include "../backend/subalbum.h"
00026
#include "../backend/photo.h"
00027
#include "../config.h"
00028
00029
00030 LayoutWidget::LayoutWidget(
QWidget *parent,
const char* name ) :
QWidget(parent,name)
00031 {
00032
window = (
Window*)parent;
00033
subalbums =
new SubalbumsWidget(
this,
"subalbums" );
00034 connect(
subalbums, SIGNAL(
collectionSelected(
Subalbum*)),
00035
this, SLOT(
showCollection(
Subalbum* )) );
00036
00037
subalbum =
new SubalbumWidget( NULL,
this,
"subalbum" );
00038
editingInterface =
new EditingInterface(
this,
"editingInterface" );
00039
00040
tabbedArea =
new QTabWidget(
this,
"tabbedArea" );
00041
tabbedArea->addTab(
subalbum, tr(
"Organize") );
00042
tabbedArea->addTab(
editingInterface, tr(
"Edit") );
00043
00044
00045
tabbedArea->setTabEnabled(
editingInterface,
false);
00046
00047
00048
00049 connect(
tabbedArea, SIGNAL( currentChanged(
QWidget*) ),
00050
this, SLOT(
tabChanged(
QWidget*) ) );
00051
00052
00053
00054 connect(
subalbum, SIGNAL( selectedPhotoStateChanged() ),
00055
this, SLOT(
photoStateChangedEvent() ) );
00056
00057
00058
00059 connect(
editingInterface, SIGNAL( photoModified() ),
00060
this, SLOT(
photoStateChangedEvent() ) );
00061
00062
00063
grid =
new QGridLayout(
this, 1, 2, 0 );
00064
00065
grid->addWidget(
subalbums, 0, 0 );
00066
grid->setColSpacing( 0,
subalbums->sizeHint().width() );
00067
00068
grid->addWidget(
tabbedArea, 0, 1 );
00069
grid->setColStretch( 1, 1 );
00070 }
00071
00072 void LayoutWidget::showCollection(
Subalbum* collection)
00073 {
00074
00075
organize();
00076
00077
00078
subalbum->
setSubalbum(collection);
00079
00080
00081 emit
collectionSelected( collection );
00082 }
00083
00084 void LayoutWidget::refreshSelectedCollectionIconName()
00085 {
00086
subalbums->
refreshSelectedCollectionName();
00087 }
00088
00089 void LayoutWidget::updateSubalbumImage( QPixmap* val)
00090 {
00091
subalbums->
updatedSelectedCollectionImage(val);
00092 }
00093
00094 SubalbumWidget*
LayoutWidget::getSubalbum()
00095 {
00096
return subalbum;
00097 }
00098
00099 SubalbumsWidget*
LayoutWidget::getSubalbums()
00100 {
00101
return subalbums;
00102 }
00103
00104 Window*
LayoutWidget::getWindow()
00105 {
00106
return window;
00107 }
00108
00109 void LayoutWidget::refresh()
00110 {
00111
subalbums->
refreshCollectionsList();
00112 }
00113
00114 void LayoutWidget::tabChanged(
QWidget* widget)
00115 {
00116
00117
if(widget !=
editingInterface)
00118 {
00119
00120
subalbum->
refreshAllPhotos();
00121
00122
00123
photoStateChangedEvent();
00124
00125
00126
00127
subalbum->
setSelectedPhoto(
editingInterface->
getPhoto() );
00128
00129
return;
00130 }
00131
00132
else
00133 {
00135
Subalbum* collection =
subalbum->
getSubalbum();
00136
Photo* photo =
subalbum->
getFirstSelectedPhoto();
00137
00138
00139
if(collection == NULL || photo == NULL)
00140
return;
00141
00142
00143
editingInterface->
setPhoto( collection, photo);
00144
editingInterface->
setFocus();
00145
00146
00147
photoStateChangedEvent();
00148 }
00149 }
00150
00151 void LayoutWidget::editSelectedPhoto()
00152 {
00153
tabbedArea->showPage(
editingInterface );
00154 }
00155
00156 void LayoutWidget::organize()
00157 {
00158
tabbedArea->setCurrentPage( 0 );
00159 }
00160
00161 void LayoutWidget::setEditTabEnabled(
bool val)
00162 {
00163
tabbedArea->setTabEnabled(
editingInterface, val);
00164 }
00165
00166 void LayoutWidget::revertPhotos()
00167 {
00168
if(
tabbedArea->currentPage() ==
subalbum )
00169
subalbum->
revertSelectedPhotos();
00170
else if(
tabbedArea->currentPage() ==
editingInterface )
00171
editingInterface->
revertCurrentPhoto();
00172 }
00173
00174 void LayoutWidget::photoStateChangedEvent()
00175 {
00176
00177
00178
00179
bool anySelected =
false;
00180
bool anyRevertable =
false;
00181
00182
if(
tabbedArea->currentPage() ==
subalbum )
00183 {
00184 anySelected =
subalbum->
anyPhotosSelected();
00185 anyRevertable = anySelected &&
subalbum->
anySelectedPhotosRevertable();
00186 }
00187
else
00188 {
00189
00190 anySelected =
false;
00191 anyRevertable =
editingInterface->
currentPhotoRevertable();
00192 }
00193
00194
00195
window->
getTitle()->
updateMenus(anySelected, anyRevertable);
00196 }
00197