Part 3 Feature: Open more that one file
ClosedPublic

Authored by laysrodrigues on Feb 24 2018, 5:18 AM.

Details

Summary
  • Used a TabWidget to control the open/close of gcode files.
  • Using KTextEditor as base, you need one Editor, and a view

for each document. So the newView and newDoc methods works for
this.

  • Added a signal to change the guiFactory view related to the

files edited.

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

New Dialog: Choose file for print

This dialog will open to the user with the list of
opened files and he will choose one to print.

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Update AtCoreInstanceWidget methods to use ChooseFileDialog

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Add to instances the open files

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Diff Detail

Repository
R231 Atelier
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
laysrodrigues requested review of this revision.Feb 24 2018, 5:18 AM
laysrodrigues created this revision.
rizzitello requested changes to this revision.Feb 24 2018, 1:25 PM
rizzitello added inline comments.
src/dialogs/choosefiledialog.cpp
28 ↗(On Diff #27896)

NO UI!!! High Five :D

src/widgets/atcoreinstancewidget.cpp
160 ↗(On Diff #27896)

Only show the dialog if more then one files is open.

This revision now requires changes to proceed.Feb 24 2018, 1:25 PM
patrickelectric requested changes to this revision.Feb 24 2018, 3:52 PM
patrickelectric added inline comments.
src/dialogs/choosefiledialog.cpp
32 ↗(On Diff #27896)

const auto&

36 ↗(On Diff #27896)

Gen only m_choosen_file in lambda, receive const ref in t

src/mainwindow.cpp
43–53

const KTextEditor.
Get by ref in lambda and not by copy.

src/widgets/gcodeeditorwidget.cpp
52

else is inline with last brackets.

81

if(!m_tabwidget->count())

laysrodrigues marked 6 inline comments as done.Feb 25 2018, 1:59 AM
laysrodrigues added inline comments.
src/dialogs/choosefiledialog.cpp
36 ↗(On Diff #27896)

Like this?

connect(listWigdet, &QListWidget::currentTextChanged, [ &m_choosen_file ](const QString& t){
    m_choosen_file = t;
});

Isnt working =/ Idk about all these tricks using lambda =|

Fixes and Rebase

Updating D10789: Part 3

Feature: Open more that one file

rizzitello requested changes to this revision.Feb 25 2018, 2:11 AM
rizzitello added inline comments.
src/widgets/atcoreinstancewidget.cpp
152 ↗(On Diff #27976)

size is not needed just m_files.size() directly.

154 ↗(On Diff #27976)

How about this ?

switch (m_files.size()) {
 case 0: 
     QMessageBox::warning(this, i18n("Error"), i18n("There's no GCode File open. \n Please select a file and try again."), QMessageBox::Ok);
     break;
 case 1:
    printFile(m_files.at(0));
    break;
 default:
      auto dialog = new ChooseFileDialog(this, m_files);
      if(dialog->exec() == QDialog::Accepted){
            printFile(dialog->choosenFile());
      }
}
This revision now requires changes to proceed.Feb 25 2018, 2:11 AM
laysrodrigues marked an inline comment as done.

Sith suggestions

This comment was removed by laysrodrigues.
laysrodrigues added inline comments.Feb 25 2018, 7:22 PM
src/widgets/atcoreinstancewidget.cpp
154 ↗(On Diff #27976)

much better =D Adding it

patrickelectric requested changes to this revision.Feb 26 2018, 1:37 PM
patrickelectric added inline comments.
src/dialogs/choosefiledialog.cpp
36 ↗(On Diff #27896)

My fault, you can only use this or & in this case

src/mainwindow.cpp
46

const KTextEditor

src/widgets/atcoreinstancewidget.cpp
25 ↗(On Diff #28061)

This import appears to be weird.

308 ↗(On Diff #28061)

const ref

src/widgets/gcodeeditorwidget.cpp
59–65

const

67

I'm not a big fan when using auto without the class type/name after =

71–72

const

This revision now requires changes to proceed.Feb 26 2018, 1:37 PM
laysrodrigues marked 5 inline comments as done.Mar 1 2018, 2:37 AM
laysrodrigues added inline comments.
src/mainwindow.cpp
46

That gives an error:
../src/mainwindow.cpp:48:37: error: invalid conversion from ‘const KXMLGUIClient*’ to ‘KXMLGUIClient*’ [-fpermissive]
Slots arent compatible

src/widgets/gcodeeditorwidget.cpp
71–72

Gives an error, we cant change and const object...
../src/widgets/gcodeeditorwidget.cpp:74:37: error: passing ‘const KTextEditor::Document’ as ‘this’ argument discards qualifiers [-fpermissive]

I need to pass this on the argument, otherwises it gives an another error:
../src/widgets/gcodeeditorwidget.cpp:74:33: error: no matching function for call to ‘KTextEditor::Document::createView() const’

Some of patrick fixes
Rebase

rizzitello added inline comments.Mar 1 2018, 12:23 PM
src/widgets/gcodeeditorwidget.cpp
42

New Empty Line

patrickelectric requested changes to this revision.Mar 1 2018, 6:42 PM
patrickelectric added inline comments.
src/dialogs/choosefiledialog.h
22 ↗(On Diff #28308)

includes in alphabetical order

src/mainwindow.h
24

includes in alphabetical order

src/widgets/atcoreinstancewidget.cpp
25 ↗(On Diff #28061)

dialogs/choosefiledialog ?
Try to solve this in the cmake

src/widgets/gcodeeditorwidget.h
21

QTab before qWidget

This revision now requires changes to proceed.Mar 1 2018, 6:42 PM
laysrodrigues marked 4 inline comments as done.Mar 2 2018, 11:21 AM

Rebase and fixes

rizzitello accepted this revision.Mar 2 2018, 1:51 PM
rizzitello added inline comments.
src/widgets/atcoreinstancewidget.cpp
25 ↗(On Diff #28061)

With both the widgets and dialogs being staticly linked into the applicaiton i really don't see a problem with the include being like this

patrickelectric requested changes to this revision.Mar 3 2018, 3:06 AM
patrickelectric added inline comments.
src/dialogs/choosefiledialog.cpp
23 ↗(On Diff #28391)

Includes in alphabetical order.

src/widgets/atcoreinstancewidget.cpp
25 ↗(On Diff #28061)

That's terrible to maintain code...
Should add the file in the cmakelists.

This revision now requires changes to proceed.Mar 3 2018, 3:06 AM
laysrodrigues planned changes to this revision.Mar 3 2018, 5:51 PM
laysrodrigues marked 2 inline comments as done.
patrickelectric accepted this revision.Mar 4 2018, 2:22 AM
This revision is now accepted and ready to land.Mar 4 2018, 2:22 AM
This revision was automatically updated to reflect the committed changes.