/* void DateTimeGrid::paintUserDefinedHeader( QPainter* painter, const QRectF& headerRect, const QRectF& exposedRect, qreal offset, const KGantt::DateTimeScaleFormatter* formatter, QWidget* widget) { const QStyle* const style = widget ? widget->style() : QApplication::style(); QDateTime dt = formatter->currentRangeBegin( mapToDateTime( offset + exposedRect.left() ) ).toUTC(); qreal x = mapFromDateTime( dt ); while ( x < exposedRect.right() + offset ) { const QDateTime next = formatter->nextRangeBegin( dt ); const qreal nextx = mapFromDateTime( next ); QStyleOptionHeader opt; if ( widget ) opt.init( widget ); opt.rect = QRectF( x - offset+1, headerRect.top(), qMax( 1., nextx-x-1 ), headerRect.height() ).toAlignedRect(); //opt.state = QStyle::State_Raised | QStyle::State_Enabled; opt.textAlignment = formatter->alignment(); opt.text = formatter->text( dt ); // use white text on black background opt.palette.setColor(QPalette::Window, QColor("black")); opt.palette.setColor(QPalette::ButtonText, QColor("white")); style->drawControl( QStyle::CE_Header, &opt, painter, widget ); dt = next; x = nextx; } } */ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ), m_model( new ProjectModel( this ) ), m_view( new KGantt::View ) { m_view->setModel( m_model ); m_view->setSelectionModel( new QItemSelectionModel(m_model)); // slotToolsNewItem(); m_view->leftView()->setItemDelegateForColumn( 1, new MyItemDelegate( this ) ); m_view->leftView()->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_view->graphicsView()->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); m_view->setGrid(new DateTimeGrid(this)); //QItemEditorCreatorBase *creator = new QItemEditorCreator<ItemTypeComboBox>("itemType"); //QItemEditorFactory* factory = new QItemEditorFactory; //factory->registerEditor( QVariant( KGantt::TypeTask ).type(), creator ); //m_view->itemDelegate()->setItemEditorFactory( factory ); setCentralWidget( m_view ); QMenuBar* mb = menuBar(); QMenu* fileMenu = new QMenu( tr( "&File" ) ); #ifndef QT_NO_PRINTER fileMenu->addAction( tr( "&Save as PDF..." ), this, SLOT( slotFileSavePdf() ) ); fileMenu->addAction( tr( "&Print..." ), this, SLOT( slotFilePrint() ) ); #endif fileMenu->addSeparator(); fileMenu->addAction( tr( "&Quit" ), this, SLOT( slotFileQuit() ) ); mb->addMenu( fileMenu ); QMenu* toolsMenu = new QMenu( tr( "&Tools" ) ); toolsMenu->addAction( tr( "&New Item" ), this, SLOT( slotToolsNewItem() ) ); toolsMenu->addAction( tr( "&Add Item" ), this, SLOT( slotToolsAppendItem() ) ); toolsMenu->addSeparator(); QMenu *alignMenu = toolsMenu->addMenu( tr( "Ali&gn" ) ); alignMenu->addAction( tr( "&Left" ), this, SLOT( slotAlignLeft() ) ); alignMenu->addAction( tr( "&Center" ), this, SLOT( slotAlignCenter() ) ); alignMenu->addAction( tr( "&Right" ), this, SLOT( slotAlignRight() ) ); alignMenu->addAction( tr( "&Hidden" ), this, SLOT( slotAlignHidden() ) ); toolsMenu->addSeparator(); toolsMenu->addAction( tr( "&Collapse All" ), this, SLOT( slotCollapseAll() ) ); toolsMenu->addAction( tr( "&Expand All" ), this, SLOT( slotExpandAll() ) ); mb->addMenu( toolsMenu ); /* slotToolsNewItem(); slotToolsNewItem(); slotToolsNewItem(); for (int i = 0; i < 3; ++i) { m_model->setData(m_model->index(i,2,QModelIndex()), qVariantFromValue(QDateTime::currentDateTime().addDays(i)), KGantt::StartTimeRole); m_model->setData(m_model->index(i,3,QModelIndex()), qVariantFromValue(QDateTime::currentDateTime().addDays(i+1)), KGantt::EndTimeRole); } m_view->setConstraintModel(new KGantt::ConstraintModel(m_view)); m_view->constraintModel()->addConstraint(KGantt::Constraint(m_model->index(0,0,QModelIndex()),m_model->index(1,0,QModelIndex()))); m_view->constraintModel()->addConstraint(KGantt::Constraint(m_model->index(1,0,QModelIndex()),m_model->index(2,0,QModelIndex()))); */ }
// decoupled from resetActions in toplevel.cpp // as resetActions simply uses the action groups // specified in the ui.rc file void KEBApp::createActions() { m_actionsImpl = new ActionsImpl(this, GlobalBookmarkManager::self()->model()); connect(m_actionsImpl->testLinkHolder(), SIGNAL(setCancelEnabled(bool)), this, SLOT(setCancelTestsEnabled(bool))); connect(m_actionsImpl->favIconHolder(), SIGNAL(setCancelEnabled(bool)), this, SLOT(setCancelFavIconUpdatesEnabled(bool))); // save and quit should probably not be in the toplevel??? (void) KStandardAction::quit( this, SLOT( close() ), actionCollection()); KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection()); (void) KStandardAction::configureToolbars( this, SLOT( slotConfigureToolbars() ), actionCollection()); if (m_browser) { (void) KStandardAction::open( m_actionsImpl, SLOT( slotLoad() ), actionCollection()); (void) KStandardAction::saveAs( m_actionsImpl, SLOT( slotSaveAs() ), actionCollection()); } (void) KStandardAction::cut(m_actionsImpl, SLOT( slotCut() ), actionCollection()); (void) KStandardAction::copy(m_actionsImpl, SLOT( slotCopy() ), actionCollection()); (void) KStandardAction::paste(m_actionsImpl, SLOT( slotPaste() ), actionCollection()); // actions KAction* m_actionsImplDelete = actionCollection()->addAction("delete"); m_actionsImplDelete->setIcon(KIcon("edit-delete")); m_actionsImplDelete->setText(i18n("&Delete")); m_actionsImplDelete->setShortcut(Qt::Key_Delete); connect(m_actionsImplDelete, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotDelete() )); KAction* m_actionsImplRename = actionCollection()->addAction("rename"); m_actionsImplRename->setIcon(KIcon("edit-rename")); m_actionsImplRename->setText(i18n("Rename")); m_actionsImplRename->setShortcut(Qt::Key_F2); connect(m_actionsImplRename, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotRename() )); KAction* m_actionsImplChangeURL = actionCollection()->addAction("changeurl"); m_actionsImplChangeURL->setIcon(KIcon("edit-rename")); m_actionsImplChangeURL->setText(i18n("C&hange Location")); m_actionsImplChangeURL->setShortcut(Qt::Key_F3); connect(m_actionsImplChangeURL, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotChangeURL() )); KAction* m_actionsImplChangeComment = actionCollection()->addAction("changecomment"); m_actionsImplChangeComment->setIcon(KIcon("edit-rename")); m_actionsImplChangeComment->setText(i18n("C&hange Comment")); m_actionsImplChangeComment->setShortcut(Qt::Key_F4); connect(m_actionsImplChangeComment, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotChangeComment() )); KAction* m_actionsImplChangeIcon = actionCollection()->addAction("changeicon"); m_actionsImplChangeIcon->setIcon(KIcon("preferences-desktop-icons")); m_actionsImplChangeIcon->setText(i18n("Chan&ge Icon...")); connect(m_actionsImplChangeIcon, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotChangeIcon() )); KAction* m_actionsImplUpdateFavIcon = actionCollection()->addAction("updatefavicon"); m_actionsImplUpdateFavIcon->setText(i18n("Update Favicon")); connect(m_actionsImplUpdateFavIcon, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotUpdateFavIcon() )); KAction* m_actionsImplRecursiveSort = actionCollection()->addAction("recursivesort"); m_actionsImplRecursiveSort->setText(i18n("Recursive Sort")); connect(m_actionsImplRecursiveSort, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotRecursiveSort() )); KAction* m_actionsImplNewFolder = actionCollection()->addAction("newfolder"); m_actionsImplNewFolder->setIcon(KIcon("folder-new")); m_actionsImplNewFolder->setText(i18n("&New Folder...")); m_actionsImplNewFolder->setShortcut(Qt::CTRL+Qt::Key_N); connect(m_actionsImplNewFolder, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotNewFolder() )); KAction* m_actionsImplNewBookmark = actionCollection()->addAction("newbookmark"); m_actionsImplNewBookmark->setIcon(KIcon("bookmark-new")); m_actionsImplNewBookmark->setText(i18n("&New Bookmark")); connect(m_actionsImplNewBookmark, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotNewBookmark() )); KAction* m_actionsImplInsertSeparator = actionCollection()->addAction("insertseparator"); m_actionsImplInsertSeparator->setText(i18n("&Insert Separator")); m_actionsImplInsertSeparator->setShortcut(Qt::CTRL+Qt::Key_I); connect(m_actionsImplInsertSeparator, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotInsertSeparator() )); KAction* m_actionsImplSort = actionCollection()->addAction("sort"); m_actionsImplSort->setText(i18n("&Sort Alphabetically")); connect(m_actionsImplSort, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotSort() )); KAction* m_actionsImplSetAsToolbar = actionCollection()->addAction("setastoolbar"); m_actionsImplSetAsToolbar->setIcon(KIcon("bookmark-toolbar")); m_actionsImplSetAsToolbar->setText(i18n("Set as T&oolbar Folder")); connect(m_actionsImplSetAsToolbar, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotSetAsToolbar() )); KAction* m_actionsImplExpandAll = actionCollection()->addAction("expandall"); m_actionsImplExpandAll->setText(i18n("&Expand All Folders")); connect(m_actionsImplExpandAll, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExpandAll() )); KAction* m_actionsImplCollapseAll = actionCollection()->addAction("collapseall"); m_actionsImplCollapseAll->setText(i18n("Collapse &All Folders")); connect(m_actionsImplCollapseAll, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotCollapseAll() )); KAction* m_actionsImplOpenLink = actionCollection()->addAction("openlink"); m_actionsImplOpenLink->setIcon(KIcon("document-open")); m_actionsImplOpenLink->setText(i18n("&Open in Konqueror")); connect(m_actionsImplOpenLink, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotOpenLink() )); KAction* m_actionsImplTestSelection = actionCollection()->addAction("testlink"); m_actionsImplTestSelection->setIcon(KIcon("bookmarks")); m_actionsImplTestSelection->setText(i18n("Check &Status")); connect(m_actionsImplTestSelection, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotTestSelection() )); KAction* m_actionsImplTestAll = actionCollection()->addAction("testall"); m_actionsImplTestAll->setText(i18n("Check Status: &All")); connect(m_actionsImplTestAll, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotTestAll() )); KAction* m_actionsImplUpdateAllFavIcons = actionCollection()->addAction("updateallfavicons"); m_actionsImplUpdateAllFavIcons->setText(i18n("Update All &Favicons")); connect(m_actionsImplUpdateAllFavIcons, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotUpdateAllFavIcons() )); KAction* m_actionsImplCancelAllTests = actionCollection()->addAction("canceltests"); m_actionsImplCancelAllTests->setText(i18n("Cancel &Checks")); connect(m_actionsImplCancelAllTests, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotCancelAllTests() )); KAction* m_actionsImplCancelFavIconUpdates = actionCollection()->addAction("cancelfaviconupdates"); m_actionsImplCancelFavIconUpdates->setText(i18n("Cancel &Favicon Updates")); connect(m_actionsImplCancelFavIconUpdates, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotCancelFavIconUpdates() )); KAction* m_actionsImplImportNS = actionCollection()->addAction("importNS"); m_actionsImplImportNS->setObjectName( QLatin1String("NS" )); m_actionsImplImportNS->setIcon(KIcon("netscape")); m_actionsImplImportNS->setText(i18n("Import &Netscape Bookmarks...")); connect(m_actionsImplImportNS, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); KAction* m_actionsImplImportOpera = actionCollection()->addAction("importOpera"); m_actionsImplImportOpera->setObjectName( QLatin1String("Opera" )); m_actionsImplImportOpera->setIcon(KIcon("opera")); m_actionsImplImportOpera->setText(i18n("Import &Opera Bookmarks...")); connect(m_actionsImplImportOpera, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); /* KAction* m_actionsImplImportCrashes = actionCollection()->addAction("importCrashes"); m_actionsImplImportCrashes->setObjectName( QLatin1String("Crashes" )); m_actionsImplImportCrashes->setText(i18n("Import All &Crash Sessions as Bookmarks...")); connect(m_actionsImplImportCrashes, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); */ KAction* m_actionsImplImportGaleon = actionCollection()->addAction("importGaleon"); m_actionsImplImportGaleon->setObjectName( QLatin1String("Galeon" )); m_actionsImplImportGaleon->setText(i18n("Import &Galeon Bookmarks...")); connect(m_actionsImplImportGaleon, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); KAction* m_actionsImplImportKDE2 = actionCollection()->addAction("importKDE2"); m_actionsImplImportKDE2->setObjectName( QLatin1String("KDE2" )); m_actionsImplImportKDE2->setIcon(KIcon("kde")); m_actionsImplImportKDE2->setText(i18n("Import &KDE 2 or KDE 3 Bookmarks...")); connect(m_actionsImplImportKDE2, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); KAction* m_actionsImplImportIE = actionCollection()->addAction("importIE"); m_actionsImplImportIE->setObjectName( QLatin1String("IE" )); m_actionsImplImportIE->setText(i18n("Import &Internet Explorer Bookmarks...")); connect(m_actionsImplImportIE, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); KAction* m_actionsImplImportMoz = actionCollection()->addAction("importMoz"); m_actionsImplImportMoz->setObjectName( QLatin1String("Moz" )); m_actionsImplImportMoz->setIcon(KIcon("mozilla")); m_actionsImplImportMoz->setText(i18n("Import &Mozilla Bookmarks...")); connect(m_actionsImplImportMoz, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotImport() )); KAction* m_actionsImplExportNS = actionCollection()->addAction("exportNS"); m_actionsImplExportNS->setIcon(KIcon("netscape")); m_actionsImplExportNS->setText(i18n("Export &Netscape Bookmarks")); connect(m_actionsImplExportNS, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExportNS() )); KAction* m_actionsImplExportOpera = actionCollection()->addAction("exportOpera"); m_actionsImplExportOpera->setIcon(KIcon("opera")); m_actionsImplExportOpera->setText(i18n("Export &Opera Bookmarks...")); connect(m_actionsImplExportOpera, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExportOpera() )); KAction* m_actionsImplExportHTML = actionCollection()->addAction("exportHTML"); m_actionsImplExportHTML->setIcon(KIcon("text-html")); m_actionsImplExportHTML->setText(i18n("Export &HTML Bookmarks...")); connect(m_actionsImplExportHTML, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExportHTML() )); KAction* m_actionsImplExportIE = actionCollection()->addAction("exportIE"); m_actionsImplExportIE->setText(i18n("Export &Internet Explorer Bookmarks...")); connect(m_actionsImplExportIE, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExportIE() )); KAction* m_actionsImplExportMoz = actionCollection()->addAction("exportMoz"); m_actionsImplExportMoz->setIcon(KIcon("mozilla")); m_actionsImplExportMoz->setText(i18n("Export &Mozilla Bookmarks...")); connect(m_actionsImplExportMoz, SIGNAL( triggered() ), m_actionsImpl, SLOT( slotExportMoz() )); }