~ubuntu-branches/ubuntu/quantal/kdevplatform/quantal-proposed

« back to all changes in this revision

Viewing changes to shell/workingsetcontroller.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-24 00:06:18 UTC
  • mfrom: (0.3.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101024000618-7otebin77mfcmt3b
Tags: 1.1.0-0ubuntu1
* New upstream release
  - Bump build-dependencies
  - Build against libboost-serialization1.42-dev
  - Update kdevplatform1-libs.install
  - Update kdevplatform-dev.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
    KConfigGroup setConfig(Core::self()->activeSession()->config(), "Working File Sets");
88
88
    foreach(const QString& set, setConfig.groupList())
89
89
    {
90
 
        if(setConfig.hasKey("iconName"))
 
90
        if(setConfig.group(set).hasKey("iconName"))
91
91
            getWorkingSet(set, setConfig.group(set).readEntry<QString>("iconName", QString()));
92
92
        else
93
93
            kDebug() << "have garbage working set with id " << set;
96
96
 
97
97
void WorkingSetController::cleanup()
98
98
{
 
99
    foreach(Sublime::MainWindow* window, Core::self()->uiControllerInternal()->mainWindows()) {
 
100
        foreach (Sublime::Area *area, window->areas()) {
 
101
            if (!area->workingSet().isEmpty()) {
 
102
                Q_ASSERT(m_workingSets.contains(area->workingSet()));
 
103
                m_workingSets[area->workingSet()]->saveFromArea(area, area->rootIndex());
 
104
            }
 
105
        }
 
106
    }
 
107
 
99
108
    foreach(WorkingSet* set, m_workingSets) {
100
109
        kDebug() << "set" << set->id() << "persistent" << set->isPersistent() << "has areas:" << set->hasConnectedAreas() << "files" << set->fileList();
101
110
        if(!set->isPersistent() && !set->hasConnectedAreas()) {
179
188
        Q_ASSERT(areaIndex->viewCount() == 0 && !areaIndex->isSplitted());
180
189
        return;
181
190
    }
 
191
    
182
192
    kDebug() << "saving" << m_id << "from area";
183
193
 
 
194
    bool wasPersistent = isPersistent();
 
195
    
184
196
    KConfigGroup setConfig(Core::self()->activeSession()->config(), "Working File Sets");
185
197
    KConfigGroup group = setConfig.group(m_id);
 
198
    deleteGroupRecursive(group);
186
199
    group.writeEntry("iconName", m_iconName);
187
 
    deleteGroupRecursive(group);
 
200
    if (area->activeView()) {
 
201
        group.writeEntry("Active View", area->activeView()->document()->documentSpecifier());
 
202
    } else {
 
203
        group.writeEntry("Active View", QString());
 
204
    }
188
205
    saveFromArea(area, areaIndex, group);
189
206
 
190
207
    if(isEmpty())
191
208
        deleteGroupRecursive(group);
192
209
 
 
210
    setPersistent(wasPersistent);
 
211
    
193
212
    setConfig.sync();
194
213
 
195
214
    emit setChangedSignificantly();
216
235
 
217
236
        int index = 0;
218
237
        foreach (Sublime::View* view, area->views()) {
 
238
            kDebug() << view->document()->title();
219
239
            group.writeEntry(QString("View %1 Type").arg(index), view->document()->documentType());
220
240
            group.writeEntry(QString("View %1").arg(index), view->document()->documentSpecifier());
221
241
 
339
359
 
340
360
    loadToArea(area, areaIndex, group);
341
361
 
342
 
    //activate first view in the working set
 
362
    //activate view in the working set
343
363
    if (!area->views().isEmpty()) {
344
364
        foreach(Sublime::MainWindow* window, Core::self()->uiControllerInternal()->mainWindows()) {
345
365
            if(window->area() == area) {
346
366
                window->setArea(area);
347
 
                window->activateView(area->views().first());
 
367
                QString activeView = group.readEntry("Active View", QString());
 
368
                kDebug() << activeView;
 
369
                bool found = false;
 
370
                foreach (Sublime::View *v, area->views()) {
 
371
                    if (v->document()->documentSpecifier() == activeView) {
 
372
                        window->activateView(v);
 
373
                        found = true;
 
374
                        break;
 
375
                    }
 
376
                }
 
377
                if (!found) window->activateView(area->views().first()); //fallback
 
378
                break;
348
379
            }
349
380
        }
350
381
    }
398
429
                             KTextEditor::Cursor::invalid(), IDocumentController::DoNotActivate | IDocumentController::DoNotCreateView);
399
430
            Sublime::Document *document = dynamic_cast<Sublime::Document*>(doc);
400
431
            if (document) {
 
432
                kDebug() << document->title();
401
433
                Sublime::View* view = document->createView();
402
434
 
403
435
                QString state = group.readEntry(QString("View %1 State").arg(i), "");
548
580
void WorkingSetToolButton::closeSet()
549
581
{
550
582
    m_set->setPersistent(true);
 
583
    m_set->saveFromArea(mainWindow()->area(), mainWindow()->area()->rootIndex());
551
584
 
552
585
    if(!Core::self()->documentControllerInternal()->saveAllDocumentsForWindow(mainWindow(), KDevelop::IDocument::Default))
553
586
        return;
636
669
    if (from == to)
637
670
        return;
638
671
    Q_ASSERT(m_areas.contains(area));
 
672
    if (!m_id.isEmpty()) saveFromArea(area, area->rootIndex());
639
673
    disconnectArea(area);
640
674
    WorkingSet* newSet = Core::self()->workingSetControllerInternal()->getWorkingSet(to);
641
675
    newSet->connectArea(area);
706
740
}
707
741
 
708
742
WorkingSetToolTipWidget::WorkingSetToolTipWidget(QWidget* parent, WorkingSet* set, MainWindow* mainwindow) : QWidget(parent), m_set(set) {
709
 
    QFrame* frame = new QFrame(this);
710
 
    frame->setFrameStyle(QFrame::Panel | QFrame::Plain);
711
 
    frame->setLineWidth(1);
712
743
    QVBoxLayout* layout = new QVBoxLayout(this);
 
744
    layout->setSpacing(0);
713
745
    layout->setMargin(0);
714
 
    layout->addWidget(frame);
715
 
    QVBoxLayout* layout2 = new QVBoxLayout(frame);
716
 
    layout2->setSpacing(0);
717
 
    layout2->setContentsMargins(0, 0, 0, 0);
718
746
 
719
747
    // title bar
720
748
    {
743
771
        connect(m_deleteButton, SIGNAL(clicked(bool)), m_set, SLOT(deleteSet()));
744
772
        connect(m_deleteButton, SIGNAL(clicked(bool)), this, SIGNAL(shouldClose()));
745
773
        topLayout->addWidget(m_deleteButton);
746
 
        layout2->addLayout(topLayout);
 
774
        layout->addLayout(topLayout);
747
775
        // horizontal line
748
776
        QFrame* line = new QFrame();
749
777
        line->setFrameShape(QFrame::HLine);
750
778
        line->setFrameShadow(QFrame::Raised);
751
 
        layout2->addWidget(line);
 
779
        layout->addWidget(line);
752
780
    }
753
781
 
754
782
    // everything else is added to the following widget which just has a different background color
756
784
    {
757
785
        QWidget* body = new QWidget();
758
786
        body->setLayout(bodyLayout);
759
 
        QPalette palette = body->palette();
760
 
        QColor bgColor = palette.color(QPalette::Background);
761
 
        bgColor.setAlpha(0.4*255);
762
 
        palette.setColor(QPalette::Background, bgColor);
763
 
        body->setPalette(palette);
764
 
        body->setAutoFillBackground(true);
765
 
        layout2->addWidget(body);
 
787
        layout->addWidget(body);
766
788
    }
767
789
 
768
790
    // document list actions
790
812
        connect(m_subtractButton, SIGNAL(clicked(bool)), m_setButton, SLOT(subtractSet()));
791
813
        actionsLayout->addWidget(m_subtractButton);
792
814
        bodyLayout->addLayout(actionsLayout);
793
 
        // horizontal line
794
 
        QFrame* line = new QFrame();
795
 
        line->setFrameShape(QFrame::HLine);
796
 
        line->setFrameShadow(QFrame::Sunken);
797
 
        bodyLayout->addWidget(line);
798
815
    }
799
816
 
800
817
    QStringList files = m_set->fileList();