00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "parley.h"
00027 #include "prefs.h"
00028
00029 #include "kvttablemodel.h"
00030 #include "kvtsortfiltermodel.h"
00031 #include "kvttableview.h"
00032 #include "kvtlessonmodel.h"
00033 #include "kvtlessonview.h"
00034
00035 #include <KTabWidget>
00036 #include <KActionCollection>
00037 #include <KLineEdit>
00038 #include <KComboBox>
00039 #include <KRecentFilesAction>
00040 #include <KStatusBar>
00041 #include <KToggleAction>
00042 #include <KLocale>
00043 #include <KDialog>
00044 #include <knewstuff2/ui/knewstuffaction.h>
00045
00046 #include <QClipboard>
00047 #include <QTimer>
00048 #include <QLabel>
00049 #include <QHeaderView>
00050 #include <QSplitter>
00051 #include <QTreeView>
00052 #include <QAbstractItemModel>
00053 #include <QVBoxLayout>
00054
00055 ParleyApp::ParleyApp(const QString& appName, QWidget *parent) : KXmlGuiWindow(parent)
00056 {
00057 m_appName = appName;
00058 m_doc = 0;
00059 m_tableView = 0;
00060 m_tableModel = 0;
00061 m_lessonModel = 0;
00062 m_lessonView = 0;
00063 m_sortFilterModel = 0;
00064 m_lessonSelectionCombo = 0;
00065 m_searchLine = 0;
00066 m_mainSplitter = 0;
00067 m_searchWidget = 0;
00068 m_newStuff = 0;
00069 m_pronunciationStatusBarLabel = 0;
00070 m_remarkStatusBarLabel = 0;
00071 m_typeStatusBarLabel = 0;
00072
00073 pbar = 0;
00074
00075 entryDlg = 0;
00076
00077 initStatusBar();
00078 initActions();
00079
00080 fileOpenRecent->loadEntries(KGlobal::config()->group("Recent Files"));
00081
00082 initModel();
00083 initDoc();
00084 initView();
00085
00086 editDelete->setEnabled(m_tableModel->rowCount(QModelIndex()) > 0);
00087
00088 if (Prefs::autoBackup()) {
00089 QTimer::singleShot(Prefs::backupTime() * 60 * 1000, this, SLOT(slotTimeOutBackup()));
00090 }
00091 }
00092
00093
00094 void ParleyApp::initActions()
00095 {
00096
00097 KAction* fileNew = KStandardAction::openNew(this, SLOT(slotFileNew()), actionCollection());
00098 fileNew->setWhatsThis(i18n("Creates a new blank vocabulary document"));
00099 fileNew->setToolTip(fileNew->whatsThis());
00100 fileNew->setStatusTip(fileNew->whatsThis());
00101
00102 KAction* fileOpen = KStandardAction::open(this, SLOT(slotFileOpen()), actionCollection());
00103 fileOpen->setWhatsThis(i18n("Opens an existing vocabulary document"));
00104 fileOpen->setToolTip(fileOpen->whatsThis());
00105 fileOpen->setStatusTip(fileOpen->whatsThis());
00106
00107 KAction* fileOpenExample = new KAction(this);
00108 actionCollection()->addAction("file_open_example", fileOpenExample);
00109 fileOpenExample->setIcon(KIcon("document-open"));
00110 fileOpenExample->setText(i18n("Open &Example..."));
00111 connect(fileOpenExample, SIGNAL(triggered(bool)), this, SLOT(slotFileOpenExample()));
00112 fileOpenExample->setWhatsThis(i18n("Open an example vocabulary document"));
00113 fileOpenExample->setToolTip(fileOpenExample->whatsThis());
00114 fileOpenExample->setStatusTip(fileOpenExample->whatsThis());
00115
00116 KAction* fileGHNS = KNS::standardAction(i18n("Vocabularies..."), this, SLOT(slotGHNS()), actionCollection(), "file_ghns");
00117 fileGHNS->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
00118 fileGHNS->setWhatsThis(i18n("Downloads new vocabularies"));
00119 fileGHNS->setToolTip(fileGHNS->whatsThis());
00120 fileGHNS->setStatusTip(fileGHNS->whatsThis());
00121
00122 fileOpenRecent = KStandardAction::openRecent(this, SLOT(slotFileOpenRecent(const KUrl&)), actionCollection());
00123
00124 KAction* fileMerge = new KAction(this);
00125 actionCollection()->addAction("file_merge", fileMerge);
00126 fileMerge->setText(i18n("&Merge..."));
00127 connect(fileMerge, SIGNAL(triggered(bool)), this, SLOT(slotFileMerge()));
00128 fileMerge->setWhatsThis(i18n("Merge an existing vocabulary document with the current one"));
00129 fileMerge->setToolTip(fileMerge->whatsThis());
00130 fileMerge->setStatusTip(fileMerge->whatsThis());
00131 fileMerge->setEnabled(false);
00132
00133 KAction* fileSave = KStandardAction::save(this, SLOT(slotFileSave()), actionCollection());
00134 fileSave->setWhatsThis(i18n("Save the active vocabulary document"));
00135 fileSave->setToolTip(fileSave->whatsThis());
00136 fileSave->setStatusTip(fileSave->whatsThis());
00137
00138 KAction* fileSaveAs = KStandardAction::saveAs(this, SLOT(slotFileSaveAs()), actionCollection());
00139 fileSaveAs->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
00140 fileSaveAs->setWhatsThis(i18n("Save the active vocabulary document with a different name"));
00141 fileSaveAs->setToolTip(fileSaveAs->whatsThis());
00142 fileSaveAs->setStatusTip(fileSaveAs->whatsThis());
00143
00144 KAction* filePrint = KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection());
00145 filePrint->setWhatsThis(i18n("Print the active vocabulary document"));
00146 filePrint->setToolTip(filePrint->whatsThis());
00147 filePrint->setStatusTip(filePrint->whatsThis());
00148
00149 KAction* fileProperties = new KAction(this);
00150 actionCollection()->addAction("file_properties", fileProperties);
00151 fileProperties->setText(i18n("&Properties..."));
00152 connect(fileProperties, SIGNAL(triggered(bool)), SLOT(slotDocumentProperties()));
00153 fileProperties->setIcon(KIcon("document-properties"));
00154 fileProperties->setWhatsThis(i18n("Edit document properties"));
00155 fileProperties->setToolTip(fileProperties->whatsThis());
00156 fileProperties->setStatusTip(fileProperties->whatsThis());
00157
00158
00159 KAction* fileQuit = KStandardAction::quit(this, SLOT(slotFileQuit()), actionCollection());
00160 fileQuit->setWhatsThis(i18n("Quit Parley"));
00161 fileQuit->setToolTip(fileQuit->whatsThis());
00162 fileQuit->setStatusTip(fileQuit->whatsThis());
00163
00164
00165
00166 KAction* editCopy = KStandardAction::copy(this, SLOT(slotEditCopy()), actionCollection());
00167 editCopy->setWhatsThis(i18n("Copy"));
00168 editCopy->setToolTip(editCopy->whatsThis());
00169 editCopy->setStatusTip(editCopy->whatsThis());
00170
00171 KAction* editCut = KStandardAction::cut(this, SLOT(slotCutEntry()), actionCollection());
00172 editCut->setWhatsThis(i18n("Copy"));
00173 editCut->setToolTip(editCut->whatsThis());
00174 editCut->setStatusTip(editCut->whatsThis());
00175
00176 KAction* editPaste = KStandardAction::paste(this, SLOT(slotEditPaste()), actionCollection());
00177 editPaste->setWhatsThis(i18n("Paste"));
00178 editPaste->setToolTip(editPaste->whatsThis());
00179 editPaste->setStatusTip(editPaste->whatsThis());
00180
00181
00182 KAction* editLanguages =new KAction(this);
00183 actionCollection()->addAction("edit_languages", editLanguages);
00184 editLanguages->setIcon(KIcon("preferences-desktop-locale"));
00185 editLanguages->setText(i18n("&Languages..."));
00186 connect(editLanguages, SIGNAL(triggered()), this, SLOT(slotEditLanguages()));
00188
00189 KAction* editGramar = new KAction(this);
00190 actionCollection()->addAction("edit_grammar", editGramar);
00191 editGramar->setText(i18n("&Grammar..."));
00192 editGramar->setWhatsThis(i18n("Edit language properties (types, tenses and usages)."));
00193 editGramar->setToolTip(editGramar->whatsThis());
00194 editGramar->setStatusTip(editGramar->whatsThis());
00195 connect(editGramar, SIGNAL(triggered(bool)), SLOT(slotLanguageProperties()));
00196
00197
00198 KAction* editSelectAll = KStandardAction::selectAll(this, SLOT(slotSelectAll()), actionCollection());
00199 editSelectAll->setWhatsThis(i18n("Select all rows"));
00200 editSelectAll->setToolTip(editSelectAll->whatsThis());
00201 editSelectAll->setStatusTip(editSelectAll->whatsThis());
00202
00203 KAction* editClearSelection = KStandardAction::deselect(this, SLOT(slotCancelSelection()), actionCollection());
00204 editClearSelection->setWhatsThis(i18n("Deselect all rows"));
00205 editClearSelection->setToolTip(editClearSelection->whatsThis());
00206 editClearSelection->setStatusTip(editClearSelection->whatsThis());
00207
00208 KAction* editAppend = new KAction(this);
00209 actionCollection()->addAction("edit_append", editAppend);
00210 editAppend->setIcon(KIcon("list-add-card"));
00211 editAppend->setText(i18n("&Add New Entry"));
00212 connect(editAppend, SIGNAL(triggered(bool)), this, SLOT(slotNewEntry()));
00213 editAppend->setShortcut(QKeySequence(Qt::Key_Insert));
00214 editAppend->setWhatsThis(i18n("Append a new row to the vocabulary"));
00215 editAppend->setToolTip(editAppend->whatsThis());
00216 editAppend->setStatusTip(editAppend->whatsThis());
00217
00218 editDelete = new KAction(this);
00219 actionCollection()->addAction("edit_remove_selected_area", editDelete);
00220 editDelete->setIcon(KIcon("list-remove-card"));
00221 editDelete->setText(i18n("&Delete Entry"));
00222 connect(editDelete, SIGNAL(triggered(bool)), this, SLOT(slotDeleteEntry()));
00223 editDelete->setShortcut(QKeySequence(Qt::Key_Delete));
00224 editDelete->setWhatsThis(i18n("Delete the selected rows"));
00225 editDelete->setToolTip(editDelete->whatsThis());
00226 editDelete->setStatusTip(editDelete->whatsThis());
00227
00228 KAction* editEditEntry = new KAction(this);
00229 actionCollection()->addAction("edit_edit_selected_area", editEditEntry);
00230 editEditEntry->setIcon(KIcon("document-properties-card"));
00231 editEditEntry->setText(i18n("&Edit Entry..."));
00232 connect(editEditEntry, SIGNAL(triggered(bool)), this, SLOT(slotEditEntry()));
00233 editEditEntry->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return));
00234 editEditEntry->setWhatsThis(i18n("Edit the entries in the selected rows"));
00235 editEditEntry->setToolTip(editEditEntry->whatsThis());
00236 editEditEntry->setStatusTip(editEditEntry->whatsThis());
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 KAction *actionNewLesson = new KAction(this);
00252 actionCollection()->addAction("new_lesson", actionNewLesson);
00253 actionNewLesson->setText(i18n("New Lesson"));
00254 actionNewLesson->setIcon(KIcon("lesson-add"));
00255 actionNewLesson->setWhatsThis(i18n("Add a new lesson to your document"));
00256 actionNewLesson->setToolTip(actionNewLesson->whatsThis());
00257 actionNewLesson->setStatusTip(actionNewLesson->whatsThis());
00258 actionNewLesson->setStatusTip(actionNewLesson->whatsThis());
00259
00260 KAction *actionRenameLesson = new KAction(this);
00261 actionCollection()->addAction("rename_lesson", actionRenameLesson);
00262 actionRenameLesson->setText(i18n("Rename Lesson"));
00263 actionRenameLesson->setIcon(KIcon("edit-rename"));
00264 actionRenameLesson->setWhatsThis(i18n("Rename the selected lesson"));
00265 actionRenameLesson->setToolTip(actionRenameLesson->whatsThis());
00266 actionRenameLesson->setStatusTip(actionRenameLesson->whatsThis());
00267 actionRenameLesson->setStatusTip(actionRenameLesson->whatsThis());
00268
00269 KAction *actionDeleteLesson = new KAction(this);
00270 actionCollection()->addAction("delete_lesson", actionDeleteLesson);
00271 actionDeleteLesson->setText(i18n("Delete Lesson"));
00272 actionDeleteLesson->setIcon(KIcon("lesson-remove"));
00273 actionDeleteLesson->setWhatsThis(i18n("Delete the selected lesson."));
00274 actionDeleteLesson->setToolTip(actionDeleteLesson->whatsThis());
00275 actionDeleteLesson->setStatusTip(actionDeleteLesson->whatsThis());
00276 actionDeleteLesson->setStatusTip(actionDeleteLesson->whatsThis());
00277
00278 KAction *actionCheckAllLessons = new KAction(this);
00279 actionCollection()->addAction("check_all_lessons", actionCheckAllLessons);
00280 actionCheckAllLessons->setText(i18n("Select All Lessons"));
00281 actionCheckAllLessons->setIcon(KIcon("edit-select-all"));
00282 actionCheckAllLessons->setWhatsThis(i18n("Select all lessons for the test."));
00283 actionCheckAllLessons->setToolTip(actionCheckAllLessons->whatsThis());
00284 actionCheckAllLessons->setStatusTip(actionCheckAllLessons->whatsThis());
00285 actionCheckAllLessons->setStatusTip(actionCheckAllLessons->whatsThis());
00286
00287 KAction *actionCheckNoLessons = new KAction(this);
00288 actionCollection()->addAction("check_no_lessons", actionCheckNoLessons);
00289 actionCheckNoLessons->setText(i18n("Deselect All Lessons"));
00290 actionCheckNoLessons->setIcon(KIcon("edit-clear"));
00291 actionCheckNoLessons->setWhatsThis(i18n("Remove all lessons from the test."));
00292 actionCheckNoLessons->setToolTip(actionCheckNoLessons->whatsThis());
00293 actionCheckNoLessons->setStatusTip(actionCheckNoLessons->whatsThis());
00294 actionCheckNoLessons->setStatusTip(actionCheckNoLessons->whatsThis());
00295
00296 KAction *actionSplitLesson = new KAction(this);
00297 actionCollection()->addAction("split_lesson", actionSplitLesson);
00298 actionSplitLesson->setText(i18n("Split Lesson into Smaller Lessons"));
00299 actionSplitLesson->setIcon(KIcon("edit-copy"));
00300 actionSplitLesson->setWhatsThis(i18n("Make multiple smaller lessons out of one big lesson."));
00301 actionSplitLesson->setToolTip(actionSplitLesson->whatsThis());
00302 actionSplitLesson->setStatusTip(actionSplitLesson->whatsThis());
00303 actionSplitLesson->setStatusTip(actionSplitLesson->whatsThis());
00304
00305
00306
00307 KAction* vocabCleanUp = new KAction(this);
00308 actionCollection()->addAction("vocab_clean_up", vocabCleanUp);
00309 vocabCleanUp->setIcon(KIcon("edit-clear"));
00310 vocabCleanUp->setText(i18n("Remove &Duplicates"));
00311 connect(vocabCleanUp, SIGNAL(triggered(bool)), this, SLOT(slotCleanVocabulary()));
00312 vocabCleanUp->setWhatsThis(i18n("Remove duplicate entries from the vocabulary"));
00313 vocabCleanUp->setToolTip(vocabCleanUp->whatsThis());
00314 vocabCleanUp->setStatusTip(vocabCleanUp->whatsThis());
00315
00316
00317
00318 KAction* configurePractice = new KAction(this);
00319 configurePractice->setText(i18n("Configure Practice..."));
00320 configurePractice->setIcon(KIcon("practice-setup"));
00321 configurePractice->setWhatsThis(i18n("Set up and start a test"));
00322 configurePractice->setToolTip(configurePractice->whatsThis());
00323 configurePractice->setStatusTip(configurePractice->whatsThis());
00324 actionCollection()->addAction("practice_configure", configurePractice);
00325 connect(configurePractice, SIGNAL(triggered(bool)), SLOT(configurePractice()));
00326
00327 KAction* startPractice = new KAction(this);
00328 startPractice->setText(i18n("Start Practice..."));
00329 startPractice->setIcon(KIcon("practice-start"));
00330 startPractice->setWhatsThis(i18n("Start a test with the last settings"));
00331 startPractice->setToolTip(startPractice->whatsThis());
00332 startPractice->setStatusTip(startPractice->whatsThis());
00333 actionCollection()->addAction("practice_start", startPractice);
00334 connect(startPractice, SIGNAL(triggered(bool)), SLOT(startPractice()));
00335
00336 KAction* showStatistics = new KAction(this);
00337 actionCollection()->addAction("show_statistics", showStatistics);
00338 showStatistics->setIcon(KIcon("view-statistics"));
00339 showStatistics->setText(i18n("&Statistics..."));
00340 connect(showStatistics, SIGNAL(triggered(bool)), this, SLOT(slotShowStatistics()));
00341 showStatistics->setWhatsThis(i18n("Show and reset statistics for the current vocabulary"));
00342 showStatistics->setToolTip(showStatistics->whatsThis());
00343 showStatistics->setStatusTip(showStatistics->whatsThis());
00344
00345
00346
00347
00348 KAction* configApp = KStandardAction::preferences(this, SLOT(slotGeneralOptions()), actionCollection());
00349 configApp->setWhatsThis(i18n("Show the configuration dialog"));
00350 configApp->setToolTip(configApp->whatsThis());
00351 configApp->setStatusTip(configApp->whatsThis());
00352
00353 KAction* configToolbar = new KAction(this);
00354 actionCollection()->addAction("options_configure_toolbars", configToolbar);
00355 configToolbar->setWhatsThis(i18n("Toggle display of the toolbars"));
00356 configToolbar->setToolTip(configToolbar->whatsThis());
00357 configToolbar->setStatusTip(configToolbar->whatsThis());
00358
00359 vocabShowSearchBar = actionCollection()->add<KToggleAction>("config_show_search");
00360 vocabShowSearchBar->setText(i18n("Show Se&arch"));
00361 connect(vocabShowSearchBar, SIGNAL(triggered(bool)), this, SLOT(slotConfigShowSearch()));
00362 vocabShowSearchBar->setWhatsThis(i18n("Toggle display of the search bar"));
00363 vocabShowSearchBar->setToolTip(vocabShowSearchBar->whatsThis());
00364 vocabShowSearchBar->setStatusTip(vocabShowSearchBar->whatsThis());
00365
00366 KAction *actionShowLessonColumn = new KAction(this);
00367 actionCollection()->addAction("config_show_lesson_column", actionShowLessonColumn);
00368 actionShowLessonColumn->setText(i18n("Show Lesson Column"));
00369 actionShowLessonColumn->setCheckable((true));
00370 actionShowLessonColumn->setChecked(Prefs::tableLessonColumnVisible());
00371
00372 KAction *actionShowActiveColumn = new KAction(this);
00373 actionCollection()->addAction("config_show_active_column", actionShowActiveColumn);
00374 actionShowActiveColumn->setText(i18n("Show Active Entry Column"));
00375 actionShowActiveColumn->setCheckable((true));
00376 actionShowActiveColumn->setChecked(Prefs::tableActiveColumnVisible());
00377
00378
00379
00380 KAction *actionRestoreNativeOrder = new KAction(this);
00381 actionCollection()->addAction("restore_native_order", actionRestoreNativeOrder);
00382 actionRestoreNativeOrder->setText(i18n("Restore Native Order"));
00383
00384
00385 if (!initialGeometrySet()) {
00386 resize(QSize(800, 500).expandedTo(minimumSizeHint()));
00387 }
00388 setupGUI(ToolBar | Keys | StatusBar | Create);
00389 setAutoSaveSettings();
00390 }
00391
00392
00393 void ParleyApp::initStatusBar()
00394 {
00395 m_typeStatusBarLabel = new QLabel(statusBar());
00396 m_typeStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00397 statusBar()->addWidget(m_typeStatusBarLabel, 150);
00398
00399 m_pronunciationStatusBarLabel = new QLabel(statusBar());
00400 m_pronunciationStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00401 m_pronunciationStatusBarLabel->setFont(Prefs::iPAFont());
00402 statusBar()->addWidget(m_pronunciationStatusBarLabel, 200);
00403
00404 m_remarkStatusBarLabel = new QLabel(statusBar());
00405 m_remarkStatusBarLabel->setFrameStyle(QFrame::NoFrame);
00406 statusBar()->addWidget(m_remarkStatusBarLabel, 150);
00407 }
00408
00409
00410 void ParleyApp::initDoc()
00411 {
00412 if (fileOpenRecent->actions().count() > 0
00413 && fileOpenRecent->action(
00414 fileOpenRecent->actions().count()-1)->isEnabled() )
00415 {
00416 fileOpenRecent->action(fileOpenRecent->actions().count()-1)->trigger();
00417 } else {
00418
00419 m_doc = new KEduVocDocument();
00420
00421 m_lessonModel->setDocument(m_doc);
00422 if (m_lessonView) {
00423 m_lessonView->setModel(m_lessonModel);
00424 m_lessonView->initializeSelection();
00425 }
00426 if (m_tableView) {
00427 m_tableView->adjustContent();
00428 m_tableView->setColumnHidden(KV_COL_LESS, !Prefs::tableLessonColumnVisible());
00429 m_tableView->setColumnHidden(KV_COL_MARK, !Prefs::tableActiveColumnVisible());
00430 }
00431
00432 m_tableModel->setDocument(m_doc);
00433 initializeDefaultGrammar();
00434 createExampleEntries();
00435
00436 connect(m_doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateWindowCaption()));
00437 }
00438 }
00439
00440 void ParleyApp::initModel()
00441 {
00442 m_lessonModel = new KVTLessonModel(this);
00443 m_tableModel = new KVTTableModel(this);
00444 m_sortFilterModel= new KVTSortFilterModel(this);
00445 m_sortFilterModel->setSourceModel(m_tableModel);
00446 }
00447
00451 QWidget* ParleyApp::initLessonList(QWidget *parent)
00452 {
00453
00454 QWidget *left = new QWidget(parent);
00455
00456 QVBoxLayout *boxLayout = new QVBoxLayout(left);
00457 boxLayout->setMargin(0);
00458 boxLayout->setSpacing(KDialog::spacingHint());
00459
00460
00461 m_lessonView = new KVTLessonView(left);
00462
00463 m_lessonView->setRootIsDecorated(false);
00464
00465 m_lessonModel->setDocument(m_doc);
00466
00467 m_lessonView->setModel(m_lessonModel);
00468 m_lessonView->setToolTip(i18n("Right click to add, delete, or rename lessons. \n"
00469 "With the checkboxes you can select which lessons you want to practice. \n"
00470 "Only checked lessons [x] will be asked in the tests!"));
00471
00472
00473 m_lessonSelectionCombo = new KComboBox();
00474 m_lessonSelectionCombo->addItem(i18n("Edit current lesson"));
00475 m_lessonSelectionCombo->addItem(i18n("Edit lessons in test"));
00476 m_lessonSelectionCombo->addItem(i18n("Edit all lessons"));
00477 m_lessonSelectionCombo->setToolTip(i18n("Select which lessons should be displayed for editing to the right."));
00478
00479 boxLayout->addWidget(m_lessonSelectionCombo);
00480 boxLayout->addWidget(m_lessonView);
00481
00483 connect(m_lessonView, SIGNAL(signalCurrentLessonChanged(int)), m_sortFilterModel, SLOT(slotCurrentLessonChanged(int)));
00484 connect(m_lessonView, SIGNAL(signalCurrentLessonChanged(int)), this, SLOT(slotCurrentLessonChanged()));
00486 connect(m_lessonModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), m_sortFilterModel, SLOT(slotLessonsInQueryChanged()));
00487
00488 connect(m_lessonSelectionCombo, SIGNAL(currentIndexChanged(int)), m_sortFilterModel, SLOT(setLessonSelection(int)));
00489 connect(m_lessonModel, SIGNAL(modelReset()), m_lessonView, SLOT(slotModelReset()));
00490
00491 m_lessonSelectionCombo->setCurrentIndex(Prefs::lessonEditingSelection());
00492
00493
00494 m_lessonView->initializeSelection();
00495
00496 connect(actionCollection()->action("new_lesson"), SIGNAL(triggered()), m_lessonView, SLOT(slotCreateNewLesson()));
00497 connect(actionCollection()->action("rename_lesson"), SIGNAL(triggered()), m_lessonView, SLOT(slotRenameLesson()));
00498 connect(actionCollection()->action("delete_lesson"), SIGNAL(triggered()), m_lessonView, SLOT(slotDeleteLesson()));
00499 connect(actionCollection()->action("check_all_lessons"), SIGNAL(triggered()), m_lessonView, SLOT(slotCheckAllLessons()));
00500 connect(actionCollection()->action("check_no_lessons"), SIGNAL(triggered()), m_lessonView, SLOT(slotCheckNoLessons()));
00501 connect(actionCollection()->action("split_lesson"), SIGNAL(triggered()), m_lessonView, SLOT(slotSplitLesson()));
00502
00503 m_lessonView->addAction(actionCollection()->action("new_lesson"));
00504 m_lessonView->addAction(actionCollection()->action("rename_lesson")); m_lessonView->addAction(actionCollection()->action("delete_lesson"));
00506 m_lessonView->addAction(actionCollection()->action("check_all_lessons")); m_lessonView->addAction(actionCollection()->action("check_no_lessons"));
00508 m_lessonView->addAction(actionCollection()->action("split_lesson"));
00509
00510 return left;
00511 }
00512
00513
00517 void ParleyApp::initView()
00518 {
00520 QWidget * mainWidget = new QWidget(this);
00521 setCentralWidget(mainWidget);
00522 QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
00523 topLayout->setMargin(KDialog::marginHint());
00524 topLayout->setSpacing(KDialog::spacingHint());
00526 m_mainSplitter = new QSplitter(centralWidget());
00527 topLayout->addWidget(m_mainSplitter);
00529 m_mainSplitter->addWidget(initLessonList(centralWidget()));
00530
00531 m_searchLine = new KLineEdit(this);
00532 m_searchLine->show();
00533 m_searchLine->setFocusPolicy(Qt::ClickFocus);
00534 m_searchLine->setClearButtonShown(true);
00535 m_searchLine->setClickMessage(i18n("Enter search terms here"));
00536 connect(m_searchLine, SIGNAL(textChanged(const QString&)), m_sortFilterModel, SLOT(slotSearch(const QString&)));
00537 m_searchLine->setToolTip(i18n("Enter space-separated search terms to find words.\n\nEnter ^abc to look for words beginning with \"abc\".\nEnter abc$ to look for words ending with \"abc\".\nEnter type:verb to search for verbs."));
00538
00539 QLabel *label = new QLabel(i18n("S&earch:"), this);
00540 label->setBuddy(m_searchLine);
00541 label->show();
00542
00543 m_searchWidget = new QWidget(this);
00544 QHBoxLayout* layout = new QHBoxLayout(m_searchWidget);
00545 layout->setSpacing(KDialog::spacingHint());
00546 layout->setMargin(0);
00547 layout->addWidget(label);
00548 layout->addWidget(m_searchLine);
00549
00550 QWidget * rightWidget = new QWidget(this);
00551 QVBoxLayout * rightLayout = new QVBoxLayout(rightWidget);
00552 rightLayout->setSpacing(KDialog::spacingHint());
00553 rightLayout->setMargin(0);
00554 rightLayout->addWidget(m_searchWidget);
00555 m_searchWidget->setVisible(Prefs::showSearch());
00556 vocabShowSearchBar->setChecked(Prefs::showSearch());
00557
00559 m_tableView = new KVTTableView(centralWidget());
00560 m_tableView->setFrameStyle(QFrame::NoFrame);
00561 m_tableView->setAlternatingRowColors(true);
00562 rightLayout->addWidget(m_tableView, 1, 0);
00563
00564 m_mainSplitter->addWidget(rightWidget);
00566
00567 m_tableView->setModel(m_sortFilterModel);
00568 m_tableView->setColumnWidth(0, qvariant_cast<QSize>(m_tableModel->headerData(0, Qt::Horizontal, Qt::SizeHintRole)).width());
00569 m_tableView->setColumnWidth(1, qvariant_cast<QSize>(m_tableModel->headerData(1, Qt::Horizontal, Qt::SizeHintRole)).width());
00570 m_tableView->setColumnWidth(2, qvariant_cast<QSize>(m_tableModel->headerData(2, Qt::Horizontal, Qt::SizeHintRole)).width());
00571 m_tableView->setColumnWidth(3, qvariant_cast<QSize>(m_tableModel->headerData(2, Qt::Horizontal, Qt::SizeHintRole)).width());
00572 m_tableView->horizontalHeader()->setResizeMode(KV_COL_MARK, QHeaderView::Fixed);
00573 int currentColumn = Prefs::currentCol();
00574 int currentRow = Prefs::currentRow();
00575 if (currentColumn <= KV_COL_LESS) {
00576 currentColumn = KV_COL_TRANS;
00577 }
00578
00579
00580 m_tableView->setCurrentIndex(m_sortFilterModel->mapFromSource(m_tableModel->index(currentRow, currentColumn)));
00581
00582 setCaption(m_doc->url().fileName(), false);
00583
00584
00585 connect(m_tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
00586 this, SLOT(slotCurrentChanged(const QModelIndex &, const QModelIndex &)));
00587
00588 connect(m_tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
00589 this, SLOT(slotSelectionChanged(const QItemSelection &, const QItemSelection &)));
00590
00591
00592 connect(m_tableView, SIGNAL(appendEntry()),
00593 m_tableModel, SLOT(appendEntry()));
00594
00595
00596 slotCurrentChanged(m_tableView->currentIndex(), m_tableView->currentIndex());
00597
00598 m_tableView->addAction(actionCollection()->action("edit_append"));
00599 m_tableView->addAction(actionCollection()->action("edit_edit_selected_area"));
00600 m_tableView->addAction(actionCollection()->action("edit_remove_selected_area"));
00601
00602
00603 m_tableView->setColumnHidden(KV_COL_LESS, !Prefs::tableLessonColumnVisible());
00604 m_tableView->setColumnHidden(KV_COL_MARK, !Prefs::tableActiveColumnVisible());
00605
00606 QAction *actionShowLessonColumn = actionCollection()->action("config_show_lesson_column");
00607 m_tableView->horizontalHeader()->addAction(actionShowLessonColumn);
00608 connect(actionShowLessonColumn, SIGNAL(toggled(bool)), m_tableView, SLOT(slotShowLessonColumn(bool)));
00609
00610 QAction *actionShowActiveColumn = actionCollection()->action("config_show_active_column");
00611 m_tableView->horizontalHeader()->addAction(actionShowActiveColumn);
00612 connect(actionShowActiveColumn, SIGNAL(toggled(bool)), m_tableView, SLOT(slotShowActiveColumn(bool)));
00613
00614 QAction * actionRestoreNativeOrder = actionCollection()->action("restore_native_order");
00615 m_tableView->horizontalHeader()->addAction(actionRestoreNativeOrder);
00616 connect(actionRestoreNativeOrder, SIGNAL(triggered()), m_sortFilterModel, SLOT(restoreNativeOrder()));
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629 m_sortFilterModel->clear();
00630
00631 m_mainSplitter->setSizes(Prefs::mainWindowSplitter());
00632 m_doc->setModified(false);
00633 m_sortFilterModel->restoreNativeOrder();
00634 }
00635