22 #include "mainwidget.h"
24 #include "groupconfigdialog.h"
25 #include "groupview.h"
26 #include "syncprocess.h"
27 #include "syncprocessmanager.h"
29 #include <libqopensync/environment.h>
31 #include <tdeaboutdata.h>
32 #include <tdeaction.h>
34 #include <kinputdialog.h>
35 #include <tdelistview.h>
36 #include <tdelocale.h>
37 #include <tdemessagebox.h>
38 #include <kstdaction.h>
39 #include <kxmlguiclient.h>
43 MainWidget::MainWidget( KXMLGUIClient *guiClient, TQWidget *widget,
const char *name )
44 : TQWidget( widget, name ), mGUIClient( guiClient )
50 int count = SyncProcessManager::self()->count();
51 for (
int i = 0; i < count; ++i ) {
52 SyncProcessManager::self()->at( i )->applyObjectTypeFilter();
56 mGroupView->updateView();
58 connect( SyncProcessManager::self(), TQT_SIGNAL( changed() ),
59 mGroupView, TQT_SLOT( updateView() ) );
60 connect( SyncProcessManager::self(), TQT_SIGNAL( syncProcessChanged( SyncProcess* ) ),
61 mGroupView, TQT_SLOT( updateSyncProcess( SyncProcess* ) ) );
66 MainWidget::~MainWidget()
70 KXMLGUIClient *MainWidget::guiClient()
const
75 TDEAboutData *MainWidget::aboutData()
77 TDEAboutData *about =
new TDEAboutData(
"kitchensync", I18N_NOOP(
"KitchenSync" ),
78 "0.1", I18N_NOOP(
"The TDE Syncing Application" ),
79 TDEAboutData::License_GPL_V2,
80 I18N_NOOP(
"(c) 2005, The KDE PIM Team" ) );
81 about->addAuthor(
"Tobias Koenig", I18N_NOOP(
"Current maintainer" ),
"tokoe@kde.org" );
82 about->addAuthor(
"Cornelius Schumacher", 0,
"schumacher@kde.org" );
87 void MainWidget::initGUI()
89 TQVBoxLayout *topLayout =
new TQVBoxLayout(
this );
91 mGroupView =
new GroupView(
this );
92 topLayout->addWidget( mGroupView );
94 connect( mGroupView, TQT_SIGNAL( addGroup() ), TQT_SLOT( addGroup() ) );
95 connect( mGroupView, TQT_SIGNAL( synchronizeGroup( SyncProcess* ) ),
96 TQT_SLOT( sync( SyncProcess* ) ) );
97 connect( mGroupView, TQT_SIGNAL( abortSynchronizeGroup( SyncProcess* ) ),
98 TQT_SLOT( abortSync( SyncProcess* ) ) );
99 connect( mGroupView, TQT_SIGNAL( configureGroup( SyncProcess* ) ),
100 TQT_SLOT( editGroup( SyncProcess* ) ) );
103 void MainWidget::initActions()
105 mActionSynchronize =
new TDEAction( i18n(
"Synchronize"),
"hotsync", 0, TQT_TQOBJECT(
this), TQT_SLOT( sync() ),
106 mGUIClient->actionCollection(),
"sync" );
107 mActionAddGroup =
new TDEAction( i18n(
"Add Group..."),
"document-new", 0, TQT_TQOBJECT(
this), TQT_SLOT( addGroup() ),
108 mGUIClient->actionCollection(),
"add_group" );
109 mActionDeleteGroup =
new TDEAction( i18n(
"Delete Group..."),
"edit-delete", 0, TQT_TQOBJECT(
this), TQT_SLOT( deleteGroup() ),
110 mGUIClient->actionCollection(),
"delete_group" );
111 mActionEditGroup =
new TDEAction( i18n(
"Edit Group..."),
"edit", 0, TQT_TQOBJECT(
this), TQT_SLOT( editGroup() ),
112 mGUIClient->actionCollection(),
"edit_group" );
115 void MainWidget::enableActions()
117 bool state = ( SyncProcessManager::self()->count() > 0 );
119 mActionSynchronize->setEnabled( state );
120 mActionDeleteGroup->setEnabled( state );
121 mActionEditGroup->setEnabled( state );
124 void MainWidget::addGroup()
127 TQString name = KInputDialog::getText( i18n(
"Create Synchronization Group"),
128 i18n(
"Name for new synchronization group."), TQString(), &ok,
this );
130 SyncProcessManager::self()->addGroup( name );
133 SyncProcess *process = SyncProcessManager::self()->byGroupName( name );
135 editGroup( process );
139 void MainWidget::deleteGroup()
141 SyncProcess *syncProcess = mGroupView->selectedSyncProcess();
143 int result = KMessageBox::warningContinueCancel(
this,
144 i18n(
"Delete synchronization group '%1'?").arg( syncProcess->group().name() ) );
145 if ( result == KMessageBox::Continue ) {
146 SyncProcessManager::self()->remove( syncProcess );
152 void MainWidget::editGroup()
154 editGroup( mGroupView->selectedSyncProcess() );
157 void MainWidget::editGroup( SyncProcess *syncProcess )
160 GroupConfigDialog dlg(
this, syncProcess );
167 void MainWidget::sync()
169 sync( mGroupView->selectedSyncProcess() );
172 void MainWidget::sync( SyncProcess *syncProcess )
175 syncProcess->reinitEngine();
176 QSync::Result result = syncProcess->engine()->synchronize();
178 tqDebug(
"%s", result.message().latin1() );
180 tqDebug(
"synchronization worked" );
185 void MainWidget::abortSync( SyncProcess *syncProcess )
188 syncProcess->engine()->abort();
191 #include "mainwidget.moc"